3.2.2 Fixes

This commit is contained in:
rockyhawk64 2020-07-07 19:47:14 +10:00
parent 32c4b96894
commit a8bc43be1c
11 changed files with 100 additions and 84 deletions

View File

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

View File

@ -54,7 +54,7 @@ public class commandpanels extends JavaPlugin {
public List<String> panelRunning = new ArrayList(); public List<String> panelRunning = new ArrayList();
public List<String[]> userInputStrings = new ArrayList(); public List<String[]> userInputStrings = new ArrayList();
public List<String[]> editorInputStrings = new ArrayList(); public List<String[]> editorInputStrings = new ArrayList();
public ArrayList<YamlConfiguration> panelFiles = new ArrayList<YamlConfiguration>(); public ArrayList<String> panelFiles = new ArrayList<String>(); //names of all the files in the panels folder including extension
public ArrayList<String[]> panelNames = new ArrayList<String[]>(); //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 ArrayList<String[]> panelNames = new ArrayList<String[]>(); //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; public File panelsf;
@ -1127,8 +1127,12 @@ public class commandpanels extends JavaPlugin {
panelNames.clear(); panelNames.clear();
int count = 0; int count = 0;
for (String fileName : Objects.requireNonNull(panelsf.list())) { for (String fileName : Objects.requireNonNull(panelsf.list())) {
panelFiles.add(YamlConfiguration.loadConfiguration(new File(panelsf + File.separator + fileName))); int ind = fileName.lastIndexOf(".");
for (String tempName : Objects.requireNonNull(panelFiles.get(count).getConfigurationSection("panels")).getKeys(false)) { 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)}); panelNames.add(new String[]{tempName, Integer.toString(count)});
} }
count += 1; count += 1;
@ -1196,7 +1200,8 @@ public class commandpanels extends JavaPlugin {
ArrayList<String> panelTitles = new ArrayList<String>(); //all panels from ALL files (panel titles) ArrayList<String> panelTitles = new ArrayList<String>(); //all panels from ALL files (panel titles)
ArrayList<Material> panelItems = new ArrayList<Material>(); //all panels from ALL files (panel materials) ArrayList<Material> panelItems = new ArrayList<Material>(); //all panels from ALL files (panel materials)
try { 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; String key;
if (!checkPanels(temp)) { if (!checkPanels(temp)) {
return; return;

View File

@ -13,6 +13,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import java.io.File;
import java.util.*; import java.util.*;
public class commandpanel implements CommandExecutor { public class commandpanel implements CommandExecutor {
@ -32,7 +33,8 @@ public class commandpanel implements CommandExecutor {
boolean found = false; boolean found = false;
//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 (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)){ if(!plugin.checkPanels(temp)){
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.error") + ": Panel with syntax error found!")); sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.error") + ": Panel with syntax error found!"));
return true; return true;

View File

@ -38,7 +38,8 @@ public class commandpanelcustom implements Listener {
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
String panel = null; 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; String key;
tpanels = ""; tpanels = "";
if(!plugin.checkPanels(temp)){ if(!plugin.checkPanels(temp)){

View File

@ -24,10 +24,9 @@ public class commandpanelslist implements CommandExecutor {
if (label.equalsIgnoreCase("cpl") || label.equalsIgnoreCase("commandpanellist") || label.equalsIgnoreCase("cpanell")) { if (label.equalsIgnoreCase("cpl") || label.equalsIgnoreCase("commandpanellist") || label.equalsIgnoreCase("cpanell")) {
if (sender.hasPermission("commandpanel.list")) { if (sender.hasPermission("commandpanel.list")) {
//command /cpl //command /cpl
File panelsf = new File(plugin.getDataFolder() + File.separator + "panels"); //check to make sure the panels isn't empty
//check to make sure the panels folder isn't empty
try { try {
if (panelsf.list() == null || panelsf.list().length == 0) { if (plugin.panelFiles == null) {
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.RED + "No panels found!")); sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.RED + "No panels found!"));
return true; return true;
} }
@ -35,15 +34,14 @@ public class commandpanelslist implements CommandExecutor {
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.RED + "No panels found!")); sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.RED + "No panels found!"));
return true; return true;
} }
ArrayList<String> filenames = new ArrayList<String>(Arrays.asList(panelsf.list()));
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
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; 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 + plugin.panelFiles.get(f)));
apanels.add("%file%" + filenames.get(f)); apanels.add("%file%" + plugin.panelFiles.get(f));
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;

View File

@ -7,6 +7,7 @@ import org.bukkit.command.TabCompleter;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
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;
@ -23,7 +24,8 @@ public class cpTabComplete implements TabCompleter {
ArrayList<String> apanels = new ArrayList<String>(); //all panels ArrayList<String> apanels = new ArrayList<String>(); //all panels
String tpanels; //tpanels is the temp to check through the files String tpanels; //tpanels is the temp to check through the files
try { 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; String key;
tpanels = ""; tpanels = "";
if(!plugin.checkPanels(temp)){ if(!plugin.checkPanels(temp)){

View File

@ -39,7 +39,8 @@ public class newGenUtils implements Listener {
YamlConfiguration cf; 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(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)){ if(!plugin.checkPanels(temp)){
continue; continue;
} }

View File

@ -7,6 +7,7 @@ import org.bukkit.command.TabCompleter;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
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;
@ -23,7 +24,8 @@ public class cpTabCompleteIngame implements TabCompleter {
ArrayList<String> apanels = new ArrayList<String>(); //all panels ArrayList<String> apanels = new ArrayList<String>(); //all panels
String tpanels; //tpanels is the temp to check through the files String tpanels; //tpanels is the temp to check through the files
try { 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; String key;
tpanels = ""; tpanels = "";
if(!plugin.checkPanels(temp)){ if(!plugin.checkPanels(temp)){

View File

@ -17,6 +17,7 @@ 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.Iterator;
import java.util.Objects;
public class editorUtils implements Listener { public class editorUtils implements Listener {
public YamlConfiguration tempEdit; public YamlConfiguration tempEdit;
@ -31,7 +32,7 @@ public class editorUtils implements Listener {
Player p = (Player)e.getWhoClicked(); Player p = (Player)e.getWhoClicked();
//if the inventory isn't the editor main window //if the inventory isn't the editor main window
try { try {
if (e.getClickedInventory().getType() != InventoryType.CHEST) { if (Objects.requireNonNull(e.getClickedInventory()).getType() != InventoryType.CHEST) {
return; return;
} }
}catch(NullPointerException nu){return;} }catch(NullPointerException nu){return;}
@ -46,15 +47,16 @@ public class editorUtils implements Listener {
ArrayList<String> panelTitles = new ArrayList<String>(); //all panels from ALL files (panel titles) ArrayList<String> panelTitles = new ArrayList<String>(); //all panels from ALL files (panel titles)
ArrayList<YamlConfiguration> panelYaml = new ArrayList<YamlConfiguration>(); //all panels from ALL files (panel yaml files) ArrayList<YamlConfiguration> panelYaml = new ArrayList<YamlConfiguration>(); //all panels from ALL files (panel yaml files)
try { 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; String key;
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;
panelNames.add(ChatColor.translateAlternateColorCodes('&', key)); 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); panelYaml.add(temp);
} }
} }
@ -66,16 +68,16 @@ public class editorUtils implements Listener {
if(e.getSlot() == 48){ if(e.getSlot() == 48){
//previous page button //previous page button
try { try {
if (e.getCurrentItem().getType() == Material.PAPER) { if (Objects.requireNonNull(e.getCurrentItem()).getType() == Material.PAPER) {
plugin.openEditorGui(p, -1); plugin.openEditorGui(p, -1);
p.updateInventory(); p.updateInventory();
return; return;
} }
}catch(NullPointerException nu){} }catch(NullPointerException ignored){}
} }
if(e.getSlot() == 49){ if(e.getSlot() == 49){
//sunflower page index //sunflower page index
if(e.getCurrentItem().getType() == Material.SUNFLOWER){ if(Objects.requireNonNull(e.getCurrentItem()).getType() == Material.SUNFLOWER){
p.updateInventory(); p.updateInventory();
return; return;
} }
@ -83,12 +85,12 @@ public class editorUtils implements Listener {
if(e.getSlot() == 50){ if(e.getSlot() == 50){
//next page button //next page button
try{ try{
if(e.getCurrentItem().getType() == Material.PAPER){ if(Objects.requireNonNull(e.getCurrentItem()).getType() == Material.PAPER){
plugin.openEditorGui(p, 1); plugin.openEditorGui(p, 1);
p.updateInventory(); p.updateInventory();
return; return;
} }
}catch(NullPointerException nu){} }catch(NullPointerException ignored){}
} }
if(e.getSlot() == 45){ if(e.getSlot() == 45){
//exit button //exit button
@ -104,7 +106,7 @@ public class editorUtils implements Listener {
//if left click //if left click
int count = 0; int count = 0;
for(String panelName : panelNames){ 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); plugin.openGui(panelName, p, panelYaml.get(count),3,0);
return; return;
} }
@ -114,7 +116,7 @@ public class editorUtils implements Listener {
//if right click //if right click
int count = 0; int count = 0;
for(String panelName : panelNames){ 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)); plugin.openPanelSettings(p,panelName,panelYaml.get(count));
return; return;
} }
@ -123,7 +125,7 @@ public class editorUtils implements Listener {
p.updateInventory(); p.updateInventory();
} }
} }
}catch(NullPointerException nu){} }catch(NullPointerException ignored){}
} }
p.updateInventory(); p.updateInventory();
} }
@ -142,17 +144,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 fileTempName : plugin.panelFiles) { //will loop through all the files in folder
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
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.getName(); fileName = fileTempName;
file = temp; file = temp;
found = true; found = true;
break; break;
@ -328,7 +330,8 @@ 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 (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)){ if(!plugin.checkPanels(temp)){
return; return;
} }
@ -425,7 +428,8 @@ 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 (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)){ if(!plugin.checkPanels(temp)){
return; return;
} }

View File

@ -12,9 +12,7 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.Objects;
import java.util.Arrays;
import java.util.Iterator;
public class commandpanelrefresher implements Listener { public class commandpanelrefresher implements Listener {
commandpanels plugin; commandpanels plugin;
@ -28,7 +26,7 @@ public class commandpanelrefresher implements Listener {
public void onInventoryOpen(InventoryOpenEvent e){ //Handles when Players open inventory public void onInventoryOpen(InventoryOpenEvent e){ //Handles when Players open inventory
//I have to convert HumanEntity to a player //I have to convert HumanEntity to a player
if (plugin.config.contains("config.refresh-panels")) { 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; return;
} }
} }
@ -44,28 +42,27 @@ public class commandpanelrefresher implements Listener {
YamlConfiguration cf = null; YamlConfiguration cf = null;
String panel = null; String panel = null;
String panelTitle = null; String panelTitle = null;
ArrayList<String> filenames = new ArrayList<String>(Arrays.asList(plugin.panelsf.list()));
try { try {
boolean foundPanel = false; 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; String key;
YamlConfiguration temp; YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + filenames.get(f))); if (!plugin.checkPanels(temp)) {
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!"))); 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; 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(ChatColor.translateAlternateColorCodes('&',temp.getString("panels." + key + ".title")).equals(e.getView().getTitle())){ if (ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(temp.getString("panels." + key + ".title"))).equals(e.getView().getTitle())) {
panel = key; panel = key;
panelTitle = ChatColor.translateAlternateColorCodes('&',temp.getString("panels." + key + ".title")); panelTitle = ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(temp.getString("panels." + key + ".title")));
cf = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + filenames.get(f))); cf = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
foundPanel= true; foundPanel = true;
break; break;
} }
} }
if(foundPanel){ if (foundPanel) {
//this is to avoid the plugin to continue looking when it was already found //this is to avoid the plugin to continue looking when it was already found
break; break;
} }
@ -77,15 +74,17 @@ public class commandpanelrefresher implements Listener {
return; return;
} }
//there is already a runnable running for this player //there is already a runnable running for this player
assert p != null;
if(plugin.panelRunning.contains(p.getName() + ";" + panel)){ if(plugin.panelRunning.contains(p.getName() + ";" + panel)){
return; return;
} }
plugin.panelRunning.add(p.getName() + ";" + panel); plugin.panelRunning.add(p.getName() + ";" + panel);
if (plugin.config.contains("config.panel-snooper")) { 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); Bukkit.getConsoleSender().sendMessage("[CommandPanels] " + p.getName() + " Opened " + panel);
} }
} }
assert cf != null;
if(cf.contains("panels." + panel + ".animatevalue")){ if(cf.contains("panels." + panel + ".animatevalue")){
animatevalue = cf.getInt("panels." + panel + ".animatevalue"); animatevalue = cf.getInt("panels." + panel + ".animatevalue");
} }
@ -98,7 +97,7 @@ public class commandpanelrefresher implements Listener {
@Override @Override
public void run() { public void run() {
//counter counts to refresh delay (in seconds) then restarts //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; c+=1;
}else{ }else{
c=0; c=0;
@ -121,9 +120,9 @@ public class commandpanelrefresher implements Listener {
} }
} }
}else{ }else{
if(plugin.config.getString("config.stop-sound").trim().equalsIgnoreCase("true")){ if(Objects.requireNonNull(plugin.config.getString("config.stop-sound")).trim().equalsIgnoreCase("true")){
try { 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){ }catch(Exception sou){
//skip //skip
} }
@ -162,7 +161,7 @@ public class commandpanelrefresher implements Listener {
} }
plugin.panelRunning.remove(p.getName() + ";" + fpanel); plugin.panelRunning.remove(p.getName() + ";" + fpanel);
if (plugin.config.contains("config.panel-snooper")) { 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); Bukkit.getConsoleSender().sendMessage("[CommandPanels] " + p.getName() + " Closed " + fpanel);
} }
} }

