From 0bdc56a58cb6cde702a85d83246c25c5a0b7eab5 Mon Sep 17 00:00:00 2001
From: mfnalex <1122571+mfnalex@users.noreply.github.com>
Date: Wed, 31 Jul 2019 20:02:25 +0200
Subject: [PATCH 1/2] 7.0 added GUI
---
pom.xml | 2 +-
.../JeffChestSortCommandExecutor.java | 17 ++++
.../JeffChestSort/JeffChestSortListener.java | 97 +++++++++++++++++--
.../JeffChestSort/JeffChestSortMessages.java | 26 ++++-
.../JeffChestSortPlayerSetting.java | 13 ++-
.../JeffChestSort/JeffChestSortPlugin.java | 29 +++++-
.../JeffChestSortSettingsGUI.java | 96 ++++++++++++++++++
src/main/resources/config.yml | 97 +++++++++++++++++--
src/main/resources/plugin.yml | 2 +-
9 files changed, 359 insertions(+), 20 deletions(-)
create mode 100644 src/main/java/de/jeffclan/JeffChestSort/JeffChestSortSettingsGUI.java
diff --git a/pom.xml b/pom.xml
index 4cec12b..5bab183 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
de.jeffclan
JeffChestSort
- 6.4.5
+ 7.0-SNAPSHOT-1
jar
JeffChestSort
diff --git a/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortCommandExecutor.java b/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortCommandExecutor.java
index b460d8e..6663c41 100644
--- a/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortCommandExecutor.java
+++ b/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortCommandExecutor.java
@@ -29,6 +29,23 @@ public class JeffChestSortCommandExecutor implements CommandExecutor {
// fix for Spigot's stupid /reload function
plugin.listener.registerPlayerIfNeeded(p);
+ // Settings GUI
+ if(args.length>0) {
+ if(args[0].equalsIgnoreCase("hotkey") || args[0].equalsIgnoreCase("hotkeys")) {
+
+ if(plugin.hotkeyGUI==false) {
+ p.sendMessage(plugin.messages.MSG_ERR_HOTKEYSDISABLED);
+ return true;
+ }
+
+ plugin.settingsGUI.openGUI(p);
+
+ return true;
+ }
+
+ }
+ // Settings GUI End
+
JeffChestSortPlayerSetting setting = plugin.PerPlayerSettings.get(p.getUniqueId().toString());
setting.sortingEnabled = !setting.sortingEnabled;
setting.hasSeenMessage=true;
diff --git a/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortListener.java b/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortListener.java
index ea70bd0..3f8a1a1 100644
--- a/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortListener.java
+++ b/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortListener.java
@@ -13,6 +13,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
+import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryEvent;
@@ -65,19 +66,33 @@ public class JeffChestSortListener implements Listener {
File playerFile = new File(plugin.getDataFolder() + File.separator + "playerdata",
p.getUniqueId().toString() + ".yml");
YamlConfiguration playerConfig = YamlConfiguration.loadConfiguration(playerFile);
+
+ playerConfig.addDefault("middleClick", plugin.getConfig().getBoolean("hotkeys.middle-click"));
+ playerConfig.addDefault("shiftClick", plugin.getConfig().getBoolean("hotkeys.shift-click"));
+ playerConfig.addDefault("doubleClick", plugin.getConfig().getBoolean("hotkeys.double-click"));
+ playerConfig.addDefault("shiftRightClick", plugin.getConfig().getBoolean("hotkeys.shift-right-click"));
boolean activeForThisPlayer = false;
+ boolean middleClick, shiftClick, doubleClick, shiftRightClick;
if (!playerFile.exists()) {
// If the player settings file does not exist for this player, set it to the
// default value
activeForThisPlayer = plugin.getConfig().getBoolean("sorting-enabled-by-default");
+ middleClick = plugin.getConfig().getBoolean("hotkeys.middle-click");
+ shiftClick = plugin.getConfig().getBoolean("hotkeys.shift-click");
+ doubleClick = plugin.getConfig().getBoolean("hotkeys.double-click");
+ shiftRightClick = plugin.getConfig().getBoolean("hotkeys.shift-right-click");
} else {
// If the file exists, check if the player has sorting enabled
activeForThisPlayer = playerConfig.getBoolean("sortingEnabled");
+ middleClick = playerConfig.getBoolean("middleClick");
+ shiftClick = playerConfig.getBoolean("shiftClick");
+ doubleClick = playerConfig.getBoolean("doubleClick");
+ shiftRightClick = playerConfig.getBoolean("shiftRightClick");
}
- JeffChestSortPlayerSetting newSettings = new JeffChestSortPlayerSetting(activeForThisPlayer);
+ JeffChestSortPlayerSetting newSettings = new JeffChestSortPlayerSetting(activeForThisPlayer,middleClick,shiftClick,doubleClick,shiftRightClick);
// when "show-message-again-after-logout" is enabled, we don't care if the
// player already saw the message
@@ -271,16 +286,18 @@ public class JeffChestSortListener implements Listener {
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onInventoryClickEvent(InventoryClickEvent event) {
- if(!plugin.getConfig().getBoolean("allow-hotkeys")) {
- return;
- }
-
if(!(event.getWhoClicked() instanceof Player)) {
return;
}
Player p = (Player) event.getWhoClicked();
+ registerPlayerIfNeeded(p);
+
+ if(!plugin.getConfig().getBoolean("allow-hotkeys")) {
+ return;
+ }
+
// DEBUG START
// p.sendMessage("=====================");
// p.sendMessage("Click type: " + event.getClick().name());
@@ -301,14 +318,23 @@ public class JeffChestSortListener implements Listener {
boolean sort = false;
+ JeffChestSortPlayerSetting setting = plugin.PerPlayerSettings.get(p.getUniqueId().toString());
+
+ // Do not sort the GUI inventory
+ if(event.getClickedInventory() == setting.guiInventory) {
+ return;
+ }
+
switch(event.getClick()) {
case MIDDLE:
- if(plugin.getConfig().getBoolean("hotkeys.middle-click")) {
+ //if(plugin.getConfig().getBoolean("hotkeys.middle-click")) {
+ if(setting.middleClick) {
sort=true;
}
break;
case DOUBLE_CLICK:
- if(plugin.getConfig().getBoolean("hotkeys.double-click")) {
+ //if(plugin.getConfig().getBoolean("hotkeys.double-click")) {
+ if(setting.doubleClick) {
// We need getCursor() instead of getCurrentItem(), because after picking up the item, it is gone into the cursor
if(event.getCursor() == null || (event.getCursor() != null && event.getCursor().getType() == Material.AIR)) {
sort=true;
@@ -316,14 +342,16 @@ public class JeffChestSortListener implements Listener {
}
break;
case SHIFT_LEFT:
- if(plugin.getConfig().getBoolean("hotkeys.shift-click")) {
+ //if(plugin.getConfig().getBoolean("hotkeys.shift-click")) {
+ if(setting.shiftClick) {
if(event.getCurrentItem() == null || (event.getCurrentItem() != null && event.getCurrentItem().getType() == Material.AIR) ){
sort=true;
}
}
break;
case SHIFT_RIGHT:
- if(plugin.getConfig().getBoolean("hotkeys.shift-right-click")) {
+ //if(plugin.getConfig().getBoolean("hotkeys.shift-right-click")) {
+ if(setting.shiftRightClick) {
if(event.getCurrentItem() == null || ( event.getCurrentItem() != null && event.getCurrentItem().getType() == Material.AIR)) {
sort=true;
}
@@ -374,5 +402,56 @@ public class JeffChestSortListener implements Listener {
}
}
}
+
+ @EventHandler
+ void onGUIInteract(InventoryClickEvent event) {
+ if(plugin.hotkeyGUI==false) {
+ return;
+ }
+ if(!(event.getWhoClicked() instanceof Player)) {
+ return;
+ }
+ Player p = (Player) event.getWhoClicked();
+ registerPlayerIfNeeded(p);
+ JeffChestSortPlayerSetting setting = plugin.PerPlayerSettings.get(p.getUniqueId().toString());
+
+ if(setting.guiInventory==null) {
+ return;
+ }
+
+ if(event.getClickedInventory()==null) {
+ return;
+ }
+
+ if(event.getClickedInventory() != setting.guiInventory) {
+ return;
+ }
+
+ // We only get this far if the player has clicked inside his GUI inventory
+ event.setCancelled(true);
+ if(event.getClick() != ClickType.LEFT) {
+ return;
+ }
+
+ if(event.getSlot() == JeffChestSortSettingsGUI.slotMiddleClick) {
+ setting.middleClick = !setting.middleClick;
+ plugin.settingsGUI.openGUI(p);
+ return;
+ }
+ else if(event.getSlot() == JeffChestSortSettingsGUI.slotShiftClick) {
+ setting.shiftClick = !setting.shiftClick;
+ plugin.settingsGUI.openGUI(p);
+ return;
+ } else if(event.getSlot() == JeffChestSortSettingsGUI.slotDoubleClick) {
+ setting.doubleClick = !setting.doubleClick;
+ plugin.settingsGUI.openGUI(p);
+ return;
+ } else if(event.getSlot() == JeffChestSortSettingsGUI.slotShiftRightClick) {
+ setting.shiftRightClick = !setting.shiftRightClick;
+ plugin.settingsGUI.openGUI(p);
+ return;
+ }
+
+ }
}
diff --git a/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortMessages.java b/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortMessages.java
index cf7fe43..df67e80 100644
--- a/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortMessages.java
+++ b/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortMessages.java
@@ -14,7 +14,11 @@ public class JeffChestSortMessages {
JeffChestSortPlugin plugin;
final String MSG_ACTIVATED, MSG_DEACTIVATED, MSG_COMMANDMESSAGE, MSG_COMMANDMESSAGE2, MSG_PLAYERSONLY,
- MSG_PLAYERINVSORTED, MSG_INVALIDOPTIONS;
+ MSG_PLAYERINVSORTED, MSG_INVALIDOPTIONS, MSG_ERR_HOTKEYSDISABLED;
+
+ final String MSG_GUI_ENABLED, MSG_GUI_DISABLED;
+
+ final String MSG_GUI_MIDDLECLICK, MSG_GUI_SHIFTCLICK, MSG_GUI_DOUBLECLICK, MSG_GUI_SHIFTRIGHTCLICK;
JeffChestSortMessages(JeffChestSortPlugin plugin) {
this.plugin = plugin;
@@ -39,6 +43,26 @@ public class JeffChestSortMessages {
MSG_INVALIDOPTIONS = ChatColor.translateAlternateColorCodes('&', plugin.getConfig()
.getString("message-error-invalid-options", "&cError: Unknown option %s. Valid options are %s."));
+
+ MSG_GUI_ENABLED = ChatColor.translateAlternateColorCodes('&', plugin.getConfig()
+ .getString("message-gui-enabled","&aEnabled"));
+
+ MSG_GUI_DISABLED = ChatColor.translateAlternateColorCodes('&', plugin.getConfig()
+ .getString("message-gui-disabled","&cDisabled"));
+
+ MSG_GUI_MIDDLECLICK = ChatColor.translateAlternateColorCodes('&', plugin.getConfig()
+ .getString("message-gui-middle-click","Middle-Click"));
+
+ MSG_GUI_SHIFTCLICK = ChatColor.translateAlternateColorCodes('&', plugin.getConfig()
+ .getString("message-gui-shift-click","Shift + Click"));
+
+ MSG_GUI_DOUBLECLICK = ChatColor.translateAlternateColorCodes('&', plugin.getConfig()
+ .getString("message-gui-double-click","Double-Click"));
+
+ MSG_GUI_SHIFTRIGHTCLICK = ChatColor.translateAlternateColorCodes('&', plugin.getConfig()
+ .getString("message-gui-shift-right-click","Shift + Right-Click"));
+
+ MSG_ERR_HOTKEYSDISABLED = ChatColor.RED + "[ChestSort] Hotkey settings are only available for Minecraft 1.14 and later.";
}
}
diff --git a/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortPlayerSetting.java b/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortPlayerSetting.java
index 31817e5..efca1af 100644
--- a/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortPlayerSetting.java
+++ b/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortPlayerSetting.java
@@ -1,5 +1,7 @@
package de.jeffclan.JeffChestSort;
+import org.bukkit.inventory.Inventory;
+
public class JeffChestSortPlayerSetting {
// Represents the information regarding a player
@@ -9,12 +11,21 @@ public class JeffChestSortPlayerSetting {
// Sorting enabled for this player?
boolean sortingEnabled;
+
+ // Hotkey settings
+ boolean middleClick, shiftClick, doubleClick, shiftRightClick;
+
+ Inventory guiInventory = null;
// Did we already show the message how to activate sorting?
boolean hasSeenMessage = false;
- JeffChestSortPlayerSetting(boolean sortingEnabled) {
+ JeffChestSortPlayerSetting(boolean sortingEnabled, boolean middleClick, boolean shiftClick, boolean doubleClick, boolean shiftRightClick) {
this.sortingEnabled = sortingEnabled;
+ this.middleClick = middleClick;
+ this.shiftClick = shiftClick;
+ this.doubleClick = doubleClick;
+ this.shiftRightClick = shiftRightClick;
}
}
diff --git a/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortPlugin.java b/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortPlugin.java
index 229f563..cd7ebdf 100644
--- a/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortPlugin.java
+++ b/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortPlugin.java
@@ -65,18 +65,27 @@ public class JeffChestSortPlugin extends JavaPlugin {
JeffChestSortOrganizer organizer;
JeffChestSortUpdateChecker updateChecker;
JeffChestSortListener listener;
+ JeffChestSortSettingsGUI settingsGUI;
String sortingMethod;
ArrayList disabledWorlds;
- int currentConfigVersion = 17;
+ int currentConfigVersion = 18;
boolean usingMatchingConfig = true;
boolean debug = false;
boolean verbose = true;
+ boolean hotkeyGUI = true;
public boolean hookCrackShot = false;
public boolean hookInventoryPages = false;
private long updateCheckInterval = 86400; // in seconds. We check on startup and every 24 hours (if you never
// restart your server)
+
+ String mcVersion; // 1.13.2 = 1_13_R2
+ // 1.14.4 = 1_14_R1
+ // 1.8.0 = 1_8_R1
+ int mcMinorVersion; // 14 for 1.14, 13 for 1.13, ...
+
+
// Public API method to sort any given inventory
public void sortInventory(Inventory inv) {
@@ -219,6 +228,18 @@ public class JeffChestSortPlugin extends JavaPlugin {
@Override
public void onEnable() {
+
+ String tmpVersion = getServer().getClass().getPackage().getName();
+ mcVersion = tmpVersion.substring(tmpVersion.lastIndexOf('.') + 1);
+ tmpVersion = mcVersion.substring(mcVersion.indexOf("_")+1);
+ mcMinorVersion = Integer.parseInt(tmpVersion.substring(0,tmpVersion.indexOf("_")));
+
+ //getLogger().info("Running MC version 1."+mcMinorVersion);
+ if(mcMinorVersion < 14) {
+ getLogger().info("You are running a Minecraft version below 1.14. Hotkey GUI will be disabled.");
+ hotkeyGUI = false;
+ }
+
// Create the config file, including checks for old config versions, and load
// the default values for unset options
createConfig();
@@ -249,6 +270,8 @@ public class JeffChestSortPlugin extends JavaPlugin {
// Organizer will load all category files and will be ready to sort stuff
organizer = new JeffChestSortOrganizer(this);
+
+ settingsGUI = new JeffChestSortSettingsGUI(this);
// UpdateChecker will check on startup and every 24 hours for new updates (when
// enabled)
@@ -486,6 +509,10 @@ public class JeffChestSortPlugin extends JavaPlugin {
YamlConfiguration playerConfig = YamlConfiguration.loadConfiguration(playerFile);
playerConfig.set("sortingEnabled", setting.sortingEnabled);
playerConfig.set("hasSeenMessage", setting.hasSeenMessage);
+ playerConfig.set("middleClick",setting.middleClick);
+ playerConfig.set("shiftClick",setting.shiftClick);
+ playerConfig.set("doubleClick",setting.doubleClick);
+ playerConfig.set("shiftRightClick",setting.shiftRightClick);
try {
playerConfig.save(playerFile);
} catch (IOException e) {
diff --git a/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortSettingsGUI.java b/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortSettingsGUI.java
new file mode 100644
index 0000000..be05cba
--- /dev/null
+++ b/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortSettingsGUI.java
@@ -0,0 +1,96 @@
+package de.jeffclan.JeffChestSort;
+
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.Material;
+import org.bukkit.entity.Player;
+import org.bukkit.event.inventory.InventoryType;
+import org.bukkit.inventory.Inventory;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.meta.ItemMeta;
+
+public class JeffChestSortSettingsGUI {
+
+ JeffChestSortPlugin plugin;
+
+ public static int slotMiddleClick = 1 + 9;
+ public static int slotShiftClick = 3 + 9;
+ public static int slotDoubleClick = 5 + 9;
+ public static int slotShiftRightClick = 7 + 9;
+
+ enum Hotkey {
+ MiddleClick, ShiftClick, DoubleClick, ShiftRightClick;
+ }
+
+ JeffChestSortSettingsGUI(JeffChestSortPlugin plugin) {
+ this.plugin=plugin;
+ }
+
+ ItemStack getItem(boolean active, Hotkey hotkey) {
+ ItemStack is = null;
+ String suffix;
+ Material green = Material.getMaterial("GREEN_WOOL");
+ Material red = Material.getMaterial("RED_WOOL");
+
+ if(green==null || red==null) {
+ return null;
+ }
+
+ if(active) {
+ is = new ItemStack(green);
+ suffix = plugin.messages.MSG_GUI_ENABLED;
+ }
+ else {
+ is = new ItemStack(red);
+ suffix = plugin.messages.MSG_GUI_DISABLED;
+ }
+
+ ItemMeta meta = is.getItemMeta();
+
+ switch(hotkey) {
+ case MiddleClick:
+ meta.setDisplayName(ChatColor.RESET + plugin.messages.MSG_GUI_MIDDLECLICK + ": " + suffix);
+ break;
+ case ShiftClick:
+ meta.setDisplayName(ChatColor.RESET + plugin.messages.MSG_GUI_SHIFTCLICK + ": " + suffix);
+ break;
+ case DoubleClick:
+ meta.setDisplayName(ChatColor.RESET + plugin.messages.MSG_GUI_DOUBLECLICK + ": " + suffix);
+ break;
+ case ShiftRightClick:
+ meta.setDisplayName(ChatColor.RESET + plugin.messages.MSG_GUI_SHIFTRIGHTCLICK + ": " + suffix);
+ break;
+ default:
+ break;
+ }
+
+ is.setItemMeta(meta);
+
+ return is;
+ }
+
+ void openGUI(Player player) {
+ Inventory inventory = createGUI("ChestSort", player);
+
+ JeffChestSortPlayerSetting setting = plugin.PerPlayerSettings.get(player.getUniqueId().toString());
+
+ // Test if running 1.13 or later
+ if(Material.getMaterial("GREEN_WOOL") == null) {
+ player.sendMessage(plugin.messages.MSG_ERR_HOTKEYSDISABLED);
+ return;
+ }
+
+ inventory.setItem(slotMiddleClick, getItem(setting.middleClick,Hotkey.MiddleClick));
+ inventory.setItem(slotShiftClick, getItem(setting.shiftClick,Hotkey.ShiftClick));
+ inventory.setItem(slotDoubleClick, getItem(setting.doubleClick,Hotkey.DoubleClick));
+ inventory.setItem(slotShiftRightClick, getItem(setting.shiftRightClick,Hotkey.ShiftRightClick));
+
+ setting.guiInventory = inventory;
+ player.openInventory(inventory);
+ }
+
+ Inventory createGUI(String name, Player inventoryHolder) {
+ Inventory inventory = Bukkit.createInventory(inventoryHolder, InventoryType.CHEST, name);
+ return inventory;
+ }
+}
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index c3f7abe..da90694 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -71,6 +71,7 @@ allow-hotkeys: true
# You can disable/enable certain hotkeys when you have allow-hotkeys enabled.
# Hotkeys that could interfere with Minecraft's normal behaviour (e.g.
# shift+left-click) only work on empty slots, so don't worry about them.
+# Players can also enable/disable all shortcuts individually via /chestsort settings
hotkeys:
# Use middle click (mousewheel) on ANY inventory slot as hotkey
middle-click: true
@@ -199,6 +200,12 @@ message-sorting-enabled: "&7Automatic chest sorting has been &aenabled&7."
message-player-inventory-sorted: "&7Your inventory has been sorted."
message-error-players-only: "&cError: This command can only be run by players."
message-error-invalid-options: "&cError: Unknown option %s. Valid options are %s."
+message-gui-enabled: "&aEnabled"
+message-gui-disabled: "&cDisabled"
+message-gui-middle-click: "Middle-Click"
+message-gui-shift-click: "Shift + Click"
+message-gui-double-click: "Double-Click"
+message-gui-shift-right-click: "Shift + Right-Click"
##### English
#message-when-using-chest: "&7Hint: Type &6/chestsort&7 to enable automatic chest sorting."
@@ -208,8 +215,15 @@ message-error-invalid-options: "&cError: Unknown option %s. Valid options are %s
#message-player-inventory-sorted: "&7Your inventory has been sorted."
#message-error-players-only: "&cError: This command can only be run by players."
#message-error-invalid-options: "&cError: Unknown option %s. Valid options are %s."
+#message-gui-enabled: "&aEnabled"
+#message-gui-disabled: "&cDisabled"
+#message-gui-middle-click: "Middle-Click"
+#message-gui-shift-click: "Shift + Click"
+#message-gui-double-click: "Double-Click"
+#message-gui-shift-right-click: "Shift + Right-Click"
##### Chinese - Thanks to qsefthuopq for translating! -> https://www.spigotmc.org/members/qsefthuopq.339953/
+##### Note: Some messages are still untranslated. Please send me your translation at SpigotMC
#message-when-using-chest: "&7提示: 输入 &6/chestsort&7 来启用自动整理箱子."
#message-when-using-chest2: "&7提示: 输入 &6/chestsort&7 来关闭自动整理箱子."
#message-sorting-disabled: "&7自动整理箱子已 &c关闭&7."
@@ -217,9 +231,15 @@ message-error-invalid-options: "&cError: Unknown option %s. Valid options are %s
#message-player-inventory-sorted: "&7已成功整理你的背包."
#message-error-players-only: "&c错误: 指令只能由玩家运行."
#message-error-invalid-options: "&c错误: 位置选项 %s. 有效选项为 %s."
+#message-gui-enabled: "&aEnabled"
+#message-gui-disabled: "&cDisabled"
+#message-gui-middle-click: "Middle-Click"
+#message-gui-shift-click: "Shift + Click"
+#message-gui-double-click: "Double-Click"
+#message-gui-shift-right-click: "Shift + Right-Click"
##### Chinese (Traditional) 繁體中文
-##### Note: the last two messages are still untranslated. Please send me your translation at SpigotMC
+##### Note: Some messages are still untranslated. Please send me your translation at SpigotMC
#message-when-using-chest: "&7小提醒: 輸入 &6/chestsort&7 來開啟自動整理箱子"
#message-when-using-chest2: "&7小提醒: 輸入 &6/chestsort&7 來關閉自動整理箱子"
#message-sorting-disabled: "&7自動整理箱子已 &c關閉&7"
@@ -227,8 +247,15 @@ message-error-invalid-options: "&cError: Unknown option %s. Valid options are %s
#message-player-inventory-sorted: "&7你的背包已成功整理."
#message-error-players-only: "&c錯誤: 這個指令只能由玩家使用"
#message-error-invalid-options: "&c錯誤: 未知選項 %s. 有效的選項為 %s."
+#message-gui-enabled: "&aEnabled"
+#message-gui-disabled: "&cDisabled"
+#message-gui-middle-click: "Middle-Click"
+#message-gui-shift-click: "Shift + Click"
+#message-gui-double-click: "Double-Click"
+#message-gui-shift-right-click: "Shift + Right-Click"
##### Dutch - Thanks to Xeyame for translating! -> https://github.com/Xeyame
+##### Note: Some messages are still untranslated. Please send me your translation at SpigotMC
#message-when-using-chest: "&7Hint: Gebruik &6/chestsort&7 om automatische kist sortering aan te zetten."
#message-when-using-chest2: "&7Hint: Gebruik &6/chestsort&7 om automatische kist sortering uit te zetten."
#message-sorting-disabled: "&7Automatische kist sortering is &cuitgeschakeld&7."
@@ -236,9 +263,15 @@ message-error-invalid-options: "&cError: Unknown option %s. Valid options are %s
#message-player-inventory-sorted: "&7Je inventaris is gesorteerd."
#message-error-players-only: "&cFout: Dit commando kan alleen door spelers worden gebruikt."
#message-error-invalid-options: "&cFout: Onbekende optie %s. Mogelijke opties zijn %s."
+#message-gui-enabled: "&aEnabled"
+#message-gui-disabled: "&cDisabled"
+#message-gui-middle-click: "Middle-Click"
+#message-gui-shift-click: "Shift + Click"
+#message-gui-double-click: "Double-Click"
+#message-gui-shift-right-click: "Shift + Right-Click"
##### French - Thanks to automatizer for translating! -> https://www.spigotmc.org/members/automatizer.26188/
-##### Note: the last two messages are still untranslated. Please send me your translation at SpigotMC
+##### Note: Some messages are still untranslated. Please send me your translation at SpigotMC
#message-when-using-chest: "&7Astuce: Écris &6/chestsort&7 pour activer le classement automatique."
#message-when-using-chest2: "&7Astuce: Écris &6/chestsort&7 pour désactiver le classement automatique."
#message-sorting-disabled: "&7Le classement automatique a été &cdésactivé&7."
@@ -246,6 +279,12 @@ message-error-invalid-options: "&cError: Unknown option %s. Valid options are %s
#message-player-inventory-sorted: "&7Your inventory has been sorted."
#message-error-players-only: "&cErreur: Cette commande ne peut être utilisée que par des joueurs."
#message-error-invalid-options: "&cError: Unknown option %s. Valid options are %s."
+#message-gui-enabled: "&aEnabled"
+#message-gui-disabled: "&cDisabled"
+#message-gui-middle-click: "Middle-Click"
+#message-gui-shift-click: "Shift + Click"
+#message-gui-double-click: "Double-Click"
+#message-gui-shift-right-click: "Shift + Right-Click"
##### German
#message-when-using-chest: "&7Hinweis: Benutze &6/chestsort&7 um die automatische Kistensortierung zu aktivieren."
@@ -255,8 +294,15 @@ message-error-invalid-options: "&cError: Unknown option %s. Valid options are %s
#message-player-inventory-sorted: "&7Dein Inventar wurde sortiert."
#message-error-players-only: "&cFehler: Dieser Befehl ist nur für Spieler verfügbar."
#message-error-invalid-options: "&cFehler: Unbekannte Option %s. Gültige Optionen sind %s."
+#message-gui-enabled: "&aAktiviert"
+#message-gui-disabled: "&cDeaktiviert"
+#message-gui-middle-click: "Mittel-Klick"
+#message-gui-shift-click: "Shift + Klick"
+#message-gui-double-click: "Doppelklick"
+#message-gui-shift-right-click: "Shift + Rechtsklick"
-##### Italian - Translated with Google. Please tell me if something is wrong :)
+##### Italian
+##### Note: Some messages are still untranslated. Please send me your translation at SpigotMC
#message-when-using-chest: "&7Nota: inserire &6/chestsort&7 per abilitare l'ordinamento automatico dei bauli."
#message-when-using-chest2: "&7Nota: inserire &6/chestsort&7 per disabilitare l'ordinamento automatico dei bauli."
#message-sorting-disabled: "&7L'ordinamento automatico dei bauli è stato &cdisattivato&7."
@@ -264,9 +310,15 @@ message-error-invalid-options: "&cError: Unknown option %s. Valid options are %s
#message-player-inventory-sorted: "&7Il tuo inventario è stato ordinato."
#message-error-players-only: "&cErrore: questo comando è disponibile solo per i giocatori."
#message-error-invalid-options: "&cErrore: Parametro sconosciuto %s. I parametri validi sono %s."
+#message-gui-enabled: "&aEnabled"
+#message-gui-disabled: "&cDisabled"
+#message-gui-middle-click: "Middle-Click"
+#message-gui-shift-click: "Shift + Click"
+#message-gui-double-click: "Double-Click"
+#message-gui-shift-right-click: "Shift + Right-Click"
##### Japanese
-##### Note: the last two messages are still untranslated. Please send me your translation at SpigotMC
+##### Note: Some messages are still untranslated. Please send me your translation at SpigotMC
#message-when-using-chest: "&7ヒント: &6/chestsort&7 と入力して自動チェスト整理を有効にできます。"
#message-when-using-chest2: "&7ヒント: &6/chestsort&7 と入力すると自動チェスト整理を無効にできます。"
#message-sorting-disabled: "&7自動チェスト整理は現在 &cOFF&7です。"
@@ -274,9 +326,15 @@ message-error-invalid-options: "&cError: Unknown option %s. Valid options are %s
#message-error-players-only: "&cエラー: このコマンドはプレイヤーのみ実行できます。"
#message-player-inventory-sorted: "&7Your inventory has been sorted."
#message-error-invalid-options: "&cError: Unknown option %s. Valid options are %s."
+#message-gui-enabled: "&aEnabled"
+#message-gui-disabled: "&cDisabled"
+#message-gui-middle-click: "Middle-Click"
+#message-gui-shift-click: "Shift + Click"
+#message-gui-double-click: "Double-Click"
+#message-gui-shift-right-click: "Shift + Right-Click"
##### Portuguese - Thanks to wildastral for translating! -> https://www.spigotmc.org/members/wildastral.673147/
-##### Note: the last two messages are still untranslated. Please send me your translation at SpigotMC
+##### Note: Some messages are still untranslated. Please send me your translation at SpigotMC
#message-when-using-chest: "&7Dica: Digite &6/chestsort&7 para habilitar a organização automática."
#message-when-using-chest2: "&7Dica: Digite &6/chestsort&7 para desabilitar a organização automática."
#message-sorting-disabled: "&7A Organização automática de baús foi &cdesabilitada&7."
@@ -284,8 +342,15 @@ message-error-invalid-options: "&cError: Unknown option %s. Valid options are %s
#message-player-inventory-sorted: "&7Seu inventário foi organizado."
#message-error-players-only: "&cErro: Esse comando não pode ser executado por jogadores."
#message-error-invalid-options: "&cError: Unknown option %s. Valid options are %s."
+#message-gui-enabled: "&aEnabled"
+#message-gui-disabled: "&cDisabled"
+#message-gui-middle-click: "Middle-Click"
+#message-gui-shift-click: "Shift + Click"
+#message-gui-double-click: "Double-Click"
+#message-gui-shift-right-click: "Shift + Right-Click"
##### Russian - Thanks to Gandon for translating! -> https://www.spigotmc.org/members/gandon.443887/
+##### Note: Some messages are still untranslated. Please send me your translation at SpigotMC
#message-when-using-chest: "&7Подсказка: введите &6/chestsort&7, чтобы включить автоматическую сортировку вещей в сундуках."
#message-when-using-chest2: "&7Подсказка: введите &6/chestsort&7, чтобы отключить автоматическую сортировку вещей в сундуках."
#message-sorting-disabled: "&7Автоматическая сортировка вещей в сундуках была &cотключена&7."
@@ -293,8 +358,15 @@ message-error-invalid-options: "&cError: Unknown option %s. Valid options are %s
#message-player-inventory-sorted: "&7Ваш инвентарь был отсортирован."
#message-error-players-only: "&cОшибка: эта команда может быть использована только игроками."
#message-error-invalid-options: "&cОшибка: Неизвестная опция %s. Допустимые опции: %s."
+#message-gui-enabled: "&aEnabled"
+#message-gui-disabled: "&cDisabled"
+#message-gui-middle-click: "Middle-Click"
+#message-gui-shift-click: "Shift + Click"
+#message-gui-double-click: "Double-Click"
+#message-gui-shift-right-click: "Shift + Right-Click"
##### Spanish - Thanks to Bers_ for translating! -> https://www.spigotmc.org/members/bers_.146126/
+##### Note: Some messages are still untranslated. Please send me your translation at SpigotMC
#message-when-using-chest: "&7Pista: Usa &6/chestsort&7 para activar el orden automático de los cofres."
#message-when-using-chest2: "&7Pista: Usa &6/chestsort&7 para desactivar el orden automático de los cofres."
#message-sorting-disabled: "&7Orden automático de los cofres &cdesactivado&7."
@@ -302,8 +374,15 @@ message-error-invalid-options: "&cError: Unknown option %s. Valid options are %s
#message-player-inventory-sorted: "&7Tu inventario ha sido ordenado."
#message-error-players-only: "&cError: Este comando solo puede ser ejecutado por jugadores."
#message-error-invalid-options: "&cError: %s es una opción inválida. Las opciones válidas son: %s."
+#message-gui-enabled: "&aEnabled"
+#message-gui-disabled: "&cDisabled"
+#message-gui-middle-click: "Middle-Click"
+#message-gui-shift-click: "Shift + Click"
+#message-gui-double-click: "Double-Click"
+#message-gui-shift-right-click: "Shift + Right-Click"
##### Turkish - Thanks to bertek41 for translating!-> https://www.spigotmc.org/members/bertek41.247705/
+##### Note: Some messages are still untranslated. Please send me your translation at SpigotMC
#message-when-using-chest: "&7Ipucu: &6/chestsort&7 Yazarak Otomatik Sandık Organizasyon Sistemini Aktif Edebilirsin."
#message-when-using-chest2: "&7Ipucu: &6/chestsort&7 Yazarak Otomatik Sandık Organizasyon Sistemini Kapatabilirsin."
#message-sorting-disabled: "&7Otomatik Sandık Organizasyonu &cKapatıldı&7."
@@ -311,10 +390,16 @@ message-error-invalid-options: "&cError: Unknown option %s. Valid options are %s
#message-player-inventory-sorted: "&7Envanteriniz Düzenlendi."
#message-error-players-only: "&cHata: Bu Komut Yalnızca Oyuncular Tarafından Kullanılabilir."
#message-error-invalid-options: "&cHata: Bilinmeyen Ayar %s."
+#message-gui-enabled: "&aEnabled"
+#message-gui-disabled: "&cDisabled"
+#message-gui-middle-click: "Middle-Click"
+#message-gui-shift-click: "Shift + Click"
+#message-gui-double-click: "Double-Click"
+#message-gui-shift-right-click: "Shift + Right-Click"
#########################
##### Done! #####
#########################
# please do not change the following line manually!
-config-version: 17
+config-version: 18
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 0887ad2..cde6a8c 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -1,6 +1,6 @@
main: de.jeffclan.JeffChestSort.JeffChestSortPlugin
name: ChestSort
-version: 6.4.5
+version: 7.0-SNAPSHOT-1
api-version: 1.13
description: Allows automatic chest sorting
author: mfnalex
From 2acb0ceaec6fdc1b4178c22f1f18fbd1944cd1a6 Mon Sep 17 00:00:00 2001
From: mfnalex <1122571+mfnalex@users.noreply.github.com>
Date: Thu, 1 Aug 2019 18:50:22 +0200
Subject: [PATCH 2/2] 7.0 release
---
pom.xml | 2 +-
.../JeffChestSortCommandExecutor.java | 8 +++---
.../JeffChestSort/JeffChestSortListener.java | 3 +--
.../JeffChestSort/JeffChestSortMessages.java | 4 +--
.../JeffChestSort/JeffChestSortPlugin.java | 8 +++---
.../JeffChestSortSettingsGUI.java | 26 ++++++++++++-------
src/main/resources/plugin.yml | 4 +--
7 files changed, 31 insertions(+), 24 deletions(-)
diff --git a/pom.xml b/pom.xml
index 5bab183..e67c104 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
de.jeffclan
JeffChestSort
- 7.0-SNAPSHOT-1
+ 7.0
jar
JeffChestSort
diff --git a/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortCommandExecutor.java b/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortCommandExecutor.java
index 6663c41..02bdf22 100644
--- a/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortCommandExecutor.java
+++ b/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortCommandExecutor.java
@@ -33,10 +33,10 @@ public class JeffChestSortCommandExecutor implements CommandExecutor {
if(args.length>0) {
if(args[0].equalsIgnoreCase("hotkey") || args[0].equalsIgnoreCase("hotkeys")) {
- if(plugin.hotkeyGUI==false) {
- p.sendMessage(plugin.messages.MSG_ERR_HOTKEYSDISABLED);
- return true;
- }
+// if(plugin.hotkeyGUI==false) {
+// p.sendMessage(plugin.messages.MSG_ERR_HOTKEYSDISABLED);
+// return true;
+// }
plugin.settingsGUI.openGUI(p);
diff --git a/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortListener.java b/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortListener.java
index 3f8a1a1..964ea1e 100644
--- a/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortListener.java
+++ b/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortListener.java
@@ -422,8 +422,7 @@ public class JeffChestSortListener implements Listener {
if(event.getClickedInventory()==null) {
return;
}
-
- if(event.getClickedInventory() != setting.guiInventory) {
+ if(!event.getClickedInventory().equals(setting.guiInventory)) {
return;
}
diff --git a/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortMessages.java b/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortMessages.java
index df67e80..98ff629 100644
--- a/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortMessages.java
+++ b/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortMessages.java
@@ -14,7 +14,7 @@ public class JeffChestSortMessages {
JeffChestSortPlugin plugin;
final String MSG_ACTIVATED, MSG_DEACTIVATED, MSG_COMMANDMESSAGE, MSG_COMMANDMESSAGE2, MSG_PLAYERSONLY,
- MSG_PLAYERINVSORTED, MSG_INVALIDOPTIONS, MSG_ERR_HOTKEYSDISABLED;
+ MSG_PLAYERINVSORTED, MSG_INVALIDOPTIONS;
final String MSG_GUI_ENABLED, MSG_GUI_DISABLED;
@@ -62,7 +62,7 @@ public class JeffChestSortMessages {
MSG_GUI_SHIFTRIGHTCLICK = ChatColor.translateAlternateColorCodes('&', plugin.getConfig()
.getString("message-gui-shift-right-click","Shift + Right-Click"));
- MSG_ERR_HOTKEYSDISABLED = ChatColor.RED + "[ChestSort] Hotkey settings are only available for Minecraft 1.14 and later.";
+ //MSG_ERR_HOTKEYSDISABLED = ChatColor.RED + "[ChestSort] Hotkeys are only available for Minecraft 1.9 and later.";
}
}
diff --git a/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortPlugin.java b/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortPlugin.java
index cd7ebdf..4faf59d 100644
--- a/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortPlugin.java
+++ b/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortPlugin.java
@@ -235,10 +235,10 @@ public class JeffChestSortPlugin extends JavaPlugin {
mcMinorVersion = Integer.parseInt(tmpVersion.substring(0,tmpVersion.indexOf("_")));
//getLogger().info("Running MC version 1."+mcMinorVersion);
- if(mcMinorVersion < 14) {
- getLogger().info("You are running a Minecraft version below 1.14. Hotkey GUI will be disabled.");
- hotkeyGUI = false;
- }
+// if(mcMinorVersion < 9) {
+// getLogger().info("You are running a Minecraft version below 1.9. Hotkey GUI will be disabled.");
+// hotkeyGUI = false;
+// }
// Create the config file, including checks for old config versions, and load
// the default values for unset options
diff --git a/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortSettingsGUI.java b/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortSettingsGUI.java
index be05cba..487eeb7 100644
--- a/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortSettingsGUI.java
+++ b/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortSettingsGUI.java
@@ -18,6 +18,9 @@ public class JeffChestSortSettingsGUI {
public static int slotDoubleClick = 5 + 9;
public static int slotShiftRightClick = 7 + 9;
+ final static Material red = Material.REDSTONE_BLOCK;
+ final static Material green = Material.EMERALD_BLOCK;
+
enum Hotkey {
MiddleClick, ShiftClick, DoubleClick, ShiftRightClick;
}
@@ -29,12 +32,17 @@ public class JeffChestSortSettingsGUI {
ItemStack getItem(boolean active, Hotkey hotkey) {
ItemStack is = null;
String suffix;
- Material green = Material.getMaterial("GREEN_WOOL");
- Material red = Material.getMaterial("RED_WOOL");
+ //Material green = Material.getMaterial("GREEN_WOOL");
+ //Material red = Material.getMaterial("RED_WOOL");
+ //Material green = Material.GREEN_WOOL;
+ //Material red = Material.RED_WOOL;
- if(green==null || red==null) {
- return null;
- }
+// if(green==null || red==null) {
+// //plugin.getLogger().warning("Using unsupported Minecraft version");
+// green = Material.EMERALD_BLOCK;
+// red = Material.REDSTONE_BLOCK;
+// //return null;
+// }
if(active) {
is = new ItemStack(green);
@@ -75,10 +83,10 @@ public class JeffChestSortSettingsGUI {
JeffChestSortPlayerSetting setting = plugin.PerPlayerSettings.get(player.getUniqueId().toString());
// Test if running 1.13 or later
- if(Material.getMaterial("GREEN_WOOL") == null) {
- player.sendMessage(plugin.messages.MSG_ERR_HOTKEYSDISABLED);
- return;
- }
+// if(Material.getMaterial("GREEN_WOOL") == null) {
+// player.sendMessage(plugin.messages.MSG_ERR_HOTKEYSDISABLED);
+// return;
+// }
inventory.setItem(slotMiddleClick, getItem(setting.middleClick,Hotkey.MiddleClick));
inventory.setItem(slotShiftClick, getItem(setting.shiftClick,Hotkey.ShiftClick));
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index cde6a8c..2668ec6 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -1,6 +1,6 @@
main: de.jeffclan.JeffChestSort.JeffChestSortPlugin
name: ChestSort
-version: 7.0-SNAPSHOT-1
+version: 7.0
api-version: 1.13
description: Allows automatic chest sorting
author: mfnalex
@@ -11,7 +11,7 @@ loadbefore: [InvUnload]
softdepend: [CrackShot, InventoryPages]
commands:
chestsort:
- description: Toggle automatic chest sorting
+ description: Toggle automatic chest sorting.
usage: /
aliases: sort
permission: chestsort.use