mirror of
https://github.com/GeorgH93/Minepacks.git
synced 2025-01-07 19:28:11 +01:00
Use translated command for shortcut
This commit is contained in:
parent
c32cf7419c
commit
1cf93591e0
@ -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;
|
||||
}
|
||||
}
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user