3.2.3 Fixes

This commit is contained in:
rockyhawk64 2020-07-07 21:24:35 +10:00
parent 559d2aa209
commit 60f13a9d9c
12 changed files with 63 additions and 72 deletions

View File

@ -1,4 +1,4 @@
version: 3.2.2 version: 3.2.3
main: me.rockyhawk.commandPanels.commandpanels main: me.rockyhawk.commandPanels.commandpanels
name: CommandPanels name: CommandPanels
author: RockyHawk author: RockyHawk

View File

@ -1593,9 +1593,7 @@ public class commandpanels extends JavaPlugin {
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.RED + " Cannot check for update."); Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.RED + " Cannot check for update.");
return; return;
} }
if(this.getDescription().getVersion().equals(gitVersion)){ if(!this.getDescription().getVersion().equals(gitVersion)){
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.GREEN + " Running the latest version.");
}else{
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + " ================================================"); Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + " ================================================");
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + " An update for CommandPanels is available."); Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + " An update for CommandPanels is available.");
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + " Download version " + gitVersion + " here:"); Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + " Download version " + gitVersion + " here:");

View File

@ -1,6 +1,5 @@
package me.rockyhawk.commandPanels.commands; package me.rockyhawk.commandPanels.commands;
import me.clip.placeholderapi.PlaceholderAPI;
import me.rockyhawk.commandPanels.commandpanels; import me.rockyhawk.commandPanels.commandpanels;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;

View File

@ -12,8 +12,8 @@ import org.bukkit.event.player.*;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator; import java.util.Iterator;
import java.util.Objects;
public class commandpanelcustom implements Listener { public class commandpanelcustom implements Listener {
commandpanels plugin; commandpanels plugin;
@ -27,13 +27,12 @@ public class commandpanelcustom implements Listener {
Player p = (Player)e.getPlayer(); Player p = (Player)e.getPlayer();
File panelsf = new File(plugin.getDataFolder() + File.separator + "panels"); File panelsf = new File(plugin.getDataFolder() + File.separator + "panels");
try { try {
if (panelsf.list() == null || panelsf.list().length == 0) { if (panelsf.list() == null || Objects.requireNonNull(panelsf.list()).length == 0) {
return; return;
} }
}catch(Exception b){ }catch(Exception b){
return; return;
} }
ArrayList<String> filenames = new ArrayList<String>(Arrays.asList(panelsf.list()));
YamlConfiguration cf; //this is the file to use for any panel.* requests 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) ArrayList<String> apanels = new ArrayList<String>(); //all panels from all files (panel names)
String tpanels; //tpanels is the temp to check through the files String tpanels; //tpanels is the temp to check through the files
@ -50,7 +49,7 @@ public class commandpanelcustom implements Listener {
} }
return; 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(); key = (String) var10.next();
apanels.add(key); apanels.add(key);
} }

View File

@ -10,7 +10,6 @@ import org.bukkit.event.EventHandler;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator; import java.util.Iterator;

View File

