3.12.4 Fixes

This commit is contained in:
rockyhawk64 2020-10-16 16:05:33 +11:00
parent 8cb27f4957
commit 8a84ceac33
12 changed files with 131 additions and 81 deletions

View File

@ -8,6 +8,7 @@ config:
panel-blocks: true panel-blocks: true
ingame-editor: true ingame-editor: true
hotbar-items: true hotbar-items: true
custom-commands: true
refresh-delay: 4 refresh-delay: 4
server-ping-timeout: 10 server-ping-timeout: 10
stop-sound: true stop-sound: true

View File

@ -9,16 +9,17 @@ panels:
panelType: default panelType: default
rows: 4 rows: 4
title: '&6[&bExample Panel&6]&f Welcome!' title: '&6[&bExample Panel&6]&f Welcome!'
command: example commands:
- "example"
sound-on-open: BLOCK_NOTE_BLOCK_CHIME sound-on-open: BLOCK_NOTE_BLOCK_CHIME
empty: BLACK_STAINED_GLASS_PANE empty: BLACK_STAINED_GLASS_PANE
disabled-worlds: disabled-worlds:
- 'world_nether' - 'world_nether'
open-with-item: open-with-item:
material: CLOCK material: CLOCK
name: '&6[&bExample Panel&6]' name: '&6[&bExample Panel&6]'
lore: lore:
- '&3Click me to open the panel!' - '&3Click me to open the panel!'
stationary: 4 stationary: 4
item: item:
'0': '0':
@ -76,7 +77,7 @@ panels:
material: RED_WOOL material: RED_WOOL
name: '&cYour nickname is not ''RockyHawk''' name: '&cYour nickname is not ''RockyHawk'''
commands: commands:
- 'msg= &cNot RockyHawk' - 'msg= &cNot RockyHawk'
hasvalue: hasvalue:
output: true output: true
value: RockyHawk value: RockyHawk
@ -84,7 +85,7 @@ panels:
material: LIME_WOOL material: LIME_WOOL
name: '&aYour username is ''RockyHawk''' name: '&aYour username is ''RockyHawk'''
commands: commands:
- 'msg= &aWelcome my master!' - 'msg= &aWelcome my master!'
'27': '27':
material: LEATHER_BOOTS material: LEATHER_BOOTS
name: '&e&lYELLOW' name: '&e&lYELLOW'
@ -96,38 +97,38 @@ panels:
enchanted: true enchanted: true
name: '&cClick Me' name: '&cClick Me'
lore: lore:
- '&fI will teleport you home!' - '&fI will teleport you home!'
commands: commands:
- home - home
- commandpanels:commandpanelclose - commandpanels:commandpanelclose
- console= title %cp-player-name% times 20 60 20 - console= title %cp-player-name% times 20 60 20
- console= title %cp-player-name% subtitle {"text":"%cp-player-displayname%","color":"green"} - console= title %cp-player-name% subtitle {"text":"%cp-player-displayname%","color":"green"}
- console= title %cp-player-name% title {"text":"Welcome Home"} - console= title %cp-player-name% title {"text":"Welcome Home"}
'30': '30':
material: POTION material: POTION
name: '&5&lInstant Health II' name: '&5&lInstant Health II'
potion: INSTANT_HEAL potion: INSTANT_HEAL
commands: commands:
- heal - heal
- commandpanels:commandpanelclose - commandpanels:commandpanelclose
'34': '34':
material: REDSTONE_BLOCK material: REDSTONE_BLOCK
name: '&cNo Permission' name: '&cNo Permission'
lore: lore:
- '&4You cannot change to' - '&4You cannot change to'
- '&4creative looking like that!' - '&4creative looking like that!'
hasperm: hasperm:
perm: essentials.gamemode perm: essentials.gamemode
output: true output: true
material: EMERALD_BLOCK material: EMERALD_BLOCK
name: '&aClick Me' name: '&aClick Me'
lore: lore:
- '&2I will change you' - '&2I will change you'
- '&2to creative mode!' - '&2to creative mode!'
commands: commands:
- gamemode creative - gamemode creative
- commandpanels:commandpanelclose - commandpanels:commandpanelclose
- console= title %cp-player-name% times 20 60 20 - console= title %cp-player-name% times 20 60 20
- console= title %cp-player-name% subtitle {"text":"You are now in creative - console= title %cp-player-name% subtitle {"text":"You are now in creative
mode!","color":"green"} mode!","color":"green"}
- console= title %cp-player-name% title {"text":"Awesome %cp-player-displayname%"} - console= title %cp-player-name% title {"text":"Awesome %cp-player-displayname%"}

