From f6f3ff0313edaa3ea529274c2d4f658ba9a91dff Mon Sep 17 00:00:00 2001 From: rockyhawk64 Date: Mon, 17 Aug 2020 18:44:11 +1000 Subject: [PATCH] 3.9.1 Fixes --- Command Panels.iml | 2 +- resource/plugin.yml | 2 +- .../commandPanels/commandpanels.java | 49 ++++++++++--------- .../commandPanels/commands/commandpanel.java | 3 +- .../commands/commandpanelcustom.java | 3 +- .../commands/commandpanelslist.java | 6 +-- .../completeTabs/cpTabComplete.java | 25 +++++----- .../ingameEditor/cpIngameEditCommand.java | 3 +- .../ingameEditor/cpTabCompleteIngame.java | 2 +- .../ingameEditor/editorUtils.java | 12 ++--- .../openWithItem/utilsOpenWithItem.java | 16 +++--- .../panelBlocks/blocksTabComplete.java | 2 +- .../premium/commandpanelrefresher.java | 4 +- 13 files changed, 63 insertions(+), 66 deletions(-) diff --git a/Command Panels.iml b/Command Panels.iml index 4baa056..4603bb8 100644 --- a/Command Panels.iml +++ b/Command Panels.iml @@ -6,7 +6,7 @@ - + diff --git a/resource/plugin.yml b/resource/plugin.yml index aab103f..0fda631 100644 --- a/resource/plugin.yml +++ b/resource/plugin.yml @@ -1,4 +1,4 @@ -version: 3.9.0 +version: 3.9.1 main: me.rockyhawk.commandPanels.commandpanels name: CommandPanels author: RockyHawk diff --git a/src/me/rockyhawk/commandPanels/commandpanels.java b/src/me/rockyhawk/commandPanels/commandpanels.java index 97c5210..c9d700b 100644 --- a/src/me/rockyhawk/commandPanels/commandpanels.java +++ b/src/me/rockyhawk/commandPanels/commandpanels.java @@ -354,7 +354,8 @@ public class commandpanels extends JavaPlugin { } public ItemStack getItem(String b64stringtexture) { - GameProfile profile = new GameProfile(UUID.randomUUID(), (String) null); + //get head from base64 + GameProfile profile = new GameProfile(UUID.randomUUID(), null); PropertyMap propertyMap = profile.getProperties(); if (propertyMap == null) { throw new IllegalStateException("Profile doesn't contain a property map"); @@ -378,7 +379,6 @@ public class commandpanels extends JavaPlugin { private Field getField(Class target, String name, Class fieldType, int index) { Field[] var4 = target.getDeclaredFields(); - int var5 = var4.length; for (Field field : var4) { if ((name == null || field.getName().equals(name)) && fieldType.isAssignableFrom(field.getType()) && index-- <= 0) { @@ -1005,6 +1005,11 @@ public class commandpanels extends JavaPlugin { if(!fileName.substring(ind).equalsIgnoreCase(".yml") && !fileName.substring(ind).equalsIgnoreCase(".yaml")){ continue; } + //check before adding the file to commandpanels + if(!checkPanels(YamlConfiguration.loadConfiguration(new File(directory + File.separator + fileName)))){ + this.getServer().getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.RED + " Error in: " + fileName); + continue; + } panelFiles.add((directory + File.separator + fileName).replace(panelsf.toString() + File.separator,"")); for (String tempName : Objects.requireNonNull(YamlConfiguration.loadConfiguration(new File(directory + File.separator + fileName)).getConfigurationSection("panels")).getKeys(false)) { panelNames.add(new String[]{tempName, Integer.toString(count)}); @@ -1014,24 +1019,25 @@ public class commandpanels extends JavaPlugin { } public void reloadPanelFiles() { - try { - panelFiles.clear(); - panelNames.clear(); - //load panel files - fileNamesFromDirectory(panelsf); - //this bit will set openWithItem to false/true upson reload - YamlConfiguration tempFile; - String tempName; - openWithItem = false; - for(String[] panelName : panelNames){ - tempFile = YamlConfiguration.loadConfiguration(new File(panelsf + File.separator + panelFiles.get(Integer.parseInt(panelName[1])))); - tempName = panelName[0]; - if(tempFile.contains("panels." + tempName + ".open-with-item")) { - openWithItem = true; - } + panelFiles.clear(); + panelNames.clear(); + //load panel files + fileNamesFromDirectory(panelsf); + //this bit will set openWithItem to false/true upson reload + YamlConfiguration tempFile; + String tempName; + openWithItem = false; + for(String[] panelName : panelNames){ + tempFile = YamlConfiguration.loadConfiguration(new File(panelsf + File.separator + panelFiles.get(Integer.parseInt(panelName[1])))); + if(!checkPanels(tempFile)){ + this.getServer().getConsoleSender().sendMessage("[CommandPanels] Error in: " + panelFiles.get(Integer.parseInt(panelName[1]))); + continue; + } + tempName = panelName[0]; + if(tempFile.contains("panels." + tempName + ".open-with-item")) { + openWithItem = true; + break; } - } catch (NullPointerException noPanels) { - this.getServer().getConsoleSender().sendMessage("[CommandPanels] No panels found to load!"); } } @@ -1096,7 +1102,6 @@ public class commandpanels extends JavaPlugin { }}; public void openEditorGui(Player p, int pageChange) { - reloadPanelFiles(); Inventory i = Bukkit.createInventory(null, 54, "Command Panels Editor"); ArrayList panelNames = new ArrayList(); //all panels from ALL files (panel names) ArrayList panelTitles = new ArrayList(); //all panels from ALL files (panel titles) @@ -1106,7 +1111,7 @@ public class commandpanels extends JavaPlugin { YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(panelsf + File.separator + fileName)); String key; if (!checkPanels(temp)) { - return; + continue; } for (String s : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)) { key = s; @@ -1185,7 +1190,6 @@ public class commandpanels extends JavaPlugin { } public void openPanelSettings(Player p, String panelName, YamlConfiguration cf) { - reloadPanelFiles(); Inventory i = Bukkit.createInventory(null, 45, "Panel Settings: " + panelName); List lore = new ArrayList(); ItemStack temp; @@ -1370,7 +1374,6 @@ public class commandpanels extends JavaPlugin { } public void openItemSettings(Player p, String panelName, YamlConfiguration cf, int itemNumber) { - reloadPanelFiles(); Inventory i = Bukkit.createInventory(null, 36, "Item Settings: " + panelName); List lore = new ArrayList(); ItemStack temp; diff --git a/src/me/rockyhawk/commandPanels/commands/commandpanel.java b/src/me/rockyhawk/commandPanels/commands/commandpanel.java index 1d1f022..b03604e 100644 --- a/src/me/rockyhawk/commandPanels/commands/commandpanel.java +++ b/src/me/rockyhawk/commandPanels/commands/commandpanel.java @@ -33,8 +33,7 @@ public class commandpanel implements CommandExecutor { for(String fileName : plugin.panelFiles) { //will loop through all the files in folder YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName)); if(!plugin.checkPanels(temp)){ - sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + ": Panel with syntax error found!")); - return true; + continue; } for (String key : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)) { apanels.add(temp.getString("panels." + key + ".title")); diff --git a/src/me/rockyhawk/commandPanels/commands/commandpanelcustom.java b/src/me/rockyhawk/commandPanels/commands/commandpanelcustom.java index 1155602..5f1f058 100644 --- a/src/me/rockyhawk/commandPanels/commands/commandpanelcustom.java +++ b/src/me/rockyhawk/commandPanels/commands/commandpanelcustom.java @@ -40,8 +40,7 @@ public class commandpanelcustom implements Listener { String key; tpanels = ""; if(!plugin.checkPanels(temp)){ - p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + ": File with no Panels found!")); - return; + continue; } for (Iterator var10 = Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") { key = (String) var10.next(); diff --git a/src/me/rockyhawk/commandPanels/commands/commandpanelslist.java b/src/me/rockyhawk/commandPanels/commands/commandpanelslist.java index e5b4f6c..688e39f 100644 --- a/src/me/rockyhawk/commandPanels/commands/commandpanelslist.java +++ b/src/me/rockyhawk/commandPanels/commands/commandpanelslist.java @@ -42,8 +42,8 @@ public class commandpanelslist implements CommandExecutor { temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + plugin.panelFiles.get(f))); apanels.add("%file%" + plugin.panelFiles.get(f)); if(!plugin.checkPanels(temp)){ - sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + ": File with no Panels found!")); - return true; + apanels.add("Error Reading File!"); + continue; } for (Iterator var10 = temp.getConfigurationSection("panels").getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") { key = (String) var10.next(); @@ -74,7 +74,7 @@ public class commandpanelslist implements CommandExecutor { sender.sendMessage(ChatColor.AQUA + "Type /cpl " + (page+1) + " to read next page"); break; } - sender.sendMessage(ChatColor.DARK_GREEN + apanels.get(f).replaceAll("%file%","").replaceAll(".yml","")); + sender.sendMessage(ChatColor.DARK_GREEN + apanels.get(f).replaceAll("%file%","")); }else{ sender.sendMessage(ChatColor.GREEN + "- " + apanels.get(f)); } diff --git a/src/me/rockyhawk/commandPanels/completeTabs/cpTabComplete.java b/src/me/rockyhawk/commandPanels/completeTabs/cpTabComplete.java index 1fc638e..99ab4a7 100644 --- a/src/me/rockyhawk/commandPanels/completeTabs/cpTabComplete.java +++ b/src/me/rockyhawk/commandPanels/completeTabs/cpTabComplete.java @@ -6,6 +6,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.command.TabCompleter; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; +import org.yaml.snakeyaml.scanner.ScannerException; import java.io.File; import java.util.ArrayList; @@ -23,35 +24,35 @@ public class cpTabComplete implements TabCompleter { if(label.equalsIgnoreCase("cp") || label.equalsIgnoreCase("cpanel") || label.equalsIgnoreCase("commandpanel")){ ArrayList apanels = new ArrayList(); //all panels String tpanels; //tpanels is the temp to check through the files - try { - for(String fileName : plugin.panelFiles) { //will loop through all the files in folder + for(String fileName : plugin.panelFiles) { //will loop through all the files in folder + try { YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName)); String key; tpanels = ""; - if(!plugin.checkPanels(temp)){ - return null; + if (!plugin.checkPanels(temp)) { + continue; } for (Iterator var10 = temp.getConfigurationSection("panels").getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") { key = (String) var10.next(); - if(!key.startsWith(args[0])){ + if (!key.startsWith(args[0])) { //this will narrow down the panels to what the user types continue; } - if(sender.hasPermission("commandpanel.panel." + temp.getString("panels." + key + ".perm"))) { - if(temp.contains("panels." + key + ".disabled-worlds")){ + if (sender.hasPermission("commandpanel.panel." + temp.getString("panels." + key + ".perm"))) { + if (temp.contains("panels." + key + ".disabled-worlds")) { List disabledWorlds = temp.getStringList("panels." + key + ".disabled-worlds"); - if(!disabledWorlds.contains(p.getWorld().getName())){ + if (!disabledWorlds.contains(p.getWorld().getName())) { apanels.add(key); } - }else{ + } else { apanels.add(key); } } } - //if file contains opened panel then start + }catch(Exception skip){ + //ignore panel } - }catch(Exception fail){ - //could not fetch all panel names (probably no panels exist) + //if file contains opened panel then start } return apanels; } diff --git a/src/me/rockyhawk/commandPanels/ingameEditor/cpIngameEditCommand.java b/src/me/rockyhawk/commandPanels/ingameEditor/cpIngameEditCommand.java index 9477322..5554924 100644 --- a/src/me/rockyhawk/commandPanels/ingameEditor/cpIngameEditCommand.java +++ b/src/me/rockyhawk/commandPanels/ingameEditor/cpIngameEditCommand.java @@ -49,8 +49,7 @@ public class cpIngameEditCommand implements CommandExecutor { tpanels = ""; temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + filename)); if (!plugin.checkPanels(temp)) { - sender.sendMessage(plugin.papi( tag + plugin.config.getString("config.format.error") + ": File with no Panels found!")); - return true; + continue; } for (Iterator var10 = temp.getConfigurationSection("panels").getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") { key = (String) var10.next(); diff --git a/src/me/rockyhawk/commandPanels/ingameEditor/cpTabCompleteIngame.java b/src/me/rockyhawk/commandPanels/ingameEditor/cpTabCompleteIngame.java index bb123d0..737835d 100644 --- a/src/me/rockyhawk/commandPanels/ingameEditor/cpTabCompleteIngame.java +++ b/src/me/rockyhawk/commandPanels/ingameEditor/cpTabCompleteIngame.java @@ -30,7 +30,7 @@ public class cpTabCompleteIngame implements TabCompleter { String key; tpanels = ""; if(!plugin.checkPanels(temp)){ - return null; + continue; } for (Iterator var10 = Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") { key = (String) var10.next(); diff --git a/src/me/rockyhawk/commandPanels/ingameEditor/editorUtils.java b/src/me/rockyhawk/commandPanels/ingameEditor/editorUtils.java index 07a7ae4..73dcaa6 100644 --- a/src/me/rockyhawk/commandPanels/ingameEditor/editorUtils.java +++ b/src/me/rockyhawk/commandPanels/ingameEditor/editorUtils.java @@ -49,7 +49,7 @@ public class editorUtils implements Listener { YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName)); String key; if(!plugin.checkPanels(temp)){ - return; + continue; } for (String s : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)) { key = s; @@ -146,7 +146,7 @@ public class editorUtils implements Listener { YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName)); String key; if(!plugin.checkPanels(temp)){ - return; + continue; } for (String s : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)) { key = s; @@ -213,7 +213,7 @@ public class editorUtils implements Listener { YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + tempName)); String key; if(!plugin.checkPanels(temp)){ - return; + continue; } for (String s : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)) { key = s; @@ -332,7 +332,7 @@ public class editorUtils implements Listener { for(String fileName : plugin.panelFiles) { //will loop through all the files in folder YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName)); if(!plugin.checkPanels(temp)){ - return; + continue; } for (String key : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)){ if(e.getView().getTitle().equals("Panel Settings: " + key)){ @@ -459,7 +459,7 @@ public class editorUtils implements Listener { for(String fileName : plugin.panelFiles) { //will loop through all the files in folder YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName)); if(!plugin.checkPanels(temp)){ - return; + continue; } for (String key : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)){ if(e.getView().getTitle().equals("Item Settings: " + key)){ @@ -594,7 +594,7 @@ public class editorUtils implements Listener { YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + tempFile)); String key; if(!plugin.checkPanels(temp)){ - return; + continue; } for (String s : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)) { key = s; diff --git a/src/me/rockyhawk/commandPanels/openWithItem/utilsOpenWithItem.java b/src/me/rockyhawk/commandPanels/openWithItem/utilsOpenWithItem.java index 9f13b5e..fdd5d7e 100644 --- a/src/me/rockyhawk/commandPanels/openWithItem/utilsOpenWithItem.java +++ b/src/me/rockyhawk/commandPanels/openWithItem/utilsOpenWithItem.java @@ -141,7 +141,7 @@ public class utilsOpenWithItem implements Listener { String key; tpanels = ""; if(!plugin.checkPanels(temp)){ - return; + continue; } for (Iterator var10 = Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") { key = (String) var10.next(); @@ -184,7 +184,7 @@ public class utilsOpenWithItem implements Listener { String key; tpanels = ""; if(!plugin.checkPanels(temp)){ - return; + continue; } for (Iterator var10 = temp.getConfigurationSection("panels").getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") { key = (String) var10.next(); @@ -225,7 +225,7 @@ public class utilsOpenWithItem implements Listener { String key; tpanels = ""; if(!plugin.checkPanels(temp)){ - return; + continue; } for (Iterator var10 = Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") { key = (String) var10.next(); @@ -259,8 +259,7 @@ public class utilsOpenWithItem implements Listener { String key; tpanels = ""; if(!plugin.checkPanels(temp)){ - p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + ": Missing required component in panel!")); - return; + continue; } for (Iterator var10 = Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") { key = (String) var10.next(); @@ -312,7 +311,6 @@ public class utilsOpenWithItem implements Listener { }catch(Exception b){ return; } - YamlConfiguration cf; //this is the file to use for any panel.* requests String tpanels; //tpanels is the temp to check through the files ItemStack clicked = e.getItemDrop().getItemStack(); for(String fileName : plugin.panelFiles) { //will loop through all the files in folder @@ -320,7 +318,7 @@ public class utilsOpenWithItem implements Listener { String key; tpanels = ""; if(!plugin.checkPanels(temp)){ - return; + continue; } for (Iterator var10 = Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") { key = (String) var10.next(); @@ -371,7 +369,7 @@ public class utilsOpenWithItem implements Listener { String key; tpanels = ""; if(!plugin.checkPanels(temp)){ - return; + continue; } for (Iterator var10 = Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") { key = (String) var10.next(); @@ -423,7 +421,7 @@ public class utilsOpenWithItem implements Listener { String key; tpanels = ""; if(!plugin.checkPanels(temp)){ - return; + continue; } for (Iterator var10 = Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") { key = (String) var10.next(); diff --git a/src/me/rockyhawk/commandPanels/panelBlocks/blocksTabComplete.java b/src/me/rockyhawk/commandPanels/panelBlocks/blocksTabComplete.java index 909a248..401b6d0 100644 --- a/src/me/rockyhawk/commandPanels/panelBlocks/blocksTabComplete.java +++ b/src/me/rockyhawk/commandPanels/panelBlocks/blocksTabComplete.java @@ -32,7 +32,7 @@ public class blocksTabComplete implements TabCompleter { String key; tpanels = ""; if (!plugin.checkPanels(temp)) { - return null; + continue; } for (Iterator var10 = Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") { key = (String) var10.next(); diff --git a/src/me/rockyhawk/commandPanels/premium/commandpanelrefresher.java b/src/me/rockyhawk/commandPanels/premium/commandpanelrefresher.java index 407245a..11f8bee 100644 --- a/src/me/rockyhawk/commandPanels/premium/commandpanelrefresher.java +++ b/src/me/rockyhawk/commandPanels/premium/commandpanelrefresher.java @@ -48,9 +48,7 @@ public class commandpanelrefresher implements Listener { String key; YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName)); if (!plugin.checkPanels(temp)) { - assert p != null; - p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + ": File with no Panels found or Panel with syntax error Found!")); - return; + continue; } for (String s : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)) { key = s;