diff --git a/resource/plugin.yml b/resource/plugin.yml index e1c8372..9d302b9 100644 --- a/resource/plugin.yml +++ b/resource/plugin.yml @@ -1,4 +1,4 @@ -version: 3.2.2 +version: 3.2.3 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 5a12de4..76f1a53 100644 --- a/src/me/rockyhawk/commandPanels/commandpanels.java +++ b/src/me/rockyhawk/commandPanels/commandpanels.java @@ -1593,9 +1593,7 @@ public class commandpanels extends JavaPlugin { Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.RED + " Cannot check for update."); return; } - if(this.getDescription().getVersion().equals(gitVersion)){ - Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.GREEN + " Running the latest version."); - }else{ + if(!this.getDescription().getVersion().equals(gitVersion)){ Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + " ================================================"); Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + " An update for CommandPanels is available."); Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + " Download version " + gitVersion + " here:"); diff --git a/src/me/rockyhawk/commandPanels/commands/commandpanelclose.java b/src/me/rockyhawk/commandPanels/commands/commandpanelclose.java index 745e55c..3a3ff99 100644 --- a/src/me/rockyhawk/commandPanels/commands/commandpanelclose.java +++ b/src/me/rockyhawk/commandPanels/commands/commandpanelclose.java @@ -1,6 +1,5 @@ package me.rockyhawk.commandPanels.commands; -import me.clip.placeholderapi.PlaceholderAPI; import me.rockyhawk.commandPanels.commandpanels; import org.bukkit.ChatColor; import org.bukkit.command.Command; diff --git a/src/me/rockyhawk/commandPanels/commands/commandpanelcustom.java b/src/me/rockyhawk/commandPanels/commands/commandpanelcustom.java index 905c38d..af25b7d 100644 --- a/src/me/rockyhawk/commandPanels/commands/commandpanelcustom.java +++ b/src/me/rockyhawk/commandPanels/commands/commandpanelcustom.java @@ -12,8 +12,8 @@ import org.bukkit.event.player.*; import java.io.File; import java.util.ArrayList; -import java.util.Arrays; import java.util.Iterator; +import java.util.Objects; public class commandpanelcustom implements Listener { commandpanels plugin; @@ -27,13 +27,12 @@ public class commandpanelcustom implements Listener { Player p = (Player)e.getPlayer(); File panelsf = new File(plugin.getDataFolder() + File.separator + "panels"); try { - if (panelsf.list() == null || panelsf.list().length == 0) { + if (panelsf.list() == null || Objects.requireNonNull(panelsf.list()).length == 0) { return; } }catch(Exception b){ return; } - ArrayList<String> filenames = new ArrayList<String>(Arrays.asList(panelsf.list())); YamlConfiguration cf; //this is the file to use for any panel.* requests ArrayList<String> apanels = new ArrayList<String>(); //all panels from all files (panel names) String tpanels; //tpanels is the temp to check through the files @@ -50,7 +49,7 @@ public class commandpanelcustom implements Listener { } return; } - for (Iterator var10 = temp.getConfigurationSection("panels").getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") { + for (Iterator var10 = Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") { key = (String) var10.next(); apanels.add(key); } diff --git a/src/me/rockyhawk/commandPanels/commands/commandpanelslist.java b/src/me/rockyhawk/commandPanels/commands/commandpanelslist.java index f7691be..5988237 100644 --- a/src/me/rockyhawk/commandPanels/commands/commandpanelslist.java +++ b/src/me/rockyhawk/commandPanels/commands/commandpanelslist.java @@ -10,7 +10,6 @@ import org.bukkit.event.EventHandler; import java.io.File; import java.util.ArrayList; -import java.util.Arrays; import java.util.Iterator; diff --git a/src/me/rockyhawk/commandPanels/generatePanels/newGenUtils.java b/src/me/rockyhawk/commandPanels/generatePanels/newGenUtils.java index 6012468..86c7e0a 100644 --- a/src/me/rockyhawk/commandPanels/generatePanels/newGenUtils.java +++ b/src/me/rockyhawk/commandPanels/generatePanels/newGenUtils.java @@ -15,6 +15,7 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; +import java.util.Objects; public class newGenUtils implements Listener { public YamlConfiguration tempEdit; @@ -32,11 +33,8 @@ public class newGenUtils implements Listener { } //reload panel files to avoid conflicts plugin.reloadPanelFiles(); - //get all panel names (not titles) - File panelsf = new File(plugin.getDataFolder() + File.separator + "panels"); Boolean pexist = true; //pexist is true if panels exist - YamlConfiguration cf; ArrayList<String> apanels = new ArrayList<String>(); //all panels from all files (panel names) try { for(String fileName : plugin.panelFiles) { //will loop through all the files in folder @@ -44,9 +42,7 @@ public class newGenUtils implements Listener { if(!plugin.checkPanels(temp)){ continue; } - for (String key : temp.getConfigurationSection("panels").getKeys(false)) { - apanels.add(key); - } + apanels.addAll(Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)); } }catch(Exception fail){ //could not fetch all panel names (probably no panels exist) @@ -69,13 +65,13 @@ public class newGenUtils implements Listener { //String date: is what the panel and file name will be called String date = "panel-1"; if(pexist){ - for(int count = 1; (Arrays.asList(panelsf.list()).contains("panel-" + count + ".yml")) || (apanels.contains("panel-" + count)); count++){ + for(int count = 1; (Arrays.asList(plugin.panelsf.list()).contains("panel-" + count + ".yml")) || (apanels.contains("panel-" + count)); count++){ date = "panel-" + (count+1); } }else{ date = "panel-1"; } - //String date = new SimpleDateFormat("dd-HH-mm-ss").format(new Date()); + //String date = new SimpleDateFormat("dd-HH-mm-ss").format(new Date()); (OLD) File folder = new File(plugin.getDataFolder() + File.separator + "panels"); file = YamlConfiguration.loadConfiguration(new File(folder + File.separator + date + ".yml")); file.addDefault("panels." + date + ".perm", "default"); diff --git a/src/me/rockyhawk/commandPanels/ingameEditor/cpIngameEditCommand.java b/src/me/rockyhawk/commandPanels/ingameEditor/cpIngameEditCommand.java index 9df5673..6873d5f 100644 --- a/src/me/rockyhawk/commandPanels/ingameEditor/cpIngameEditCommand.java +++ b/src/me/rockyhawk/commandPanels/ingameEditor/cpIngameEditCommand.java @@ -27,7 +27,7 @@ public class cpIngameEditCommand implements CommandExecutor { sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.perms"))); return true; } - if(plugin.config.getString("config.ingame-editor").equalsIgnoreCase("false")){ + if(Objects.requireNonNull(plugin.config.getString("config.ingame-editor")).equalsIgnoreCase("false")){ //this will cancel every /cpe command if ingame-editor is set to false sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.RED + "Editor disabled!")); return true; @@ -36,8 +36,6 @@ public class cpIngameEditCommand implements CommandExecutor { sender.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.RED + "Please execute command as a Player!")); return true; } - File panelsf = new File(plugin.getDataFolder() + File.separator + "panels"); - ArrayList<String> filenames = new ArrayList<String>(Arrays.asList(panelsf.list())); File panelscf = new File(plugin.getDataFolder() + File.separator + "panels" + File.separator + "example.yml"); //cf == correct file YamlConfiguration cf; //this is the file to use for any panel.* requests String panels = ""; @@ -46,13 +44,13 @@ public class cpIngameEditCommand implements CommandExecutor { String tpanels; //tpanels is the temp to check through the files //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 (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; tpanels = ""; - temp = YamlConfiguration.loadConfiguration(new File(panelsf + File.separator + filenames.get(f))); - if(!plugin.checkPanels(temp)){ - sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.error") + ": File with no Panels found!")); + 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") + ": File with no Panels found!")); return true; } for (Iterator var10 = temp.getConfigurationSection("panels").getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") { @@ -70,9 +68,9 @@ public class cpIngameEditCommand implements CommandExecutor { } } //if nfound is true it was not found - if(!nfound){ + if (!nfound) { panels = tpanels; - panelscf = new File(panelsf + File.separator + filenames.get(f)); + panelscf = new File(plugin.panelsf + File.separator + filename); } } panels = panels.trim(); diff --git a/src/me/rockyhawk/commandPanels/ingameEditor/cpTabCompleteIngame.java b/src/me/rockyhawk/commandPanels/ingameEditor/cpTabCompleteIngame.java index 9f7fbef..8a49f48 100644 --- a/src/me/rockyhawk/commandPanels/ingameEditor/cpTabCompleteIngame.java +++ b/src/me/rockyhawk/commandPanels/ingameEditor/cpTabCompleteIngame.java @@ -11,6 +11,7 @@ import java.io.File; import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import java.util.Objects; public class cpTabCompleteIngame implements TabCompleter { @@ -31,7 +32,7 @@ public class cpTabCompleteIngame implements TabCompleter { if(!plugin.checkPanels(temp)){ return null; } - for (Iterator var10 = temp.getConfigurationSection("panels").getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") { + for (Iterator var10 = Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") { key = (String) var10.next(); if(!key.startsWith(args[0])){ //this will narrow down the panels to what the user types @@ -40,6 +41,8 @@ public class cpTabCompleteIngame implements TabCompleter { if(sender.hasPermission("commandpanel.panel." + temp.getString("panels." + key + ".perm"))) { if(temp.contains("panels." + key + ".disabled-worlds")){ List<String> disabledWorlds = (List<String>) temp.getList("panels." + key + ".disabled-worlds"); + assert p != null; + assert disabledWorlds != null; if(!disabledWorlds.contains(p.getWorld().getName())){ apanels.add(key); } diff --git a/src/me/rockyhawk/commandPanels/ingameEditor/editorUserInput.java b/src/me/rockyhawk/commandPanels/ingameEditor/editorUserInput.java index ef7e621..7c38f73 100644 --- a/src/me/rockyhawk/commandPanels/ingameEditor/editorUserInput.java +++ b/src/me/rockyhawk/commandPanels/ingameEditor/editorUserInput.java @@ -13,6 +13,7 @@ import org.bukkit.event.player.AsyncPlayerChatEvent; import java.io.File; import java.util.ArrayList; import java.util.List; +import java.util.Objects; public class editorUserInput implements Listener { commandpanels plugin; @@ -34,16 +35,16 @@ public class editorUserInput implements Listener { String section = temp[2]; YamlConfiguration cf = null; try { - for (File tempFile : plugin.panelsf.listFiles()) { //will loop through all the files in folder - YamlConfiguration tempConf = YamlConfiguration.loadConfiguration(tempFile); + for (String tempFile : plugin.panelFiles) { //will loop through all the files in folder + YamlConfiguration tempConf = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + tempFile)); if (!plugin.checkPanels(tempConf)) { continue; } - for (String key : tempConf.getConfigurationSection("panels").getKeys(false)) { + for (String key : Objects.requireNonNull(tempConf.getConfigurationSection("panels")).getKeys(false)) { if (key.equals(panelName)) { cf = tempConf; - panelFile = tempFile; - panelTitle = ChatColor.translateAlternateColorCodes('&',tempConf.getString("panels." + key + ".title")); + panelFile = new File(plugin.panelsf + File.separator + tempFile); + panelTitle = ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(tempConf.getString("panels." + key + ".title"))); break; } } @@ -55,7 +56,7 @@ public class editorUserInput implements Listener { if(e.getMessage().equalsIgnoreCase(plugin.config.getString("config.input-cancel"))){ plugin.editorInputStrings.remove(temp); plugin.reloadPanelFiles(); - e.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&',plugin.config.getString("config.input-cancelled"))); + e.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(plugin.config.getString("config.input-cancelled")))); return; } if(section.startsWith("panel.")) { @@ -96,7 +97,7 @@ public class editorUserInput implements Listener { switch (section) { case "panel.delete": if (e.getMessage().contains("y")) { - if(cf.getConfigurationSection("panels").getKeys(false).size() != 1){ + if(Objects.requireNonNull(cf.getConfigurationSection("panels")).getKeys(false).size() != 1){ //if the file has more than one panel in it cf.set("panels." + panelName, null); if(savePanelFile(cf, panelFile)){ @@ -170,7 +171,7 @@ public class editorUserInput implements Listener { } String materialTemp = null; try { - materialTemp = Material.matchMaterial(e.getMessage()).toString(); + materialTemp = Objects.requireNonNull(Material.matchMaterial(e.getMessage())).toString(); }catch(NullPointerException ex){ p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.RED + e.getMessage() + " is not a valid Material!")); } @@ -218,7 +219,7 @@ public class editorUserInput implements Listener { p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Added new command: " + e.getMessage())); break; case "panel.commands-on-open.remove": - List<String> commandsOnOpenRemove = new ArrayList<>(); + List<String> commandsOnOpenRemove; if(cf.contains("panels." + panelName + ".commands-on-open")){ commandsOnOpenRemove = cf.getStringList("panels." + panelName + ".commands-on-open"); }else{ @@ -344,7 +345,7 @@ public class editorUserInput implements Listener { p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Added new command: " + e.getMessage())); break; case "commands.remove": - List<String> commandsOnOpenRemove = new ArrayList<>(); + List<String> commandsOnOpenRemove; if(cf.contains("panels." + panelName + ".item." + itemSlot + ".commands")){ commandsOnOpenRemove = cf.getStringList("panels." + panelName + ".item." + itemSlot + ".commands"); }else{ @@ -376,7 +377,7 @@ public class editorUserInput implements Listener { p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Added new lore: " + e.getMessage())); break; case "lore.remove": - List<String> loreOnOpenRemove = new ArrayList<>(); + List<String> loreOnOpenRemove; if(cf.contains("panels." + panelName + ".item." + itemSlot + ".lore")){ loreOnOpenRemove = cf.getStringList("panels." + panelName + ".item." + itemSlot + ".lore"); }else{ diff --git a/src/me/rockyhawk/commandPanels/ingameEditor/editorUtils.java b/src/me/rockyhawk/commandPanels/ingameEditor/editorUtils.java index 1f57bf4..94079ac 100644 --- a/src/me/rockyhawk/commandPanels/ingameEditor/editorUtils.java +++ b/src/me/rockyhawk/commandPanels/ingameEditor/editorUtils.java @@ -1,7 +1,6 @@ package me.rockyhawk.commandPanels.ingameEditor; import me.rockyhawk.commandPanels.commandpanels; -import net.milkbowl.vault.chat.Chat; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.configuration.file.YamlConfiguration; @@ -16,7 +15,6 @@ import org.bukkit.inventory.ItemStack; 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 { @@ -101,7 +99,7 @@ public class editorUtils implements Listener { if(e.getSlot() <= 44){ //if panel slots are selected try{ - if(e.getCurrentItem().getType() != Material.AIR){ + if(Objects.requireNonNull(e.getCurrentItem()).getType() != Material.AIR){ if(e.getClick().isLeftClick() && !e.getClick().isShiftClick()){ //if left click int count = 0; @@ -172,7 +170,7 @@ public class editorUtils implements Listener { //this basically just determines if something is dragged. try { if (tempEdit.contains("panels." + panelName + ".temp." + p.getName() + ".material")) { - if (e.getOldCursor().getType() != Material.matchMaterial(tempEdit.getString("panels." + panelName + ".temp." + p.getName() + ".material"))) { + if (e.getOldCursor().getType() != Material.matchMaterial(Objects.requireNonNull(tempEdit.getString("panels." + panelName + ".temp." + p.getName() + ".material")))) { clearTemp(p, panelName); return; } @@ -211,17 +209,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 tempName : plugin.panelFiles) { //will loop through all the files in folder + YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + tempName)); 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; + fileName = new File(plugin.panelsf + File.separator + tempName); file = temp; found = true; break; @@ -257,9 +255,9 @@ public class editorUtils implements Listener { return; } if(tempEdit.contains("panels." + panelName + ".temp." + p.getName() + ".material")) { - if(e.getCursor().getType() != Material.PLAYER_HEAD) { + if(Objects.requireNonNull(e.getCursor()).getType() != Material.PLAYER_HEAD) { //if the material doesn't match and also isn't a PLAYER_HEAD - if (e.getCursor().getType() != Material.matchMaterial(tempEdit.getString("panels." + panelName + ".temp." + p.getName() + ".material"))) { + if (e.getCursor().getType() != Material.matchMaterial(Objects.requireNonNull(tempEdit.getString("panels." + panelName + ".temp." + p.getName() + ".material")))) { clearTemp(p, panelName); } } @@ -315,7 +313,7 @@ public class editorUtils implements Listener { Player p = (Player)e.getWhoClicked(); String tag = plugin.config.getString("config.format.tag") + " "; try { - if (e.getClickedInventory().getType() != InventoryType.CHEST) { + if (Objects.requireNonNull(e.getClickedInventory()).getType() != InventoryType.CHEST) { return; } }catch(Exception outOf){ @@ -335,7 +333,7 @@ public class editorUtils implements Listener { if(!plugin.checkPanels(temp)){ return; } - for (String key : temp.getConfigurationSection("panels").getKeys(false)){ + for (String key : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)){ if(e.getView().getTitle().equals("Panel Settings: " + key)){ panelName = key; found = true; @@ -412,7 +410,7 @@ public class editorUtils implements Listener { Player p = (Player)e.getWhoClicked(); String tag = plugin.config.getString("config.format.tag") + " "; try { - if (e.getClickedInventory().getType() != InventoryType.CHEST) { + if (Objects.requireNonNull(e.getClickedInventory()).getType() != InventoryType.CHEST) { return; } }catch(Exception outOf){ @@ -433,7 +431,7 @@ public class editorUtils implements Listener { if(!plugin.checkPanels(temp)){ return; } - for (String key : temp.getConfigurationSection("panels").getKeys(false)){ + for (String key : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)){ if(e.getView().getTitle().equals("Item Settings: " + key)){ panelName = key; panelYaml = temp; @@ -452,7 +450,7 @@ public class editorUtils implements Listener { } int itemSlot; try { - itemSlot = Integer.parseInt(e.getView().getTopInventory().getItem(35).getItemMeta().getDisplayName().split("\\s")[2]); + itemSlot = Integer.parseInt(Objects.requireNonNull(Objects.requireNonNull(e.getView().getTopInventory().getItem(35)).getItemMeta()).getDisplayName().split("\\s")[2]); }catch(Exception ex){ plugin.getServer().getConsoleSender().sendMessage("[CommandPanels] Could not get item slot"); plugin.debug(ex); @@ -562,17 +560,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 tempFile : plugin.panelFiles) { //will loop through all the files in folder + YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + tempFile)); 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(invView.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 (invView.getTitle().equals(ChatColor.GRAY + "Editing Panel: " + ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(temp.getString("panels." + key + ".title"))))) { panelName = key; - fileName = tempFile.getName(); + fileName = tempFile; file = temp; found = true; break; @@ -602,7 +600,7 @@ public class editorUtils implements Listener { } } if(file.contains("panels." + panelName + ".item." + i + ".material")){ - if(file.getString("panels." + panelName + ".item." + i + ".material").contains("%") || file.getString("panels." + panelName + ".item." + i + ".material").contains("=")){ + if(Objects.requireNonNull(file.getString("panels." + panelName + ".item." + i + ".material")).contains("%") || Objects.requireNonNull(file.getString("panels." + panelName + ".item." + i + ".material")).contains("=")){ if(cont.getType() != Material.PLAYER_HEAD){ file.set("panels." + panelName + ".item." + i + ".material", cont.getType().toString()); } @@ -626,15 +624,15 @@ public class editorUtils implements Listener { } if(file.contains("panels." + panelName + ".item." + i + ".name")){ //these will ensure &f items (blank items) will be set to &f to stay blank - if(file.getString("panels." + panelName + ".item." + i + ".name").equalsIgnoreCase("&f") || file.getString("panels." + panelName + ".item." + i + ".name").equalsIgnoreCase("§f")){ + if(Objects.requireNonNull(file.getString("panels." + panelName + ".item." + i + ".name")).equalsIgnoreCase("&f") || file.getString("panels." + panelName + ".item." + i + ".name").equalsIgnoreCase("§f")){ file.set("panels." + panelName + ".item." + i + ".name", "&f"); }else{ - file.set("panels." + panelName + ".item." + i + ".name", cont.getItemMeta().getDisplayName()); + file.set("panels." + panelName + ".item." + i + ".name", Objects.requireNonNull(cont.getItemMeta()).getDisplayName()); } }else { - file.set("panels." + panelName + ".item." + i + ".name", cont.getItemMeta().getDisplayName()); + file.set("panels." + panelName + ".item." + i + ".name", Objects.requireNonNull(cont.getItemMeta()).getDisplayName()); } - file.set("panels." + panelName + ".item." + i + ".lore", cont.getItemMeta().getLore()); + file.set("panels." + panelName + ".item." + i + ".lore", Objects.requireNonNull(cont.getItemMeta()).getLore()); }catch(Exception n){ //skip over an item that spits an error } diff --git a/src/me/rockyhawk/commandPanels/premium/commandpanelUserInput.java b/src/me/rockyhawk/commandPanels/premium/commandpanelUserInput.java index 198a737..adbe777 100644 --- a/src/me/rockyhawk/commandPanels/premium/commandpanelUserInput.java +++ b/src/me/rockyhawk/commandPanels/premium/commandpanelUserInput.java @@ -6,6 +6,8 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.AsyncPlayerChatEvent; +import java.util.Objects; + public class commandpanelUserInput implements Listener { commandpanels plugin; public commandpanelUserInput(commandpanels pl) { @@ -17,7 +19,7 @@ public class commandpanelUserInput implements Listener { if(plugin.userInputStrings.get(o)[0].equals(e.getPlayer().getName())){ if(e.getMessage().equalsIgnoreCase(plugin.config.getString("config.input-cancel"))){ e.setCancelled(true); - e.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.config.getString("config.input-cancelled"))); + e.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(plugin.config.getString("config.input-cancelled")))); for(int i = 0; plugin.userInputStrings.size() > i; i++){ if(plugin.userInputStrings.get(i)[0].equals(e.getPlayer().getName())){ plugin.userInputStrings.remove(i); diff --git a/src/me/rockyhawk/commandPanels/utils.java b/src/me/rockyhawk/commandPanels/utils.java index f37b98b..ef30b62 100644 --- a/src/me/rockyhawk/commandPanels/utils.java +++ b/src/me/rockyhawk/commandPanels/utils.java @@ -80,14 +80,12 @@ public class utils implements Listener { }catch(Exception b){ return; } - ArrayList<String> filenames = new ArrayList<String>(Arrays.asList(Objects.requireNonNull(plugin.panelsf.list()))); YamlConfiguration cf = null; //this is the file to use for any panel.* requests String panel = null; boolean foundPanel = false; - for (String filename : filenames) { //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 + filename)); + YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + filename)); if (!plugin.checkPanels(temp)) { p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + plugin.papi(p, plugin.config.getString("config.format.error") + ": Syntax error Found or Missing certain element!"))); return;