View File

@ -32,8 +32,8 @@ public class utils implements Listener {
if(e.getAction() == InventoryAction.NOTHING){return;} if(e.getAction() == InventoryAction.NOTHING){return;}
if (e.getRawSlot() == -999) {return;} if (e.getRawSlot() == -999) {return;}
if (e.getSlotType() != InventoryType.SlotType.QUICKBAR) {return;} if (e.getSlotType() != InventoryType.SlotType.QUICKBAR) {return;}
for(String[] panelName : plugin.panelNames){ 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]; String tempName = panelName[0];
if(tempFile.contains("panels." + tempName + ".open-with-item") && Objects.requireNonNull(e.getClickedInventory()).getType() == InventoryType.PLAYER) { if(tempFile.contains("panels." + tempName + ".open-with-item") && Objects.requireNonNull(e.getClickedInventory()).getType() == InventoryType.PLAYER) {
try{ try{
@ -73,7 +73,7 @@ public class utils implements Listener {
//if the inventory is just a chest that has no panel //if the inventory is just a chest that has no panel
return; return;
} }
if (plugin.panelsf.list() == null || Objects.requireNonNull(plugin.panelsf.list()).length == 0) { if (plugin.panelFiles == null) {
//if no panels are present //if no panels are present
return; 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){ if(e.getAction() != Action.RIGHT_CLICK_AIR && e.getAction() != Action.RIGHT_CLICK_BLOCK && Objects.requireNonNull(e.getItem()).getType() == Material.AIR){
return; return;
} }
if (plugin.panelsf.list() == null || Objects.requireNonNull(plugin.panelsf.list()).length == 0) { if (plugin.panelFiles == null) {
return; return;
} }
}catch(Exception b){ }catch(Exception b){
@ -297,7 +297,7 @@ public class utils implements Listener {
ItemStack clicked = e.getItem(); ItemStack clicked = e.getItem();
Player p = e.getPlayer(); Player p = e.getPlayer();
for(String[] panelName : plugin.panelNames){ 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]; String tempName = panelName[0];
if(tempFile.contains("panels." + tempName + ".open-with-item")) { if(tempFile.contains("panels." + tempName + ".open-with-item")) {
try{ try{
@ -336,7 +336,7 @@ public class utils implements Listener {
*/ */
Player p = e.getPlayer(); Player p = e.getPlayer();
try { try {
if (plugin.panelsf.list() == null || Objects.requireNonNull(plugin.panelsf.list()).length == 0) { if (plugin.panelFiles == null) {
return; return;
} }
}catch(Exception b){ }catch(Exception b){
@ -344,7 +344,8 @@ public class utils implements Listener {
} }
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 tpanels; //tpanels is the temp to check through the files 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; String key;
tpanels = ""; tpanels = "";
if(!plugin.checkPanels(temp)){ if(!plugin.checkPanels(temp)){
@ -380,7 +381,7 @@ public class utils implements Listener {
public void onPlayerRespawn(PlayerRespawnEvent e){ public void onPlayerRespawn(PlayerRespawnEvent e){
Player p = e.getPlayer(); Player p = e.getPlayer();
try { try {
if (plugin.panelsf.list() == null || Objects.requireNonNull(plugin.panelsf.list()).length == 0) { if (plugin.panelFiles == null) {
return; return;
} }
}catch(Exception b){ }catch(Exception b){
@ -388,7 +389,8 @@ public class utils implements Listener {
} }
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 tpanels; //tpanels is the temp to check through the files 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; String key;
tpanels = ""; tpanels = "";
if(!plugin.checkPanels(temp)){ if(!plugin.checkPanels(temp)){
@ -421,9 +423,8 @@ public class utils implements Listener {
@EventHandler @EventHandler
public void onPlayerDeath(PlayerDeathEvent e){ public void onPlayerDeath(PlayerDeathEvent e){
Player p = (Player)e.getEntity(); Player p = (Player)e.getEntity();
File panelsf = new File(plugin.getDataFolder() + File.separator + "panels");
try { try {
if (panelsf.list() == null || Objects.requireNonNull(panelsf.list()).length == 0) { if (plugin.panelFiles == null) {
return; return;
} }
}catch(Exception b){ }catch(Exception b){
@ -431,7 +432,8 @@ public class utils implements Listener {
} }
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 tpanels; //tpanels is the temp to check through the files 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; String key;
tpanels = ""; tpanels = "";
if(!plugin.checkPanels(temp)){ if(!plugin.checkPanels(temp)){
@ -457,7 +459,6 @@ public class utils implements Listener {
@EventHandler @EventHandler
public void onPlayerJoin(PlayerJoinEvent e){ public void onPlayerJoin(PlayerJoinEvent e){
Player p = e.getPlayer(); Player p = e.getPlayer();
File panelsf = new File(plugin.getDataFolder() + File.separator + "panels");
String tag = plugin.config.getString("config.format.tag") + " "; String tag = plugin.config.getString("config.format.tag") + " ";
if(p.isOp() || p.hasPermission("*.*")){ if(p.isOp() || p.hasPermission("*.*")){
if(plugin.update) { if(plugin.update) {
@ -466,14 +467,15 @@ public class utils implements Listener {
} }
} }
try { try {
if (panelsf.list() == null || Objects.requireNonNull(panelsf.list()).length == 0) { if (plugin.panelFiles == null) {
return; return;
} }
}catch(Exception b){ }catch(Exception b){
return; return;
} }
String tpanels; //tpanels is the temp to check through the files 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; String key;
tpanels = ""; tpanels = "";
if(!plugin.checkPanels(temp)){ if(!plugin.checkPanels(temp)){
@ -526,9 +528,8 @@ public class utils implements Listener {
public void onPlayerDropItem(PlayerDropItemEvent e){ public void onPlayerDropItem(PlayerDropItemEvent e){
//if item dropped //if item dropped
Player p = e.getPlayer(); Player p = e.getPlayer();
File panelsf = new File(plugin.getDataFolder() + File.separator + "panels");
try { try {
if (panelsf.list() == null || Objects.requireNonNull(panelsf.list()).length == 0) { if (plugin.panelFiles == null) {
return; return;
} }
}catch(Exception b){ }catch(Exception b){
@ -537,7 +538,8 @@ public class utils implements Listener {
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 tpanels; //tpanels is the temp to check through the files String tpanels; //tpanels is the temp to check through the files
ItemStack clicked = e.getItemDrop().getItemStack(); 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; String key;
tpanels = ""; tpanels = "";
if(!plugin.checkPanels(temp)){ if(!plugin.checkPanels(temp)){
@ -574,9 +576,8 @@ public class utils implements Listener {
@EventHandler @EventHandler
public void onPlayerSwapHandItemsEvent(PlayerSwapHandItemsEvent e){ public void onPlayerSwapHandItemsEvent(PlayerSwapHandItemsEvent e){
Player p = e.getPlayer(); Player p = e.getPlayer();
File panelsf = new File(plugin.getDataFolder() + File.separator + "panels");
try { try {
if (panelsf.list() == null || Objects.requireNonNull(panelsf.list()).length == 0) { if (plugin.panelFiles == null) {
return; return;
} }
}catch(Exception b){ }catch(Exception b){
@ -585,7 +586,8 @@ public class utils implements Listener {
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 tpanels; //tpanels is the temp to check through the files String tpanels; //tpanels is the temp to check through the files
ItemStack clicked = e.getOffHandItem(); 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; String key;
tpanels = ""; tpanels = "";
if(!plugin.checkPanels(temp)){ if(!plugin.checkPanels(temp)){
@ -645,9 +647,8 @@ public class utils implements Listener {
public void onInteractEntity(PlayerInteractEntityEvent e){ public void onInteractEntity(PlayerInteractEntityEvent e){
//cancel everything if holding item (item frames eg) //cancel everything if holding item (item frames eg)
Player p = (Player)e.getPlayer(); Player p = (Player)e.getPlayer();
File panelsf = new File(plugin.getDataFolder() + File.separator + "panels");
try { try {
if (panelsf.list() == null || Objects.requireNonNull(panelsf.list()).length == 0) { if (plugin.panelFiles == null) {
return; return;
} }
}catch(Exception b){ }catch(Exception b){
@ -656,7 +657,8 @@ public class utils implements Listener {
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 tpanels; //tpanels is the temp to check through the files String tpanels; //tpanels is the temp to check through the files
ItemStack clicked = e.getPlayer().getInventory().getItemInMainHand(); 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; String key;
tpanels = ""; tpanels = "";
if(!plugin.checkPanels(temp)){ if(!plugin.checkPanels(temp)){