View File

@ -9,7 +9,8 @@ panels:
panelType: default panelType: default
rows: 4 rows: 4
title: '&6[&bExample Panel&6]&f Welcome!' title: '&6[&bExample Panel&6]&f Welcome!'
command: example commands:
- "example"
empty: STAINED_GLASS_PANE empty: STAINED_GLASS_PANE
emptyID: 15 emptyID: 15
disabled-worlds: disabled-worlds:

View File

@ -1,4 +1,4 @@
version: 3.12.3 version: 3.12.4
main: me.rockyhawk.commandpanels.CommandPanels main: me.rockyhawk.commandpanels.CommandPanels
name: CommandPanels name: CommandPanels
author: RockyHawk author: RockyHawk

View File

@ -14,6 +14,7 @@ import me.realized.tokenmanager.api.TokenManager;
import me.rockyhawk.commandpanels.classresources.*; import me.rockyhawk.commandpanels.classresources.*;
import me.rockyhawk.commandpanels.commands.*; import me.rockyhawk.commandpanels.commands.*;
import me.rockyhawk.commandpanels.completetabs.CpTabComplete; import me.rockyhawk.commandpanels.completetabs.CpTabComplete;
import me.rockyhawk.commandpanels.customcommands.Commandpanelcustom;
import me.rockyhawk.commandpanels.generatepanels.Commandpanelsgenerate; import me.rockyhawk.commandpanels.generatepanels.Commandpanelsgenerate;
import me.rockyhawk.commandpanels.generatepanels.GenUtils; import me.rockyhawk.commandpanels.generatepanels.GenUtils;
import me.rockyhawk.commandpanels.generatepanels.TabCompleteGenerate; import me.rockyhawk.commandpanels.generatepanels.TabCompleteGenerate;
@ -127,7 +128,6 @@ public class CommandPanels extends JavaPlugin {
this.getServer().getPluginManager().registerEvents(new Utils(this), this); this.getServer().getPluginManager().registerEvents(new Utils(this), this);
this.getServer().getPluginManager().registerEvents(new UtilsPanelsLoader(this), this); this.getServer().getPluginManager().registerEvents(new UtilsPanelsLoader(this), this);
this.getServer().getPluginManager().registerEvents(new GenUtils(this), this); this.getServer().getPluginManager().registerEvents(new GenUtils(this), this);
this.getServer().getPluginManager().registerEvents(new Commandpanelcustom(this), this);
this.getServer().getPluginManager().registerEvents(new CommandpanelUserInput(this), this); this.getServer().getPluginManager().registerEvents(new CommandpanelUserInput(this), this);
//if refresh-panels set to false, don't load this //if refresh-panels set to false, don't load this
@ -135,6 +135,11 @@ public class CommandPanels extends JavaPlugin {
this.getServer().getPluginManager().registerEvents(new Commandpanelrefresher(this), this); this.getServer().getPluginManager().registerEvents(new Commandpanelrefresher(this), this);
} }
//if custom-commands set to false, don't load this
if(Objects.requireNonNull(config.getString("config.custom-commands")).equalsIgnoreCase("true")){
this.getServer().getPluginManager().registerEvents(new Commandpanelcustom(this), this);
}
//if hotbar-items set to false, don't load this //if hotbar-items set to false, don't load this
if(Objects.requireNonNull(config.getString("config.hotbar-items")).equalsIgnoreCase("true")){ if(Objects.requireNonNull(config.getString("config.hotbar-items")).equalsIgnoreCase("true")){
this.getServer().getPluginManager().registerEvents(new UtilsOpenWithItem(this), this); this.getServer().getPluginManager().registerEvents(new UtilsOpenWithItem(this), this);

View File

@ -304,7 +304,7 @@ public class ItemCreation {
//if output is true, and values match it will be this item, vice versa //if output is true, and values match it will be this item, vice versa
outputValue = cf.getBoolean("hasvalue.output"); outputValue = cf.getBoolean("hasvalue.output");
} }
String value = cf.getString("hasvalue.value"); String value = ChatColor.stripColor(plugin.papi(p,plugin.setCpPlaceholders(p,cf.getString("hasvalue.value"))));
String compare = ChatColor.stripColor(plugin.papi(p,plugin.setCpPlaceholders(p,cf.getString("hasvalue.compare")))); String compare = ChatColor.stripColor(plugin.papi(p,plugin.setCpPlaceholders(p,cf.getString("hasvalue.compare"))));
if (compare.equals(value) == outputValue) { if (compare.equals(value) == outputValue) {
//onOpen being 3 means it is the editor panel.. hasvalue items cannot be included to avoid item breaking //onOpen being 3 means it is the editor panel.. hasvalue items cannot be included to avoid item breaking
@ -321,7 +321,7 @@ public class ItemCreation {
//if output is true, and values match it will be this item, vice versa //if output is true, and values match it will be this item, vice versa
outputValue = cf.getBoolean("hasvalue" + count + ".output"); outputValue = cf.getBoolean("hasvalue" + count + ".output");
} }
value = cf.getString("hasvalue" + count + ".value"); value = ChatColor.stripColor(plugin.papi(p,plugin.setCpPlaceholders(p,cf.getString("hasvalue" + count + ".value"))));
compare = ChatColor.stripColor(plugin.papi(p,plugin.setCpPlaceholders(p,cf.getString("hasvalue" + count + ".compare")))); compare = ChatColor.stripColor(plugin.papi(p,plugin.setCpPlaceholders(p,cf.getString("hasvalue" + count + ".compare"))));
if (compare.equals(value) == outputValue) { if (compare.equals(value) == outputValue) {
//onOpen being 3 means it is the editor panel.. hasvalue items cannot be included to avoid item breaking //onOpen being 3 means it is the editor panel.. hasvalue items cannot be included to avoid item breaking
@ -340,7 +340,7 @@ public class ItemCreation {
//if output is true, and values match it will be this item, vice versa //if output is true, and values match it will be this item, vice versa
outputValue = cf.getBoolean("hasgreater.output"); outputValue = cf.getBoolean("hasgreater.output");
} }
int value = cf.getInt("hasgreater.value"); int value = Integer.parseInt(ChatColor.stripColor(plugin.papi(p,plugin.setCpPlaceholders(p,cf.getString("hasgreater.value")))));
double compare = Double.parseDouble(ChatColor.stripColor(plugin.papi(p,plugin.setCpPlaceholders(p,cf.getString("hasgreater.compare"))))); double compare = Double.parseDouble(ChatColor.stripColor(plugin.papi(p,plugin.setCpPlaceholders(p,cf.getString("hasgreater.compare")))));
if ((compare >= value) == outputValue) { if ((compare >= value) == outputValue) {
//onOpen being 3 means it is the editor panel.. hasgreater items cannot be included to avoid item breaking //onOpen being 3 means it is the editor panel.. hasgreater items cannot be included to avoid item breaking
@ -356,7 +356,7 @@ public class ItemCreation {
//if output is true, and values match it will be this item, vice versa //if output is true, and values match it will be this item, vice versa
outputValue = cf.getBoolean("hasgreater" + count + ".output"); outputValue = cf.getBoolean("hasgreater" + count + ".output");
} }
value = cf.getInt("hasgreater" + count + ".value"); value = Integer.parseInt(ChatColor.stripColor(plugin.papi(p,plugin.setCpPlaceholders(p,cf.getString("hasgreater" + count + ".value")))));
compare = Double.parseDouble(ChatColor.stripColor(plugin.papi(p,plugin.setCpPlaceholders(p,cf.getString("hasgreater" + count + ".compare"))))); compare = Double.parseDouble(ChatColor.stripColor(plugin.papi(p,plugin.setCpPlaceholders(p,cf.getString("hasgreater" + count + ".compare")))));
if ((compare >= value) == outputValue) { if ((compare >= value) == outputValue) {
//onOpen being 3 means it is the editor panel.. hasgreater items cannot be included to avoid item breaking //onOpen being 3 means it is the editor panel.. hasgreater items cannot be included to avoid item breaking

View File

@ -155,10 +155,16 @@ public class OpenEditorGuis {
temp = new ItemStack(Material.IRON_DOOR, 1); temp = new ItemStack(Material.IRON_DOOR, 1);
lore.clear(); lore.clear();
lore.add(ChatColor.GRAY + "Custom command to open panel"); lore.add(ChatColor.GRAY + "Custom commands to open panel");
if (cf.contains("command")) { lore.add(ChatColor.GRAY + "- Left click to add command");
lore.add(ChatColor.WHITE + "----------------------------"); lore.add(ChatColor.GRAY + "- Right click to remove command");
lore.add(ChatColor.WHITE + cf.getString("command")); if (cf.contains("commands")) {
lore.add(ChatColor.WHITE + "-----------------------------");
int count = 1;
for (String tempLore : cf.getStringList("commands")) {
lore.add(ChatColor.WHITE + Integer.toString(count) + ") " + tempLore);
count += 1;
}
} }
plugin.setName(temp, ChatColor.WHITE + "Panel Command", lore, p,true, true); plugin.setName(temp, ChatColor.WHITE + "Panel Command", lore, p,true, true);
i.setItem(7, temp); i.setItem(7, temp);

View File

@ -1,6 +1,7 @@
package me.rockyhawk.commandpanels.commands; package me.rockyhawk.commandpanels.commands;
import me.rockyhawk.commandpanels.CommandPanels; import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.customcommands.Commandpanelcustom;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
@ -9,7 +10,6 @@ import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import java.io.File; import java.io.File;
import java.io.IOException;
public class Commandpanelsreload implements CommandExecutor { public class Commandpanelsreload implements CommandExecutor {
CommandPanels plugin; CommandPanels plugin;
@ -25,8 +25,10 @@ public class Commandpanelsreload implements CommandExecutor {
//empty //empty
} }
plugin.config = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder() + File.separator + "config.yml")); plugin.config = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder() + File.separator + "config.yml"));
//check for duplicates //check for duplicates
plugin.checkDuplicatePanel(sender); plugin.checkDuplicatePanel(sender);
tag = plugin.config.getString("config.format.tag") + " "; tag = plugin.config.getString("config.format.tag") + " ";
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.reload"))); sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.reload")));
return true; return true;

View File

@ -1,6 +1,7 @@
package me.rockyhawk.commandpanels.commands; package me.rockyhawk.commandpanels.customcommands;
import me.rockyhawk.commandpanels.CommandPanels; import me.rockyhawk.commandpanels.CommandPanels;
import org.bukkit.ChatColor;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -28,11 +29,23 @@ public class Commandpanelcustom implements Listener {
for(String[] panelName : plugin.panelNames){ for(String[] panelName : plugin.panelNames){
tempFile = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + plugin.panelFiles.get(Integer.parseInt(panelName[1])))).getConfigurationSection("panels." + panelName[0]); tempFile = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + plugin.panelFiles.get(Integer.parseInt(panelName[1])))).getConfigurationSection("panels." + panelName[0]);
if(tempFile.contains("commands")) {
List<String> panelCommands = tempFile.getStringList("commands");
if(panelCommands.contains(e.getMessage().replace("/",""))){
e.setCancelled(true);
plugin.openVoids.openCommandPanel(e.getPlayer(),e.getPlayer(),panelName[0],tempFile,false);
return;
}
}
//this will be deleted next update
if(tempFile.contains("command")) { if(tempFile.contains("command")) {
List<String> panelCommands = Arrays.asList(tempFile.getString("command").split("\\s")); List<String> panelCommands = Arrays.asList(tempFile.getString("command").split("\\s"));
if(panelCommands.contains(e.getMessage().replace("/",""))){ if(panelCommands.contains(e.getMessage().replace("/",""))){
e.setCancelled(true); e.setCancelled(true);
plugin.getServer().getConsoleSender().sendMessage(ChatColor.RED + "[CommandPanels] Using command: for custom commands will soon be deprecated. Please use commands: as shown in the wiki instead!");
plugin.openVoids.openCommandPanel(e.getPlayer(),e.getPlayer(),panelName[0],tempFile,false); plugin.openVoids.openCommandPanel(e.getPlayer(),e.getPlayer(),panelName[0],tempFile,false);
return;
} }
} }
} }

