Use translated command for shortcut

This commit is contained in:
GeorgH93 2020-03-20 00:58:32 +01:00
parent c32cf7419c
commit 1cf93591e0
No known key found for this signature in database
GPG Key ID: D1630D37F9E4B3C8
3 changed files with 11 additions and 10 deletions

View File

@ -23,7 +23,7 @@
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
import java.util.LinkedList;
import java.util.ArrayList;
import java.util.List;
public class Language extends at.pcgamingfreaks.Bukkit.Language
@ -43,7 +43,7 @@ protected void doUpgrade(@NotNull YamlFileManager oldLang)
{
if(oldLang.getVersion() < 10) // Pre v2.0 versions
{
OldFileUpdater.updateLanguage(oldLang.getYaml(), getYaml(), plugin.getLogger());
OldFileUpdater.updateLanguage(oldLang.getYamlE(), getYaml(), plugin.getLogger());
}
else
{
@ -58,7 +58,7 @@ public String[] getCommandAliases(final String command)
public String[] getCommandAliases(final String command, final @NotNull String... defaults)
{
List<String> aliases = getLang().getStringList("Command." + command, new LinkedList<>());
List<String> aliases = getLangE().getStringList("Command." + command, new ArrayList<>(0));
return (aliases.size() > 0) ? aliases.toArray(new String[0]) : defaults;
}
}

View File

@ -50,7 +50,7 @@ public class ItemShortcut implements Listener
{
private static final UUID MINEPACKS_UUID = UUID.nameUUIDFromBytes("Minepacks".getBytes());
private final Minepacks plugin;
private final String itemName, value;
private final String itemName, value, openCommand;
private final Message messageDoNotRemoveItem;
private final boolean improveDeathChestCompatibility, blockAsHat, allowRightClickOnContainers;
private final int preferredSlotId;
@ -65,6 +65,7 @@ public ItemShortcut(Minepacks plugin)
blockAsHat = plugin.getConfiguration().isItemShortcutBlockAsHatEnabled();
allowRightClickOnContainers = plugin.getConfiguration().isItemShortcutRightClickOnContainerAllowed();
preferredSlotId = plugin.getConfiguration().getItemShortcutPreferredSlotId();
openCommand = plugin.getLanguage().getCommandAliases("Backpack", "backpack")[0] + ' ' + plugin.getLanguage().getCommandAliases("Open", "open")[0];
messageDoNotRemoveItem = plugin.getLanguage().getMessage("Ingame.DontRemoveShortcut");
if(allowRightClickOnContainers)
@ -160,7 +161,7 @@ public void onItemInteract(PlayerInteractEvent event)
//noinspection ConstantConditions
if(containerMaterials.contains(event.getClickedBlock().getType())) return;
}
event.getPlayer().performCommand("backpack open");
event.getPlayer().performCommand(openCommand);
event.setCancelled(true);
}
}
@ -170,7 +171,7 @@ public void onArmorStandManipulation(PlayerArmorStandManipulateEvent event)
{
if(isItemShortcut(event.getPlayerItem()))
{
event.getPlayer().performCommand("backpack open");
event.getPlayer().performCommand(openCommand);
event.setCancelled(true);
}
}
@ -190,7 +191,7 @@ public void onItemFrameInteract(PlayerInteractEntityEvent event)
}
if(isItemShortcut(item))
{
event.getPlayer().performCommand("backpack open");
event.getPlayer().performCommand(openCommand);
event.setCancelled(true);
}
}
@ -200,7 +201,7 @@ public void onBlockPlace(BlockPlaceEvent event)
{
if(isItemShortcut(event.getItemInHand()))
{
event.getPlayer().performCommand("backpack open");
event.getPlayer().performCommand(openCommand);
event.setCancelled(true);
}
}
@ -238,7 +239,7 @@ public void onItemClick(InventoryClickEvent event)
}
else if(event.getClick() == ClickType.RIGHT || event.getClick() == ClickType.SHIFT_RIGHT)
{
player.performCommand("backpack open");
player.performCommand(openCommand);
event.setCancelled(true);
}
else if(event.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY)

View File

@ -7,7 +7,7 @@
<packaging>pom</packaging>
<properties>
<revision>2.3.5-RC1</revision>
<revision>2.3.5-RC2</revision>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>