@ -15,6 +15,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Objects;
public class newGenUtils implements Listener { public class newGenUtils implements Listener {
public YamlConfiguration tempEdit; public YamlConfiguration tempEdit;
@ -32,11 +33,8 @@ public class newGenUtils implements Listener {
} }
//reload panel files to avoid conflicts //reload panel files to avoid conflicts
plugin.reloadPanelFiles(); plugin.reloadPanelFiles();
//get all panel names (not titles)
File panelsf = new File(plugin.getDataFolder() + File.separator + "panels");
Boolean pexist = true; Boolean pexist = true;
//pexist is true if panels exist //pexist is true if panels exist
YamlConfiguration cf;
ArrayList<String> apanels = new ArrayList<String>(); //all panels from all files (panel names) ArrayList<String> apanels = new ArrayList<String>(); //all panels from all files (panel names)
try { 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
@ -44,9 +42,7 @@ public class newGenUtils implements Listener {
if(!plugin.checkPanels(temp)){ if(!plugin.checkPanels(temp)){
continue; continue;
} }
for (String key : temp.getConfigurationSection("panels").getKeys(false)) { apanels.addAll(Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false));
apanels.add(key);
}
} }
}catch(Exception fail){ }catch(Exception fail){
//could not fetch all panel names (probably no panels exist) //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: is what the panel and file name will be called
String date = "panel-1"; String date = "panel-1";
if(pexist){ 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); date = "panel-" + (count+1);
} }
}else{ }else{
date = "panel-1"; 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 folder = new File(plugin.getDataFolder() + File.separator + "panels");
file = YamlConfiguration.loadConfiguration(new File(folder + File.separator + date + ".yml")); file = YamlConfiguration.loadConfiguration(new File(folder + File.separator + date + ".yml"));
file.addDefault("panels." + date + ".perm", "default"); file.addDefault("panels." + date + ".perm", "default");

View File

@ -27,7 +27,7 @@ public class cpIngameEditCommand implements CommandExecutor {
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.perms"))); sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.perms")));
return true; 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 //this will cancel every /cpe command if ingame-editor is set to false
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.RED + "Editor disabled!")); sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.RED + "Editor disabled!"));
return true; return true;
@ -36,8 +36,6 @@ public class cpIngameEditCommand implements CommandExecutor {
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.RED + "Please execute command as a Player!")); sender.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.RED + "Please execute command as a Player!"));
return true; 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 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 YamlConfiguration cf; //this is the file to use for any panel.* requests
String panels = ""; String panels = "";
@ -46,11 +44,11 @@ public class cpIngameEditCommand implements CommandExecutor {
String tpanels; //tpanels is the temp to check through the files String tpanels; //tpanels is the temp to check through the files
//below is going to go through the files and find the right one //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 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; String key;
YamlConfiguration temp; YamlConfiguration temp;
tpanels = ""; tpanels = "";
temp = YamlConfiguration.loadConfiguration(new File(panelsf + File.separator + filenames.get(f))); temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + filename));
if (!plugin.checkPanels(temp)) { if (!plugin.checkPanels(temp)) {
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + plugin.config.getString("config.format.error") + ": File with no Panels found!")); sender.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + plugin.config.getString("config.format.error") + ": File with no Panels found!"));
return true; return true;
@ -72,7 +70,7 @@ public class cpIngameEditCommand implements CommandExecutor {
//if nfound is true it was not found //if nfound is true it was not found
if (!nfound) { if (!nfound) {
panels = tpanels; panels = tpanels;
panelscf = new File(panelsf + File.separator + filenames.get(f)); panelscf = new File(plugin.panelsf + File.separator + filename);
} }
} }
panels = panels.trim(); panels = panels.trim();

View File