View File

@ -122,10 +122,9 @@ 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(Objects.requireNonNull(cf.getConfigurationSection("panels")).getKeys(false).size() != 1){ if(Objects.requireNonNull(cfile.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); if(savePanelFile(null, cfile, panelName, panelFile)){
if(savePanelFile(cf, cfile, panelName, panelFile)){
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Deleted Panel!")); p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Deleted Panel!"));
}else{ }else{
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Could Not Delete Panel!")); p.sendMessage(plugin.papi( tag + ChatColor.RED + "Could Not Delete Panel!"));
@ -182,9 +181,9 @@ public class EditorUserInput implements Listener {
p.sendMessage(plugin.papi(tag + ChatColor.RED + e.getMessage() + " is in use from another panel!")); p.sendMessage(plugin.papi(tag + ChatColor.RED + e.getMessage() + " is in use from another panel!"));
break; break;
} }
cf.set("panels." + e.getMessage(), cf.get("panels." + panelName)); cfile.set("panels." + e.getMessage(), cfile.get("panels." + panelName));
cf.set("panels." + panelName, null); //I have put null there instead of cf because that will replicate cp = null to delete it
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(null, cfile, panelName, panelFile);
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Set new Name to " + e.getMessage())); p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Set new Name to " + e.getMessage()));
break; break;
case "panel.empty": case "panel.empty":
@ -222,16 +221,37 @@ public class EditorUserInput implements Listener {
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Sound when opening is now " + tempSound)); p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Sound when opening is now " + tempSound));
break; break;
case "panel.command": case "panel.commands.add":
if(e.getMessage().trim().equalsIgnoreCase("remove")){ List<String> commandsAdd = new ArrayList<>();
cf.set("command", null); if(cf.contains("commands")){
savePanelFile(cf, cfile, panelName, panelFile); commandsAdd = cf.getStringList("commands");
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Custom commands have been removed.")); }
commandsAdd.add(e.getMessage());
cf.set("commands", commandsAdd);
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Added new command: " + e.getMessage()));
break;
case "panel.commands.remove":
List<String> commandsRemove;
if(cf.contains("commands")){
commandsRemove = cf.getStringList("commands");
}else{
p.sendMessage(plugin.papi( tag + ChatColor.RED + "No commands found to remove!"));
break; break;
} }
cf.set("command", e.getMessage()); try {
commandsRemove.remove(Integer.parseInt(e.getMessage())-1);
}catch (Exception ex){
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Could not find command!"));
break;
}
if(commandsRemove.size() == 0){
cf.set("commands", null);
}else{
cf.set("commands", commandsRemove);
}
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Set new custom commands to " + ChatColor.WHITE + "/" + e.getMessage().trim().replace(" ", " /"))); p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Removed command line " + e.getMessage()));
break; break;
case "panel.commands-on-open.add": case "panel.commands-on-open.add":
List<String> commandsOnOpenAdd = new ArrayList<>(); List<String> commandsOnOpenAdd = new ArrayList<>();
@ -386,7 +406,7 @@ public class EditorUserInput implements Listener {
everything else everything else
*/ */
String tag = plugin.config.getString("config.format.tag") + " "; String tag = plugin.config.getString("config.format.tag") + " ";
String itemSlot = section.split("\\:")[1]; String itemSlot = section.split(":")[1];
String sectionChange = section.replace("item:" + itemSlot + ":",""); String sectionChange = section.replace("item:" + itemSlot + ":","");
switch (sectionChange) { switch (sectionChange) {
case "name": case "name":
@ -571,10 +591,10 @@ public class EditorUserInput implements Listener {
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Removed Section " + ChatColor.WHITE + playerMessage)); p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Removed Section " + ChatColor.WHITE + playerMessage));
break; break;
case "change": case "change":
cf.set("item." + itemSection + "." + playerMessage.split("\\:")[0], playerMessage.split("\\:")[1]); cf.set("item." + itemSection + "." + playerMessage.split(":")[0], playerMessage.split(":")[1]);
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
plugin.reloadPanelFiles(); plugin.reloadPanelFiles();
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Set " + playerMessage.split("\\:")[0] + " to " + ChatColor.WHITE + playerMessage.split("\\:")[1])); p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Set " + playerMessage.split(":")[0] + " to " + ChatColor.WHITE + playerMessage.split(":")[1]));
break; break;
} }
} }

