diff --git a/.idea/libraries/PlaceholderAPI_2_10_8.xml b/.idea/libraries/PlaceholderAPI_2_10_8.xml
index 8dadc91..7d8b81d 100644
--- a/.idea/libraries/PlaceholderAPI_2_10_8.xml
+++ b/.idea/libraries/PlaceholderAPI_2_10_8.xml
@@ -1,7 +1,7 @@
-
+
diff --git a/Command Panels.iml b/Command Panels.iml
index ee411f3..9871615 100644
--- a/Command Panels.iml
+++ b/Command Panels.iml
@@ -12,8 +12,8 @@
-
+
\ No newline at end of file
diff --git a/resource/exampleLegacy.yml b/resource/exampleLegacy.yml
index 53a68f5..984a6e5 100644
--- a/resource/exampleLegacy.yml
+++ b/resource/exampleLegacy.yml
@@ -9,7 +9,6 @@ panels:
rows: 4
title: '&6[&bExample Panel&6]&f Welcome!'
command: example
- sound-on-open: NOTE_PLING
empty: STAINED_GLASS_PANE
emptyID: 15
disabled-worlds:
diff --git a/resource/plugin.yml b/resource/plugin.yml
index bf00e01..15ba477 100644
--- a/resource/plugin.yml
+++ b/resource/plugin.yml
@@ -1,4 +1,4 @@
-version: 3.11.2
+version: 3.12.0
main: me.rockyhawk.commandpanels.CommandPanels
name: CommandPanels
author: RockyHawk
diff --git a/src/me/rockyhawk/commandpanels/classresources/ItemCreation.java b/src/me/rockyhawk/commandpanels/classresources/ItemCreation.java
index b3afc89..7a1594c 100644
--- a/src/me/rockyhawk/commandpanels/classresources/ItemCreation.java
+++ b/src/me/rockyhawk/commandpanels/classresources/ItemCreation.java
@@ -3,9 +3,13 @@ package me.rockyhawk.commandpanels.classresources;
import me.arcaniax.hdb.api.HeadDatabaseAPI;
import me.rockyhawk.commandpanels.CommandPanels;
import org.bukkit.*;
+import org.bukkit.block.banner.Pattern;
+import org.bukkit.block.banner.PatternType;
import org.bukkit.configuration.ConfigurationSection;
+import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
+import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.*;
@@ -17,6 +21,8 @@ import org.bukkit.potion.PotionType;
import javax.swing.*;
import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Objects;
import java.util.UUID;
@@ -195,6 +201,20 @@ public class ItemCreation {
customMeta.setCustomModelData(Integer.parseInt(Objects.requireNonNull(itemSection.getString("customdata"))));
s.setItemMeta(customMeta);
}
+ try {
+ if (itemSection.contains("banner")) {
+ BannerMeta bannerMeta = (BannerMeta) s.getItemMeta();
+ List patterns = new ArrayList<>(); //Load patterns in order top to bottom
+ for (String temp : itemSection.getStringList("banner")) {
+ String[] dyePattern = temp.split(",");
+ patterns.add(new Pattern(DyeColor.valueOf(dyePattern[0]), PatternType.valueOf(dyePattern[1]))); //load patterns in config: RED:STRIPE_TOP
+ }
+ bannerMeta.setPatterns(patterns);
+ s.setItemMeta(bannerMeta);
+ }
+ }catch(Exception ignore){
+ //not a banner or error
+ }
if (itemSection.contains("leatherarmor")) {
//if the item is leather armor, change the colour to this
try {
@@ -375,4 +395,72 @@ public class ItemCreation {
}
return "";
}
+
+ @SuppressWarnings("deprecation")
+ public YamlConfiguration generatePanelFile(String panelName, Inventory inv, YamlConfiguration file){
+ ItemStack cont;
+ for(int i = 0; inv.getSize() > i; i++){
+ cont = inv.getItem(i);
+ //repeat through all the items in the editor
+ try{
+ //make the item here
+ if(cont == null){
+ //remove if items have been removed
+ if(file.contains("panels." + panelName + ".item." + i)){
+ file.set("panels." + panelName + ".item." + i, null);
+ continue;
+ }
+ }
+ if(plugin.legacy.isLegacy()){
+ if (cont.getDurability() != 0 && !cont.getType().toString().equals("SKULL_ITEM")) {
+ file.set("panels." + panelName + ".item." + i + ".ID", cont.getDurability());
+ }
+ }
+ if(file.contains("panels." + panelName + ".item." + i + ".material")){
+ if(Objects.requireNonNull(file.getString("panels." + panelName + ".item." + i + ".material")).contains("%") || Objects.requireNonNull(file.getString("panels." + panelName + ".item." + i + ".material")).contains("=")){
+ if(!plugin.getHeads.ifSkullOrHead(cont.getType().toString())){
+ file.set("panels." + panelName + ".item." + i + ".material", cont.getType().toString());
+ }
+ }else{
+ file.set("panels." + panelName + ".item." + i + ".material", cont.getType().toString());
+ }
+ }else{
+ file.set("panels." + panelName + ".item." + i + ".material", cont.getType().toString());
+ }
+ if(plugin.getHeads.ifSkullOrHead(cont.getType().toString())){
+ SkullMeta meta = (SkullMeta) cont.getItemMeta();
+ //disable for legacy as is broken
+ if(!plugin.legacy.isLegacy()) {
+ if (plugin.customHeads.getHeadBase64(cont) != null) {
+ //inject base64 here
+ file.set("panels." + panelName + ".item." + i + ".material", "cps= " + plugin.customHeads.getHeadBase64(cont));
+ } else if (meta.hasOwner()) {
+ //check for skull owner
+ file.set("panels." + panelName + ".item." + i + ".material", "cps= " + meta.getOwner());
+ }
+ }
+ }
+ try {
+ BannerMeta bannerMeta = (BannerMeta) cont.getItemMeta();
+ List dyePattern = new ArrayList<>();
+ for(Pattern pattern : bannerMeta.getPatterns()) { //sublist to skip first value
+ dyePattern.add(pattern.getColor().toString() + "," + pattern.getPattern().toString());
+ }
+ file.set("panels." + panelName + ".item." + i + ".banner", dyePattern);
+ }catch(Exception ignore){
+ //not a banner
+ file.set("panels." + panelName + ".item." + i + ".banner", null);
+ }
+ file.set("panels." + panelName + ".item." + i + ".stack", cont.getAmount());
+ if(!cont.getEnchantments().isEmpty()){
+ file.set("panels." + panelName + ".item." + i + ".enchanted", "true");
+ }
+ file.set("panels." + panelName + ".item." + i + ".name", Objects.requireNonNull(cont.getItemMeta()).getDisplayName());
+ file.set("panels." + panelName + ".item." + i + ".lore", Objects.requireNonNull(cont.getItemMeta()).getLore());
+ }catch(Exception n){
+ //skip over an item that spits an error
+ }
+ }
+ return file;
+ }
}
diff --git a/src/me/rockyhawk/commandpanels/classresources/OpenEditorGuis.java b/src/me/rockyhawk/commandpanels/classresources/OpenEditorGuis.java
index a115d5f..d644922 100644
--- a/src/me/rockyhawk/commandpanels/classresources/OpenEditorGuis.java
+++ b/src/me/rockyhawk/commandpanels/classresources/OpenEditorGuis.java
@@ -1,19 +1,14 @@
package me.rockyhawk.commandpanels.classresources;
-import me.arcaniax.hdb.api.HeadDatabaseAPI;
import me.rockyhawk.commandpanels.CommandPanels;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
-import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
-import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
-import org.bukkit.inventory.meta.ItemMeta;
-import org.bukkit.inventory.meta.SkullMeta;
import java.io.File;
import java.util.ArrayList;
@@ -181,6 +176,22 @@ public class OpenEditorGuis {
plugin.setName(temp, ChatColor.WHITE + "Panel Rows", lore, p,true, true);
i.setItem(23, temp);
+ temp = new ItemStack(Material.STONE, 1);
+ lore.clear();
+ lore.add(ChatColor.GRAY + "Worlds that cannot access the panel");
+ lore.add(ChatColor.GRAY + "- Left click to add world");
+ lore.add(ChatColor.GRAY + "- Right click to remove world");
+ if (cf.contains("panels." + panelName + ".disabled-worlds")) {
+ lore.add(ChatColor.WHITE + "-----------------------------");
+ int count = 1;
+ for (String tempLore : cf.getStringList("panels." + panelName + ".disabled-worlds")) {
+ lore.add(ChatColor.WHITE + Integer.toString(count) + ") " + tempLore);
+ count += 1;
+ }
+ }
+ plugin.setName(temp, ChatColor.WHITE + "Disabled Worlds", lore, p,true, true);
+ i.setItem(25, temp);
+
temp = new ItemStack(Material.GLASS, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Fill empty slots with an item");
@@ -304,7 +315,8 @@ public class OpenEditorGuis {
p.openInventory(i);
}
- public void openItemSettings(Player p, String panelName, YamlConfiguration cf, int itemNumber) {
+ //section is similar to hassection, but with the slot eg, 1.hasperm.hasvalue
+ public void openItemSettings(Player p, String panelName, ConfigurationSection cf, String section) {
Inventory i = Bukkit.createInventory(null, 36, ChatColor.stripColor("Item Settings: " + panelName));
List lore = new ArrayList();
ItemStack temp;
@@ -318,10 +330,10 @@ public class OpenEditorGuis {
//make all the items
temp = new ItemStack(Material.NAME_TAG, 1);
lore.add(ChatColor.GRAY + "Display name of the item in the Panel");
- if (cf.contains("panels." + panelName + ".item." + itemNumber + ".name")) {
- if (!Objects.equals(cf.getString("panels." + panelName + ".item." + itemNumber + ".name"), "")) {
+ if (cf.contains("name")) {
+ if (!Objects.equals(cf.getString("name"), "")) {
lore.add(ChatColor.WHITE + "--------------------------------");
- lore.add(ChatColor.WHITE + cf.getString("panels." + panelName + ".item." + itemNumber + ".name"));
+ lore.add(ChatColor.WHITE + cf.getString("name"));
}
}
plugin.setName(temp, ChatColor.WHITE + "Item Name", lore, p,true, true);
@@ -332,10 +344,10 @@ public class OpenEditorGuis {
lore.add(ChatColor.GRAY + "Execute commands when item is clicked");
lore.add(ChatColor.GRAY + "- Left click to add command");
lore.add(ChatColor.GRAY + "- Right click to remove command");
- if (cf.contains("panels." + panelName + ".item." + itemNumber + ".commands")) {
+ if (cf.contains("commands")) {
lore.add(ChatColor.WHITE + "-----------------------------");
int count = 1;
- for (String tempLore : cf.getStringList("panels." + panelName + ".item." + itemNumber + ".commands")) {
+ for (String tempLore : cf.getStringList("commands")) {
lore.add(ChatColor.WHITE + Integer.toString(count) + ") " + tempLore);
count += 1;
}
@@ -346,10 +358,10 @@ public class OpenEditorGuis {
temp = new ItemStack(Material.ENCHANTED_BOOK, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Display enchantment of the item in the Panel");
- if (cf.contains("panels." + panelName + ".item." + itemNumber + ".enchanted")) {
- if (!Objects.equals(cf.getString("panels." + panelName + ".item." + itemNumber + ".name"), "")) {
+ if (cf.contains("enchanted")) {
+ if (!Objects.equals(cf.getString("name"), "")) {
lore.add(ChatColor.WHITE + "--------------------------------");
- lore.add(ChatColor.WHITE + cf.getString("panels." + panelName + ".item." + itemNumber + ".enchanted"));
+ lore.add(ChatColor.WHITE + cf.getString("enchanted"));
}
} else {
lore.add(ChatColor.WHITE + "--------------------------------");
@@ -361,10 +373,10 @@ public class OpenEditorGuis {
temp = new ItemStack(Material.POTION, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Display potion effect of the item in the Panel");
- if (cf.contains("panels." + panelName + ".item." + itemNumber + ".potion")) {
- if (!Objects.equals(cf.getString("panels." + panelName + ".item." + itemNumber + ".potion"), "")) {
+ if (cf.contains("potion")) {
+ if (!Objects.equals(cf.getString("potion"), "")) {
lore.add(ChatColor.WHITE + "--------------------------------");
- lore.add(ChatColor.WHITE + cf.getString("panels." + panelName + ".item." + itemNumber + ".potion"));
+ lore.add(ChatColor.WHITE + cf.getString("potion"));
}
}
plugin.setName(temp, ChatColor.WHITE + "Item Potion Effect", lore, p,true, true);
@@ -375,10 +387,10 @@ public class OpenEditorGuis {
lore.add(ChatColor.GRAY + "Display a lore under the item name");
lore.add(ChatColor.GRAY + "- Left click to add lore line");
lore.add(ChatColor.GRAY + "- Right click to remove lore line");
- if (cf.contains("panels." + panelName + ".item." + itemNumber + ".lore")) {
+ if (cf.contains("lore")) {
lore.add(ChatColor.WHITE + "-----------------------------");
int count = 1;
- for (String tempLore : cf.getStringList("panels." + panelName + ".item." + itemNumber + ".lore")) {
+ for (String tempLore : cf.getStringList("lore")) {
lore.add(ChatColor.WHITE + Integer.toString(count) + ") " + tempLore);
count += 1;
}
@@ -389,14 +401,14 @@ public class OpenEditorGuis {
temp = new ItemStack(Material.ITEM_FRAME, 2);
lore.clear();
lore.add(ChatColor.GRAY + "How many of the item will be stacked");
- if (cf.contains("panels." + panelName + ".item." + itemNumber + ".stack")) {
- if (!Objects.equals(cf.getString("panels." + panelName + ".item." + itemNumber + ".stack"), "")) {
+ if (cf.contains("stack")) {
+ if (!Objects.equals(cf.getString("stack"), "")) {
try {
- temp.setAmount(Integer.parseInt(Objects.requireNonNull(cf.getString("panels." + panelName + ".item." + itemNumber + ".stack"))));
+ temp.setAmount(Integer.parseInt(Objects.requireNonNull(cf.getString("stack"))));
} catch (Exception ignored) {
}
lore.add(ChatColor.WHITE + "--------------------------------");
- lore.add(ChatColor.WHITE + cf.getString("panels." + panelName + ".item." + itemNumber + ".stack"));
+ lore.add(ChatColor.WHITE + cf.getString("stack"));
}
}
plugin.setName(temp, ChatColor.WHITE + "Item Stack Size", lore, p, true, true);
@@ -406,24 +418,38 @@ public class OpenEditorGuis {
temp = new ItemStack(Material.PAINTING, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Add Custom Model Data here");
- if (cf.contains("panels." + panelName + ".item." + itemNumber + ".customdata")) {
- if (!Objects.equals(cf.getString("panels." + panelName + ".item." + itemNumber + ".customdata"), "")) {
+ if (cf.contains("customdata")) {
+ if (!Objects.equals(cf.getString("customdata"), "")) {
lore.add(ChatColor.WHITE + "--------------------------------");
- lore.add(ChatColor.WHITE + cf.getString("panels." + panelName + ".item." + itemNumber + ".customdata"));
+ lore.add(ChatColor.WHITE + cf.getString("customdata"));
}
}
plugin.setName(temp, ChatColor.WHITE + "Custom Model Data", lore, p, true, true);
i.setItem(23, temp);
}
+ /*show the compass that opens the viewer for the sections..
+ it will only show the sections immidiatly under the other, so
+ if there is a hasperm inside another hasperm, it will not appear
+ until the other hasperm is opened.
+ */
+ temp = new ItemStack(Material.COMPASS, 1);
+ lore.clear();
+ lore.add(ChatColor.GRAY + "View the items different");
+ lore.add(ChatColor.GRAY + "Sections and add complex values.");
+ lore.add(ChatColor.WHITE + "--------------------------------");
+ lore.add(ChatColor.WHITE + section);
+ plugin.setName(temp, ChatColor.WHITE + "Item Sections", lore, p, true, true);
+ i.setItem(31, temp);
+
temp = new ItemStack(Material.LEATHER_HELMET, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Choose a colour for the armor");
lore.add(ChatColor.GRAY + "use r,g,b or a spigot API color");
- if (cf.contains("panels." + panelName + ".item." + itemNumber + ".leatherarmor")) {
- if (!Objects.equals(cf.getString("panels." + panelName + ".item." + itemNumber + ".leatherarmor"), "")) {
+ if (cf.contains("leatherarmor")) {
+ if (!Objects.equals(cf.getString("leatherarmor"), "")) {
lore.add(ChatColor.WHITE + "--------------------------------");
- lore.add(ChatColor.WHITE + cf.getString("panels." + panelName + ".item." + itemNumber + ".leatherarmor"));
+ lore.add(ChatColor.WHITE + cf.getString("leatherarmor"));
}
}
plugin.setName(temp, ChatColor.WHITE + "Leather Armor Colour", lore, p, true, true);
@@ -433,13 +459,73 @@ public class OpenEditorGuis {
plugin.setName(temp, ChatColor.RED + "Back", null, p, true, true);
i.setItem(27, temp);
- temp = plugin.itemCreate.makeItemFromConfig(cf.getConfigurationSection("panels." + panelName + ".item." + itemNumber),p,false,false);
+ temp = plugin.itemCreate.makeItemFromConfig(cf,p,false,false);
lore.clear();
lore.add(ChatColor.GRAY + "Click to set custom material");
lore.add(ChatColor.GRAY + "typically for custom heads");
- plugin.setName(temp, ChatColor.WHITE + "Item Slot " + itemNumber + " Preview", lore, p, true, true);
+ plugin.setName(temp, ChatColor.WHITE + "Item Section " + section + " Preview", lore, p, true, true);
i.setItem(35, temp);
p.openInventory(i);
}
+
+ //section is similar to hassection, but with the slot eg, 1.hasperm.hasvalue
+ public void openItemSections(Player p, String panelName, ConfigurationSection cf, String itemSection) {
+ Inventory i = Bukkit.createInventory(null, 45, ChatColor.stripColor("Item Sections: " + panelName));
+ ItemStack temp;
+ int slot = 0;
+ for(String section : cf.getKeys(false)){
+ //get list of item sections
+ if(slot > 35){
+ break;
+ }
+ if(section.contains("hasperm") || section.contains("hasvalue") || section.contains("hasgreater")){
+ List lore = new ArrayList<>();
+ lore.add(ChatColor.GRAY + "Left click to open item");
+ lore.add(ChatColor.GRAY + "Right click to change below settings");
+ if(cf.contains(section + ".output")) {
+ lore.add(ChatColor.WHITE + "Output: " + ChatColor.GRAY + cf.getString(section + ".output"));
+ }else{
+ lore.add(ChatColor.WHITE + "Output: " + ChatColor.GRAY + "true");
+ }
+ if(cf.contains(section + ".perm")) {
+ lore.add(ChatColor.WHITE + "Perm: " + ChatColor.GRAY + cf.getString(section + ".perm"));
+ }
+ if(cf.contains(section + ".value")) {
+ lore.add(ChatColor.WHITE + "Value: " + ChatColor.GRAY + cf.getString(section + ".value"));
+ }
+ if(cf.contains(section + ".compare")) {
+ lore.add(ChatColor.WHITE + "Compare: " + ChatColor.GRAY + cf.getString(section + ".compare"));
+ }
+
+ temp = plugin.itemCreate.makeItemFromConfig(cf.getConfigurationSection(section),p,false,false);
+ plugin.setName(temp, ChatColor.AQUA + section, lore, p,false, true);
+ i.setItem(slot, temp);
+ slot++;
+ }
+ }
+
+ temp = new ItemStack(Material.REDSTONE, 1);
+ plugin.setName(temp, ChatColor.WHITE + "Remove Section", null, p, true, true);
+ i.setItem(38, temp);
+
+ temp = new ItemStack(Material.SLIME_BALL, 1);
+ plugin.setName(temp, ChatColor.WHITE + "Add Section", null, p, true, true);
+ i.setItem(42, temp);
+
+ temp = new ItemStack(Material.BARRIER, 1);
+ plugin.setName(temp, ChatColor.RED + "Back", null, p, true, true);
+ i.setItem(36, temp);
+
+ temp = new ItemStack(Material.BOOK, 1);
+ List lore = new ArrayList<>();
+ lore.add(ChatColor.GRAY + "Section Types:");
+ lore.add(ChatColor.GRAY + "- hasperm");
+ lore.add(ChatColor.GRAY + "- hasvalue");
+ lore.add(ChatColor.GRAY + "- hasgreater");
+ plugin.setName(temp, ChatColor.WHITE + "Item Section " + itemSection, lore, p, true, true);
+ i.setItem(44, temp);
+
+ p.openInventory(i);
+ }
}
diff --git a/src/me/rockyhawk/commandpanels/commands/Commandpanelsreload.java b/src/me/rockyhawk/commandpanels/commands/Commandpanelsreload.java
index 4863520..60089ad 100644
--- a/src/me/rockyhawk/commandpanels/commands/Commandpanelsreload.java
+++ b/src/me/rockyhawk/commandpanels/commands/Commandpanelsreload.java
@@ -21,10 +21,8 @@ public class Commandpanelsreload implements CommandExecutor {
if (label.equalsIgnoreCase("cpr") || label.equalsIgnoreCase("commandpanelreload") || label.equalsIgnoreCase("cpanelr")) {
if (sender.hasPermission("commandpanel.reload")) {
plugin.reloadPanelFiles();
- try {
- YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder() + File.separator + "temp.yml")).save(new File(plugin.getDataFolder() + File.separator + "temp.yml"));
- } catch (IOException e) {
- //skip clearing temp
+ if(new File(plugin.getDataFolder() + File.separator + "temp.yml").delete()){
+ //empty
}
plugin.config = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder() + File.separator + "config.yml"));
tag = plugin.config.getString("config.format.tag") + " ";
diff --git a/src/me/rockyhawk/commandpanels/generatepanels/GenUtils.java b/src/me/rockyhawk/commandpanels/generatepanels/GenUtils.java
index f799d2f..0f268f0 100644
--- a/src/me/rockyhawk/commandpanels/generatepanels/GenUtils.java
+++ b/src/me/rockyhawk/commandpanels/generatepanels/GenUtils.java
@@ -3,7 +3,6 @@ package me.rockyhawk.commandpanels.generatepanels;
import me.rockyhawk.commandpanels.CommandPanels;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
-import org.bukkit.Material;
import org.bukkit.block.Chest;
import org.bukkit.block.DoubleChest;
import org.bukkit.configuration.file.YamlConfiguration;
@@ -15,8 +14,6 @@ import org.bukkit.event.inventory.*;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
-import org.bukkit.inventory.meta.PotionMeta;
-import org.bukkit.inventory.meta.SkullMeta;
import java.io.File;
import java.io.IOException;
@@ -94,59 +91,19 @@ public class GenUtils implements Listener {
}
File folder = new File(plugin.getDataFolder() + File.separator + "panels");
file = YamlConfiguration.loadConfiguration(new File(folder + File.separator + date + ".yml"));
- file.addDefault("panels." + date + ".perm", "default");
- file.addDefault("panels." + date + ".panelType", "default");
- file.addDefault("panels." + date + ".rows", inv.getSize()/9);
- file.addDefault("panels." + date + ".title", "&8Generated " + date);
+ file.set("panels." + date + ".perm", "default");
+ file.set("panels." + date + ".panelType", "default");
+ file.set("panels." + date + ".rows", inv.getSize()/9);
+ file.set("panels." + date + ".title", "&8Generated " + date);
file.addDefault("panels." + date + ".command", date);
if(plugin.legacy.isLegacy()) {
- file.addDefault("panels." + date + ".empty", "STAINED_GLASS_PANE");
- file.addDefault("panels." + date + ".emptyID", "15");
+ file.set("panels." + date + ".empty", "STAINED_GLASS_PANE");
+ file.set("panels." + date + ".emptyID", "15");
}else{
- file.addDefault("panels." + date + ".empty", "BLACK_STAINED_GLASS_PANE");
+ file.set("panels." + date + ".empty", "BLACK_STAINED_GLASS_PANE");
}
- for(int i = 0; cont.length > i; i++){
- //repeat through all the items in the chest
- try{
- //make the item here
- if(plugin.getHeads.ifSkullOrHead(cont[i].getType().toString())){
- SkullMeta meta = (SkullMeta) cont[i].getItemMeta();
- if(plugin.customHeads.getHeadBase64(cont[i]) != null){
- //check for base64
- file.addDefault("panels." + date + ".item." + i + ".material", "cps= " + plugin.customHeads.getHeadBase64(cont[i]));
- }else if(meta.hasOwner()){
- //check for skull owner
- file.addDefault("panels." + date + ".item." + i + ".material", "cps= " + meta.getOwner());
- }else{
- file.addDefault("panels." + date + ".item." + i + ".material", cont[i].getType().toString());
- }
- }else {
- file.addDefault("panels." + date + ".item." + i + ".material", cont[i].getType().toString());
- }
- if(plugin.legacy.isLegacy()){
- if (cont[i].getDurability() != 0 && !cont[i].getType().toString().equals("SKULL_ITEM") && !cont[i].getType().toString().equals("SKULL_ITEM")) {
- file.addDefault("panels." + date + ".item." + i + ".ID", cont[i].getDurability());
- }
- }
- if(cont[i].getAmount() != 1){
- file.addDefault("panels." + date + ".item." + i + ".stack", cont[i].getAmount());
- }
- if(!cont[i].getEnchantments().isEmpty()){
- file.addDefault("panels." + date + ".item." + i + ".enchanted", "true");
- }
- try {
- PotionMeta potionMeta = (PotionMeta) cont[i].getItemMeta();
- file.addDefault("panels." + date + ".item." + i + ".potion", potionMeta.getBasePotionData().getType().name());
- } catch (Exception er) {
- //don't add the effect
- }
- file.addDefault("panels." + date + ".item." + i + ".name", Objects.requireNonNull(cont[i].getItemMeta()).getDisplayName());
- file.addDefault("panels." + date + ".item." + i + ".lore", Objects.requireNonNull(cont[i].getItemMeta()).getLore());
- }catch(Exception n){
- //skip over an item that spits an error
- }
- }
- file.options().copyDefaults(true);
+ //add items
+ file = plugin.itemCreate.generatePanelFile(date,inv,file);
try {
file.save(new File(plugin.panelsf + File.separator + date + ".yml"));
diff --git a/src/me/rockyhawk/commandpanels/ingameeditor/EditorUserInput.java b/src/me/rockyhawk/commandpanels/ingameeditor/EditorUserInput.java
index 46d0d8d..13a365d 100644
--- a/src/me/rockyhawk/commandpanels/ingameeditor/EditorUserInput.java
+++ b/src/me/rockyhawk/commandpanels/ingameeditor/EditorUserInput.java
@@ -4,6 +4,7 @@ import me.rockyhawk.commandpanels.CommandPanels;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.Sound;
+import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@@ -61,8 +62,10 @@ public class EditorUserInput implements Listener {
}
if(section.startsWith("panel.")) {
panelSectionCheck(p, section, panelName, panelTitle, cf, panelFile, e);
- }else if(section.startsWith("item.")){
+ }else if(section.startsWith("item:")){
itemSectionCheck(p, section, panelName, cf, panelFile, e);
+ }else if(section.startsWith("section.")){
+ itemSectionSectionCheck(p, section, panelName, cf, panelFile, e);
}
plugin.editorInputStrings.remove(temp);
plugin.reloadPanelFiles();
@@ -72,13 +75,31 @@ public class EditorUserInput implements Listener {
plugin.editorGuis.openEditorGui(p, 0); //I have to do this to run regular Bukkit voids in an ASYNC Event
}
});
- }else if(section.startsWith("item.")) {
+ }else if(section.startsWith("item:")) {
final YamlConfiguration finalCF = cf;
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
public void run() {
plugin.openGui(panelName, p, finalCF, 3,0); //I have to do this to run regular Bukkit voids in an ASYNC Event
}
});
+ }else if(section.startsWith("section.")){
+ String itemSection = ChatColor.stripColor(section.replace("section." + section.split("\\.")[1] + ".", ""));
+ final ConfigurationSection finalCF = cf.getConfigurationSection("panels." + panelName + ".item." + itemSection);
+ if(section.contains("change")){
+ final String changeItemSection = itemSection.substring(0, itemSection.lastIndexOf("."));
+ final ConfigurationSection changeFinalCF = cf.getConfigurationSection("panels." + panelName + ".item." + changeItemSection);
+ plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
+ public void run() {
+ plugin.editorGuis.openItemSections(p,panelName,changeFinalCF,changeItemSection);
+ }
+ });
+ }else{
+ plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
+ public void run() {
+ plugin.editorGuis.openItemSections(p,panelName,finalCF,itemSection);
+ }
+ });
+ }
}
return;
}
@@ -92,6 +113,7 @@ public class EditorUserInput implements Listener {
return false;
}
}
+
void panelSectionCheck(Player p, String section, String panelName, String panelTitle, YamlConfiguration cf, File panelFile, AsyncPlayerChatEvent e){
String tag = plugin.config.getString("config.format.tag") + " ";
switch (section) {
@@ -240,6 +262,38 @@ public class EditorUserInput implements Listener {
savePanelFile(cf, panelFile);
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Removed command line " + e.getMessage()));
break;
+ case "panel.disabled-worlds.add":
+ List disabledWorldsAdd = new ArrayList<>();
+ if(cf.contains("panels." + panelName + ".disabled-worlds")){
+ disabledWorldsAdd = cf.getStringList("panels." + panelName + ".disabled-worlds");
+ }
+ disabledWorldsAdd.add(e.getMessage());
+ cf.set("panels." + panelName + ".disabled-worlds", disabledWorldsAdd);
+ savePanelFile(cf, panelFile);
+ p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Added new World: " + e.getMessage()));
+ break;
+ case "panel.disabled-worlds.remove":
+ List disabledWorldsRemove;
+ if(cf.contains("panels." + panelName + ".disabled-worlds")){
+ disabledWorldsRemove = cf.getStringList("panels." + panelName + ".disabled-worlds");
+ }else{
+ p.sendMessage(plugin.papi( tag + ChatColor.RED + "No Worlds found to remove!"));
+ break;
+ }
+ try {
+ disabledWorldsRemove.remove(Integer.parseInt(e.getMessage())-1);
+ }catch (Exception ex){
+ p.sendMessage(plugin.papi( tag + ChatColor.RED + "Could not find World!"));
+ break;
+ }
+ if(disabledWorldsRemove.size() == 0){
+ cf.set("panels." + panelName + ".disabled-worlds", null);
+ }else{
+ cf.set("panels." + panelName + ".disabled-worlds", disabledWorldsRemove);
+ }
+ savePanelFile(cf, panelFile);
+ p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Removed World line " + e.getMessage()));
+ break;
case "panel.hotbar.material":
if(e.getMessage().trim().equalsIgnoreCase("remove")){
cf.set("panels." + panelName + ".open-with-item", null);
@@ -320,10 +374,11 @@ public class EditorUserInput implements Listener {
break;
}
}
+
void itemSectionCheck(Player p, String section, String panelName, YamlConfiguration cf, File panelFile, AsyncPlayerChatEvent e){
String tag = plugin.config.getString("config.format.tag") + " ";
- String itemSlot = section.split("\\.")[1];
- String sectionChange = section.replace("item." + itemSlot + ".","");
+ String itemSlot = section.split("\\:")[1];
+ String sectionChange = section.replace("item:" + itemSlot + ":","");
switch (sectionChange) {
case "name":
if(e.getMessage().trim().equalsIgnoreCase("remove")){
@@ -478,4 +533,40 @@ public class EditorUserInput implements Listener {
break;
}
}
+
+ void itemSectionSectionCheck(Player p, String section, String panelName, YamlConfiguration cf, File panelFile, AsyncPlayerChatEvent e){
+ String tag = plugin.config.getString("config.format.tag") + " ";
+ String secondValue = section.split("\\.")[1];
+ //section includes slot at front eg, 1.hasvalue
+ String itemSection = ChatColor.stripColor(section.replace("section." + secondValue + ".", ""));
+ String playerMessage = ChatColor.stripColor(e.getMessage()).toLowerCase();
+ switch (secondValue) {
+ case "add":
+ cf.set("panels." + panelName + ".item." + itemSection + "." + playerMessage + ".output", "true");
+ if(playerMessage.equals("hasperm")) {
+ cf.set("panels." + panelName + ".item." + itemSection + "." + playerMessage + ".perm", "admin");
+ }else{
+ cf.set("panels." + panelName + ".item." + itemSection + "." + playerMessage + ".value", "10");
+ cf.set("panels." + panelName + ".item." + itemSection + "." + playerMessage + ".compare", "%cp-player-balance%");
+ }
+ cf.set("panels." + panelName + ".item." + itemSection + "." + playerMessage + ".material", "DIRT");
+ cf.set("panels." + panelName + ".item." + itemSection + "." + playerMessage + ".name", "");
+ savePanelFile(cf, panelFile);
+ plugin.reloadPanelFiles();
+ p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Added Section " + ChatColor.WHITE + playerMessage));
+ break;
+ case "remove":
+ cf.set("panels." + panelName + ".item." + itemSection + "." + playerMessage, null);
+ savePanelFile(cf, panelFile);
+ plugin.reloadPanelFiles();
+ p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Removed Section " + ChatColor.WHITE + playerMessage));
+ break;
+ case "change":
+ cf.set("panels." + panelName + ".item." + itemSection + "." + playerMessage.split("\\:")[0], playerMessage.split("\\:")[1]);
+ savePanelFile(cf, panelFile);
+ plugin.reloadPanelFiles();
+ p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Set " + playerMessage.split("\\:")[0] + " to " + ChatColor.WHITE + playerMessage.split("\\:")[1]));
+ break;
+ }
+ }
}
diff --git a/src/me/rockyhawk/commandpanels/ingameeditor/EditorUtils.java b/src/me/rockyhawk/commandpanels/ingameeditor/EditorUtils.java
index 44f4b96..085816a 100644
--- a/src/me/rockyhawk/commandpanels/ingameeditor/EditorUtils.java
+++ b/src/me/rockyhawk/commandpanels/ingameeditor/EditorUtils.java
@@ -3,6 +3,7 @@ package me.rockyhawk.commandpanels.ingameeditor;
import me.rockyhawk.commandpanels.CommandPanels;
import org.bukkit.ChatColor;
import org.bukkit.Material;
+import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@@ -10,8 +11,6 @@ import org.bukkit.event.Listener;
import org.bukkit.event.inventory.*;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
-import org.bukkit.inventory.ItemStack;
-import org.bukkit.inventory.meta.SkullMeta;
import java.io.File;
import java.io.IOException;
@@ -243,14 +242,15 @@ public class EditorUtils implements Listener {
Save temp item if the item is picked up from inside the panel
*/
if(e.getClick().isShiftClick() && e.getClickedInventory() == e.getView().getTopInventory()){
- if(e.getCurrentItem() == null) {
+ if(e.getInventory().getItem(e.getSlot()) == null) {
return;
}
onEditPanelClose(p,e.getInventory(),e.getView());
inventoryItemSettingsOpening.add(p.getName());
//refresh the yaml config
file = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
- plugin.editorGuis.openItemSettings(p,panelName,file,e.getSlot());
+ plugin.editorGuis.openItemSettings(p,panelName,file.getConfigurationSection("panels." + panelName + ".item." + e.getSlot()), String.valueOf(e.getSlot()));
+ p.updateInventory();
return;
}
if(tempEdit.contains("panels." + panelName + ".temp." + p.getName() + ".material")) {
@@ -261,14 +261,19 @@ public class EditorUtils implements Listener {
}
}
}
+ if(e.getSlotType() != InventoryType.SlotType.CONTAINER){
+ return;
+ }
if(e.getAction() == InventoryAction.CLONE_STACK){
saveTempItem(e, p, file, panelName);
+ saveFile(fileName,file,true);
}else if(e.getAction() == InventoryAction.PLACE_ALL){
loadTempItem(e, p, file, fileName, panelName);
clearTemp(p, panelName);
+ saveFile(fileName,file,true);
}else if(e.getAction() == InventoryAction.COLLECT_TO_CURSOR){
- //e.setCancelled(true);
saveTempItem(e, p, file, panelName);
+ saveFile(fileName,file,true);
}else if(e.getAction() == InventoryAction.DROP_ALL_CURSOR){
e.setCancelled(true);
}else if(e.getAction() == InventoryAction.DROP_ALL_SLOT){
@@ -285,18 +290,24 @@ public class EditorUtils implements Listener {
e.setCancelled(true);
}else if(e.getAction() == InventoryAction.PLACE_SOME){
loadTempItem(e, p, file, fileName, panelName);
+ saveFile(fileName,file,true);
}else if(e.getAction() == InventoryAction.SWAP_WITH_CURSOR){
e.setCancelled(true);
}else if(e.getAction() == InventoryAction.PICKUP_ALL){
saveTempItem(e, p, file, panelName);
+ saveFile(fileName,file,true);
}else if(e.getAction() == InventoryAction.PICKUP_HALF){
saveTempItem(e, p, file, panelName);
+ saveFile(fileName,file,true);
}else if(e.getAction() == InventoryAction.PICKUP_ONE){
saveTempItem(e, p, file, panelName);
+ saveFile(fileName,file,true);
}else if(e.getAction() == InventoryAction.PICKUP_SOME){
saveTempItem(e, p, file, panelName);
+ saveFile(fileName,file,true);
}else if(e.getAction() == InventoryAction.PLACE_ONE){
loadTempItem(e, p, file, fileName, panelName);
+ saveFile(fileName,file,true);
}
}
@EventHandler
@@ -354,53 +365,64 @@ public class EditorUtils implements Listener {
}
if(e.getSlot() == 1){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.perm"});
- p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Permission"));
+ p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Enter New Permission"));
p.closeInventory();
}
if(e.getSlot() == 3){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.title"});
- p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Title"));
+ p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Enter New Title"));
p.closeInventory();
}
if(e.getSlot() == 5){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.sound-on-open"});
- p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Sound ID"));
+ p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Enter New Sound ID"));
p.closeInventory();
}
if(e.getSlot() == 7){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.command"});
- p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Command"));
+ p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Enter New Command"));
p.closeInventory();
}
if(e.getSlot() == 21){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.delete"});
- p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Are you sure? (yes/no)"));
+ p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Are you sure? (yes/no)"));
p.closeInventory();
}
if(e.getSlot() == 23){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.rows"});
- p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter Row Amount (1 to 6)"));
+ p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Enter Row Amount (1 to 6)"));
p.closeInventory();
}
if(e.getSlot() == 13){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.empty"});
- p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Material ID"));
+ p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Enter New Material ID"));
p.closeInventory();
}
if(e.getSlot() == 15){
//adds abilities to add and remove lines
if(e.getClick().isLeftClick()) {
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.commands-on-open.add"});
- p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Command"));
+ 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.GREEN + "Enter command line to remove (must be an integer)"));
+ p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Enter Command line to remove (must be an integer)"));
+ }
+ p.closeInventory();
+ }
+ if(e.getSlot() == 25){
+ //adds abilities to add and remove lines
+ if(e.getClick().isLeftClick()) {
+ plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.disabled-worlds.add"});
+ p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Enter New World Name"));
+ }else{
+ plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.disabled-worlds.remove"});
+ p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Enter World line to remove (must be an integer)"));
}
p.closeInventory();
}
if(e.getSlot() == 11){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.name"});
- p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Name"));
+ p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Enter New Name"));
p.closeInventory();
}
if(e.getSlot() == 18){
@@ -409,31 +431,32 @@ public class EditorUtils implements Listener {
}
if(e.getSlot() == 40){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.material"});
- p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Material"));
+ p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Enter New Material"));
p.closeInventory();
}
if(e.getSlot() == 38 && hotbarItems){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.name"});
- p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Name"));
+ p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Enter New Name"));
p.closeInventory();
}
if(e.getSlot() == 36 && hotbarItems){
//adds abilities to add and remove lines
if(e.getClick().isLeftClick()) {
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.lore.add"});
- p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Item Lore"));
+ p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Enter New Item Lore"));
}else{
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.lore.remove"});
- p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter lore line to remove (must be an integer)"));
+ p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Enter lore line to remove (must be an integer)"));
}
p.closeInventory();
}
if(e.getSlot() == 42 && hotbarItems){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.stationary"});
- p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter Location (1 to 9)"));
+ p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Enter Location (1 to 9)"));
p.closeInventory();
}
}
+
@EventHandler
public void onItemSettings(InventoryClickEvent e) {
Player p = (Player)e.getWhoClicked();
@@ -454,7 +477,7 @@ public class EditorUtils implements Listener {
YamlConfiguration panelYaml = null; //all panels from ALL files (panel names)
boolean found = false;
try {
- //neew to loop through files to get file names
+ //loop through files to get file names
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)){
@@ -468,6 +491,9 @@ public class EditorUtils implements Listener {
break;
}
}
+ if(found){
+ break;
+ }
}
}catch(Exception fail){
//could not fetch all panel names (probably no panels exist)
@@ -477,76 +503,181 @@ public class EditorUtils implements Listener {
if(!found){
return;
}
- int itemSlot;
+ String itemSlot;
try {
- itemSlot = Integer.parseInt(Objects.requireNonNull(Objects.requireNonNull(e.getView().getTopInventory().getItem(35)).getItemMeta()).getDisplayName().split("\\s")[2]);
+ itemSlot = ChatColor.stripColor(e.getView().getTopInventory().getItem(35).getItemMeta().getDisplayName().split("\\s")[2]);
}catch(Exception ex){
plugin.getServer().getConsoleSender().sendMessage("[CommandPanels] Could not get item slot");
plugin.debug(ex);
return;
}
if(e.getSlot() == 1){
- plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item." + itemSlot + ".name"});
- p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Item Name"));
+ plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item:" + itemSlot + ":name"});
+ p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Enter New Item Name"));
p.closeInventory();
}
if(e.getSlot() == 3){
//adds abilities to add and remove lines
if(e.getClick().isLeftClick()) {
- plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "item." + itemSlot + ".commands.add"});
- p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Item Command"));
+ plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "item:" + itemSlot + ":commands:add"});
+ p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Enter New Item Command"));
}else{
- plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "item." + itemSlot + ".commands.remove"});
- p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter command line to remove (must be an integer)"));
+ plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "item:" + itemSlot + ":commands:remove"});
+ p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Enter command line to remove (must be an integer)"));
}
p.closeInventory();
}
if(e.getSlot() == 5){
- plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item." + itemSlot + ".enchanted"});
- p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Item Enchantment"));
+ plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item:" + itemSlot + ":enchanted"});
+ p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Enter New Item Enchantment"));
p.closeInventory();
}
if(e.getSlot() == 7){
- plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item." + itemSlot + ".potion"});
- p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Item Potion Effect"));
+ plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item:" + itemSlot + ":potion"});
+ p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Enter New Item Potion Effect"));
p.closeInventory();
}
if(e.getSlot() == 19){
//adds abilities to add and remove lines
if(e.getClick().isLeftClick()) {
- plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "item." + itemSlot + ".lore.add"});
- p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Item Lore"));
+ plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "item:" + itemSlot + ":lore:add"});
+ p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Enter New Item Lore"));
}else{
- plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "item." + itemSlot + ".lore.remove"});
- p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter lore line to remove (must be an integer)"));
+ plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "item:" + itemSlot + ":lore:remove"});
+ p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Enter lore line to remove (must be an integer)"));
}
p.closeInventory();
}
if(e.getSlot() == 21){
- plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item." + itemSlot + ".stack"});
- p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Item Stack (must be an integer)"));
+ plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item:" + itemSlot + ":stack"});
+ p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Enter New Item Stack (must be an integer)"));
p.closeInventory();
}
if(e.getSlot() == 23){
- plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item." + itemSlot + ".customdata"});
- p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Custom Model Data"));
+ plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item:" + itemSlot + ":customdata"});
+ p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Enter New Custom Model Data"));
p.closeInventory();
}
if(e.getSlot() == 25){
- plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item." + itemSlot + ".leatherarmor"});
- p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Leather Armor Colour"));
+ plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item:" + itemSlot + ":leatherarmor"});
+ p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Enter New Leather Armor Colour"));
p.closeInventory();
}
+ if(e.getSlot() == 31){
+ //section includes the slot number at the front
+ plugin.editorGuis.openItemSections(p,panelName,panelYaml.getConfigurationSection("panels." + panelName + ".item." + itemSlot), itemSlot);
+ p.updateInventory();
+ }
if(e.getSlot() == 35){
- plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item." + itemSlot + ".head"});
- p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Custom Material (eg. cps= self)"));
+ plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item:" + itemSlot + ":head"});
+ p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Enter New Custom Material (eg. cps= self)"));
p.closeInventory();
}
if(e.getSlot() == 27){
- plugin.openGui(panelName, p, panelYaml,3,0);
+ if(itemSlot.contains(".")){
+ String newSection = itemSlot.substring(0, itemSlot.lastIndexOf("."));
+ plugin.editorGuis.openItemSections(p,panelName,panelYaml.getConfigurationSection("panels." + panelName + ".item." + newSection), newSection);
+ }else {
+ plugin.openGui(panelName, p, panelYaml, 3, 0);
+ }
p.updateInventory();
}
}
+
+ //item section viewer click event
+ @EventHandler
+ public void onItemSection(InventoryClickEvent e) {
+ Player p = (Player)e.getWhoClicked();
+ String tag = plugin.config.getString("config.format.tag") + " ";
+ try {
+ if (Objects.requireNonNull(e.getClickedInventory()).getType() != InventoryType.CHEST) {
+ return;
+ }
+ }catch(Exception outOf){
+ //skip as player clicked outside the inventory
+ return;
+ }
+ if(!p.getOpenInventory().getTitle().contains("Item Sections:")){
+ return;
+ }
+ e.setCancelled(true);
+ String panelName = ""; //all panels from ALL files (panel names)
+ YamlConfiguration panelYaml = null;
+ ConfigurationSection itemConfSection; //all panels from ALL files (panel names)
+ boolean found = false;
+ try {
+ //loop through files to get file names
+ YamlConfiguration temp;
+ for(String fileName : plugin.panelFiles) { //will loop through all the files in folder
+ temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
+ if(!plugin.checkPanels(temp)){
+ continue;
+ }
+ for (String key : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)){
+ if(e.getView().getTitle().equals("Item Sections: " + key)){
+ panelName = key;
+ panelYaml = temp;
+ found = true;
+ break;
+ }
+ }
+ if(found){
+ break;
+ }
+ }
+ }catch(Exception fail){
+ //could not fetch all panel names (probably no panels exist)
+ plugin.debug(fail);
+ return;
+ }
+ if(!found){
+ return;
+ }
+
+ //this section includes slot at front
+ String section;
+ try {
+ section = ChatColor.stripColor(Objects.requireNonNull(Objects.requireNonNull(e.getView().getTopInventory().getItem(44)).getItemMeta()).getDisplayName().split("\\s")[2]);
+ }catch(Exception ex){
+ plugin.getServer().getConsoleSender().sendMessage("[CommandPanels] Could not get item slot");
+ plugin.debug(ex);
+ return;
+ }
+ itemConfSection = panelYaml.getConfigurationSection("panels." + panelName + ".item." + section);
+
+ if(e.getSlot() <= 35){
+ if(e.getInventory().getItem(e.getSlot()) != null){
+ if(e.getClick().isLeftClick()) {
+ String newSection = section + "." + ChatColor.stripColor(e.getInventory().getItem(e.getSlot()).getItemMeta().getDisplayName());
+ plugin.editorGuis.openItemSettings(p, panelName, itemConfSection.getConfigurationSection(ChatColor.stripColor(e.getInventory().getItem(e.getSlot()).getItemMeta().getDisplayName())), newSection);
+ p.updateInventory();
+ }else{
+ String itemNameSection = "." + ChatColor.stripColor(e.getInventory().getItem(e.getSlot()).getItemMeta().getDisplayName());
+ plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"section.change." + section + itemNameSection});
+ p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Enter Setting to change, eg, value:500"));
+ p.closeInventory();
+ }
+ }
+ }
+
+ if(e.getSlot() == 38){
+ plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"section.remove." + section});
+ p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Enter Section name to remove, eg, hasperm or hasperm0"));
+ p.closeInventory();
+ }
+
+ if(e.getSlot() == 42){
+ plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"section.add." + section});
+ p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Enter Section name to add, eg, hasperm or hasperm0"));
+ p.closeInventory();
+ }
+
+ if(e.getSlot() == 36){
+ plugin.editorGuis.openItemSettings(p,panelName,itemConfSection, section);
+ p.updateInventory();
+ }
+ }
+
public void saveTempItem(InventoryClickEvent e, Player p, YamlConfiguration file, String panelName){
//saves item to temp, using getslot
tempEdit.set("panels." + panelName + ".temp." + p.getName(),file.get("panels." + panelName + ".item." + e.getSlot()));
@@ -617,60 +748,7 @@ public class EditorUtils implements Listener {
return;
}
//save items as they appear
- ItemStack cont;
- for(int i = 0; inv.getSize() > i; i++){
- cont = inv.getItem(i);
- //repeat through all the items in the editor
- try{
- //make the item here
- if(cont == null){
- //remove if items have been removed
- if(file.contains("panels." + panelName + ".item." + i)){
- file.set("panels." + panelName + ".item." + i, null);
- continue;
- }
- }
- if(plugin.legacy.isLegacy()){
- if (cont.getDurability() != 0 && !cont.getType().toString().equals("SKULL_ITEM") && !cont.getType().toString().equals("SKULL_ITEM")) {
- file.addDefault("panels." + panelName + ".item." + i + ".ID", cont.getDurability());
- }
- }
- if(file.contains("panels." + panelName + ".item." + i + ".material")){
- if(Objects.requireNonNull(file.getString("panels." + panelName + ".item." + i + ".material")).contains("%") || Objects.requireNonNull(file.getString("panels." + panelName + ".item." + i + ".material")).contains("=")){
- if(!plugin.getHeads.ifSkullOrHead(cont.getType().toString())){
- file.set("panels." + panelName + ".item." + i + ".material", cont.getType().toString());
- }
- }else{
- file.set("panels." + panelName + ".item." + i + ".material", cont.getType().toString());
- }
- }else{
- file.set("panels." + panelName + ".item." + i + ".material", cont.getType().toString());
- }
- if(plugin.getHeads.ifSkullOrHead(cont.getType().toString())){
- SkullMeta meta = (SkullMeta) cont.getItemMeta();
- //disable for legacy as is broken
- if(!plugin.legacy.isLegacy()) {
- if (plugin.customHeads.getHeadBase64(cont) != null) {
- //inject base64 here
- file.set("panels." + panelName + ".item." + i + ".material", "cps= " + plugin.customHeads.getHeadBase64(cont));
- } else if (meta.hasOwner()) {
- //check for skull owner
- file.set("panels." + panelName + ".item." + i + ".material", "cps= " + meta.getOwner());
- }
- }
- }
- if(cont.getAmount() != 1){
- file.set("panels." + panelName + ".item." + i + ".stack", cont.getAmount());
- }
- if(!cont.getEnchantments().isEmpty()){
- file.set("panels." + panelName + ".item." + i + ".enchanted", "true");
- }
- file.set("panels." + panelName + ".item." + i + ".name", Objects.requireNonNull(cont.getItemMeta()).getDisplayName());
- file.set("panels." + panelName + ".item." + i + ".lore", Objects.requireNonNull(cont.getItemMeta()).getLore());
- }catch(Exception n){
- //skip over an item that spits an error
- }
- }
+ file = plugin.itemCreate.generatePanelFile(panelName,inv,file);
try {
file.save(new File(plugin.panelsf + File.separator + fileName));
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Saved Changes!"));