@ -11,6 +11,7 @@ import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Objects;
public class cpTabCompleteIngame implements TabCompleter { public class cpTabCompleteIngame implements TabCompleter {
@ -31,7 +32,7 @@ public class cpTabCompleteIngame implements TabCompleter {
if(!plugin.checkPanels(temp)){ if(!plugin.checkPanels(temp)){
return null; 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(); 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 //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(sender.hasPermission("commandpanel.panel." + temp.getString("panels." + key + ".perm"))) {
if(temp.contains("panels." + key + ".disabled-worlds")){ if(temp.contains("panels." + key + ".disabled-worlds")){
List<String> disabledWorlds = (List<String>) temp.getList("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())){ if(!disabledWorlds.contains(p.getWorld().getName())){
apanels.add(key); apanels.add(key);
} }

View File

@ -13,6 +13,7 @@ import org.bukkit.event.player.AsyncPlayerChatEvent;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
public class editorUserInput implements Listener { public class editorUserInput implements Listener {
commandpanels plugin; commandpanels plugin;
@ -34,16 +35,16 @@ public class editorUserInput implements Listener {
String section = temp[2]; String section = temp[2];
YamlConfiguration cf = null; YamlConfiguration cf = null;
try { try {
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 tempConf = YamlConfiguration.loadConfiguration(tempFile); YamlConfiguration tempConf = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + tempFile));
if (!plugin.checkPanels(tempConf)) { if (!plugin.checkPanels(tempConf)) {
continue; continue;
} }
for (String key : tempConf.getConfigurationSection("panels").getKeys(false)) { for (String key : Objects.requireNonNull(tempConf.getConfigurationSection("panels")).getKeys(false)) {
if (key.equals(panelName)) { if (key.equals(panelName)) {
cf = tempConf; cf = tempConf;
panelFile = tempFile; panelFile = new File(plugin.panelsf + File.separator + tempFile);
panelTitle = ChatColor.translateAlternateColorCodes('&',tempConf.getString("panels." + key + ".title")); panelTitle = ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(tempConf.getString("panels." + key + ".title")));
break; break;
} }
} }
@ -55,7 +56,7 @@ public class editorUserInput implements Listener {
if(e.getMessage().equalsIgnoreCase(plugin.config.getString("config.input-cancel"))){ if(e.getMessage().equalsIgnoreCase(plugin.config.getString("config.input-cancel"))){
plugin.editorInputStrings.remove(temp); plugin.editorInputStrings.remove(temp);
plugin.reloadPanelFiles(); 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; return;
} }
if(section.startsWith("panel.")) { if(section.startsWith("panel.")) {
@ -96,7 +97,7 @@ public class editorUserInput implements Listener {
switch (section) { switch (section) {
case "panel.delete": case "panel.delete":
if (e.getMessage().contains("y")) { 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 //if the file has more than one panel in it
cf.set("panels." + panelName, null); cf.set("panels." + panelName, null);
if(savePanelFile(cf, panelFile)){ if(savePanelFile(cf, panelFile)){
@ -170,7 +171,7 @@ public class editorUserInput implements Listener {
} }
String materialTemp = null; String materialTemp = null;
try { try {
materialTemp = Material.matchMaterial(e.getMessage()).toString(); materialTemp = Objects.requireNonNull(Material.matchMaterial(e.getMessage())).toString();
}catch(NullPointerException ex){ }catch(NullPointerException ex){
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.RED + e.getMessage() + " is not a valid Material!")); 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())); p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Added new command: " + e.getMessage()));
break; break;
case "panel.commands-on-open.remove": case "panel.commands-on-open.remove":
List<String> commandsOnOpenRemove = new ArrayList<>(); List<String> commandsOnOpenRemove;
if(cf.contains("panels." + panelName + ".commands-on-open")){ if(cf.contains("panels." + panelName + ".commands-on-open")){
commandsOnOpenRemove = cf.getStringList("panels." + panelName + ".commands-on-open"); commandsOnOpenRemove = cf.getStringList("panels." + panelName + ".commands-on-open");
}else{ }else{
@ -344,7 +345,7 @@ public class editorUserInput implements Listener {
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Added new command: " + e.getMessage())); p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Added new command: " + e.getMessage()));
break; break;
case "commands.remove": case "commands.remove":
List<String> commandsOnOpenRemove = new ArrayList<>(); List<String> commandsOnOpenRemove;
if(cf.contains("panels." + panelName + ".item." + itemSlot + ".commands")){ if(cf.contains("panels." + panelName + ".item." + itemSlot + ".commands")){
commandsOnOpenRemove = cf.getStringList("panels." + panelName + ".item." + itemSlot + ".commands"); commandsOnOpenRemove = cf.getStringList("panels." + panelName + ".item." + itemSlot + ".commands");
}else{ }else{
@ -376,7 +377,7 @@ public class editorUserInput implements Listener {
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Added new lore: " + e.getMessage())); p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Added new lore: " + e.getMessage()));
break; break;
case "lore.remove": case "lore.remove":
List<String> loreOnOpenRemove = new ArrayList<>(); List<String> loreOnOpenRemove;
if(cf.contains("panels." + panelName + ".item." + itemSlot + ".lore")){ if(cf.contains("panels." + panelName + ".item." + itemSlot + ".lore")){
loreOnOpenRemove = cf.getStringList("panels." + panelName + ".item." + itemSlot + ".lore"); loreOnOpenRemove = cf.getStringList("panels." + panelName + ".item." + itemSlot + ".lore");
}else{ }else{

View File

@ -1,7 +1,6 @@
package me.rockyhawk.commandPanels.ingameEditor; package me.rockyhawk.commandPanels.ingameEditor;
import me.rockyhawk.commandPanels.commandpanels; import me.rockyhawk.commandPanels.commandpanels;
import net.milkbowl.vault.chat.Chat;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
@ -16,7 +15,6 @@ import org.bukkit.inventory.ItemStack;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator;
import java.util.Objects; import java.util.Objects;
public class editorUtils implements Listener { public class editorUtils implements Listener {
@ -101,7 +99,7 @@ public class editorUtils implements Listener {
if(e.getSlot() <= 44){ if(e.getSlot() <= 44){
//if panel slots are selected //if panel slots are selected
try{ try{
if(e.getCurrentItem().getType() != Material.AIR){ if(Objects.requireNonNull(e.getCurrentItem()).getType() != Material.AIR){
if(e.getClick().isLeftClick() && !e.getClick().isShiftClick()){ if(e.getClick().isLeftClick() && !e.getClick().isShiftClick()){
//if left click //if left click
int count = 0; int count = 0;
@ -172,7 +170,7 @@ public class editorUtils implements Listener {
//this basically just determines if something is dragged. //this basically just determines if something is dragged.
try { try {
if (tempEdit.contains("panels." + panelName + ".temp." + p.getName() + ".material")) { 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); clearTemp(p, panelName);
return; return;
} }
@ -211,17 +209,17 @@ public class editorUtils implements Listener {
boolean found = false; boolean found = false;
try { try {
//neew to loop through files to get file names //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; String key;
YamlConfiguration temp = YamlConfiguration.loadConfiguration(tempFile);
if(!plugin.checkPanels(temp)){ if(!plugin.checkPanels(temp)){
return; return;
} }
for (Iterator var10 = temp.getConfigurationSection("panels").getKeys(false).iterator(); var10.hasNext();) { for (String s : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)) {
key = (String) var10.next(); key = s;
if(e.getView().getTitle().equals(ChatColor.GRAY + "Editing Panel: " + ChatColor.translateAlternateColorCodes('&', temp.getString("panels." + key + ".title")))){ if (e.getView().getTitle().equals(ChatColor.GRAY + "Editing Panel: " + ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(temp.getString("panels." + key + ".title"))))) {
panelName = key; panelName = key;
fileName = tempFile; fileName = new File(plugin.panelsf + File.separator + tempName);
file = temp; file = temp;
found = true; found = true;
break; break;
@ -257,9 +255,9 @@ public class editorUtils implements Listener {
return; return;
} }
if(tempEdit.contains("panels." + panelName + ".temp." + p.getName() + ".material")) { 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 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); clearTemp(p, panelName);
} }
} }
@ -315,7 +313,7 @@ public class editorUtils implements Listener {
Player p = (Player)e.getWhoClicked(); Player p = (Player)e.getWhoClicked();
String tag = plugin.config.getString("config.format.tag") + " "; String tag = plugin.config.getString("config.format.tag") + " ";
try { try {
if (e.getClickedInventory().getType() != InventoryType.CHEST) { if (Objects.requireNonNull(e.getClickedInventory()).getType() != InventoryType.CHEST) {
return; return;
} }
}catch(Exception outOf){ }catch(Exception outOf){
@ -335,7 +333,7 @@ public class editorUtils implements Listener {
if(!plugin.checkPanels(temp)){ if(!plugin.checkPanels(temp)){
return; 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)){ if(e.getView().getTitle().equals("Panel Settings: " + key)){
panelName = key; panelName = key;
found = true; found = true;
@ -412,7 +410,7 @@ public class editorUtils implements Listener {
Player p = (Player)e.getWhoClicked(); Player p = (Player)e.getWhoClicked();
String tag = plugin.config.getString("config.format.tag") + " "; String tag = plugin.config.getString("config.format.tag") + " ";
try { try {
if (e.getClickedInventory().getType() != InventoryType.CHEST) { if (Objects.requireNonNull(e.getClickedInventory()).getType() != InventoryType.CHEST) {
return; return;
} }
}catch(Exception outOf){ }catch(Exception outOf){
@ -433,7 +431,7 @@ public class editorUtils implements Listener {
if(!plugin.checkPanels(temp)){ if(!plugin.checkPanels(temp)){
return; 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)){ if(e.getView().getTitle().equals("Item Settings: " + key)){
panelName = key; panelName = key;
panelYaml = temp; panelYaml = temp;
@ -452,7 +450,7 @@ public class editorUtils implements Listener {
} }
int itemSlot; int itemSlot;
try { 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){ }catch(Exception ex){
plugin.getServer().getConsoleSender().sendMessage("[CommandPanels] Could not get item slot"); plugin.getServer().getConsoleSender().sendMessage("[CommandPanels] Could not get item slot");
plugin.debug(ex); plugin.debug(ex);
@ -562,17 +560,17 @@ public class editorUtils implements Listener {
boolean found = false; boolean found = false;
try { try {
//neew to loop through files to get file names //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; String key;
YamlConfiguration temp = YamlConfiguration.loadConfiguration(tempFile);
if(!plugin.checkPanels(temp)){ if(!plugin.checkPanels(temp)){
return; return;
} }
for (Iterator var10 = temp.getConfigurationSection("panels").getKeys(false).iterator(); var10.hasNext();) { for (String s : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)) {
key = (String) var10.next(); key = s;
if(invView.getTitle().equals(ChatColor.GRAY + "Editing Panel: " + ChatColor.translateAlternateColorCodes('&', temp.getString("panels." + key + ".title")))){ if (invView.getTitle().equals(ChatColor.GRAY + "Editing Panel: " + ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(temp.getString("panels." + key + ".title"))))) {
panelName = key; panelName = key;
fileName = tempFile.getName(); fileName = tempFile;
file = temp; file = temp;
found = true; found = true;
break; break;
@ -602,7 +600,7 @@ public class editorUtils implements Listener {
} }
} }
if(file.contains("panels." + panelName + ".item." + i + ".material")){ 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){ if(cont.getType() != Material.PLAYER_HEAD){
file.set("panels." + panelName + ".item." + i + ".material", cont.getType().toString()); 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")){ if(file.contains("panels." + panelName + ".item." + i + ".name")){
//these will ensure &f items (blank items) will be set to &f to stay blank //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"); file.set("panels." + panelName + ".item." + i + ".name", "&f");
}else{ }else{
file.set("panels." + panelName + ".item." + i + ".name", cont.getItemMeta().getDisplayName()); file.set("panels." + panelName + ".item." + i + ".name", Objects.requireNonNull(cont.getItemMeta()).getDisplayName());
} }
}else { }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){ }catch(Exception n){
//skip over an item that spits an error //skip over an item that spits an error
} }

View File

@ -6,6 +6,8 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.AsyncPlayerChatEvent;
import java.util.Objects;
public class commandpanelUserInput implements Listener { public class commandpanelUserInput implements Listener {
commandpanels plugin; commandpanels plugin;
public commandpanelUserInput(commandpanels pl) { public commandpanelUserInput(commandpanels pl) {
@ -17,7 +19,7 @@ public class commandpanelUserInput implements Listener {
if(plugin.userInputStrings.get(o)[0].equals(e.getPlayer().getName())){ if(plugin.userInputStrings.get(o)[0].equals(e.getPlayer().getName())){
if(e.getMessage().equalsIgnoreCase(plugin.config.getString("config.input-cancel"))){ if(e.getMessage().equalsIgnoreCase(plugin.config.getString("config.input-cancel"))){
e.setCancelled(true); 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++){ for(int i = 0; plugin.userInputStrings.size() > i; i++){
if(plugin.userInputStrings.get(i)[0].equals(e.getPlayer().getName())){ if(plugin.userInputStrings.get(i)[0].equals(e.getPlayer().getName())){
plugin.userInputStrings.remove(i); plugin.userInputStrings.remove(i);

View File

@ -80,14 +80,12 @@ public class utils implements Listener {
}catch(Exception b){ }catch(Exception b){
return; 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 YamlConfiguration cf = null; //this is the file to use for any panel.* requests
String panel = null; String panel = null;
boolean foundPanel = false; 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; String key;
YamlConfiguration temp; YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + filename));
temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + filename));
if (!plugin.checkPanels(temp)) { 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!"))); p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + plugin.papi(p, plugin.config.getString("config.format.error") + ": Syntax error Found or Missing certain element!")));
return; return;