From e3872e11b82b08de87f81ca26a3e46b4cd578cb5 Mon Sep 17 00:00:00 2001 From: rockyhawk64 Date: Fri, 4 Dec 2020 11:02:33 +1100 Subject: [PATCH] v3.14.1.1 --- .../commandpanels/CommandPanels.java | 2 +- .../classresources/CommandTags.java | 7 +++- .../classresources/ExecuteOpenVoids.java | 4 +-- .../commands/Commandpanelsreload.java | 1 - .../ingameeditor/EditorUtils.java | 14 +++----- .../openpanelsmanager/OpenPanelsLoader.java | 35 ++++++++++++++----- .../openpanelsmanager/UtilsPanelsLoader.java | 31 ++++------------ 7 files changed, 47 insertions(+), 47 deletions(-) diff --git a/src/me/rockyhawk/commandpanels/CommandPanels.java b/src/me/rockyhawk/commandpanels/CommandPanels.java index 6170bbb..b3ba166 100644 --- a/src/me/rockyhawk/commandpanels/CommandPanels.java +++ b/src/me/rockyhawk/commandpanels/CommandPanels.java @@ -493,7 +493,7 @@ public class CommandPanels extends JavaPlugin { ArrayList opanelsTemp = new ArrayList(); for(String tempName : apanels){ if(opanelsTemp.contains(tempName)){ - sender.sendMessage("[CommandPanels]" + ChatColor.RED + " Error duplicate panel name: " + tempName); + sender.sendMessage(papi(tag) + ChatColor.RED + " Error duplicate panel name: " + tempName); return false; } opanelsTemp.add(tempName); diff --git a/src/me/rockyhawk/commandpanels/classresources/CommandTags.java b/src/me/rockyhawk/commandpanels/classresources/CommandTags.java index 428529d..f6ca01d 100644 --- a/src/me/rockyhawk/commandpanels/classresources/CommandTags.java +++ b/src/me/rockyhawk/commandpanels/classresources/CommandTags.java @@ -55,6 +55,7 @@ public class CommandTags { for(String[] tempName : plugin.panelNames){ if(tempName[0].equals(panelName)){ ConfigurationSection panelConfig = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + plugin.panelFiles.get(Integer.parseInt(tempName[1])))).getConfigurationSection("panels." + panelName); + plugin.openPanels.skipPanels.add(p.getName()); plugin.openVoids.openCommandPanel(p,p,panelName,panelConfig,false); return; } @@ -487,7 +488,11 @@ public class CommandTags { }else if (command.split("\\s")[0].equalsIgnoreCase("item-paywall=")) { //if player uses item-paywall= [Material] [Amount] [Id] try { - ItemStack sellItem = new ItemStack(Objects.requireNonNull(Material.matchMaterial(command.split("\\s")[1])),Integer.parseInt(command.split("\\s")[2]), Short.parseShort(command.split("\\s")[3])); + short id = 0; + if(command.split("\\s").length == 4){ + id = Short.parseShort(command.split("\\s")[3]); + } + ItemStack sellItem = new ItemStack(Objects.requireNonNull(Material.matchMaterial(command.split("\\s")[1])),Integer.parseInt(command.split("\\s")[2]), id); int sellItemAmount = sellItem.getAmount(); sellItem.setAmount(1); int removedItem = 0; diff --git a/src/me/rockyhawk/commandpanels/classresources/ExecuteOpenVoids.java b/src/me/rockyhawk/commandpanels/classresources/ExecuteOpenVoids.java index 4688935..5810cc8 100644 --- a/src/me/rockyhawk/commandpanels/classresources/ExecuteOpenVoids.java +++ b/src/me/rockyhawk/commandpanels/classresources/ExecuteOpenVoids.java @@ -42,8 +42,8 @@ public class ExecuteOpenVoids { sender.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.notitem"))); return; } - //close the inventory after the checks for permissions and worlds, so other panels can load - p.closeInventory(); + //close the panel after the checks for permissions and worlds, so other panels can load + plugin.openPanels.closePanelsForLoader(p.getName()); try { if (cf.contains("sound-on-open")) { //play sound when panel is opened diff --git a/src/me/rockyhawk/commandpanels/commands/Commandpanelsreload.java b/src/me/rockyhawk/commandpanels/commands/Commandpanelsreload.java index aeeff1c..cb3cc36 100644 --- a/src/me/rockyhawk/commandpanels/commands/Commandpanelsreload.java +++ b/src/me/rockyhawk/commandpanels/commands/Commandpanelsreload.java @@ -14,7 +14,6 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.List; -import java.util.Map; public class Commandpanelsreload implements CommandExecutor { CommandPanels plugin; diff --git a/src/me/rockyhawk/commandpanels/ingameeditor/EditorUtils.java b/src/me/rockyhawk/commandpanels/ingameeditor/EditorUtils.java index 10f211c..11b5087 100644 --- a/src/me/rockyhawk/commandpanels/ingameeditor/EditorUtils.java +++ b/src/me/rockyhawk/commandpanels/ingameeditor/EditorUtils.java @@ -325,16 +325,12 @@ public class EditorUtils implements Listener { public void onPlayerClosePanel(InventoryCloseEvent e){ //this is put here to avoid conflicts, close panel if it is closed for(int i = 0; i < plugin.openPanels.openPanelsPN.size(); i++){ + if(plugin.openPanels.skipPanels.contains(e.getPlayer().getName())){ + plugin.openPanels.skipPanels.remove(e.getPlayer().getName()); + break; + } if(plugin.openPanels.openPanelsPN.get(i)[0].equals(e.getPlayer().getName())){ - plugin.openPanels.panelCloseCommands(e.getPlayer().getName(),plugin.openPanels.openPanelsPN.get(i)[1]); - plugin.customCommand.removeCCP(plugin.openPanels.openPanelsPN.get(i)[1], e.getPlayer().getName()); - if (plugin.config.contains("config.panel-snooper")) { - if (Objects.requireNonNull(plugin.config.getString("config.panel-snooper")).trim().equalsIgnoreCase("true")) { - Bukkit.getConsoleSender().sendMessage("[CommandPanels] " + e.getPlayer().getName() + " Closed " + plugin.openPanels.openPanelsPN.get(i)[1]); - } - } - plugin.openPanels.openPanelsPN.remove(i); - plugin.openPanels.openPanelsCF.remove(i); + plugin.openPanels.closePanelForLoader(e.getPlayer().getName(), plugin.openPanels.openPanelsPN.get(i)[1]); return; } } diff --git a/src/me/rockyhawk/commandpanels/openpanelsmanager/OpenPanelsLoader.java b/src/me/rockyhawk/commandpanels/openpanelsmanager/OpenPanelsLoader.java index 844569d..5c77b52 100644 --- a/src/me/rockyhawk/commandpanels/openpanelsmanager/OpenPanelsLoader.java +++ b/src/me/rockyhawk/commandpanels/openpanelsmanager/OpenPanelsLoader.java @@ -22,6 +22,9 @@ public class OpenPanelsLoader { public List openPanelsCF = new ArrayList<>(); //panel config section public List openPanelsPN = new ArrayList<>(); //PLayer Name, Panel Name + //this will skip certain panels from closing for players + public List skipPanels = new ArrayList<>(); //PLayer Name + //this will return the panel CF based on the player, if it isn't there it returns null public ConfigurationSection getOpenPanel(String playerName){ for(int i = 0; i < openPanelsCF.size(); i++){ @@ -53,9 +56,9 @@ public class OpenPanelsLoader { } //true if the player has a panel open - public boolean hasPanelOpen(String playerName){ - for(String[] temp : openPanelsPN){ - if(temp[0].equals(playerName)){ + public boolean hasPanelOpen(String playerName) { + for (String[] temp : openPanelsPN) { + if (temp[0].equals(playerName)) { return true; } } @@ -81,14 +84,28 @@ public class OpenPanelsLoader { } } - //tell loader that the panel is closed - public void closePanelForLoader(String playerName, String panelName){ - for(int i = 0; i < openPanelsCF.size(); i++){ - if(Arrays.equals(openPanelsPN.get(i), new String[]{playerName, panelName})){ - panelCloseCommands(playerName,panelName); + //close all of the panels for a player currently open + public void closePanelsForLoader(String playerName){ + for(int i = 0; i < openPanelsPN.size(); i++){ + if(openPanelsPN.get(i)[0].equals(playerName)){ + panelCloseCommands(playerName,openPanelsPN.get(i)[1]); + plugin.customCommand.removeCCP(openPanelsPN.get(i)[1], playerName); openPanelsCF.remove(i); openPanelsPN.remove(i); - return; + i--; + } + } + } + + //tell loader that the panel is closed + public void closePanelForLoader(String playerName, String panelName){ + for(int i = 0; i < openPanelsPN.size(); i++){ + if(Arrays.equals(openPanelsPN.get(i), new String[]{playerName, panelName})){ + panelCloseCommands(playerName,panelName); + plugin.customCommand.removeCCP(panelName, playerName); + openPanelsCF.remove(i); + openPanelsPN.remove(i); + break; } } if (plugin.config.contains("config.panel-snooper")) { diff --git a/src/me/rockyhawk/commandpanels/openpanelsmanager/UtilsPanelsLoader.java b/src/me/rockyhawk/commandpanels/openpanelsmanager/UtilsPanelsLoader.java index d3de0d9..1d945f6 100644 --- a/src/me/rockyhawk/commandpanels/openpanelsmanager/UtilsPanelsLoader.java +++ b/src/me/rockyhawk/commandpanels/openpanelsmanager/UtilsPanelsLoader.java @@ -1,7 +1,6 @@ package me.rockyhawk.commandpanels.openpanelsmanager; import me.rockyhawk.commandpanels.CommandPanels; -import org.bukkit.Bukkit; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.inventory.InventoryCloseEvent; @@ -18,20 +17,7 @@ public class UtilsPanelsLoader implements Listener { //tell panel loader that player has opened panel @EventHandler public void onPlayerClosePanel(PlayerQuitEvent e){ - for(int i = 0; i < plugin.openPanels.openPanelsPN.size(); i++){ - if(plugin.openPanels.openPanelsPN.get(i)[0].equals(e.getPlayer().getName())){ - plugin.openPanels.panelCloseCommands(e.getPlayer().getName(),plugin.openPanels.openPanelsPN.get(i)[1]); - plugin.customCommand.removeCCP(plugin.openPanels.openPanelsPN.get(i)[1], e.getPlayer().getName()); - if (plugin.config.contains("config.panel-snooper")) { - if (Objects.requireNonNull(plugin.config.getString("config.panel-snooper")).trim().equalsIgnoreCase("true")) { - Bukkit.getConsoleSender().sendMessage("[CommandPanels] " + e.getPlayer().getName() + " Closed " + plugin.openPanels.openPanelsPN.get(i)[1]); - } - } - plugin.openPanels.openPanelsPN.remove(i); - plugin.openPanels.openPanelsCF.remove(i); - return; - } - } + plugin.openPanels.closePanelsForLoader(e.getPlayer().getName()); } //tell panel loader that player has closed the panel (there is also one of these in EditorUtils) @@ -40,17 +26,14 @@ public class UtilsPanelsLoader implements Listener { //only do this if editor is disabled as it will disabled this code if(!Objects.requireNonNull(plugin.config.getString("config.ingame-editor")).equalsIgnoreCase("true")) { //this is put here to avoid conflicts, close panel if it is closed + if(plugin.openPanels.skipPanels.contains(e.getPlayer().getName())){ + plugin.openPanels.skipPanels.remove(e.getPlayer().getName()); + return; + } + //loop panels for (int i = 0; i < plugin.openPanels.openPanelsPN.size(); i++) { if (plugin.openPanels.openPanelsPN.get(i)[0].equals(e.getPlayer().getName())) { - plugin.openPanels.panelCloseCommands(e.getPlayer().getName(),plugin.openPanels.openPanelsPN.get(i)[1]); - plugin.customCommand.removeCCP(plugin.openPanels.openPanelsPN.get(i)[1], e.getPlayer().getName()); - if (plugin.config.contains("config.panel-snooper")) { - if (Objects.requireNonNull(plugin.config.getString("config.panel-snooper")).trim().equalsIgnoreCase("true")) { - Bukkit.getConsoleSender().sendMessage("[CommandPanels] " + e.getPlayer().getName() + " Closed " + plugin.openPanels.openPanelsPN.get(i)[1]); - } - } - plugin.openPanels.openPanelsPN.remove(i); - plugin.openPanels.openPanelsCF.remove(i); + plugin.openPanels.closePanelForLoader(e.getPlayer().getName(),plugin.openPanels.openPanelsPN.get(i)[1]); return; } }