View File

@ -393,8 +393,13 @@ public class EditorUtils implements Listener {
p.closeInventory(); p.closeInventory();
} }
if(e.getSlot() == 7){ if(e.getSlot() == 7){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.command"}); if(e.getClick().isLeftClick()) {
p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Enter New Command")); plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.commands.add"});
p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Enter New Command"));
}else{
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.commands.remove"});
p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Enter Command to remove (must be an integer)"));
}
p.closeInventory(); p.closeInventory();
} }
if(e.getSlot() == 21){ if(e.getSlot() == 21){
@ -419,7 +424,7 @@ public class EditorUtils implements Listener {
p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Enter New Command")); p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Enter New Command"));
}else{ }else{
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.commands-on-open.remove"}); plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.commands-on-open.remove"});
p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Enter Command line to remove (must be an integer)")); p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Enter Command to remove (must be an integer)"));
} }
p.closeInventory(); p.closeInventory();
} }

View File

@ -339,7 +339,7 @@ public class UtilsOpenWithItem implements Listener {
return; return;
} }
//cancel everything if holding item (item frames eg) //cancel everything if holding item (item frames eg)
Player p = (Player)e.getPlayer(); Player p = e.getPlayer();
try { try {
if (plugin.panelFiles == null) { if (plugin.panelFiles == null) {
return; return;
@ -347,37 +347,33 @@ public class UtilsOpenWithItem implements Listener {
}catch(Exception b){ }catch(Exception b){
return; return;
} }
YamlConfiguration cf; //this is the file to use for any panel.* requests
String tpanels; //tpanels is the temp to check through the files
ItemStack clicked = e.getPlayer().getInventory().getItemInMainHand(); ItemStack clicked = e.getPlayer().getInventory().getItemInMainHand();
for(String fileName : plugin.panelFiles) { //will loop through all the files in folder String tempName;
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName)); ConfigurationSection tempFile;
String key; for(String[] panelName : plugin.panelNames){
tpanels = ""; tempName = panelName[0];
if(!plugin.checkPanels(temp)){ tempFile = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + plugin.panelFiles.get(Integer.parseInt(panelName[1])))).getConfigurationSection("panels." + tempName);
continue;
} if (tempFile.contains("open-with-item")) {
for (Iterator var10 = Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") { if (clicked.getType() != Material.AIR) {
key = (String) var10.next(); //if loop has material first to stop 1.12.2 from spitting errors
if (temp.contains("panels." + key + ".open-with-item")) { //try and catch loop to stop errors with the same material type but different name
if (clicked.getType() != Material.AIR) { try {
//if loop has material first to stop 1.12.2 from spitting errors if (clicked.getType() == new ItemStack(Objects.requireNonNull(Material.matchMaterial(Objects.requireNonNull(tempFile.getString("open-with-item.material")))), 1).getType()) {
//try and catch loop to stop errors with the same material type but different name if ((plugin.papi( Objects.requireNonNull(clicked.getItemMeta()).getDisplayName()).equals(plugin.papi( Objects.requireNonNull(tempFile.getString("open-with-item.name")))))) {
try { //cancel the click item event
if (clicked.getType() == new ItemStack(Objects.requireNonNull(Material.matchMaterial(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.material")))), 1).getType()) { if (tempFile.contains("open-with-item.stationary")) {
if ((plugin.papi( Objects.requireNonNull(clicked.getItemMeta()).getDisplayName()).equals(plugin.papi( Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.name")))))) { if (p.getInventory().getHeldItemSlot() == Integer.parseInt(Objects.requireNonNull(tempFile.getString("open-with-item.stationary")))) {
//cancel the click item event e.setCancelled(true);
if (temp.contains("panels." + key + ".open-with-item.stationary")) { p.updateInventory();
if (p.getInventory().getHeldItemSlot() == Integer.parseInt(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.stationary")))) { plugin.openVoids.openCommandPanel(p,p,tempName,tempFile,false);
e.setCancelled(true);
}
} }
return;
} }
return;
} }
} catch (NullPointerException | IllegalArgumentException n) {
plugin.debug(n);
} }
} catch (NullPointerException | IllegalArgumentException n) {
plugin.debug(n);
} }
} }
} }