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
ingame-editor: true
hotbar-items: true
custom-commands: true
refresh-delay: 4
server-ping-timeout: 10
stop-sound: true

View File

@ -9,7 +9,8 @@ panels:
panelType: default
rows: 4
title: '&6[&bExample Panel&6]&f Welcome!'
command: example
commands:
- "example"
sound-on-open: BLOCK_NOTE_BLOCK_CHIME
empty: BLACK_STAINED_GLASS_PANE
disabled-worlds:

View File

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

View File

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

View File

@ -14,6 +14,7 @@ import me.realized.tokenmanager.api.TokenManager;
import me.rockyhawk.commandpanels.classresources.*;
import me.rockyhawk.commandpanels.commands.*;
import me.rockyhawk.commandpanels.completetabs.CpTabComplete;
import me.rockyhawk.commandpanels.customcommands.Commandpanelcustom;
import me.rockyhawk.commandpanels.generatepanels.Commandpanelsgenerate;
import me.rockyhawk.commandpanels.generatepanels.GenUtils;
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 UtilsPanelsLoader(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);
//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);
}
//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(Objects.requireNonNull(config.getString("config.hotbar-items")).equalsIgnoreCase("true")){
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
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"))));
if (compare.equals(value) == outputValue) {
//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
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"))));
if (compare.equals(value) == outputValue) {
//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
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")))));
if ((compare >= value) == outputValue) {
//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
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")))));
if ((compare >= value) == outputValue) {
//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);
lore.clear();
lore.add(ChatColor.GRAY + "Custom command to open panel");
if (cf.contains("command")) {
lore.add(ChatColor.WHITE + "----------------------------");
lore.add(ChatColor.WHITE + cf.getString("command"));
lore.add(ChatColor.GRAY + "Custom commands to open panel");
lore.add(ChatColor.GRAY + "- Left click to add command");
lore.add(ChatColor.GRAY + "- Right click to remove 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);
i.setItem(7, temp);

View File

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

View File

@ -1,6 +1,7 @@
package me.rockyhawk.commandpanels.commands;
package me.rockyhawk.commandpanels.customcommands;
import me.rockyhawk.commandpanels.CommandPanels;
import org.bukkit.ChatColor;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.event.EventHandler;
@ -28,11 +29,23 @@ public class Commandpanelcustom implements Listener {
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]);
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")) {
List<String> panelCommands = Arrays.asList(tempFile.getString("command").split("\\s"));
if(panelCommands.contains(e.getMessage().replace("/",""))){
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);
return;
}
}
}

View File

@ -122,10 +122,9 @@ public class EditorUserInput implements Listener {
switch (section) {
case "panel.delete":
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
cf.set("panels." + panelName, null);
if(savePanelFile(cf, cfile, panelName, panelFile)){
if(savePanelFile(null, cfile, panelName, panelFile)){
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Deleted Panel!"));
}else{
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!"));
break;
}
cf.set("panels." + e.getMessage(), cf.get("panels." + panelName));
cf.set("panels." + panelName, null);
savePanelFile(cf, cfile, panelName, panelFile);
cfile.set("panels." + e.getMessage(), cfile.get("panels." + panelName));
//I have put null there instead of cf because that will replicate cp = null to delete it
savePanelFile(null, cfile, panelName, panelFile);
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Set new Name to " + e.getMessage()));
break;
case "panel.empty":
@ -222,16 +221,37 @@ public class EditorUserInput implements Listener {
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Sound when opening is now " + tempSound));
break;
case "panel.command":
if(e.getMessage().trim().equalsIgnoreCase("remove")){
cf.set("command", null);
case "panel.commands.add":
List<String> commandsAdd = new ArrayList<>();
if(cf.contains("commands")){
commandsAdd = cf.getStringList("commands");
}
commandsAdd.add(e.getMessage());
cf.set("commands", commandsAdd);
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Custom commands have been removed."));
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;
}
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);
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;
case "panel.commands-on-open.add":
List<String> commandsOnOpenAdd = new ArrayList<>();
@ -386,7 +406,7 @@ public class EditorUserInput implements Listener {
everything else
*/
String tag = plugin.config.getString("config.format.tag") + " ";
String itemSlot = section.split("\\:")[1];
String itemSlot = section.split(":")[1];
String sectionChange = section.replace("item:" + itemSlot + ":","");
switch (sectionChange) {
case "name":
@ -571,10 +591,10 @@ public class EditorUserInput implements Listener {
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Removed Section " + ChatColor.WHITE + playerMessage));
break;
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);
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;
}
}

View File

@ -393,8 +393,13 @@ public class EditorUtils implements Listener {
p.closeInventory();
}
if(e.getSlot() == 7){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.command"});
if(e.getClick().isLeftClick()) {
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();
}
if(e.getSlot() == 21){
@ -419,7 +424,7 @@ public class EditorUtils implements Listener {
p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Enter New Command"));
}else{
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();
}

View File

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