From 2652704a9d69111f3ee79b6d04a620077a1143ee Mon Sep 17 00:00:00 2001 From: rockyhawk64 Date: Tue, 29 Dec 2020 21:59:36 +1100 Subject: [PATCH] v3.14.4.4 --- resource/plugin.yml | 2 +- src/me/rockyhawk/commandpanels/Utils.java | 64 +++++++++++-------- .../classresources/CommandTags.java | 31 +++++++-- 3 files changed, 64 insertions(+), 33 deletions(-) diff --git a/resource/plugin.yml b/resource/plugin.yml index 0fa57fc..9c0ebb9 100644 --- a/resource/plugin.yml +++ b/resource/plugin.yml @@ -1,4 +1,4 @@ -version: 3.14.4.3 +version: 3.14.4.4 main: me.rockyhawk.commandpanels.CommandPanels name: CommandPanels author: RockyHawk diff --git a/src/me/rockyhawk/commandpanels/Utils.java b/src/me/rockyhawk/commandpanels/Utils.java index 141fe7f..9aacbab 100644 --- a/src/me/rockyhawk/commandpanels/Utils.java +++ b/src/me/rockyhawk/commandpanels/Utils.java @@ -79,38 +79,46 @@ public class Utils implements Listener { commands = commandsAfterSequence; for (int i = 0; commands.size() - 1 >= i; i++) { try { - if (commands.get(i).split("\\s")[0].equalsIgnoreCase("right=")) { - //if commands is for right clicking, remove the 'right=' and continue - commands.set(i, commands.get(i).replace("right=", "").trim()); - commands.set(i, commands.get(i).replace("RIGHT=", "").trim()); - if (e.isLeftClick() || (e.isShiftClick() && e.isLeftClick()) || (e.isShiftClick() && e.isRightClick())) { - continue; + switch(commands.get(i).split("\\s")[0]){ + case "right=":{ + //if commands is for right clicking, remove the 'right=' and continue + commands.set(i, commands.get(i).replace("right=", "").trim()); + if (e.getClick() != ClickType.RIGHT) { + continue; + } + break; } - } else if (commands.get(i).split("\\s")[0].equalsIgnoreCase("rightshift=")) { - //if commands is for right clicking, remove the 'right=' and continue - commands.set(i, commands.get(i).replace("rightshift=", "").trim()); - commands.set(i, commands.get(i).replace("RIGHTSHIFT=", "").trim()); - if (e.isLeftClick() || (!e.isShiftClick() && e.isRightClick())) { - continue; + case "rightshift=":{ + //if commands is for right clicking, remove the 'right=' and continue + commands.set(i, commands.get(i).replace("rightshift=", "").trim()); + if (e.getClick() != ClickType.SHIFT_RIGHT) { + continue; + } + break; } - } - if (commands.get(i).split("\\s")[0].equalsIgnoreCase("left=")) { - //if commands is for right clicking, remove the 'right=' and continue - commands.set(i, commands.get(i).replace("left=", "").trim()); - commands.set(i, commands.get(i).replace("LEFT=", "").trim()); - if (e.isRightClick() || (e.isShiftClick() && e.isRightClick()) || (e.isShiftClick() && e.isLeftClick())) { - continue; + case "left=":{ + //if commands is for right clicking, remove the 'right=' and continue + commands.set(i, commands.get(i).replace("left=", "").trim()); + if (e.getClick() != ClickType.LEFT) { + continue; + } + break; } - } else if (commands.get(i).split("\\s")[0].equalsIgnoreCase("leftshift=")) { - //if commands is for right clicking, remove the 'right=' and continue - commands.set(i, commands.get(i).replace("leftshift=", "").trim()); - commands.set(i, commands.get(i).replace("LEFTSHIFT=", "").trim()); - if (e.isRightClick() || (!e.isShiftClick() && e.isLeftClick())) { - continue; + case "leftshift=":{ + //if commands is for right clicking, remove the 'right=' and continue + commands.set(i, commands.get(i).replace("leftshift=", "").trim()); + if (e.getClick() != ClickType.SHIFT_LEFT) { + continue; + } + break; + } + case "middle=":{ + commands.set(i, commands.get(i).replace("middle=", "").trim()); + if (e.getClick() != ClickType.MIDDLE) { + continue; + } + break; } - } - if (!e.isLeftClick() && !e.isRightClick()) { - continue; } } catch (Exception click) { //skip if you can't do this diff --git a/src/me/rockyhawk/commandpanels/classresources/CommandTags.java b/src/me/rockyhawk/commandpanels/classresources/CommandTags.java index 0edd32b..3a7c827 100644 --- a/src/me/rockyhawk/commandpanels/classresources/CommandTags.java +++ b/src/me/rockyhawk/commandpanels/classresources/CommandTags.java @@ -15,6 +15,7 @@ import org.bukkit.scheduler.BukkitRunnable; import java.io.File; import java.util.Objects; +import java.util.UUID; public class CommandTags { CommandPanels plugin; @@ -42,17 +43,29 @@ public class CommandTags { break; } case "set-data=":{ - //this will overwrite data. set-data= [data point] [data value] + if(command.split("\\s").length == 4){ + plugin.panelData.setUserData(getOffline(command.split("\\s")[3]),command.split("\\s")[1],command.split("\\s")[2],true); + break; + } + //this will overwrite data. set-data= [data point] [data value] [optional player] plugin.panelData.setUserData(p.getUniqueId(),command.split("\\s")[1],command.split("\\s")[2],true); break; } case "add-data=":{ - //this will not overwrite existing data. add-data= [data point] [data value] + if(command.split("\\s").length == 4){ + plugin.panelData.setUserData(getOffline(command.split("\\s")[3]),command.split("\\s")[1],command.split("\\s")[2],true); + break; + } + //this will not overwrite existing data. add-data= [data point] [data value] [optional player] plugin.panelData.setUserData(p.getUniqueId(),command.split("\\s")[1],command.split("\\s")[2],false); break; } case "math-data=":{ - //only works if data is number, goes math-data= [data point] [operator:number] eg, math-data= -1 OR /3 + if(command.split("\\s").length == 4){ + plugin.panelData.setUserData(getOffline(command.split("\\s")[3]),command.split("\\s")[1],command.split("\\s")[2],true); + break; + } + //only works if data is number, goes math-data= [data point] [operator:number] [optional player] eg, math-data= -1 OR /3 plugin.panelData.doDataMath(p.getUniqueId(),command.split("\\s")[1],command.split("\\s")[2]); break; } @@ -62,7 +75,11 @@ public class CommandTags { break; } case "del-data=":{ - //this will remove data. del-data= [data point] + if(command.split("\\s").length == 3){ + plugin.panelData.setUserData(getOffline(command.split("\\s")[3]),command.split("\\s")[1],command.split("\\s")[2],true); + break; + } + //this will remove data. del-data= [data point] [optional player] plugin.panelData.delUserData(p.getUniqueId(),command.split("\\s")[1]); break; } @@ -522,6 +539,12 @@ public class CommandTags { } } + @SuppressWarnings("deprecation") + private UUID getOffline(String playerName){ + //making this a separate function as it is long and deprecated + return Bukkit.getOfflinePlayer(playerName).getUniqueId(); + } + @SuppressWarnings("deprecation") public int commandPayWall(Player p, String command) { //return 0 means no funds, 1 is they passed and 2 means paywall is not this command String tag = plugin.config.getString("config.format.tag") + " ";