mirror of
https://github.com/GeorgH93/Minepacks.git
synced 2025-01-23 21:51:31 +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.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Language extends at.pcgamingfreaks.Bukkit.Language
|
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
|
if(oldLang.getVersion() < 10) // Pre v2.0 versions
|
||||||
{
|
{
|
||||||
OldFileUpdater.updateLanguage(oldLang.getYaml(), getYaml(), plugin.getLogger());
|
OldFileUpdater.updateLanguage(oldLang.getYamlE(), getYaml(), plugin.getLogger());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -58,7 +58,7 @@ public String[] getCommandAliases(final String command)
|
|||||||
|
|
||||||
public String[] getCommandAliases(final String command, final @NotNull String... defaults)
|
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;
|
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 static final UUID MINEPACKS_UUID = UUID.nameUUIDFromBytes("Minepacks".getBytes());
|
||||||
private final Minepacks plugin;
|
private final Minepacks plugin;
|
||||||
private final String itemName, value;
|
private final String itemName, value, openCommand;
|
||||||
private final Message messageDoNotRemoveItem;
|
private final Message messageDoNotRemoveItem;
|
||||||
private final boolean improveDeathChestCompatibility, blockAsHat, allowRightClickOnContainers;
|
private final boolean improveDeathChestCompatibility, blockAsHat, allowRightClickOnContainers;
|
||||||
private final int preferredSlotId;
|
private final int preferredSlotId;
|
||||||
@ -65,6 +65,7 @@ public ItemShortcut(Minepacks plugin)
|
|||||||
blockAsHat = plugin.getConfiguration().isItemShortcutBlockAsHatEnabled();
|
blockAsHat = plugin.getConfiguration().isItemShortcutBlockAsHatEnabled();
|
||||||
allowRightClickOnContainers = plugin.getConfiguration().isItemShortcutRightClickOnContainerAllowed();
|
allowRightClickOnContainers = plugin.getConfiguration().isItemShortcutRightClickOnContainerAllowed();
|
||||||
preferredSlotId = plugin.getConfiguration().getItemShortcutPreferredSlotId();
|
preferredSlotId = plugin.getConfiguration().getItemShortcutPreferredSlotId();
|
||||||
|
openCommand = plugin.getLanguage().getCommandAliases("Backpack", "backpack")[0] + ' ' + plugin.getLanguage().getCommandAliases("Open", "open")[0];
|
||||||
messageDoNotRemoveItem = plugin.getLanguage().getMessage("Ingame.DontRemoveShortcut");
|
messageDoNotRemoveItem = plugin.getLanguage().getMessage("Ingame.DontRemoveShortcut");
|
||||||
|
|
||||||
if(allowRightClickOnContainers)
|
if(allowRightClickOnContainers)
|
||||||
@ -160,7 +161,7 @@ public void onItemInteract(PlayerInteractEvent event)
|
|||||||
//noinspection ConstantConditions
|
//noinspection ConstantConditions
|
||||||
if(containerMaterials.contains(event.getClickedBlock().getType())) return;
|
if(containerMaterials.contains(event.getClickedBlock().getType())) return;
|
||||||
}
|
}
|
||||||
event.getPlayer().performCommand("backpack open");
|
event.getPlayer().performCommand(openCommand);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -170,7 +171,7 @@ public void onArmorStandManipulation(PlayerArmorStandManipulateEvent event)
|
|||||||
{
|
{
|
||||||
if(isItemShortcut(event.getPlayerItem()))
|
if(isItemShortcut(event.getPlayerItem()))
|
||||||
{
|
{
|
||||||
event.getPlayer().performCommand("backpack open");
|
event.getPlayer().performCommand(openCommand);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -190,7 +191,7 @@ public void onItemFrameInteract(PlayerInteractEntityEvent event)
|
|||||||
}
|
}
|
||||||
if(isItemShortcut(item))
|
if(isItemShortcut(item))
|
||||||
{
|
{
|
||||||
event.getPlayer().performCommand("backpack open");
|
event.getPlayer().performCommand(openCommand);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -200,7 +201,7 @@ public void onBlockPlace(BlockPlaceEvent event)
|
|||||||
{
|
{
|
||||||
if(isItemShortcut(event.getItemInHand()))
|
if(isItemShortcut(event.getItemInHand()))
|
||||||
{
|
{
|
||||||
event.getPlayer().performCommand("backpack open");
|
event.getPlayer().performCommand(openCommand);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -238,7 +239,7 @@ public void onItemClick(InventoryClickEvent event)
|
|||||||
}
|
}
|
||||||
else if(event.getClick() == ClickType.RIGHT || event.getClick() == ClickType.SHIFT_RIGHT)
|
else if(event.getClick() == ClickType.RIGHT || event.getClick() == ClickType.SHIFT_RIGHT)
|
||||||
{
|
{
|
||||||
player.performCommand("backpack open");
|
player.performCommand(openCommand);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
else if(event.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY)
|
else if(event.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY)
|
||||||
|
2
pom.xml
2
pom.xml
@ -7,7 +7,7 @@
|
|||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<revision>2.3.5-RC1</revision>
|
<revision>2.3.5-RC2</revision>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
Loading…
Reference in New Issue
Block a user