From a8bc43be1c32983c88390548eee329cc715317be Mon Sep 17 00:00:00 2001 From: rockyhawk64 Date: Tue, 7 Jul 2020 19:47:14 +1000 Subject: [PATCH] 3.2.2 Fixes --- resource/plugin.yml | 2 +- .../commandPanels/commandpanels.java | 13 +++-- .../commandPanels/commands/commandpanel.java | 4 +- .../commands/commandpanelcustom.java | 3 +- .../commands/commandpanelslist.java | 12 ++--- .../completeTabs/cpTabComplete.java | 4 +- .../generatePanels/newGenUtils.java | 3 +- .../ingameEditor/cpTabCompleteIngame.java | 4 +- .../ingameEditor/editorUtils.java | 46 +++++++++-------- .../premium/commandpanelrefresher.java | 43 ++++++++-------- src/me/rockyhawk/commandPanels/utils.java | 50 ++++++++++--------- 11 files changed, 100 insertions(+), 84 deletions(-) diff --git a/resource/plugin.yml b/resource/plugin.yml index 1422acb..e1c8372 100644 --- a/resource/plugin.yml +++ b/resource/plugin.yml @@ -1,4 +1,4 @@ -version: 3.2.1 +version: 3.2.2 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 864f56d..5a12de4 100644 --- a/src/me/rockyhawk/commandPanels/commandpanels.java +++ b/src/me/rockyhawk/commandPanels/commandpanels.java @@ -54,7 +54,7 @@ public class commandpanels extends JavaPlugin { public List panelRunning = new ArrayList(); public List userInputStrings = new ArrayList(); public List editorInputStrings = new ArrayList(); - public ArrayList panelFiles = new ArrayList(); + public ArrayList panelFiles = new ArrayList(); //names of all the files in the panels folder including extension public ArrayList panelNames = new ArrayList(); //this will return something like {"mainMenuPanel","4"} which means the 4 is for panelFiles.get(4). So you know which file it is for public File panelsf; @@ -1127,8 +1127,12 @@ public class commandpanels extends JavaPlugin { panelNames.clear(); int count = 0; for (String fileName : Objects.requireNonNull(panelsf.list())) { - panelFiles.add(YamlConfiguration.loadConfiguration(new File(panelsf + File.separator + fileName))); - for (String tempName : Objects.requireNonNull(panelFiles.get(count).getConfigurationSection("panels")).getKeys(false)) { + int ind = fileName.lastIndexOf("."); + if(!fileName.substring(ind).equalsIgnoreCase(".yml") && !fileName.substring(ind).equalsIgnoreCase(".yaml")){ + continue; + } + panelFiles.add(fileName); + for (String tempName : Objects.requireNonNull(YamlConfiguration.loadConfiguration(new File(panelsf + File.separator + fileName)).getConfigurationSection("panels")).getKeys(false)) { panelNames.add(new String[]{tempName, Integer.toString(count)}); } count += 1; @@ -1196,7 +1200,8 @@ public class commandpanels extends JavaPlugin { ArrayList panelTitles = new ArrayList(); //all panels from ALL files (panel titles) ArrayList panelItems = new ArrayList(); //all panels from ALL files (panel materials) try { - for (YamlConfiguration temp : panelFiles) { //will loop through all the files in folder + for(String fileName : panelFiles) { //will loop through all the files in folder + YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(panelsf + File.separator + fileName)); String key; if (!checkPanels(temp)) { return; diff --git a/src/me/rockyhawk/commandPanels/commands/commandpanel.java b/src/me/rockyhawk/commandPanels/commands/commandpanel.java index bf4b7dd..3549ede 100644 --- a/src/me/rockyhawk/commandPanels/commands/commandpanel.java +++ b/src/me/rockyhawk/commandPanels/commands/commandpanel.java @@ -13,6 +13,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.inventory.ItemStack; +import java.io.File; import java.util.*; public class commandpanel implements CommandExecutor { @@ -32,7 +33,8 @@ public class commandpanel implements CommandExecutor { boolean found = false; //below is going to go through the files and find the right one if (args.length != 0) { //check to make sure the person hasn't just left it empty - for (YamlConfiguration temp : plugin.panelFiles) { //will loop through all the files in folder + 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(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.error") + ": Panel with syntax error found!")); return true; diff --git a/src/me/rockyhawk/commandPanels/commands/commandpanelcustom.java b/src/me/rockyhawk/commandPanels/commands/commandpanelcustom.java index 0e35b7a..905c38d 100644 --- a/src/me/rockyhawk/commandPanels/commands/commandpanelcustom.java +++ b/src/me/rockyhawk/commandPanels/commands/commandpanelcustom.java @@ -38,7 +38,8 @@ public class commandpanelcustom implements Listener { ArrayList apanels = new ArrayList(); //all panels from all files (panel names) String tpanels; //tpanels is the temp to check through the files String panel = null; - for (YamlConfiguration temp : plugin.panelFiles) { //will loop through all the files in folder + for(String fileName : plugin.panelFiles) { //will loop through all the files in folder + YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName)); String key; tpanels = ""; if(!plugin.checkPanels(temp)){ diff --git a/src/me/rockyhawk/commandPanels/commands/commandpanelslist.java b/src/me/rockyhawk/commandPanels/commands/commandpanelslist.java index 17d4fd7..f7691be 100644 --- a/src/me/rockyhawk/commandPanels/commands/commandpanelslist.java +++ b/src/me/rockyhawk/commandPanels/commands/commandpanelslist.java @@ -24,10 +24,9 @@ public class commandpanelslist implements CommandExecutor { if (label.equalsIgnoreCase("cpl") || label.equalsIgnoreCase("commandpanellist") || label.equalsIgnoreCase("cpanell")) { if (sender.hasPermission("commandpanel.list")) { //command /cpl - File panelsf = new File(plugin.getDataFolder() + File.separator + "panels"); - //check to make sure the panels folder isn't empty + //check to make sure the panels isn't empty try { - if (panelsf.list() == null || panelsf.list().length == 0) { + if (plugin.panelFiles == null) { sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.RED + "No panels found!")); return true; } @@ -35,15 +34,14 @@ public class commandpanelslist implements CommandExecutor { sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.RED + "No panels found!")); return true; } - ArrayList filenames = new ArrayList(Arrays.asList(panelsf.list())); ArrayList apanels = new ArrayList(); //all panels from all files (panel names) String tpanels; //tpanels is the temp to check through the files - for (int f = 0; filenames.size() > f; f++) { //will loop through all the files in folder + for (int f = 0; plugin.panelFiles.size() > f; f++) { //will loop through all the files in folder String key; YamlConfiguration temp; tpanels = ""; - temp = YamlConfiguration.loadConfiguration(new File(panelsf + File.separator + filenames.get(f))); - apanels.add("%file%" + filenames.get(f)); + 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(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.error") + ": File with no Panels found!")); return true; diff --git a/src/me/rockyhawk/commandPanels/completeTabs/cpTabComplete.java b/src/me/rockyhawk/commandPanels/completeTabs/cpTabComplete.java index a538fe4..f2522eb 100644 --- a/src/me/rockyhawk/commandPanels/completeTabs/cpTabComplete.java +++ b/src/me/rockyhawk/commandPanels/completeTabs/cpTabComplete.java @@ -7,6 +7,7 @@ import org.bukkit.command.TabCompleter; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; +import java.io.File; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -23,7 +24,8 @@ public class cpTabComplete implements TabCompleter { ArrayList apanels = new ArrayList(); //all panels String tpanels; //tpanels is the temp to check through the files try { - for (YamlConfiguration temp : plugin.panelFiles) { //will loop through all the files in folder + for(String fileName : plugin.panelFiles) { //will loop through all the files in folder + YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName)); String key; tpanels = ""; if(!plugin.checkPanels(temp)){ diff --git a/src/me/rockyhawk/commandPanels/generatePanels/newGenUtils.java b/src/me/rockyhawk/commandPanels/generatePanels/newGenUtils.java index fb66619..6012468 100644 --- a/src/me/rockyhawk/commandPanels/generatePanels/newGenUtils.java +++ b/src/me/rockyhawk/commandPanels/generatePanels/newGenUtils.java @@ -39,7 +39,8 @@ public class newGenUtils implements Listener { YamlConfiguration cf; ArrayList apanels = new ArrayList(); //all panels from all files (panel names) try { - for(YamlConfiguration temp : plugin.panelFiles) { //will loop through all the files in folder + 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)){ continue; } diff --git a/src/me/rockyhawk/commandPanels/ingameEditor/cpTabCompleteIngame.java b/src/me/rockyhawk/commandPanels/ingameEditor/cpTabCompleteIngame.java index 0690130..9f7fbef 100644 --- a/src/me/rockyhawk/commandPanels/ingameEditor/cpTabCompleteIngame.java +++ b/src/me/rockyhawk/commandPanels/ingameEditor/cpTabCompleteIngame.java @@ -7,6 +7,7 @@ import org.bukkit.command.TabCompleter; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; +import java.io.File; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -23,7 +24,8 @@ public class cpTabCompleteIngame implements TabCompleter { ArrayList apanels = new ArrayList(); //all panels String tpanels; //tpanels is the temp to check through the files try { - for (YamlConfiguration temp : plugin.panelFiles) { //will loop through all the files in folder + for(String fileName : plugin.panelFiles) { //will loop through all the files in folder + YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName)); String key; tpanels = ""; if(!plugin.checkPanels(temp)){ diff --git a/src/me/rockyhawk/commandPanels/ingameEditor/editorUtils.java b/src/me/rockyhawk/commandPanels/ingameEditor/editorUtils.java index a75d2ea..1f57bf4 100644 --- a/src/me/rockyhawk/commandPanels/ingameEditor/editorUtils.java +++ b/src/me/rockyhawk/commandPanels/ingameEditor/editorUtils.java @@ -17,6 +17,7 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; +import java.util.Objects; public class editorUtils implements Listener { public YamlConfiguration tempEdit; @@ -31,7 +32,7 @@ public class editorUtils implements Listener { Player p = (Player)e.getWhoClicked(); //if the inventory isn't the editor main window try { - if (e.getClickedInventory().getType() != InventoryType.CHEST) { + if (Objects.requireNonNull(e.getClickedInventory()).getType() != InventoryType.CHEST) { return; } }catch(NullPointerException nu){return;} @@ -46,15 +47,16 @@ public class editorUtils implements Listener { ArrayList panelTitles = new ArrayList(); //all panels from ALL files (panel titles) ArrayList panelYaml = new ArrayList(); //all panels from ALL files (panel yaml files) try { - for (YamlConfiguration temp : plugin.panelFiles) { //will loop through all the files in folder + for(String fileName : plugin.panelFiles) { //will loop through all the files in folder + YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName)); String key; if(!plugin.checkPanels(temp)){ return; } - for (Iterator var10 = temp.getConfigurationSection("panels").getKeys(false).iterator(); var10.hasNext();) { - key = (String) var10.next(); + for (String s : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)) { + key = s; panelNames.add(ChatColor.translateAlternateColorCodes('&', key)); - panelTitles.add(ChatColor.translateAlternateColorCodes('&', temp.getString("panels." + key + ".title"))); + panelTitles.add(ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(temp.getString("panels." + key + ".title")))); panelYaml.add(temp); } } @@ -66,16 +68,16 @@ public class editorUtils implements Listener { if(e.getSlot() == 48){ //previous page button try { - if (e.getCurrentItem().getType() == Material.PAPER) { + if (Objects.requireNonNull(e.getCurrentItem()).getType() == Material.PAPER) { plugin.openEditorGui(p, -1); p.updateInventory(); return; } - }catch(NullPointerException nu){} + }catch(NullPointerException ignored){} } if(e.getSlot() == 49){ //sunflower page index - if(e.getCurrentItem().getType() == Material.SUNFLOWER){ + if(Objects.requireNonNull(e.getCurrentItem()).getType() == Material.SUNFLOWER){ p.updateInventory(); return; } @@ -83,12 +85,12 @@ public class editorUtils implements Listener { if(e.getSlot() == 50){ //next page button try{ - if(e.getCurrentItem().getType() == Material.PAPER){ + if(Objects.requireNonNull(e.getCurrentItem()).getType() == Material.PAPER){ plugin.openEditorGui(p, 1); p.updateInventory(); return; } - }catch(NullPointerException nu){} + }catch(NullPointerException ignored){} } if(e.getSlot() == 45){ //exit button @@ -104,7 +106,7 @@ public class editorUtils implements Listener { //if left click int count = 0; for(String panelName : panelNames){ - if(panelName.equals(ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()))){ + if(panelName.equals(ChatColor.stripColor(Objects.requireNonNull(e.getCurrentItem().getItemMeta()).getDisplayName()))){ plugin.openGui(panelName, p, panelYaml.get(count),3,0); return; } @@ -114,7 +116,7 @@ public class editorUtils implements Listener { //if right click int count = 0; for(String panelName : panelNames){ - if(panelName.equals(ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()))){ + if(panelName.equals(ChatColor.stripColor(Objects.requireNonNull(e.getCurrentItem().getItemMeta()).getDisplayName()))){ plugin.openPanelSettings(p,panelName,panelYaml.get(count)); return; } @@ -123,7 +125,7 @@ public class editorUtils implements Listener { p.updateInventory(); } } - }catch(NullPointerException nu){} + }catch(NullPointerException ignored){} } p.updateInventory(); } @@ -142,17 +144,17 @@ public class editorUtils implements Listener { boolean found = false; try { //neew to loop through files to get file names - for (File tempFile : plugin.panelsf.listFiles()) { //will loop through all the files in folder + for(String fileTempName : plugin.panelFiles) { //will loop through all the files in folder + YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName)); String key; - YamlConfiguration temp = YamlConfiguration.loadConfiguration(tempFile); if(!plugin.checkPanels(temp)){ return; } - for (Iterator var10 = temp.getConfigurationSection("panels").getKeys(false).iterator(); var10.hasNext();) { - key = (String) var10.next(); - if(e.getView().getTitle().equals(ChatColor.GRAY + "Editing Panel: " + ChatColor.translateAlternateColorCodes('&', temp.getString("panels." + key + ".title")))){ + for (String s : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)) { + key = s; + if (e.getView().getTitle().equals(ChatColor.GRAY + "Editing Panel: " + ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(temp.getString("panels." + key + ".title"))))) { panelName = key; - fileName = tempFile.getName(); + fileName = fileTempName; file = temp; found = true; break; @@ -328,7 +330,8 @@ public class editorUtils implements Listener { boolean found = false; try { //neew to loop through files to get file names - for (YamlConfiguration temp : plugin.panelFiles) { //will loop through all configs + 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; } @@ -425,7 +428,8 @@ public class editorUtils implements Listener { boolean found = false; try { //neew to loop through files to get file names - for (YamlConfiguration temp : plugin.panelFiles) { //will loop through all configs + 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; } diff --git a/src/me/rockyhawk/commandPanels/premium/commandpanelrefresher.java b/src/me/rockyhawk/commandPanels/premium/commandpanelrefresher.java index c69020c..18636b0 100644 --- a/src/me/rockyhawk/commandPanels/premium/commandpanelrefresher.java +++ b/src/me/rockyhawk/commandPanels/premium/commandpanelrefresher.java @@ -12,9 +12,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.scheduler.BukkitRunnable; import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; +import java.util.Objects; public class commandpanelrefresher implements Listener { commandpanels plugin; @@ -28,7 +26,7 @@ public class commandpanelrefresher implements Listener { public void onInventoryOpen(InventoryOpenEvent e){ //Handles when Players open inventory //I have to convert HumanEntity to a player if (plugin.config.contains("config.refresh-panels")) { - if (plugin.config.getString("config.refresh-panels").trim().equalsIgnoreCase("false")) { + if (Objects.requireNonNull(plugin.config.getString("config.refresh-panels")).trim().equalsIgnoreCase("false")) { return; } } @@ -44,28 +42,27 @@ public class commandpanelrefresher implements Listener { YamlConfiguration cf = null; String panel = null; String panelTitle = null; - ArrayList filenames = new ArrayList(Arrays.asList(plugin.panelsf.list())); try { boolean foundPanel = false; - for (int f = 0; filenames.size() > f; f++) { //will loop through all the files in folder + for (String fileName : plugin.panelFiles) { //will loop through all the files in folder String key; - YamlConfiguration temp; - temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + filenames.get(f))); - if(!plugin.checkPanels(temp)){ - p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.papi(p, plugin.config.getString("config.format.error") + ": File with no Panels found or Panel with syntax error Found!"))); + YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName)); + if (!plugin.checkPanels(temp)) { + assert p != null; + p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + plugin.papi(p, plugin.config.getString("config.format.error") + ": File with no Panels found or Panel with syntax error Found!"))); return; } - for (Iterator var10 = temp.getConfigurationSection("panels").getKeys(false).iterator(); var10.hasNext();) { - key = (String) var10.next(); - if(ChatColor.translateAlternateColorCodes('&',temp.getString("panels." + key + ".title")).equals(e.getView().getTitle())){ + for (String s : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)) { + key = s; + if (ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(temp.getString("panels." + key + ".title"))).equals(e.getView().getTitle())) { panel = key; - panelTitle = ChatColor.translateAlternateColorCodes('&',temp.getString("panels." + key + ".title")); - cf = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + filenames.get(f))); - foundPanel= true; + panelTitle = ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(temp.getString("panels." + key + ".title"))); + cf = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName)); + foundPanel = true; break; } } - if(foundPanel){ + if (foundPanel) { //this is to avoid the plugin to continue looking when it was already found break; } @@ -77,15 +74,17 @@ public class commandpanelrefresher implements Listener { return; } //there is already a runnable running for this player + assert p != null; if(plugin.panelRunning.contains(p.getName() + ";" + panel)){ return; } plugin.panelRunning.add(p.getName() + ";" + panel); if (plugin.config.contains("config.panel-snooper")) { - if (plugin.config.getString("config.panel-snooper").trim().equalsIgnoreCase("true")) { + if (Objects.requireNonNull(plugin.config.getString("config.panel-snooper")).trim().equalsIgnoreCase("true")) { Bukkit.getConsoleSender().sendMessage("[CommandPanels] " + p.getName() + " Opened " + panel); } } + assert cf != null; if(cf.contains("panels." + panel + ".animatevalue")){ animatevalue = cf.getInt("panels." + panel + ".animatevalue"); } @@ -98,7 +97,7 @@ public class commandpanelrefresher implements Listener { @Override public void run() { //counter counts to refresh delay (in seconds) then restarts - if(c < Double.parseDouble(plugin.config.getString("config.refresh-delay").trim())){ + if(c < Double.parseDouble(Objects.requireNonNull(plugin.config.getString("config.refresh-delay")).trim())){ c+=1; }else{ c=0; @@ -121,9 +120,9 @@ public class commandpanelrefresher implements Listener { } } }else{ - if(plugin.config.getString("config.stop-sound").trim().equalsIgnoreCase("true")){ + if(Objects.requireNonNull(plugin.config.getString("config.stop-sound")).trim().equalsIgnoreCase("true")){ try { - p.stopSound(Sound.valueOf(cfFinal.getString("panels." + fpanel + ".sound-on-open").toUpperCase())); + p.stopSound(Sound.valueOf(Objects.requireNonNull(cfFinal.getString("panels." + fpanel + ".sound-on-open")).toUpperCase())); }catch(Exception sou){ //skip } @@ -162,7 +161,7 @@ public class commandpanelrefresher implements Listener { } plugin.panelRunning.remove(p.getName() + ";" + fpanel); if (plugin.config.contains("config.panel-snooper")) { - if (plugin.config.getString("config.panel-snooper").trim().equalsIgnoreCase("true")) { + if (Objects.requireNonNull(plugin.config.getString("config.panel-snooper")).trim().equalsIgnoreCase("true")) { Bukkit.getConsoleSender().sendMessage("[CommandPanels] " + p.getName() + " Closed " + fpanel); } } diff --git a/src/me/rockyhawk/commandPanels/utils.java b/src/me/rockyhawk/commandPanels/utils.java index 65b94da..f37b98b 100644 --- a/src/me/rockyhawk/commandPanels/utils.java +++ b/src/me/rockyhawk/commandPanels/utils.java @@ -32,8 +32,8 @@ public class utils implements Listener { if(e.getAction() == InventoryAction.NOTHING){return;} if (e.getRawSlot() == -999) {return;} if (e.getSlotType() != InventoryType.SlotType.QUICKBAR) {return;} - for(String[] panelName : plugin.panelNames){ - YamlConfiguration tempFile = plugin.panelFiles.get(Integer.parseInt(panelName[1])); + for(String[] panelName : plugin.panelNames){ + YamlConfiguration tempFile = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + plugin.panelFiles.get(Integer.parseInt(panelName[1])))); String tempName = panelName[0]; if(tempFile.contains("panels." + tempName + ".open-with-item") && Objects.requireNonNull(e.getClickedInventory()).getType() == InventoryType.PLAYER) { try{ @@ -73,7 +73,7 @@ public class utils implements Listener { //if the inventory is just a chest that has no panel return; } - if (plugin.panelsf.list() == null || Objects.requireNonNull(plugin.panelsf.list()).length == 0) { + if (plugin.panelFiles == null) { //if no panels are present return; } @@ -288,7 +288,7 @@ public class utils implements Listener { if(e.getAction() != Action.RIGHT_CLICK_AIR && e.getAction() != Action.RIGHT_CLICK_BLOCK && Objects.requireNonNull(e.getItem()).getType() == Material.AIR){ return; } - if (plugin.panelsf.list() == null || Objects.requireNonNull(plugin.panelsf.list()).length == 0) { + if (plugin.panelFiles == null) { return; } }catch(Exception b){ @@ -297,7 +297,7 @@ public class utils implements Listener { ItemStack clicked = e.getItem(); Player p = e.getPlayer(); for(String[] panelName : plugin.panelNames){ - YamlConfiguration tempFile = plugin.panelFiles.get(Integer.parseInt(panelName[1])); + YamlConfiguration tempFile = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + plugin.panelFiles.get(Integer.parseInt(panelName[1])))); String tempName = panelName[0]; if(tempFile.contains("panels." + tempName + ".open-with-item")) { try{ @@ -336,7 +336,7 @@ public class utils implements Listener { */ Player p = e.getPlayer(); try { - if (plugin.panelsf.list() == null || Objects.requireNonNull(plugin.panelsf.list()).length == 0) { + if (plugin.panelFiles == null) { return; } }catch(Exception b){ @@ -344,7 +344,8 @@ public class utils implements Listener { } YamlConfiguration cf; //this is the file to use for any panel.* requests String tpanels; //tpanels is the temp to check through the files - for(YamlConfiguration temp : plugin.panelFiles) { //will loop through all the files in folder + for(String fileName : plugin.panelFiles) { //will loop through all the files in folder + YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName)); String key; tpanels = ""; if(!plugin.checkPanels(temp)){ @@ -380,7 +381,7 @@ public class utils implements Listener { public void onPlayerRespawn(PlayerRespawnEvent e){ Player p = e.getPlayer(); try { - if (plugin.panelsf.list() == null || Objects.requireNonNull(plugin.panelsf.list()).length == 0) { + if (plugin.panelFiles == null) { return; } }catch(Exception b){ @@ -388,7 +389,8 @@ public class utils implements Listener { } YamlConfiguration cf; //this is the file to use for any panel.* requests String tpanels; //tpanels is the temp to check through the files - for(YamlConfiguration temp : plugin.panelFiles) { //will loop through all the files in folder + for(String fileName : plugin.panelFiles) { //will loop through all the files in folder + YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName)); String key; tpanels = ""; if(!plugin.checkPanels(temp)){ @@ -421,9 +423,8 @@ public class utils implements Listener { @EventHandler public void onPlayerDeath(PlayerDeathEvent e){ Player p = (Player)e.getEntity(); - File panelsf = new File(plugin.getDataFolder() + File.separator + "panels"); try { - if (panelsf.list() == null || Objects.requireNonNull(panelsf.list()).length == 0) { + if (plugin.panelFiles == null) { return; } }catch(Exception b){ @@ -431,7 +432,8 @@ public class utils implements Listener { } YamlConfiguration cf; //this is the file to use for any panel.* requests String tpanels; //tpanels is the temp to check through the files - for(YamlConfiguration temp : plugin.panelFiles) { //will loop through all the files in folder + for(String fileName : plugin.panelFiles) { //will loop through all the files in folder + YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName)); String key; tpanels = ""; if(!plugin.checkPanels(temp)){ @@ -457,7 +459,6 @@ public class utils implements Listener { @EventHandler public void onPlayerJoin(PlayerJoinEvent e){ Player p = e.getPlayer(); - File panelsf = new File(plugin.getDataFolder() + File.separator + "panels"); String tag = plugin.config.getString("config.format.tag") + " "; if(p.isOp() || p.hasPermission("*.*")){ if(plugin.update) { @@ -466,14 +467,15 @@ public class utils implements Listener { } } try { - if (panelsf.list() == null || Objects.requireNonNull(panelsf.list()).length == 0) { + if (plugin.panelFiles == null) { return; } }catch(Exception b){ return; } String tpanels; //tpanels is the temp to check through the files - for(YamlConfiguration temp : plugin.panelFiles) { //will loop through all the files in folder + for(String fileName : plugin.panelFiles) { //will loop through all the files in folder + YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName)); String key; tpanels = ""; if(!plugin.checkPanels(temp)){ @@ -526,9 +528,8 @@ public class utils implements Listener { public void onPlayerDropItem(PlayerDropItemEvent e){ //if item dropped Player p = e.getPlayer(); - File panelsf = new File(plugin.getDataFolder() + File.separator + "panels"); try { - if (panelsf.list() == null || Objects.requireNonNull(panelsf.list()).length == 0) { + if (plugin.panelFiles == null) { return; } }catch(Exception b){ @@ -537,7 +538,8 @@ public class utils implements Listener { 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(YamlConfiguration temp : plugin.panelFiles) { //will loop through all the files in folder + for(String fileName : plugin.panelFiles) { //will loop through all the files in folder + YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName)); String key; tpanels = ""; if(!plugin.checkPanels(temp)){ @@ -574,9 +576,8 @@ public class utils implements Listener { @EventHandler public void onPlayerSwapHandItemsEvent​(PlayerSwapHandItemsEvent e){ Player p = e.getPlayer(); - File panelsf = new File(plugin.getDataFolder() + File.separator + "panels"); try { - if (panelsf.list() == null || Objects.requireNonNull(panelsf.list()).length == 0) { + if (plugin.panelFiles == null) { return; } }catch(Exception b){ @@ -585,7 +586,8 @@ public class utils implements Listener { 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.getOffHandItem(); - for(YamlConfiguration temp : plugin.panelFiles) { //will loop through all the files in folder + for(String fileName : plugin.panelFiles) { //will loop through all the files in folder + YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName)); String key; tpanels = ""; if(!plugin.checkPanels(temp)){ @@ -645,9 +647,8 @@ public class utils implements Listener { public void onInteractEntity(PlayerInteractEntityEvent e){ //cancel everything if holding item (item frames eg) Player p = (Player)e.getPlayer(); - File panelsf = new File(plugin.getDataFolder() + File.separator + "panels"); try { - if (panelsf.list() == null || Objects.requireNonNull(panelsf.list()).length == 0) { + if (plugin.panelFiles == null) { return; } }catch(Exception b){ @@ -656,7 +657,8 @@ public class utils implements Listener { 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.getPlayer().getInventory().getItemInMainHand(); - for(YamlConfiguration temp : plugin.panelFiles) { //will loop through all the files in folder + for(String fileName : plugin.panelFiles) { //will loop through all the files in folder + YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName)); String key; tpanels = ""; if(!plugin.checkPanels(temp)){