This commit is contained in:
rockyhawk64 2021-07-03 17:41:21 +10:00
parent 27e233c4ec
commit 8f6a222f15
34 changed files with 362 additions and 314 deletions

View File

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

View File

@ -239,7 +239,7 @@ public class CommandPanels extends JavaPlugin{
})); }));
//get tag //get tag
tag = tex.papi(config.getString("config.format.tag") + " "); tag = tex.colour(config.getString("config.format.tag") + " ");
Bukkit.getLogger().info("[CommandPanels] RockyHawk's CommandPanels v" + this.getDescription().getVersion() + " Plugin Loaded!"); Bukkit.getLogger().info("[CommandPanels] RockyHawk's CommandPanels v" + this.getDescription().getVersion() + " Plugin Loaded!");
} }
@ -261,10 +261,10 @@ public class CommandPanels extends JavaPlugin{
ItemMeta renamedMeta = renamed.getItemMeta(); ItemMeta renamedMeta = renamed.getItemMeta();
//set cp placeholders //set cp placeholders
if(usePlaceholders){ if(usePlaceholders){
customName = tex.papiNoColour(panel,p,customName); customName = tex.placeholdersNoColour(panel,p,customName);
} }
if(useColours){ if(useColours){
customName = tex.papi(customName); customName = tex.colour(customName);
} }
assert renamedMeta != null; assert renamedMeta != null;
@ -279,11 +279,11 @@ public class CommandPanels extends JavaPlugin{
List<String> clore; List<String> clore;
if (lore != null) { if (lore != null) {
if(usePlaceholders && useColours){ if(usePlaceholders && useColours){
clore = tex.papi(panel, p, lore, true); clore = tex.placeholdersList(panel, p, lore, true);
}else if(usePlaceholders){ }else if(usePlaceholders){
clore = tex.papiNoColour(panel,p, lore); clore = tex.placeholdersNoColour(panel,p, lore);
}else if(useColours){ }else if(useColours){
clore = tex.papi(panel, p, lore, false); clore = tex.placeholdersList(panel, p, lore, false);
}else{ }else{
clore = lore; clore = lore;
} }
@ -328,7 +328,7 @@ public class CommandPanels extends JavaPlugin{
ArrayList<String> opanelsTemp = new ArrayList<String>(); ArrayList<String> opanelsTemp = new ArrayList<String>();
for(String tempName : apanels){ for(String tempName : apanels){
if(opanelsTemp.contains(tempName)){ if(opanelsTemp.contains(tempName)){
sender.sendMessage(tex.papi(tag) + ChatColor.RED + " Error duplicate panel name: " + tempName); sender.sendMessage(tex.colour(tag) + ChatColor.RED + " Error duplicate panel name: " + tempName);
return false; return false;
} }
opanelsTemp.add(tempName); opanelsTemp.add(tempName);
@ -392,7 +392,7 @@ public class CommandPanels extends JavaPlugin{
} }
public void helpMessage(CommandSender p) { public void helpMessage(CommandSender p) {
p.sendMessage(tex.papi( tag + ChatColor.GREEN + "Commands:")); p.sendMessage(tex.colour( tag + ChatColor.GREEN + "Commands:"));
p.sendMessage(ChatColor.GOLD + "/cp <panel> [player:item] [player] " + ChatColor.WHITE + "Open a command panel."); p.sendMessage(ChatColor.GOLD + "/cp <panel> [player:item] [player] " + ChatColor.WHITE + "Open a command panel.");
if (p.hasPermission("commandpanel.reload")) { if (p.hasPermission("commandpanel.reload")) {
p.sendMessage(ChatColor.GOLD + "/cpr " + ChatColor.WHITE + "Reloads plugin config."); p.sendMessage(ChatColor.GOLD + "/cpr " + ChatColor.WHITE + "Reloads plugin config.");

View File

@ -150,7 +150,7 @@ public class Utils implements Listener {
//end custom command PlaceHolders //end custom command PlaceHolders
//make the command //make the command
String command = plugin.tex.papi(panel,p,commands.get(i)); String command = plugin.tex.placeholders(panel,p,commands.get(i));
int val = plugin.commandTags.commandPayWall(p,command); int val = plugin.commandTags.commandPayWall(p,command);
if(val == 0){ if(val == 0){

View File

@ -79,7 +79,8 @@ public class Panel{
public ItemStack getHotbarItem(Player p){ public ItemStack getHotbarItem(Player p){
ConfigurationSection itemSection = panelConfig.getConfigurationSection("open-with-item"); ConfigurationSection itemSection = panelConfig.getConfigurationSection("open-with-item");
return plugin.itemCreate.makeItemFromConfig(this,itemSection, p, true, true, false); ItemStack s = plugin.itemCreate.makeItemFromConfig(this,itemSection, p, true, true, false);
return plugin.nbt.setNBT(s,"CommandPanelsHotbar",panelName);
} }
public boolean hasHotbarItem(){ public boolean hasHotbarItem(){

View File

@ -7,11 +7,9 @@ import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.ItemStack;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
@ -33,14 +31,14 @@ public class ExecuteOpenVoids {
panel.setConfig(YamlConfiguration.loadConfiguration(panel.getFile())); panel.setConfig(YamlConfiguration.loadConfiguration(panel.getFile()));
} }
if (!sender.hasPermission("commandpanel.panel." + panel.getConfig().getString("perm"))) { if (!sender.hasPermission("commandpanel.panel." + panel.getConfig().getString("perm"))) {
sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.perms"))); sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
return; return;
} }
//if the sender has OTHER perms, or if sendOpenedMessage is false, implying it is not for another person //if the sender has OTHER perms, or if sendOpenedMessage is false, implying it is not for another person
if(sender.hasPermission("commandpanel.other") || !openForOtherUser) { if(sender.hasPermission("commandpanel.other") || !openForOtherUser) {
//check for disabled worlds //check for disabled worlds
if(!plugin.panelPerms.isPanelWorldEnabled(p,panel.getConfig())){ if(!plugin.panelPerms.isPanelWorldEnabled(p,panel.getConfig())){
sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.perms"))); sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
return; return;
} }
@ -77,7 +75,7 @@ public class ExecuteOpenVoids {
} }
} }
}catch(Exception s){ }catch(Exception s){
p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " " + "commands-on-open: " + panel.getConfig().getString("commands-on-open"))); p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " " + "commands-on-open: " + panel.getConfig().getString("commands-on-open")));
} }
} }
@ -87,66 +85,58 @@ public class ExecuteOpenVoids {
try { try {
p.playSound(p.getLocation(), Sound.valueOf(Objects.requireNonNull(panel.getConfig().getString("sound-on-open")).toUpperCase()), 1F, 1F); p.playSound(p.getLocation(), Sound.valueOf(Objects.requireNonNull(panel.getConfig().getString("sound-on-open")).toUpperCase()), 1F, 1F);
} catch (Exception s) { } catch (Exception s) {
p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " " + "sound-on-open: " + panel.getConfig().getString("sound-on-open"))); p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " " + "sound-on-open: " + panel.getConfig().getString("sound-on-open")));
} }
} }
} }
if(openForOtherUser) { if(openForOtherUser) {
sender.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Panel Opened for " + p.getDisplayName())); sender.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Panel Opened for " + p.getDisplayName()));
} }
} catch (Exception r) { } catch (Exception r) {
plugin.debug(r,null); plugin.debug(r,null);
sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error"))); sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error")));
plugin.openPanels.closePanelForLoader(p.getName()); plugin.openPanels.closePanelForLoader(p.getName());
p.closeInventory(); p.closeInventory();
} }
}else{ }else{
sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.perms"))); sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
} }
} }
//this will give a hotbar item to a player //this will give a hotbar item to a player
public void giveHotbarItem(CommandSender sender, Player p, ConfigurationSection cf, boolean sendGiveMessage){ public void giveHotbarItem(CommandSender sender, Player p, Panel panel, boolean sendGiveMessage){
if (sender.hasPermission("commandpanel.item." + cf.getString("perm")) && cf.contains("open-with-item")) { if (sender.hasPermission("commandpanel.item." + panel.getConfig().getString("perm")) && panel.getConfig().contains("open-with-item")) {
//check for disabled worlds //check for disabled worlds
if(!plugin.panelPerms.isPanelWorldEnabled(p,cf)){ if(!plugin.panelPerms.isPanelWorldEnabled(p,panel.getConfig())){
sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.perms"))); sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
return; return;
} }
ItemStack s;
try {
s = plugin.itemCreate.makeItemFromConfig(null,Objects.requireNonNull(cf.getConfigurationSection("open-with-item")), p, false, true, false);
}catch(Exception n){
sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " open-with-item: material"));
return;
}
plugin.setName(null,s, cf.getString("open-with-item.name"), cf.getStringList("open-with-item.lore"),p,false, true, true);
//if the sender has OTHER perms, or if sendGiveMessage is false, implying it is not for another person //if the sender has OTHER perms, or if sendGiveMessage is false, implying it is not for another person
if(sender.hasPermission("commandpanel.other") || !sendGiveMessage) { if(sender.hasPermission("commandpanel.other") || !sendGiveMessage) {
try { try {
if(cf.contains("open-with-item.stationary")) { if(panel.getConfig().contains("open-with-item.stationary")) {
p.getInventory().setItem(Integer.parseInt(Objects.requireNonNull(cf.getString("open-with-item.stationary"))), s); p.getInventory().setItem(Integer.parseInt(Objects.requireNonNull(panel.getConfig().getString("open-with-item.stationary"))), panel.getHotbarItem(p));
}else{ }else{
p.getInventory().addItem(s); p.getInventory().addItem(panel.getHotbarItem(p));
} }
if(sendGiveMessage) { if(sendGiveMessage) {
sender.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Item Given to " + p.getDisplayName())); sender.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Item Given to " + p.getDisplayName()));
} }
} catch (Exception r) { } catch (Exception r) {
sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.notitem"))); sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.notitem")));
} }
}else{ }else{
sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.perms"))); sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
} }
return; return;
} }
if (!cf.contains("open-with-item")) { if (!panel.getConfig().contains("open-with-item")) {
sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.noitem"))); sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.noitem")));
return; return;
} }
sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.perms"))); sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
} }
public void beforeLoadCommands(Panel panel, Player p){ public void beforeLoadCommands(Panel panel, Player p){
@ -163,7 +153,7 @@ public class ExecuteOpenVoids {
} }
} }
}catch(Exception s){ }catch(Exception s){
p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " " + "pre-load-commands: " + panel.getConfig().getString("pre-load-commands"))); p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " " + "pre-load-commands: " + panel.getConfig().getString("pre-load-commands")));
plugin.debug(s,p); plugin.debug(s,p);
} }
} }

View File

@ -41,14 +41,14 @@ public class ItemCreation {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public ItemStack makeItemFromConfig(Panel panel, ConfigurationSection itemSection, Player p, boolean placeholders, boolean colours, boolean addNBT){ public ItemStack makeItemFromConfig(Panel panel, ConfigurationSection itemSection, Player p, boolean placeholders, boolean colours, boolean addNBT){
String material = plugin.tex.papiNoColour(panel,p,itemSection.getString("material")); String material = plugin.tex.placeholdersNoColour(panel,p,itemSection.getString("material"));
try { try {
if (Objects.requireNonNull(material).equalsIgnoreCase("AIR")) { if (Objects.requireNonNull(material).equalsIgnoreCase("AIR")) {
return null; return null;
} }
}catch(NullPointerException e){ }catch(NullPointerException e){
plugin.debug(e,p); plugin.debug(e,p);
p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " material: could not load material!")); p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " material: could not load material!"));
return null; return null;
} }
ItemStack s = null; ItemStack s = null;
@ -120,7 +120,7 @@ public class ItemCreation {
BookMeta bookMeta = (BookMeta) s.getItemMeta(); BookMeta bookMeta = (BookMeta) s.getItemMeta();
bookMeta.setTitle(matraw.split("\\s")[1]); bookMeta.setTitle(matraw.split("\\s")[1]);
bookMeta.setAuthor(matraw.split("\\s")[1]); bookMeta.setAuthor(matraw.split("\\s")[1]);
List<String> bookLines = plugin.tex.papi(panel,p,itemSection.getStringList("write"),true); List<String> bookLines = plugin.tex.placeholdersList(panel,p,itemSection.getStringList("write"),true);
String result = bookLines.stream().map(String::valueOf).collect(Collectors.joining("\n" + ChatColor.RESET, "", "")); String result = bookLines.stream().map(String::valueOf).collect(Collectors.joining("\n" + ChatColor.RESET, "", ""));
bookMeta.setPages(result); bookMeta.setPages(result);
s.setItemMeta(bookMeta); s.setItemMeta(bookMeta);
@ -148,22 +148,22 @@ public class ItemCreation {
assert meta != null; assert meta != null;
meta.setOwningPlayer(Bukkit.getOfflinePlayer(UUID.fromString(skullname))); meta.setOwningPlayer(Bukkit.getOfflinePlayer(UUID.fromString(skullname)));
} catch (Exception var23) { } catch (Exception var23) {
p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " material: cps= self")); p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " material: cps= self"));
plugin.debug(var23,p); plugin.debug(var23,p);
} }
}else{ }else{
meta.setOwner(p.getName()); meta.setOwner(p.getName());
} }
s.setItemMeta(meta); s.setItemMeta(meta);
}else if (plugin.tex.papiNoColour(panel,p,matraw.split("\\s")[1]).length() <= 16) { }else if (plugin.tex.placeholdersNoColour(panel,p,matraw.split("\\s")[1]).length() <= 16) {
//if cps= username //if cps= username
s = plugin.customHeads.getPlayerHead(plugin.tex.papiNoColour(panel,p,matraw.split("\\s")[1])); s = plugin.customHeads.getPlayerHead(plugin.tex.placeholdersNoColour(panel,p,matraw.split("\\s")[1]));
} else { } else {
//custom data cps= base64 //custom data cps= base64
s = plugin.customHeads.getCustomHead(plugin.tex.papiNoColour(panel,p,matraw.split("\\s")[1])); s = plugin.customHeads.getCustomHead(plugin.tex.placeholdersNoColour(panel,p,matraw.split("\\s")[1]));
} }
} catch (Exception var32) { } catch (Exception var32) {
p.sendMessage(plugin.tex.papi( plugin.tag + plugin.config.getString("config.format.error") + " head material: Could not load skull")); p.sendMessage(plugin.tex.colour( plugin.tag + plugin.config.getString("config.format.error") + " head material: Could not load skull"));
plugin.debug(var32,p); plugin.debug(var32,p);
} }
} }
@ -181,11 +181,11 @@ public class ItemCreation {
try { try {
s = api.getItemHead(matraw.split("\\s")[1].trim()); s = api.getItemHead(matraw.split("\\s")[1].trim());
} catch (Exception var22) { } catch (Exception var22) {
p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " hdb: could not load skull!")); p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " hdb: could not load skull!"));
plugin.debug(var22,p); plugin.debug(var22,p);
} }
} else { } else {
p.sendMessage(plugin.tex.papi(plugin.tag + "Download HeadDatabaseHook from Spigot to use this feature!")); p.sendMessage(plugin.tex.colour(plugin.tag + "Download HeadDatabaseHook from Spigot to use this feature!"));
} }
} }
@ -212,7 +212,7 @@ public class ItemCreation {
This will do maps from custom images This will do maps from custom images
the maps will be in the 'maps' folder, so the maps will be in the 'maps' folder, so
CommandPanels/maps/image.png <-- here CommandPanels/maps/image.png <-- here
Commandpanels/panels/example.yml CommandPanels/panels/example.yml
The images should be 128x128 The images should be 128x128
*/ */
try{ try{
@ -235,10 +235,10 @@ public class ItemCreation {
meta.setMapView(map); meta.setMapView(map);
s.setItemMeta(meta); s.setItemMeta(meta);
}else{ }else{
p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " map: File not found.")); p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " map: File not found."));
} }
}catch(Exception map){ }catch(Exception map){
p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " map: " + itemSection.getString("map"))); p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " map: " + itemSection.getString("map")));
plugin.debug(map,p); plugin.debug(map,p);
} }
} }
@ -258,7 +258,7 @@ public class ItemCreation {
s.setItemMeta(EnchantMeta); s.setItemMeta(EnchantMeta);
} }
} catch (Exception ench) { } catch (Exception ench) {
p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " enchanted: " + itemSection.getString("enchanted"))); p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " enchanted: " + itemSection.getString("enchanted")));
plugin.debug(ench,p); plugin.debug(ench,p);
} }
} }
@ -310,7 +310,7 @@ public class ItemCreation {
} catch (Exception er) { } catch (Exception er) {
//don't colour the armor //don't colour the armor
plugin.debug(er,p); plugin.debug(er,p);
p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " leatherarmor: " + itemSection.getString("leatherarmor"))); p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " leatherarmor: " + itemSection.getString("leatherarmor")));
} }
} }
@ -327,7 +327,7 @@ public class ItemCreation {
} catch (Exception er) { } catch (Exception er) {
//don't add the effect //don't add the effect
plugin.debug(er,p); plugin.debug(er,p);
p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + plugin.config.getString("config.format.error") + " potion: " + itemSection.getString("potion"))); p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + plugin.config.getString("config.format.error") + " potion: " + itemSection.getString("potion")));
} }
} }
if (itemSection.contains("damage")) { if (itemSection.contains("damage")) {
@ -335,10 +335,10 @@ public class ItemCreation {
//if the damage is not unbreakable and should be a value //if the damage is not unbreakable and should be a value
if (plugin.legacy.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_12)) { if (plugin.legacy.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_12)) {
try { try {
s.setDurability(Short.parseShort(Objects.requireNonNull(plugin.tex.papi(panel,p, itemSection.getString("damage"))))); s.setDurability(Short.parseShort(Objects.requireNonNull(plugin.tex.placeholders(panel,p, itemSection.getString("damage")))));
} catch (Exception e) { } catch (Exception e) {
plugin.debug(e, p); plugin.debug(e, p);
p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " damage: " + itemSection.getString("damage"))); p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " damage: " + itemSection.getString("damage")));
} }
} else { } else {
if(itemSection.getString("damage").equalsIgnoreCase("-1")){ if(itemSection.getString("damage").equalsIgnoreCase("-1")){
@ -350,21 +350,26 @@ public class ItemCreation {
try { try {
Damageable itemDamage = (Damageable) s.getItemMeta(); Damageable itemDamage = (Damageable) s.getItemMeta();
itemDamage.setDamage(Integer.parseInt(Objects.requireNonNull(plugin.tex.papi(panel,p, itemSection.getString("damage"))))); itemDamage.setDamage(Integer.parseInt(Objects.requireNonNull(plugin.tex.placeholders(panel,p, itemSection.getString("damage")))));
s.setItemMeta((ItemMeta) itemDamage); s.setItemMeta((ItemMeta) itemDamage);
} catch (Exception e) { } catch (Exception e) {
plugin.debug(e, p); plugin.debug(e, p);
p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " damage: " + itemSection.getString("damage"))); p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " damage: " + itemSection.getString("damage")));
} }
} }
} }
if (itemSection.contains("nbt")) {
for(String key : itemSection.getConfigurationSection("nbt").getKeys(false)){
s = plugin.nbt.setNBT(s,key,itemSection.getString("nbt." + key));
}
}
if (itemSection.contains("stack")) { if (itemSection.contains("stack")) {
//change the stack amount (placeholders accepted) //change the stack amount (placeholders accepted)
s.setAmount((int)Double.parseDouble(Objects.requireNonNull(plugin.tex.papi(panel,p,itemSection.getString("stack"))))); s.setAmount((int)Double.parseDouble(Objects.requireNonNull(plugin.tex.placeholders(panel,p,itemSection.getString("stack")))));
} }
} catch (IllegalArgumentException | NullPointerException var33) { } catch (IllegalArgumentException | NullPointerException var33) {
plugin.debug(var33,p); plugin.debug(var33,p);
p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " material: " + itemSection.getString("material"))); p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " material: " + itemSection.getString("material")));
return null; return null;
} }
plugin.setName(panel,s, itemSection.getString("name"), itemSection.getStringList("lore"), p, placeholders, colours, hideAttributes); plugin.setName(panel,s, itemSection.getString("name"), itemSection.getStringList("lore"), p, placeholders, colours, hideAttributes);
@ -390,8 +395,8 @@ 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 = ChatColor.stripColor(plugin.tex.papi(panel,p,cf.getString("hasvalue.value"))); String value = ChatColor.stripColor(plugin.tex.placeholders(panel,p,cf.getString("hasvalue.value")));
String compare = ChatColor.stripColor(plugin.tex.papi(panel,p,cf.getString("hasvalue.compare"))); String compare = ChatColor.stripColor(plugin.tex.placeholders(panel,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
String section = hasSection(panel,Objects.requireNonNull(cf.getConfigurationSection("hasvalue")), p); String section = hasSection(panel,Objects.requireNonNull(cf.getConfigurationSection("hasvalue")), p);
@ -407,8 +412,8 @@ 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 = ChatColor.stripColor(plugin.tex.papi(panel,p,cf.getString("hasvalue" + count + ".value"))); value = ChatColor.stripColor(plugin.tex.placeholders(panel,p,cf.getString("hasvalue" + count + ".value")));
compare = ChatColor.stripColor(plugin.tex.papi(panel,p,cf.getString("hasvalue" + count + ".compare"))); compare = ChatColor.stripColor(plugin.tex.placeholders(panel,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
String section = hasSection(panel,Objects.requireNonNull(cf.getConfigurationSection("hasvalue" + count)), p); String section = hasSection(panel,Objects.requireNonNull(cf.getConfigurationSection("hasvalue" + count)), p);
@ -426,8 +431,8 @@ 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");
} }
double value = Double.parseDouble(ChatColor.stripColor(plugin.tex.papiNoColour(panel,p,cf.getString("hasgreater.value")))); double value = Double.parseDouble(ChatColor.stripColor(plugin.tex.placeholdersNoColour(panel,p,cf.getString("hasgreater.value"))));
double compare = Double.parseDouble(ChatColor.stripColor(plugin.tex.papiNoColour(panel,p,cf.getString("hasgreater.compare")))); double compare = Double.parseDouble(ChatColor.stripColor(plugin.tex.placeholdersNoColour(panel,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
String section = hasSection(panel,Objects.requireNonNull(cf.getConfigurationSection("hasgreater")), p); String section = hasSection(panel,Objects.requireNonNull(cf.getConfigurationSection("hasgreater")), p);
@ -442,8 +447,8 @@ 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 = Double.parseDouble(ChatColor.stripColor(plugin.tex.papiNoColour(panel,p,cf.getString("hasgreater" + count + ".value")))); value = Double.parseDouble(ChatColor.stripColor(plugin.tex.placeholdersNoColour(panel,p,cf.getString("hasgreater" + count + ".value"))));
compare = Double.parseDouble(ChatColor.stripColor(plugin.tex.papiNoColour(panel,p,cf.getString("hasgreater" + count + ".compare")))); compare = Double.parseDouble(ChatColor.stripColor(plugin.tex.placeholdersNoColour(panel,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
String section = hasSection(panel,Objects.requireNonNull(cf.getConfigurationSection("hasgreater" + count)), p); String section = hasSection(panel,Objects.requireNonNull(cf.getConfigurationSection("hasgreater" + count)), p);

View File

@ -28,8 +28,8 @@ public class OpenEditorGuis {
ArrayList<ItemStack> panelItems = new ArrayList<>(); //all panels from ALL files (panel materials) ArrayList<ItemStack> panelItems = new ArrayList<>(); //all panels from ALL files (panel materials)
try { try {
for(Panel panel : plugin.panelList) { //will loop through all the files in folder for(Panel panel : plugin.panelList) { //will loop through all the files in folder
panelNames.add(plugin.tex.papi(panel.getName())); panelNames.add(plugin.tex.colour(panel.getName()));
panelTitles.add(plugin.tex.papi(panel.getConfig().getString("title"))); panelTitles.add(plugin.tex.colour(panel.getConfig().getString("title")));
if (panel.getConfig().contains("open-with-item.material")) { if (panel.getConfig().contains("open-with-item.material")) {
panelItems.add(panel.getHotbarItem(p)); panelItems.add(panel.getHotbarItem(p));
} else { } else {

View File

@ -15,22 +15,29 @@ public class CreateText {
this.plugin = pl; this.plugin = pl;
} }
//CommandPanels send message function with all placeholders
public void sendMessage(Panel panel, Player p, String message){
if(!message.equals("")) {
p.sendMessage(placeholders(panel, p,plugin.tag + message));
}
}
//CommandPanels send message function //CommandPanels send message function
public void sendMessage(Player p, String message){ public void sendMessage(Player p, String message){
if(!message.equals("")) { if(!message.equals("")) {
p.sendMessage(papi(plugin.tag + message)); p.sendMessage(colour(plugin.tag + message));
} }
} }
//CommandPanels send message function without the tag //CommandPanels send message function without the tag
public void sendString(Player p, String message){ public void sendString(Player p, String message){
if(!message.equals("")) { if(!message.equals("")) {
p.sendMessage(papi(message)); p.sendMessage(colour(message));
} }
} }
//papi except if it is a String List //papi except if it is a String List
public List<String> papiNoColour(Panel panel, Player p, List<String> setpapi) { public List<String> placeholdersNoColour(Panel panel, Player p, List<String> setpapi) {
try { try {
int tempInt = 0; int tempInt = 0;
for (String temp : setpapi) { for (String temp : setpapi) {
@ -49,7 +56,7 @@ public class CreateText {
} }
//papi except if it is a String List //papi except if it is a String List
public List<String> papi(Panel panel, Player p, List<String> setpapi, boolean placeholder) { public List<String> placeholdersList(Panel panel, Player p, List<String> setpapi, boolean placeholder) {
try { try {
if(placeholder) { if(placeholder) {
int tempInt = 0; int tempInt = 0;
@ -79,7 +86,7 @@ public class CreateText {
} }
//regular string papi, but only colours so Player doesn't need to be there //regular string papi, but only colours so Player doesn't need to be there
public String papi(String setpapi) { public String colour(String setpapi) {
try { try {
setpapi = plugin.hex.translateHexColorCodes(ChatColor.translateAlternateColorCodes('&', setpapi)); setpapi = plugin.hex.translateHexColorCodes(ChatColor.translateAlternateColorCodes('&', setpapi));
return setpapi; return setpapi;
@ -89,7 +96,7 @@ public class CreateText {
} }
//string papi with no colours //string papi with no colours
public String papiNoColour(Panel panel, Player p, String setpapi) { public String placeholdersNoColour(Panel panel, Player p, String setpapi) {
try { try {
setpapi = plugin.placeholders.setCpPlaceholders(panel, p,setpapi); setpapi = plugin.placeholders.setCpPlaceholders(panel, p,setpapi);
if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) { if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
@ -103,7 +110,7 @@ public class CreateText {
} }
//regular string papi //regular string papi
public String papi(Panel panel, Player p, String setpapi) { public String placeholders(Panel panel, Player p, String setpapi) {
try { try {
setpapi = plugin.placeholders.setCpPlaceholders(panel, p,setpapi); setpapi = plugin.placeholders.setCpPlaceholders(panel, p,setpapi);
if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) { if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {

View File

@ -37,7 +37,7 @@ public class Placeholders {
List<String> inputMessages = new ArrayList<String>(plugin.config.getStringList("config.input-message")); List<String> inputMessages = new ArrayList<String>(plugin.config.getStringList("config.input-message"));
for (String temp : inputMessages) { for (String temp : inputMessages) {
temp = temp.replaceAll("%cp-args%", Objects.requireNonNull(plugin.config.getString("config.input-cancel"))); temp = temp.replaceAll("%cp-args%", Objects.requireNonNull(plugin.config.getString("config.input-cancel")));
p.sendMessage(plugin.tex.papi(panel,p, temp)); p.sendMessage(plugin.tex.placeholders(panel,p, temp));
} }
return "cpc"; return "cpc";
} }
@ -50,7 +50,7 @@ public class Placeholders {
str = str.replaceAll("%cp-player-y%", String.valueOf(Math.round(p.getLocation().getY()))); str = str.replaceAll("%cp-player-y%", String.valueOf(Math.round(p.getLocation().getY())));
str = str.replaceAll("%cp-player-z%", String.valueOf(Math.round(p.getLocation().getZ()))); str = str.replaceAll("%cp-player-z%", String.valueOf(Math.round(p.getLocation().getZ())));
str = str.replaceAll("%cp-online-players%", Integer.toString(Bukkit.getServer().getOnlinePlayers().size())); str = str.replaceAll("%cp-online-players%", Integer.toString(Bukkit.getServer().getOnlinePlayers().size()));
str = str.replaceAll("%cp-tag%", plugin.tex.papi(plugin.tag)); str = str.replaceAll("%cp-tag%", plugin.tex.colour(plugin.tag));
//set custom placeholders to their values //set custom placeholders to their values
if(panel != null) { if(panel != null) {
@ -83,6 +83,24 @@ public class Placeholders {
} }
} }
//placeholder to check if an item has NBT %cp-nbt-slot:key%
while (str.contains("%cp-nbt-")) {
try {
int start = str.indexOf("%cp-nbt-");
int end = str.indexOf("%", str.indexOf("%cp-nbt-")+1);
String slot_key = str.substring(start, end).replace("%cp-nbt-", "").replace("%","");
String value;
value = plugin.nbt.getNBT(p.getOpenInventory().getTopInventory().getItem(Integer.parseInt(slot_key.split(":")[0])),slot_key.split(":")[1]);
if(value == null){
value = "empty";
}
str = str.replace(str.substring(start, end) + "%", value);
}catch (Exception ex){
plugin.debug(ex,p);
break;
}
}
//DO placeholders for detection of other items in a panel //DO placeholders for detection of other items in a panel
//get material value from slot in current open inventory (panel) //get material value from slot in current open inventory (panel)
while (str.contains("%cp-material-")) { while (str.contains("%cp-material-")) {
@ -283,7 +301,7 @@ public class Placeholders {
String playerLocation = str.substring(start, end).replace("%cp-player-online-", ""); String playerLocation = str.substring(start, end).replace("%cp-player-online-", "");
Player[] playerFind = Bukkit.getOnlinePlayers().toArray(new Player[Bukkit.getOnlinePlayers().size()]); Player[] playerFind = Bukkit.getOnlinePlayers().toArray(new Player[Bukkit.getOnlinePlayers().size()]);
if (Integer.parseInt(playerLocation) > playerFind.length) { if (Integer.parseInt(playerLocation) > playerFind.length) {
str = str.replace(str.substring(start, end) + "-find%", plugin.tex.papi(Objects.requireNonNull(plugin.config.getString("config.format.offline")))); str = str.replace(str.substring(start, end) + "-find%", plugin.tex.colour(Objects.requireNonNull(plugin.config.getString("config.format.offline"))));
} else { } else {
str = str.replace(str.substring(start, end) + "-find%", playerFind[Integer.parseInt(playerLocation) - 1].getName()); str = str.replace(str.substring(start, end) + "-find%", playerFind[Integer.parseInt(playerLocation) - 1].getName());
} }

View File

@ -32,7 +32,7 @@ public class Commandpanel implements CommandExecutor {
return true; return true;
} }
if(panel == null){ if(panel == null){
sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.nopanel"))); sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.nopanel")));
return true; return true;
} }
boolean disableCommand = false; boolean disableCommand = false;
@ -52,18 +52,18 @@ public class Commandpanel implements CommandExecutor {
plugin.openVoids.openCommandPanel(sender, plugin.getServer().getPlayer(args[1]), panel.copy(), true); plugin.openVoids.openCommandPanel(sender, plugin.getServer().getPlayer(args[1]), panel.copy(), true);
} }
}else{ }else{
sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Usage: /cp <panel> [item] [player]")); sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cp <panel> [item] [player]"));
} }
return true; return true;
}else if(args.length == 3){ }else if(args.length == 3){
if (args[1].equals("item")) { if (args[1].equals("item")) {
plugin.openVoids.giveHotbarItem(sender,plugin.getServer().getPlayer(args[2]),panel.getConfig(),true); plugin.openVoids.giveHotbarItem(sender,plugin.getServer().getPlayer(args[2]),panel,true);
}else{ }else{
sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Usage: /cp <panel> item [player]")); sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cp <panel> item [player]"));
} }
return true; return true;
} else { } else {
sender.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Please execute command directed to a Player!")); sender.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Please execute command directed to a Player!"));
return true; return true;
} }
}else{ }else{
@ -77,7 +77,7 @@ public class Commandpanel implements CommandExecutor {
return true; return true;
}else if(args.length == 2){ }else if(args.length == 2){
if (args[1].equals("item")) { if (args[1].equals("item")) {
plugin.openVoids.giveHotbarItem(sender, p, panel.getConfig(), false); plugin.openVoids.giveHotbarItem(sender, p, panel, false);
}else{ }else{
if(!disableCommand) { if(!disableCommand) {
plugin.openVoids.openCommandPanel(sender, plugin.getServer().getPlayer(args[1]), panel.copy(), true); plugin.openVoids.openCommandPanel(sender, plugin.getServer().getPlayer(args[1]), panel.copy(), true);
@ -85,12 +85,12 @@ public class Commandpanel implements CommandExecutor {
} }
return true; return true;
}else if(args.length == 3){ }else if(args.length == 3){
plugin.openVoids.giveHotbarItem(sender, plugin.getServer().getPlayer(args[2]), panel.getConfig(),true); plugin.openVoids.giveHotbarItem(sender, plugin.getServer().getPlayer(args[2]), panel,true);
return true; return true;
} }
} }
} }
sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Usage: /cp <panel> [player:item] [player]")); sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cp <panel> [player:item] [player]"));
return true; return true;
} }
} }

View File

@ -20,27 +20,27 @@ public class Commandpanelsdebug implements CommandExecutor {
//command /cpd //command /cpd
if(!(sender instanceof Player)) { if(!(sender instanceof Player)) {
plugin.debug.consoleDebug = !plugin.debug.consoleDebug; plugin.debug.consoleDebug = !plugin.debug.consoleDebug;
sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.GREEN + "Global Debug Mode: " + plugin.debug.consoleDebug)); sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.GREEN + "Global Debug Mode: " + plugin.debug.consoleDebug));
return true; return true;
} }
Player p = (Player)sender; Player p = (Player)sender;
if(plugin.debug.isEnabled(p)){ if(plugin.debug.isEnabled(p)){
plugin.debug.debugSet.remove(p); plugin.debug.debugSet.remove(p);
sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.GREEN + "Personal Debug Mode Disabled!")); sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.GREEN + "Personal Debug Mode Disabled!"));
}else{ }else{
plugin.debug.debugSet.add(p); plugin.debug.debugSet.add(p);
sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.GREEN + "Personal Debug Mode Enabled!")); sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.GREEN + "Personal Debug Mode Enabled!"));
} }
}else{ }else{
sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Usage: /cpd")); sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cpd"));
} }
}else{ }else{
sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.perms"))); sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
} }
return true; return true;
} }
sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Usage: /cpd")); sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cpd"));
return true; return true;
} }
} }

View File

@ -23,11 +23,11 @@ public class Commandpanelslist implements CommandExecutor {
//check to make sure the panels isn't empty //check to make sure the panels isn't empty
try { try {
if (plugin.panelList == null) { if (plugin.panelList == null) {
sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "No panels found!")); sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "No panels found!"));
return true; return true;
} }
}catch(Exception b){ }catch(Exception b){
sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "No panels found!")); sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "No panels found!"));
return true; return true;
} }
@ -39,10 +39,10 @@ public class Commandpanelslist implements CommandExecutor {
page = Integer.parseInt(args[0]); page = Integer.parseInt(args[0]);
skip = page*8-8; skip = page*8-8;
}catch (Exception e){ }catch (Exception e){
sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Inaccessible Page")); sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Inaccessible Page"));
} }
} }
sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.DARK_AQUA + "Panels: (Page " + page + ")")); sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.DARK_AQUA + "Panels: (Page " + page + ")"));
for (int f = skip; panels.size() > f && skip+8 > f; f++) { for (int f = skip; panels.size() > f && skip+8 > f; f++) {
sender.sendMessage(ChatColor.DARK_GREEN + panels.get(f).getFile().getAbsolutePath().replace(plugin.panelsf.getAbsolutePath(),"") + ChatColor.GREEN + " " + panels.get(f).getName()); sender.sendMessage(ChatColor.DARK_GREEN + panels.get(f).getFile().getAbsolutePath().replace(plugin.panelsf.getAbsolutePath(),"") + ChatColor.GREEN + " " + panels.get(f).getName());
if(panels.size()-1 == f){ if(panels.size()-1 == f){
@ -51,11 +51,11 @@ public class Commandpanelslist implements CommandExecutor {
} }
sender.sendMessage(ChatColor.AQUA + "Type /cpl " + (page+1) + " to read next page"); sender.sendMessage(ChatColor.AQUA + "Type /cpl " + (page+1) + " to read next page");
}else{ }else{
sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.perms"))); sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
} }
return true; return true;
} }
sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Usage: /cpl")); sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cpl"));
return true; return true;
} }
} }

View File

@ -42,14 +42,14 @@ public class Commandpanelsreload implements CommandExecutor {
registerCommands(); registerCommands();
} }
plugin.tag = plugin.tex.papi(plugin.config.getString("config.format.tag") + " "); plugin.tag = plugin.tex.colour(plugin.config.getString("config.format.tag") + " ");
sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.reload"))); sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.reload")));
}else{ }else{
sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.perms"))); sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
} }
return true; return true;
} }
sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Usage: /cpr")); sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cpr"));
return true; return true;
} }

View File

@ -19,29 +19,29 @@ public class Commandpanelversion implements CommandExecutor {
if (sender.hasPermission("commandpanel.version")) { if (sender.hasPermission("commandpanel.version")) {
//version command //version command
String latestVersion = plugin.updater.githubNewUpdate(false); String latestVersion = plugin.updater.githubNewUpdate(false);
sender.sendMessage(plugin.tex.papi(plugin.tag)); sender.sendMessage(plugin.tex.colour(plugin.tag));
sender.sendMessage(ChatColor.GREEN + "This Version " + ChatColor.GRAY + plugin.getDescription().getVersion()); sender.sendMessage(ChatColor.GREEN + "This Version " + ChatColor.GRAY + plugin.getDescription().getVersion());
sender.sendMessage(ChatColor.GREEN + "Latest Version " + ChatColor.GRAY + latestVersion); sender.sendMessage(ChatColor.GREEN + "Latest Version " + ChatColor.GRAY + latestVersion);
sender.sendMessage(ChatColor.GRAY + "-------------------"); sender.sendMessage(ChatColor.GRAY + "-------------------");
sender.sendMessage(ChatColor.GREEN + "Developer " + ChatColor.GRAY + "RockyHawk"); sender.sendMessage(ChatColor.GREEN + "Developer " + ChatColor.GRAY + "RockyHawk");
sender.sendMessage(ChatColor.GREEN + "Command " + ChatColor.GRAY + "/cp"); sender.sendMessage(ChatColor.GREEN + "Command " + ChatColor.GRAY + "/cp");
} else { } else {
sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.perms"))); sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
} }
}else if(args.length == 1){ }else if(args.length == 1){
if (sender.hasPermission("commandpanel.update")) { if (sender.hasPermission("commandpanel.update")) {
if (args[0].equals("cancel")) { if (args[0].equals("cancel")) {
plugin.updater.downloadVersionManually = null; plugin.updater.downloadVersionManually = null;
sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.GREEN + "Will not download a new version on restart.")); sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.GREEN + "Will not download a new version on restart."));
} else { } else {
plugin.updater.downloadVersionManually = args[0]; plugin.updater.downloadVersionManually = args[0];
sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.GREEN + "Downloading version " + ChatColor.GRAY + args[0] + ChatColor.GREEN + " upon server restart.")); sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.GREEN + "Downloading version " + ChatColor.GRAY + args[0] + ChatColor.GREEN + " upon server restart."));
} }
}else{ }else{
sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.perms"))); sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
} }
}else{ }else{
sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Usage: /cpv [update:latest:cancel]")); sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cpv [update:latest:cancel]"));
} }
return true; return true;
} }

View File

@ -40,7 +40,7 @@ public class CommandTagEvent extends Event {
this.name = split[0].trim(); this.name = split[0].trim();
this.raw = split[1].trim().split("\\s"); this.raw = split[1].trim().split("\\s");
if(doApiPlaceholders) { if(doApiPlaceholders) {
this.args = plugin.tex.papi(panel1, player, split[1].trim()).split("\\s"); this.args = plugin.tex.placeholders(panel1, player, split[1].trim()).split("\\s");
}else{ }else{
this.args = ChatColor.translateAlternateColorCodes('&',plugin.placeholders.setCpPlaceholders(panel, p,split[1].trim())).split("\\s"); this.args = ChatColor.translateAlternateColorCodes('&',plugin.placeholders.setCpPlaceholders(panel, p,split[1].trim())).split("\\s");
} }

View File

@ -30,7 +30,7 @@ public class CommandTags {
CommandTagEvent tags = new CommandTagEvent(plugin,panel,p,commandRAW); CommandTagEvent tags = new CommandTagEvent(plugin,panel,p,commandRAW);
Bukkit.getPluginManager().callEvent(tags); Bukkit.getPluginManager().callEvent(tags);
if(!tags.commandTagUsed){ if(!tags.commandTagUsed){
Bukkit.dispatchCommand(p, plugin.tex.papi(panel,p,commandRAW.trim())); Bukkit.dispatchCommand(p, plugin.tex.placeholders(panel,p,commandRAW.trim()));
} }
} }

View File

@ -56,7 +56,7 @@ public class SellItemTags implements Listener {
} else { } else {
assert api != null; assert api != null;
api.addTokens(e.p, Long.parseLong(e.args[0])); api.addTokens(e.p, Long.parseLong(e.args[0]));
plugin.tex.sendMessage(e.p, Objects.requireNonNull(plugin.config.getString("purchase.item.success")).replaceAll("%cp-args%", e.args[1])); plugin.tex.sendMessage(e.p, plugin.config.getString("purchase.item.success").replaceAll("%cp-args%", e.args[1]));
} }
} else { } else {
plugin.tex.sendMessage(e.p, ChatColor.RED + "Selling Requires TokenManager to work!"); plugin.tex.sendMessage(e.p, ChatColor.RED + "Selling Requires TokenManager to work!");
@ -96,7 +96,7 @@ public class SellItemTags implements Listener {
PotionMeta potionMeta = (PotionMeta) itm.getItemMeta(); PotionMeta potionMeta = (PotionMeta) itm.getItemMeta();
assert potionMeta != null; assert potionMeta != null;
if (!potionMeta.getBasePotionData().getType().name().equalsIgnoreCase(potion)) { if (!potionMeta.getBasePotionData().getType().name().equalsIgnoreCase(potion)) {
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Your item has the wrong potion effect")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Your item has the wrong potion effect"));
return false; return false;
} }
} }

View File

@ -19,31 +19,31 @@ public class DataTags implements Listener {
if(e.name.equalsIgnoreCase("set-data=")){ if(e.name.equalsIgnoreCase("set-data=")){
e.commandTagUsed(); e.commandTagUsed();
if(e.args.length == 3){ if(e.args.length == 3){
plugin.panelData.setUserData(getOffline(e.args[2]),e.args[0],plugin.tex.papiNoColour(e.panel,e.p,e.args[1]),true); plugin.panelData.setUserData(getOffline(e.args[2]),e.args[0],plugin.tex.placeholdersNoColour(e.panel,e.p,e.args[1]),true);
return; return;
} }
//this will overwrite data. set-data= [data point] [data value] [optional player] //this will overwrite data. set-data= [data point] [data value] [optional player]
plugin.panelData.setUserData(e.p.getUniqueId(),e.args[0],plugin.tex.papiNoColour(e.panel,e.p,e.args[1]),true); plugin.panelData.setUserData(e.p.getUniqueId(),e.args[0],plugin.tex.placeholdersNoColour(e.panel,e.p,e.args[1]),true);
return; return;
} }
if(e.name.equalsIgnoreCase("add-data=")){ if(e.name.equalsIgnoreCase("add-data=")){
e.commandTagUsed(); e.commandTagUsed();
if(e.args.length == 3){ if(e.args.length == 3){
plugin.panelData.setUserData(getOffline(e.args[2]),e.args[0],plugin.tex.papiNoColour(e.panel,e.p,e.args[1]),false); plugin.panelData.setUserData(getOffline(e.args[2]),e.args[0],plugin.tex.placeholdersNoColour(e.panel,e.p,e.args[1]),false);
return; return;
} }
//this will not overwrite existing data. add-data= [data point] [data value] [optional player] //this will not overwrite existing data. add-data= [data point] [data value] [optional player]
plugin.panelData.setUserData(e.p.getUniqueId(),e.args[0],plugin.tex.papiNoColour(e.panel,e.p,e.args[1]),false); plugin.panelData.setUserData(e.p.getUniqueId(),e.args[0],plugin.tex.placeholdersNoColour(e.panel,e.p,e.args[1]),false);
return; return;
} }
if(e.name.equalsIgnoreCase("math-data=")){ if(e.name.equalsIgnoreCase("math-data=")){
e.commandTagUsed(); e.commandTagUsed();
if(e.args.length == 3){ if(e.args.length == 3){
plugin.panelData.doDataMath(getOffline(e.args[2]),e.args[0],plugin.tex.papiNoColour(e.panel,e.p,e.args[1])); plugin.panelData.doDataMath(getOffline(e.args[2]),e.args[0],plugin.tex.placeholdersNoColour(e.panel,e.p,e.args[1]));
return; return;
} }
//only works if data is number, goes math-data= [data point] [operator:number] [optional player] eg, math-data= -1 OR /3 //only works if data is number, goes math-data= [data point] [operator:number] [optional player] eg, math-data= -1 OR /3
plugin.panelData.doDataMath(e.p.getUniqueId(),e.args[0],plugin.tex.papiNoColour(e.panel,e.p,e.args[1])); plugin.panelData.doDataMath(e.p.getUniqueId(),e.args[0],plugin.tex.placeholdersNoColour(e.panel,e.p,e.args[1]));
return; return;
} }
if(e.name.equalsIgnoreCase("clear-data=")){ if(e.name.equalsIgnoreCase("clear-data=")){

View File

@ -31,7 +31,7 @@ public class PlaceholderTags implements Listener {
//do not change the placeholder //do not change the placeholder
String placeholder = contents.substring(0,contents.indexOf(':')); String placeholder = contents.substring(0,contents.indexOf(':'));
//only convert placeholders for the value //only convert placeholders for the value
String value = plugin.tex.papi(e.panel,e.p,contents.substring(contents.indexOf(':')+1)); String value = plugin.tex.placeholders(e.panel,e.p,contents.substring(contents.indexOf(':')+1));
e.panel.placeholders.addPlaceholder(placeholder,value); e.panel.placeholders.addPlaceholder(placeholder,value);
i = i+contents.length()-1; i = i+contents.length()-1;
} }
@ -57,7 +57,7 @@ public class PlaceholderTags implements Listener {
//only convert placeholders for the value //only convert placeholders for the value
if (!e.panel.placeholders.keys.containsKey(placeholder)) { if (!e.panel.placeholders.keys.containsKey(placeholder)) {
//only convert placeholders for the value //only convert placeholders for the value
String value = plugin.tex.papi(e.panel, e.p, contents.substring(contents.indexOf(':') + 1)); String value = plugin.tex.placeholders(e.panel, e.p, contents.substring(contents.indexOf(':') + 1));
e.panel.placeholders.addPlaceholder(placeholder, value); e.panel.placeholders.addPlaceholder(placeholder, value);
} }
i = i + contents.length() - 1; i = i + contents.length() - 1;

View File

@ -42,7 +42,7 @@ public class SpecialTags implements Listener {
//do not change the placeholder //do not change the placeholder
String placeholder = contents.substring(0,contents.indexOf(':')); String placeholder = contents.substring(0,contents.indexOf(':'));
//only convert placeholders for the value //only convert placeholders for the value
String value = plugin.tex.papi(e.panel,e.p,contents.substring(contents.indexOf(':')+1)); String value = plugin.tex.placeholders(e.panel,e.p,contents.substring(contents.indexOf(':')+1));
openPanel.placeholders.addPlaceholder(placeholder,value); openPanel.placeholders.addPlaceholder(placeholder,value);
i = i+contents.length()-1; i = i+contents.length()-1;
} }

View File

@ -58,7 +58,7 @@ public class BasicTags implements Listener {
} catch (Exception exc) { } catch (Exception exc) {
e.p.setOp(isop); e.p.setOp(isop);
plugin.debug(exc,e.p); plugin.debug(exc,e.p);
e.p.sendMessage(plugin.tag + plugin.tex.papi( plugin.config.getString("config.format.error") + " op=: Error in op command!")); e.p.sendMessage(plugin.tag + plugin.tex.colour( plugin.config.getString("config.format.error") + " op=: Error in op command!"));
} }
return; return;
} }

View File

@ -18,7 +18,7 @@ public class Commandpanelsgenerate implements CommandExecutor {
@EventHandler @EventHandler
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if(!(sender instanceof Player)) { if(!(sender instanceof Player)) {
sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Please execute command as a Player!")); sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Please execute command as a Player!"));
return true; return true;
} }
Player p = (Player) sender; Player p = (Player) sender;
@ -31,30 +31,30 @@ public class Commandpanelsgenerate implements CommandExecutor {
Inventory i = Bukkit.createInventory(null, Integer.parseInt(args[0]) * 9, "Generate New Panel"); Inventory i = Bukkit.createInventory(null, Integer.parseInt(args[0]) * 9, "Generate New Panel");
p.openInventory(i); p.openInventory(i);
} else { } else {
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Please use integer from 1-6.")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Please use integer from 1-6."));
} }
}catch(Exception exc){ }catch(Exception exc){
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Please use integer from 1-6.")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Please use integer from 1-6."));
} }
return true; return true;
}else if (args.length == 0) { }else if (args.length == 0) {
if (this.plugin.generateMode.contains(p)) { if (this.plugin.generateMode.contains(p)) {
this.plugin.generateMode.remove(p); this.plugin.generateMode.remove(p);
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Generate Mode Disabled!")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Generate Mode Disabled!"));
} else { } else {
this.plugin.generateMode.add(p); this.plugin.generateMode.add(p);
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Generate Mode Enabled!")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Generate Mode Enabled!"));
} }
return true; return true;
} }
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Usage: /cpg [rows]")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Usage: /cpg [rows]"));
return true; return true;
}else{ }else{
p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.perms"))); p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
return true; return true;
} }
} }
p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Usage: /cpg [rows]")); p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cpg [rows]"));
return true; return true;
} }
} }

View File

@ -79,7 +79,7 @@ public class GenUtils implements Listener {
} }
if(!foundItem){ if(!foundItem){
//panels don't need items but I cancel on generate with no items because then players have the option to cancel if they need to //panels don't need items but I cancel on generate with no items because then players have the option to cancel if they need to
p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Cancelled Panel!")); p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Cancelled Panel!"));
return; return;
} }
YamlConfiguration file; YamlConfiguration file;
@ -111,9 +111,9 @@ public class GenUtils implements Listener {
try { try {
file.save(new File(plugin.panelsf + File.separator + date + ".yml")); file.save(new File(plugin.panelsf + File.separator + date + ".yml"));
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Saved Generated File To: " + date + ".yml")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Saved Generated File To: " + date + ".yml"));
} catch (IOException var16) { } catch (IOException var16) {
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Could Not Save Generated Panel!")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Could Not Save Generated Panel!"));
} }
plugin.reloadPanelFiles(); plugin.reloadPanelFiles();
} }

View File

@ -21,16 +21,16 @@ public class CpIngameEditCommand implements CommandExecutor {
@EventHandler @EventHandler
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if(!sender.hasPermission("commandpanel.edit")){ if(!sender.hasPermission("commandpanel.edit")){
sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.perms"))); sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
return true; return true;
} }
if(Objects.requireNonNull(plugin.config.getString("config.ingame-editor")).equalsIgnoreCase("false")){ if(Objects.requireNonNull(plugin.config.getString("config.ingame-editor")).equalsIgnoreCase("false")){
//this will cancel every /cpe command if ingame-editor is set to false //this will cancel every /cpe command if ingame-editor is set to false
sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Editor disabled!")); sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Editor disabled!"));
return true; return true;
} }
if(!(sender instanceof Player)) { if(!(sender instanceof Player)) {
sender.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Please execute command as a Player!")); sender.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Please execute command as a Player!"));
return true; return true;
} }
Player p = (Player)sender; Player p = (Player)sender;
@ -48,7 +48,7 @@ public class CpIngameEditCommand implements CommandExecutor {
plugin.editorGuis.openEditorGui(p,0); plugin.editorGuis.openEditorGui(p,0);
return true; return true;
} }
sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Usage: /cpe <panel>")); sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cpe <panel>"));
return true; return true;
} }
} }

View File

@ -43,7 +43,7 @@ public class EditorUserInput implements Listener {
cf = panel.getConfig(); cf = panel.getConfig();
cfile = YamlConfiguration.loadConfiguration(panel.getFile()); cfile = YamlConfiguration.loadConfiguration(panel.getFile());
panelFile = panel.getFile(); panelFile = panel.getFile();
panelTitle = plugin.tex.papi(cf.getString("title")); panelTitle = plugin.tex.colour(cf.getString("title"));
break; break;
} }
} }
@ -56,7 +56,7 @@ public class EditorUserInput implements Listener {
if(e.getMessage().equalsIgnoreCase(plugin.config.getString("config.input-cancel"))){ if(e.getMessage().equalsIgnoreCase(plugin.config.getString("config.input-cancel"))){
plugin.editorInputStrings.remove(temp); plugin.editorInputStrings.remove(temp);
plugin.reloadPanelFiles(); plugin.reloadPanelFiles();
e.getPlayer().sendMessage(plugin.tex.papi( Objects.requireNonNull(plugin.config.getString("config.input-cancelled")))); e.getPlayer().sendMessage(plugin.tex.colour( Objects.requireNonNull(plugin.config.getString("config.input-cancelled"))));
return; return;
} }
plugin.editorInputStrings.remove(temp); plugin.editorInputStrings.remove(temp);
@ -121,101 +121,101 @@ public class EditorUserInput implements Listener {
if(Objects.requireNonNull(cfile.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
if(savePanelFile(null, cfile, panelName, panelFile)){ if(savePanelFile(null, cfile, panelName, panelFile)){
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Deleted Panel!")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Deleted Panel!"));
}else{ }else{
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Could Not Delete Panel!")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Could Not Delete Panel!"));
} }
}else { }else {
//if the file only has one panel in it //if the file only has one panel in it
if (panelFile.delete()) { if (panelFile.delete()) {
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Deleted Panel!")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Deleted Panel!"));
}else{ }else{
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Could Not Delete Panel!")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Could Not Delete Panel!"));
} }
} }
} }
break; break;
case "panel.perm": case "panel.perm":
if(e.getMessage().contains(" ")){ if(e.getMessage().contains(" ")){
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Permission cannot contain spaces!")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Permission cannot contain spaces!"));
break; break;
} }
cf.set("perm", e.getMessage()); cf.set("perm", e.getMessage());
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Permission required is now " + "commandpanel.panel." + e.getMessage())); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Permission required is now " + "commandpanel.panel." + e.getMessage()));
break; break;
case "panel.rows": case "panel.rows":
try { try {
int rows = Integer.parseInt(e.getMessage()); int rows = Integer.parseInt(e.getMessage());
if (rows >= 7 || rows <= 0) { if (rows >= 7 || rows <= 0) {
//if the number isn't between 1-6 //if the number isn't between 1-6
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Choose an integer between 1 to 6!")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Choose an integer between 1 to 6!"));
return; return;
} }
cf.set("rows", rows); cf.set("rows", rows);
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Set Panel to " + rows + " rows!")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set Panel to " + rows + " rows!"));
} catch (Exception io) { } catch (Exception io) {
plugin.debug(io,p); plugin.debug(io,p);
} }
break; break;
case "panel.title": case "panel.title":
if(panelTitle.equals(plugin.tex.papi(e.getMessage()))){ if(panelTitle.equals(plugin.tex.colour(e.getMessage()))){
p.sendMessage(plugin.tex.papi(plugin.tag + e.getMessage() + ChatColor.RED + " is in use from another panel!")); p.sendMessage(plugin.tex.colour(plugin.tag + e.getMessage() + ChatColor.RED + " is in use from another panel!"));
break; break;
} }
cf.set("title", e.getMessage()); cf.set("title", e.getMessage());
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Set new Title to " + ChatColor.WHITE + e.getMessage())); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set new Title to " + ChatColor.WHITE + e.getMessage()));
break; break;
case "panel.name": case "panel.name":
if(e.getMessage().contains(" ")){ if(e.getMessage().contains(" ")){
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Panel name cannot contain spaces!")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Panel name cannot contain spaces!"));
break; break;
} }
if(panelName.equals(e.getMessage())){ if(panelName.equals(e.getMessage())){
p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + e.getMessage() + " is in use from another panel!")); p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + e.getMessage() + " is in use from another panel!"));
break; break;
} }
cfile.set("panels." + e.getMessage(), cfile.get("panels." + panelName)); 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 //I have put null there instead of cf because that will replicate cp = null to delete it
savePanelFile(null, cfile, panelName, panelFile); savePanelFile(null, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Set new Name to " + e.getMessage())); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set new Name to " + e.getMessage()));
break; break;
case "panel.empty": case "panel.empty":
if(e.getMessage().trim().equalsIgnoreCase("remove")){ if(e.getMessage().trim().equalsIgnoreCase("remove")){
cf.set("empty", null); cf.set("empty", null);
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Empty materials have been removed.")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Empty materials have been removed."));
break; break;
} }
String materialTemp = null; String materialTemp = null;
try { try {
materialTemp = Objects.requireNonNull(Material.matchMaterial(e.getMessage())).toString(); materialTemp = Objects.requireNonNull(Material.matchMaterial(e.getMessage())).toString();
}catch(NullPointerException ex){ }catch(NullPointerException ex){
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + e.getMessage() + " is not a valid Material!")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + e.getMessage() + " is not a valid Material!"));
} }
cf.set("empty", materialTemp); cf.set("empty", materialTemp);
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Set Empty material to " + materialTemp)); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set Empty material to " + materialTemp));
break; break;
case "panel.sound-on-open": case "panel.sound-on-open":
if(e.getMessage().trim().equalsIgnoreCase("remove")){ if(e.getMessage().trim().equalsIgnoreCase("remove")){
cf.set("sound-on-open", null); cf.set("sound-on-open", null);
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Sounds have been removed.")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Sounds have been removed."));
break; break;
} }
String tempSound; String tempSound;
try { try {
tempSound = Sound.valueOf(e.getMessage()).toString(); tempSound = Sound.valueOf(e.getMessage()).toString();
}catch(Exception ex){ }catch(Exception ex){
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + e.getMessage() + " is not a valid Sound!")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + e.getMessage() + " is not a valid Sound!"));
return; return;
} }
cf.set("sound-on-open", tempSound); cf.set("sound-on-open", tempSound);
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Sound when opening is now " + tempSound)); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Sound when opening is now " + tempSound));
break; break;
case "panel.panelType.add": case "panel.panelType.add":
List<String> typeAdd = new ArrayList<>(); List<String> typeAdd = new ArrayList<>();
@ -225,20 +225,20 @@ public class EditorUserInput implements Listener {
typeAdd.add(e.getMessage().toLowerCase()); typeAdd.add(e.getMessage().toLowerCase());
cf.set("panelType", typeAdd); cf.set("panelType", typeAdd);
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Added new panel type: " + e.getMessage().toLowerCase())); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Added new panel type: " + e.getMessage().toLowerCase()));
break; break;
case "panel.panelType.remove": case "panel.panelType.remove":
List<String> typeRemove; List<String> typeRemove;
if(cf.contains("panelType")){ if(cf.contains("panelType")){
typeRemove = cf.getStringList("panelType"); typeRemove = cf.getStringList("panelType");
}else{ }else{
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "No types found to remove!")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "No types found to remove!"));
break; break;
} }
try { try {
typeRemove.remove(Integer.parseInt(e.getMessage())-1); typeRemove.remove(Integer.parseInt(e.getMessage())-1);
}catch (Exception ex){ }catch (Exception ex){
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Could not find type!")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Could not find type!"));
break; break;
} }
if(typeRemove.size() == 0){ if(typeRemove.size() == 0){
@ -247,7 +247,7 @@ public class EditorUserInput implements Listener {
cf.set("panelType", typeRemove); cf.set("panelType", typeRemove);
} }
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Removed panel type " + e.getMessage())); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Removed panel type " + e.getMessage()));
break; break;
case "panel.commands.add": case "panel.commands.add":
List<String> commandsAdd = new ArrayList<>(); List<String> commandsAdd = new ArrayList<>();
@ -257,20 +257,20 @@ public class EditorUserInput implements Listener {
commandsAdd.add(e.getMessage()); commandsAdd.add(e.getMessage());
cf.set("commands", commandsAdd); cf.set("commands", commandsAdd);
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Added new command: " + e.getMessage())); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Added new command: " + e.getMessage()));
break; break;
case "panel.commands.remove": case "panel.commands.remove":
List<String> commandsRemove; List<String> commandsRemove;
if(cf.contains("commands")){ if(cf.contains("commands")){
commandsRemove = cf.getStringList("commands"); commandsRemove = cf.getStringList("commands");
}else{ }else{
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "No commands found to remove!")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "No commands found to remove!"));
break; break;
} }
try { try {
commandsRemove.remove(Integer.parseInt(e.getMessage())-1); commandsRemove.remove(Integer.parseInt(e.getMessage())-1);
}catch (Exception ex){ }catch (Exception ex){
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Could not find command!")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Could not find command!"));
break; break;
} }
if(commandsRemove.size() == 0){ if(commandsRemove.size() == 0){
@ -279,7 +279,7 @@ public class EditorUserInput implements Listener {
cf.set("commands", commandsRemove); cf.set("commands", commandsRemove);
} }
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Removed command line " + e.getMessage())); p.sendMessage(plugin.tex.colour( plugin.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<>();
@ -289,20 +289,20 @@ public class EditorUserInput implements Listener {
commandsOnOpenAdd.add(e.getMessage()); commandsOnOpenAdd.add(e.getMessage());
cf.set("commands-on-open", commandsOnOpenAdd); cf.set("commands-on-open", commandsOnOpenAdd);
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Added new command: " + e.getMessage())); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Added new command: " + e.getMessage()));
break; break;
case "panel.commands-on-open.remove": case "panel.commands-on-open.remove":
List<String> commandsOnOpenRemove; List<String> commandsOnOpenRemove;
if(cf.contains("commands-on-open")){ if(cf.contains("commands-on-open")){
commandsOnOpenRemove = cf.getStringList("commands-on-open"); commandsOnOpenRemove = cf.getStringList("commands-on-open");
}else{ }else{
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "No commands found to remove!")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "No commands found to remove!"));
break; break;
} }
try { try {
commandsOnOpenRemove.remove(Integer.parseInt(e.getMessage())-1); commandsOnOpenRemove.remove(Integer.parseInt(e.getMessage())-1);
}catch (Exception ex){ }catch (Exception ex){
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Could not find command!")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Could not find command!"));
break; break;
} }
if(commandsOnOpenRemove.size() == 0){ if(commandsOnOpenRemove.size() == 0){
@ -311,7 +311,7 @@ public class EditorUserInput implements Listener {
cf.set("commands-on-open", commandsOnOpenRemove); cf.set("commands-on-open", commandsOnOpenRemove);
} }
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Removed command line " + e.getMessage())); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Removed command line " + e.getMessage()));
break; break;
case "panel.disabled-worlds.add": case "panel.disabled-worlds.add":
List<String> disabledWorldsAdd = new ArrayList<>(); List<String> disabledWorldsAdd = new ArrayList<>();
@ -321,20 +321,20 @@ public class EditorUserInput implements Listener {
disabledWorldsAdd.add(e.getMessage()); disabledWorldsAdd.add(e.getMessage());
cf.set("disabled-worlds", disabledWorldsAdd); cf.set("disabled-worlds", disabledWorldsAdd);
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Added new World: " + e.getMessage())); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Added new World: " + e.getMessage()));
break; break;
case "panel.disabled-worlds.remove": case "panel.disabled-worlds.remove":
List<String> disabledWorldsRemove; List<String> disabledWorldsRemove;
if(cf.contains("disabled-worlds")){ if(cf.contains("disabled-worlds")){
disabledWorldsRemove = cf.getStringList("disabled-worlds"); disabledWorldsRemove = cf.getStringList("disabled-worlds");
}else{ }else{
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "No Worlds found to remove!")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "No Worlds found to remove!"));
break; break;
} }
try { try {
disabledWorldsRemove.remove(Integer.parseInt(e.getMessage())-1); disabledWorldsRemove.remove(Integer.parseInt(e.getMessage())-1);
}catch (Exception ex){ }catch (Exception ex){
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Could not find World!")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Could not find World!"));
break; break;
} }
if(disabledWorldsRemove.size() == 0){ if(disabledWorldsRemove.size() == 0){
@ -343,13 +343,13 @@ public class EditorUserInput implements Listener {
cf.set("disabled-worlds", disabledWorldsRemove); cf.set("disabled-worlds", disabledWorldsRemove);
} }
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Removed World line " + e.getMessage())); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Removed World line " + e.getMessage()));
break; break;
case "panel.hotbar.material": case "panel.hotbar.material":
if(e.getMessage().trim().equalsIgnoreCase("remove")){ if(e.getMessage().trim().equalsIgnoreCase("remove")){
cf.set("open-with-item", null); cf.set("open-with-item", null);
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Hotbar item have been removed.")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Hotbar item have been removed."));
//after an open-with-item has been altered, reload after changes //after an open-with-item has been altered, reload after changes
plugin.reloadPanelFiles(); plugin.reloadPanelFiles();
break; break;
@ -359,7 +359,7 @@ public class EditorUserInput implements Listener {
cf.set("open-with-item.name", panelName + " Item"); cf.set("open-with-item.name", panelName + " Item");
} }
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Set new Material to " + ChatColor.WHITE + e.getMessage())); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set new Material to " + ChatColor.WHITE + e.getMessage()));
//after an open-with-item has been altered, reload after changes //after an open-with-item has been altered, reload after changes
plugin.reloadPanelFiles(); plugin.reloadPanelFiles();
break; break;
@ -367,17 +367,17 @@ public class EditorUserInput implements Listener {
if(e.getMessage().trim().equalsIgnoreCase("remove")){ if(e.getMessage().trim().equalsIgnoreCase("remove")){
cf.set("open-with-item.stationary", null); cf.set("open-with-item.stationary", null);
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Hotbar item can now be moved.")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Hotbar item can now be moved."));
break; break;
} }
try { try {
int loc = Integer.parseInt(e.getMessage()); int loc = Integer.parseInt(e.getMessage());
if (loc >= 34 || loc <= -1) { if (loc >= 34 || loc <= -1) {
//if the number isn't between 1-9 //if the number isn't between 1-9
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Choose an integer between 0 to 33!")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Choose an integer between 0 to 33!"));
return; return;
} }
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Set Hotbar Location to " + loc + "!")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set Hotbar Location to " + loc + "!"));
//because it needs to convert 1-9 to 0-8 for in the panel //because it needs to convert 1-9 to 0-8 for in the panel
loc -= 1; loc -= 1;
cf.set("open-with-item.stationary", loc); cf.set("open-with-item.stationary", loc);
@ -389,7 +389,7 @@ public class EditorUserInput implements Listener {
case "panel.hotbar.name": case "panel.hotbar.name":
cf.set("open-with-item.name",e.getMessage()); cf.set("open-with-item.name",e.getMessage());
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Set new Name to " + ChatColor.WHITE + e.getMessage())); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set new Name to " + ChatColor.WHITE + e.getMessage()));
break; break;
case "panel.hotbar.lore.add": case "panel.hotbar.lore.add":
List<String> loreAdd = new ArrayList<>(); List<String> loreAdd = new ArrayList<>();
@ -399,20 +399,20 @@ public class EditorUserInput implements Listener {
loreAdd.add(e.getMessage()); loreAdd.add(e.getMessage());
cf.set("open-with-item.lore", loreAdd); cf.set("open-with-item.lore", loreAdd);
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Added new lore: " + e.getMessage())); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Added new lore: " + e.getMessage()));
break; break;
case "panel.hotbar.lore.remove": case "panel.hotbar.lore.remove":
List<String> loreRemove; List<String> loreRemove;
if(cf.contains("open-with-item.lore")){ if(cf.contains("open-with-item.lore")){
loreRemove = cf.getStringList("open-with-item.lore"); loreRemove = cf.getStringList("open-with-item.lore");
}else{ }else{
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "No lore found to remove!")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "No lore found to remove!"));
break; break;
} }
try { try {
loreRemove.remove(Integer.parseInt(e.getMessage())-1); loreRemove.remove(Integer.parseInt(e.getMessage())-1);
}catch (Exception ex){ }catch (Exception ex){
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Could not find lore!")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Could not find lore!"));
break; break;
} }
if(loreRemove.size() == 0){ if(loreRemove.size() == 0){
@ -421,7 +421,7 @@ public class EditorUserInput implements Listener {
cf.set("open-with-item.lore", loreRemove); cf.set("open-with-item.lore", loreRemove);
} }
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Removed lore line " + e.getMessage())); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Removed lore line " + e.getMessage()));
break; break;
case "panel.hotbar.commands.add": case "panel.hotbar.commands.add":
List<String> commandAdd = new ArrayList<>(); List<String> commandAdd = new ArrayList<>();
@ -431,20 +431,20 @@ public class EditorUserInput implements Listener {
commandAdd.add(e.getMessage()); commandAdd.add(e.getMessage());
cf.set("open-with-item.commands", commandAdd); cf.set("open-with-item.commands", commandAdd);
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Added new command: " + e.getMessage())); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Added new command: " + e.getMessage()));
break; break;
case "panel.hotbar.commands.remove": case "panel.hotbar.commands.remove":
List<String> commandRemove; List<String> commandRemove;
if(cf.contains("open-with-item.commands")){ if(cf.contains("open-with-item.commands")){
commandRemove = cf.getStringList("open-with-item.commands"); commandRemove = cf.getStringList("open-with-item.commands");
}else{ }else{
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "No commands found to remove!")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "No commands found to remove!"));
break; break;
} }
try { try {
commandRemove.remove(Integer.parseInt(e.getMessage())-1); commandRemove.remove(Integer.parseInt(e.getMessage())-1);
}catch (Exception ex){ }catch (Exception ex){
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Could not find command!")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Could not find command!"));
break; break;
} }
if(commandRemove.size() == 0){ if(commandRemove.size() == 0){
@ -453,7 +453,7 @@ public class EditorUserInput implements Listener {
cf.set("open-with-item.commands", commandRemove); cf.set("open-with-item.commands", commandRemove);
} }
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Removed command line " + e.getMessage())); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Removed command line " + e.getMessage()));
break; break;
} }
} }
@ -472,41 +472,41 @@ public class EditorUserInput implements Listener {
if(e.getMessage().trim().equalsIgnoreCase("remove")){ if(e.getMessage().trim().equalsIgnoreCase("remove")){
cf.set("item." + itemSlot + ".name", ""); cf.set("item." + itemSlot + ".name", "");
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Name is now default.")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Name is now default."));
break; break;
} }
cf.set("item." + itemSlot + ".name", e.getMessage()); cf.set("item." + itemSlot + ".name", e.getMessage());
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Set new name to " + ChatColor.WHITE + e.getMessage())); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set new name to " + ChatColor.WHITE + e.getMessage()));
break; break;
case "head": case "head":
if(e.getMessage().trim().equalsIgnoreCase("remove")){ if(e.getMessage().trim().equalsIgnoreCase("remove")){
cf.set("item." + itemSlot + ".material", plugin.getHeads.playerHeadString()); cf.set("item." + itemSlot + ".material", plugin.getHeads.playerHeadString());
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Material is now default.")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Material is now default."));
break; break;
} }
cf.set("item." + itemSlot + ".material", e.getMessage()); cf.set("item." + itemSlot + ".material", e.getMessage());
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Set Material value to " + ChatColor.WHITE + e.getMessage())); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set Material value to " + ChatColor.WHITE + e.getMessage()));
break; break;
case "stack": case "stack":
if(e.getMessage().trim().equalsIgnoreCase("remove")){ if(e.getMessage().trim().equalsIgnoreCase("remove")){
cf.set("item." + itemSlot + ".stack", null); cf.set("item." + itemSlot + ".stack", null);
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Item has been unstacked.")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Item has been unstacked."));
break; break;
} }
try { try {
int rows = Integer.parseInt(e.getMessage()); int rows = Integer.parseInt(e.getMessage());
if (rows >= 65 || rows <= 0) { if (rows >= 65 || rows <= 0) {
//if the number isn't between 1-64 //if the number isn't between 1-64
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Choose an integer between 1 to 64!")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Choose an integer between 1 to 64!"));
return; return;
} }
cf.set("item." + itemSlot + ".stack", rows); cf.set("item." + itemSlot + ".stack", rows);
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Set stack to " + rows + "!")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set stack to " + rows + "!"));
} catch (Exception io) { } catch (Exception io) {
plugin.debug(io,p); plugin.debug(io,p);
} }
@ -515,45 +515,45 @@ public class EditorUserInput implements Listener {
if(e.getMessage().trim().equalsIgnoreCase("remove")){ if(e.getMessage().trim().equalsIgnoreCase("remove")){
cf.set("item." + itemSlot + ".enchanted", null); cf.set("item." + itemSlot + ".enchanted", null);
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Enchantments have been removed.")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Enchantments have been removed."));
break; break;
} }
cf.set("item." + itemSlot + ".enchanted", e.getMessage()); cf.set("item." + itemSlot + ".enchanted", e.getMessage());
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Set new Enchantment to " + ChatColor.WHITE + e.getMessage())); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set new Enchantment to " + ChatColor.WHITE + e.getMessage()));
break; break;
case "potion": case "potion":
if(e.getMessage().trim().equalsIgnoreCase("remove")){ if(e.getMessage().trim().equalsIgnoreCase("remove")){
cf.set("item." + itemSlot + ".potion", null); cf.set("item." + itemSlot + ".potion", null);
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Potion effects have been removed.")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Potion effects have been removed."));
break; break;
} }
cf.set("item." + itemSlot + ".potion", e.getMessage()); cf.set("item." + itemSlot + ".potion", e.getMessage());
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Set new Potion to " + e.getMessage().toUpperCase())); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set new Potion to " + e.getMessage().toUpperCase()));
break; break;
case "customdata": case "customdata":
if(e.getMessage().trim().equalsIgnoreCase("remove")){ if(e.getMessage().trim().equalsIgnoreCase("remove")){
cf.set("item." + itemSlot + ".customdata", null); cf.set("item." + itemSlot + ".customdata", null);
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Custom Model Data has been removed.")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Custom Model Data has been removed."));
break; break;
} }
cf.set("item." + itemSlot + ".customdata", e.getMessage()); cf.set("item." + itemSlot + ".customdata", e.getMessage());
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Custom Model Data set to " + e.getMessage())); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Custom Model Data set to " + e.getMessage()));
break; break;
case "leatherarmor": case "leatherarmor":
if(e.getMessage().trim().equalsIgnoreCase("remove")){ if(e.getMessage().trim().equalsIgnoreCase("remove")){
cf.set("item." + itemSlot + ".leatherarmor", null); cf.set("item." + itemSlot + ".leatherarmor", null);
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Leather armor colour has been removed.")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Leather armor colour has been removed."));
break; break;
} }
cf.set("item." + itemSlot + ".leatherarmor", e.getMessage()); cf.set("item." + itemSlot + ".leatherarmor", e.getMessage());
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Leather armor colour set to " + e.getMessage())); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Leather armor colour set to " + e.getMessage()));
break; break;
case "commands:add": case "commands:add":
List<String> commandsOnOpenAdd = new ArrayList<>(); List<String> commandsOnOpenAdd = new ArrayList<>();
@ -563,20 +563,20 @@ public class EditorUserInput implements Listener {
commandsOnOpenAdd.add(e.getMessage()); commandsOnOpenAdd.add(e.getMessage());
cf.set("item." + itemSlot + ".commands", commandsOnOpenAdd); cf.set("item." + itemSlot + ".commands", commandsOnOpenAdd);
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Added new command: " + e.getMessage())); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Added new command: " + e.getMessage()));
break; break;
case "commands:remove": case "commands:remove":
List<String> commandsOnOpenRemove; List<String> commandsOnOpenRemove;
if(cf.contains("item." + itemSlot + ".commands")){ if(cf.contains("item." + itemSlot + ".commands")){
commandsOnOpenRemove = cf.getStringList("item." + itemSlot + ".commands"); commandsOnOpenRemove = cf.getStringList("item." + itemSlot + ".commands");
}else{ }else{
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "No commands found to remove!")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "No commands found to remove!"));
break; break;
} }
try { try {
commandsOnOpenRemove.remove(Integer.parseInt(e.getMessage())-1); commandsOnOpenRemove.remove(Integer.parseInt(e.getMessage())-1);
}catch (Exception ex){ }catch (Exception ex){
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Could not find command!")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Could not find command!"));
plugin.debug(ex,p); plugin.debug(ex,p);
break; break;
} }
@ -586,7 +586,7 @@ public class EditorUserInput implements Listener {
cf.set("item." + itemSlot + ".commands", commandsOnOpenRemove); cf.set("item." + itemSlot + ".commands", commandsOnOpenRemove);
} }
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Removed command line " + e.getMessage())); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Removed command line " + e.getMessage()));
break; break;
case "lore:add": case "lore:add":
List<String> loreOnOpenAdd = new ArrayList<>(); List<String> loreOnOpenAdd = new ArrayList<>();
@ -596,20 +596,20 @@ public class EditorUserInput implements Listener {
loreOnOpenAdd.add(e.getMessage()); loreOnOpenAdd.add(e.getMessage());
cf.set("item." + itemSlot + ".lore", loreOnOpenAdd); cf.set("item." + itemSlot + ".lore", loreOnOpenAdd);
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Added new lore: " + e.getMessage())); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Added new lore: " + e.getMessage()));
break; break;
case "lore:remove": case "lore:remove":
List<String> loreOnOpenRemove; List<String> loreOnOpenRemove;
if(cf.contains("item." + itemSlot + ".lore")){ if(cf.contains("item." + itemSlot + ".lore")){
loreOnOpenRemove = cf.getStringList("item." + itemSlot + ".lore"); loreOnOpenRemove = cf.getStringList("item." + itemSlot + ".lore");
}else{ }else{
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "No lore found to remove!")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "No lore found to remove!"));
break; break;
} }
try { try {
loreOnOpenRemove.remove(Integer.parseInt(e.getMessage())-1); loreOnOpenRemove.remove(Integer.parseInt(e.getMessage())-1);
}catch (Exception ex){ }catch (Exception ex){
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Could not find lore!")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Could not find lore!"));
plugin.debug(ex,p); plugin.debug(ex,p);
break; break;
} }
@ -619,7 +619,7 @@ public class EditorUserInput implements Listener {
cf.set("item." + itemSlot + ".lore", loreOnOpenRemove); cf.set("item." + itemSlot + ".lore", loreOnOpenRemove);
} }
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Removed lore line " + e.getMessage())); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Removed lore line " + e.getMessage()));
break; break;
case "duplicate:add": case "duplicate:add":
if(cf.contains("item." + itemSlot + ".duplicate")){ if(cf.contains("item." + itemSlot + ".duplicate")){
@ -628,7 +628,7 @@ public class EditorUserInput implements Listener {
cf.set("item." + itemSlot + ".duplicate", e.getMessage()); cf.set("item." + itemSlot + ".duplicate", e.getMessage());
} }
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Added new duplicate item/s: " + e.getMessage())); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Added new duplicate item/s: " + e.getMessage()));
break; break;
case "duplicate:remove": case "duplicate:remove":
if(cf.contains("item." + itemSlot + ".duplicate")){ if(cf.contains("item." + itemSlot + ".duplicate")){
@ -644,7 +644,7 @@ public class EditorUserInput implements Listener {
} }
cf.set("item." + itemSlot + ".duplicate", items.toString()); cf.set("item." + itemSlot + ".duplicate", items.toString());
} catch (Exception ex) { } catch (Exception ex) {
p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Could not delete or find item!")); p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Could not delete or find item!"));
plugin.debug(ex,p); plugin.debug(ex,p);
break; break;
} }
@ -655,11 +655,11 @@ public class EditorUserInput implements Listener {
cf.set("item." + itemSlot + ".duplicate", null); cf.set("item." + itemSlot + ".duplicate", null);
} }
}else{ }else{
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "No items found to remove!")); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "No items found to remove!"));
break; break;
} }
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Removed duplicate item/s: " + e.getMessage())); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Removed duplicate item/s: " + e.getMessage()));
break; break;
} }
} }
@ -682,19 +682,19 @@ public class EditorUserInput implements Listener {
cf.set("item." + itemSection + "." + playerMessage + ".name", ""); cf.set("item." + itemSection + "." + playerMessage + ".name", "");
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
plugin.reloadPanelFiles(); plugin.reloadPanelFiles();
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Added Section " + ChatColor.WHITE + playerMessage)); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Added Section " + ChatColor.WHITE + playerMessage));
break; break;
case "remove": case "remove":
cf.set("item." + itemSection + "." + playerMessage, null); cf.set("item." + itemSection + "." + playerMessage, null);
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
plugin.reloadPanelFiles(); plugin.reloadPanelFiles();
p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Removed Section " + ChatColor.WHITE + playerMessage)); p.sendMessage(plugin.tex.colour( plugin.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.tex.papi( plugin.tag + ChatColor.GREEN + "Set " + playerMessage.split(":")[0] + " to " + ChatColor.WHITE + playerMessage.split(":")[1])); p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set " + playerMessage.split(":")[0] + " to " + ChatColor.WHITE + playerMessage.split(":")[1]));
break; break;
} }
} }

View File

@ -35,7 +35,7 @@ public class EditorUtils implements Listener {
return; return;
} }
}catch(NullPointerException nu){return;} }catch(NullPointerException nu){return;}
if(!p.getOpenInventory().getTitle().equals(ChatColor.stripColor(plugin.tex.papi("Command Panels Editor"))) || plugin.openPanels.hasPanelOpen(p.getName())){ if(!p.getOpenInventory().getTitle().equals(ChatColor.stripColor(plugin.tex.colour("Command Panels Editor"))) || plugin.openPanels.hasPanelOpen(p.getName())){
return; return;
} }
if(e.getClickedInventory() != e.getView().getTopInventory()){ if(e.getClickedInventory() != e.getView().getTopInventory()){
@ -47,8 +47,8 @@ public class EditorUtils implements Listener {
ArrayList<ConfigurationSection> panelYaml = new ArrayList<ConfigurationSection>(); //all panels from ALL files (panel yaml files) ArrayList<ConfigurationSection> panelYaml = new ArrayList<ConfigurationSection>(); //all panels from ALL files (panel yaml files)
try { try {
for(Panel panel : plugin.panelList) { //will loop through all the files in folder for(Panel panel : plugin.panelList) { //will loop through all the files in folder
panelNames.add(plugin.tex.papi(panel.getName())); panelNames.add(plugin.tex.colour(panel.getName()));
panelTitles.add(plugin.tex.papi( Objects.requireNonNull(panel.getConfig().getString("title")))); panelTitles.add(plugin.tex.colour( Objects.requireNonNull(panel.getConfig().getString("title"))));
panelYaml.add(panel.getConfig()); panelYaml.add(panel.getConfig());
} }
}catch(Exception fail){ }catch(Exception fail){
@ -337,52 +337,52 @@ public class EditorUtils implements Listener {
} }
if(e.getSlot() == 1){ if(e.getSlot() == 1){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.perm"}); plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.perm"});
p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter New Permission")); p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Permission"));
p.closeInventory(); p.closeInventory();
} }
if(e.getSlot() == 3){ if(e.getSlot() == 3){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.title"}); plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.title"});
p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter New Title")); p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Title"));
p.closeInventory(); p.closeInventory();
} }
if(e.getSlot() == 5){ if(e.getSlot() == 5){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.sound-on-open"}); plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.sound-on-open"});
p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter New Sound ID")); p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Sound ID"));
p.closeInventory(); p.closeInventory();
} }
if(e.getSlot() == 7){ if(e.getSlot() == 7){
if(e.getClick().isLeftClick()) { if(e.getClick().isLeftClick()) {
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.commands.add"}); plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.commands.add"});
p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter New Command")); p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Command"));
}else{ }else{
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.commands.remove"}); plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.commands.remove"});
p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter Command to remove (must be an integer)")); p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter Command to remove (must be an integer)"));
} }
p.closeInventory(); p.closeInventory();
} }
if(e.getSlot() == 21){ if(e.getSlot() == 21){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.delete"}); plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.delete"});
p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Are you sure? (yes/no)")); p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Are you sure? (yes/no)"));
p.closeInventory(); p.closeInventory();
} }
if(e.getSlot() == 23){ if(e.getSlot() == 23){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.rows"}); plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.rows"});
p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter Row Amount (1 to 6)")); p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter Row Amount (1 to 6)"));
p.closeInventory(); p.closeInventory();
} }
if(e.getSlot() == 13){ if(e.getSlot() == 13){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.empty"}); plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.empty"});
p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter New Material ID")); p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Material ID"));
p.closeInventory(); p.closeInventory();
} }
if(e.getSlot() == 15){ if(e.getSlot() == 15){
//adds abilities to add and remove lines //adds abilities to add and remove lines
if(e.getClick().isLeftClick()) { if(e.getClick().isLeftClick()) {
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.commands-on-open.add"}); plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.commands-on-open.add"});
p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter New Command")); p.sendMessage(plugin.tex.colour(plugin.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.tex.papi(plugin.tag + ChatColor.WHITE + "Enter Command to remove (must be an integer)")); p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter Command to remove (must be an integer)"));
} }
p.closeInventory(); p.closeInventory();
} }
@ -390,10 +390,10 @@ public class EditorUtils implements Listener {
//adds abilities to add and remove types //adds abilities to add and remove types
if(e.getClick().isLeftClick()) { if(e.getClick().isLeftClick()) {
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.panelType.add"}); plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.panelType.add"});
p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter New Panel type")); p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Panel type"));
}else{ }else{
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.panelType.remove"}); plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.panelType.remove"});
p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter Panel Type to remove (must be an integer)")); p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter Panel Type to remove (must be an integer)"));
} }
p.closeInventory(); p.closeInventory();
} }
@ -401,16 +401,16 @@ public class EditorUtils implements Listener {
//adds abilities to add and remove lines //adds abilities to add and remove lines
if(e.getClick().isLeftClick()) { if(e.getClick().isLeftClick()) {
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.disabled-worlds.add"}); plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.disabled-worlds.add"});
p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter New World Name")); p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New World Name"));
}else{ }else{
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.disabled-worlds.remove"}); plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.disabled-worlds.remove"});
p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter World line to remove (must be an integer)")); p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter World line to remove (must be an integer)"));
} }
p.closeInventory(); p.closeInventory();
} }
if(e.getSlot() == 11){ if(e.getSlot() == 11){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.name"}); plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.name"});
p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter New Name")); p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Name"));
p.closeInventory(); p.closeInventory();
} }
if(e.getSlot() == 18){ if(e.getSlot() == 18){
@ -419,38 +419,38 @@ public class EditorUtils implements Listener {
} }
if(e.getSlot() == 40){ if(e.getSlot() == 40){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.material"}); plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.material"});
p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter New Material")); p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Material"));
p.closeInventory(); p.closeInventory();
} }
if(e.getSlot() == 38 && hotbarItems){ if(e.getSlot() == 38 && hotbarItems){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.name"}); plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.name"});
p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter New Name")); p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Name"));
p.closeInventory(); p.closeInventory();
} }
if(e.getSlot() == 36 && hotbarItems){ if(e.getSlot() == 36 && hotbarItems){
//adds abilities to add and remove lines //adds abilities to add and remove lines
if(e.getClick().isLeftClick()) { if(e.getClick().isLeftClick()) {
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.lore.add"}); plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.lore.add"});
p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter New Item Lore")); p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Item Lore"));
}else{ }else{
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.lore.remove"}); plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.lore.remove"});
p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter lore line to remove (must be an integer)")); p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter lore line to remove (must be an integer)"));
} }
p.closeInventory(); p.closeInventory();
} }
if(e.getSlot() == 42 && hotbarItems){ if(e.getSlot() == 42 && hotbarItems){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.stationary"}); plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.stationary"});
p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter Location (1 to 9)")); p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter Location (1 to 9)"));
p.closeInventory(); p.closeInventory();
} }
if(e.getSlot() == 44 && hotbarItems){ if(e.getSlot() == 44 && hotbarItems){
//adds abilities to add and remove lines //adds abilities to add and remove lines
if(e.getClick().isLeftClick()) { if(e.getClick().isLeftClick()) {
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.commands.add"}); plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.commands.add"});
p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter New Item Command")); p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Item Command"));
}else{ }else{
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.commands.remove"}); plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.commands.remove"});
p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter command line to remove (must be an integer)")); p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter command line to remove (must be an integer)"));
} }
p.closeInventory(); p.closeInventory();
} }
@ -494,38 +494,38 @@ public class EditorUtils implements Listener {
} }
if(e.getSlot() == 1){ if(e.getSlot() == 1){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item:" + itemSlot + ":name"}); plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item:" + itemSlot + ":name"});
p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter New Item Name")); p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Item Name"));
p.closeInventory(); p.closeInventory();
} }
if(e.getSlot() == 3){ if(e.getSlot() == 3){
//adds abilities to add and remove lines //adds abilities to add and remove lines
if(e.getClick().isLeftClick()) { if(e.getClick().isLeftClick()) {
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "item:" + itemSlot + ":commands:add"}); plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "item:" + itemSlot + ":commands:add"});
p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter New Item Command")); p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Item Command"));
}else{ }else{
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "item:" + itemSlot + ":commands:remove"}); plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "item:" + itemSlot + ":commands:remove"});
p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter command line to remove (must be an integer)")); p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter command line to remove (must be an integer)"));
} }
p.closeInventory(); p.closeInventory();
} }
if(e.getSlot() == 5){ if(e.getSlot() == 5){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item:" + itemSlot + ":enchanted"}); plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item:" + itemSlot + ":enchanted"});
p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter New Item Enchantment")); p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Item Enchantment"));
p.closeInventory(); p.closeInventory();
} }
if(e.getSlot() == 7){ if(e.getSlot() == 7){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item:" + itemSlot + ":potion"}); plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item:" + itemSlot + ":potion"});
p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter New Item Potion Effect")); p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Item Potion Effect"));
p.closeInventory(); p.closeInventory();
} }
if(e.getSlot() == 13){ if(e.getSlot() == 13){
//adds abilities to add and remove items //adds abilities to add and remove items
if(e.getClick().isLeftClick()) { if(e.getClick().isLeftClick()) {
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "item:" + itemSlot + ":duplicate:add"}); plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "item:" + itemSlot + ":duplicate:add"});
p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter Duplicate Item Location/s")); p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter Duplicate Item Location/s"));
}else{ }else{
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "item:" + itemSlot + ":duplicate:remove"}); plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "item:" + itemSlot + ":duplicate:remove"});
p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter Duplicate Item/s to Remove (must be an integer)")); p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter Duplicate Item/s to Remove (must be an integer)"));
} }
p.closeInventory(); p.closeInventory();
} }
@ -533,26 +533,26 @@ public class EditorUtils implements Listener {
//adds abilities to add and remove lines //adds abilities to add and remove lines
if(e.getClick().isLeftClick()) { if(e.getClick().isLeftClick()) {
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "item:" + itemSlot + ":lore:add"}); plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "item:" + itemSlot + ":lore:add"});
p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter New Item Lore")); p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Item Lore"));
}else{ }else{
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "item:" + itemSlot + ":lore:remove"}); plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "item:" + itemSlot + ":lore:remove"});
p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter lore line to remove (must be an integer)")); p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter lore line to remove (must be an integer)"));
} }
p.closeInventory(); p.closeInventory();
} }
if(e.getSlot() == 21){ if(e.getSlot() == 21){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item:" + itemSlot + ":stack"}); plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item:" + itemSlot + ":stack"});
p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter New Item Stack (must be an integer)")); p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Item Stack (must be an integer)"));
p.closeInventory(); p.closeInventory();
} }
if(e.getSlot() == 23){ if(e.getSlot() == 23){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item:" + itemSlot + ":customdata"}); plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item:" + itemSlot + ":customdata"});
p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter New Custom Model Data")); p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Custom Model Data"));
p.closeInventory(); p.closeInventory();
} }
if(e.getSlot() == 25){ if(e.getSlot() == 25){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item:" + itemSlot + ":leatherarmor"}); plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item:" + itemSlot + ":leatherarmor"});
p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter New Leather Armor Colour")); p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Leather Armor Colour"));
p.closeInventory(); p.closeInventory();
} }
if(e.getSlot() == 31){ if(e.getSlot() == 31){
@ -562,7 +562,7 @@ public class EditorUtils implements Listener {
} }
if(e.getSlot() == 35){ if(e.getSlot() == 35){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item:" + itemSlot + ":head"}); plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item:" + itemSlot + ":head"});
p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter New Custom Material (eg. cps= self)")); p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Custom Material (eg. cps= self)"));
p.closeInventory(); p.closeInventory();
} }
if(e.getSlot() == 27){ if(e.getSlot() == 27){
@ -627,7 +627,7 @@ public class EditorUtils implements Listener {
}else{ }else{
String itemNameSection = "." + ChatColor.stripColor(e.getInventory().getItem(e.getSlot()).getItemMeta().getDisplayName()); String itemNameSection = "." + ChatColor.stripColor(e.getInventory().getItem(e.getSlot()).getItemMeta().getDisplayName());
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"section.change." + section + itemNameSection}); plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"section.change." + section + itemNameSection});
p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter Setting to change, eg, value:500")); p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter Setting to change, eg, value:500"));
p.closeInventory(); p.closeInventory();
} }
} }
@ -635,13 +635,13 @@ public class EditorUtils implements Listener {
if(e.getSlot() == 38){ if(e.getSlot() == 38){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"section.remove." + section}); plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"section.remove." + section});
p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter Section name to remove, eg, hasperm or hasperm0")); p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter Section name to remove, eg, hasperm or hasperm0"));
p.closeInventory(); p.closeInventory();
} }
if(e.getSlot() == 42){ if(e.getSlot() == 42){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"section.add." + section}); plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"section.add." + section});
p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter Section name to add, eg, hasperm or hasperm0")); p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter Section name to add, eg, hasperm or hasperm0"));
p.closeInventory(); p.closeInventory();
} }
@ -720,9 +720,9 @@ public class EditorUtils implements Listener {
config = plugin.itemCreate.generatePanelFile(panelName,inv,config); config = plugin.itemCreate.generatePanelFile(panelName,inv,config);
try { try {
config.save(file); config.save(file);
p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.GREEN + "Saved Changes!")); p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.GREEN + "Saved Changes!"));
} catch (IOException s) { } catch (IOException s) {
p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Could Not Save Changes!")); p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Could Not Save Changes!"));
plugin.debug(s,p); plugin.debug(s,p);
} }
plugin.reloadPanelFiles(); plugin.reloadPanelFiles();

View File

@ -19,7 +19,7 @@ public class CommandpanelUserInput implements Listener {
if(plugin.userInputStrings.get(o)[0].equals(e.getPlayer().getName())){ if(plugin.userInputStrings.get(o)[0].equals(e.getPlayer().getName())){
if(e.getMessage().equalsIgnoreCase(plugin.config.getString("config.input-cancel"))){ if(e.getMessage().equalsIgnoreCase(plugin.config.getString("config.input-cancel"))){
e.setCancelled(true); e.setCancelled(true);
e.getPlayer().sendMessage(plugin.tex.papi( Objects.requireNonNull(plugin.config.getString("config.input-cancelled")))); e.getPlayer().sendMessage(plugin.tex.colour( Objects.requireNonNull(plugin.config.getString("config.input-cancelled"))));
for(int i = 0; plugin.userInputStrings.size() > i; i++){ for(int i = 0; plugin.userInputStrings.size() > i; i++){
if(plugin.userInputStrings.get(i)[0].equals(e.getPlayer().getName())){ if(plugin.userInputStrings.get(i)[0].equals(e.getPlayer().getName())){
plugin.userInputStrings.remove(i); plugin.userInputStrings.remove(i);

View File

@ -3,7 +3,6 @@ package me.rockyhawk.commandpanels.interactives;
import me.rockyhawk.commandpanels.CommandPanels; import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.Panel; import me.rockyhawk.commandpanels.api.Panel;
import me.rockyhawk.commandpanels.api.PanelOpenedEvent; import me.rockyhawk.commandpanels.api.PanelOpenedEvent;
import me.rockyhawk.commandpanels.ioclasses.nbt.NBT_1_13;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
@ -22,13 +21,13 @@ public class Commandpanelrefresher implements Listener {
} }
@EventHandler @EventHandler
public void onPanelOpen(PanelOpenedEvent e){ //Handles when Players open inventory public void onPanelOpen(PanelOpenedEvent e){ //Handles when Players open inventory
//I have to convert HumanEntity to a player
if (plugin.config.contains("config.refresh-panels")) { if (plugin.config.contains("config.refresh-panels")) {
if (Objects.requireNonNull(plugin.config.getString("config.refresh-panels")).trim().equalsIgnoreCase("false")) { if (Objects.requireNonNull(plugin.config.getString("config.refresh-panels")).trim().equalsIgnoreCase("false")) {
return; return;
} }
} }
//I have to convert HumanEntity to a player
Player p = e.getPlayer(); Player p = e.getPlayer();
Panel pn = e.getPanel(); Panel pn = e.getPanel();

View File

@ -10,11 +10,12 @@ public class NBTManager {
this.plugin = pl; this.plugin = pl;
} }
//commandpanel item NBT
public boolean hasNBT(ItemStack item){ public boolean hasNBT(ItemStack item){
if(plugin.legacy.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_13)){ if(plugin.legacy.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_13)){
return new NBT_1_13().contains(item, "CommandPanelsItem"); return new NBT_1_13().contains(item, "CommandPanelsItem");
}else{ }else{
return new NBT_1_14(plugin).hasNBT(item); return new NBT_1_14(plugin).hasNBT(item,"CommandPanelsItem");
} }
} }
@ -22,7 +23,28 @@ public class NBTManager {
if(plugin.legacy.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_13)){ if(plugin.legacy.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_13)){
return new NBT_1_13().set(item,1,"CommandPanelsItem"); return new NBT_1_13().set(item,1,"CommandPanelsItem");
}else{ }else{
return new NBT_1_14(plugin).addNBT(item); return new NBT_1_14(plugin).addNBT(item,"CommandPanelsItem","1");
}
}
//custom key NBT
public String getNBT(ItemStack item, String key){
String output = "";
if(plugin.legacy.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_13)){
try{
output = new NBT_1_13().getString(item, key);
}catch(NullPointerException ignore){}
}else{
output = new NBT_1_14(plugin).getNBT(item, key);
}
return output;
}
public ItemStack setNBT(ItemStack item, String key, String value){
if(plugin.legacy.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_13)){
return new NBT_1_13().set(item,value,key);
}else{
return new NBT_1_14(plugin).addNBT(item,key,value);
} }
} }
} }

View File

@ -13,17 +13,32 @@ public class NBT_1_14 {
} }
//NBT class for Minecraft versions 1.14+ //NBT class for Minecraft versions 1.14+
public ItemStack addNBT(ItemStack item){ public ItemStack addNBT(ItemStack item, String key, String value){
NamespacedKey key = new NamespacedKey(plugin, "CommandPanelsItem"); NamespacedKey ns_key = new NamespacedKey(plugin, key);
ItemMeta itemMeta = item.getItemMeta(); ItemMeta itemMeta = item.getItemMeta();
itemMeta.getPersistentDataContainer().set(key, PersistentDataType.INTEGER, 1); itemMeta.getPersistentDataContainer().set(ns_key, PersistentDataType.STRING, value);
item.setItemMeta(itemMeta); item.setItemMeta(itemMeta);
return item; return item;
} }
public boolean hasNBT(ItemStack item){ public boolean hasNBT(ItemStack item, String key){
NamespacedKey key = new NamespacedKey(plugin, "CommandPanelsItem"); NamespacedKey ns_key = new NamespacedKey(plugin, key);
ItemMeta itemMeta = item.getItemMeta(); try {
return itemMeta.getPersistentDataContainer().has(key, PersistentDataType.INTEGER); ItemMeta itemMeta = item.getItemMeta();
return itemMeta.getPersistentDataContainer().has(ns_key, PersistentDataType.STRING);
}catch (Exception e){
return false;
}
}
public String getNBT(ItemStack item, String key){
NamespacedKey ns_key = new NamespacedKey(plugin, key);
try {
ItemMeta itemMeta = item.getItemMeta();
return itemMeta.getPersistentDataContainer().get(ns_key, PersistentDataType.STRING);
}catch (Exception e){
plugin.debug(e,null);
return "";
}
} }
} }

View File

@ -2,7 +2,6 @@ package me.rockyhawk.commandpanels.openpanelsmanager;
import me.rockyhawk.commandpanels.CommandPanels; import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.Panel; import me.rockyhawk.commandpanels.api.Panel;
import me.rockyhawk.commandpanels.ioclasses.nbt.NBT_1_13;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
@ -28,7 +27,7 @@ public class OpenGUI {
String title; String title;
if (onOpen != 3) { if (onOpen != 3) {
//regular inventory //regular inventory
title = plugin.tex.papi(panel,p,pconfig.getString("title")); title = plugin.tex.placeholders(panel,p,pconfig.getString("title"));
} else { } else {
//editor inventory //editor inventory
title = "Editing Panel: " + panel.getName(); title = "Editing Panel: " + panel.getName();
@ -111,7 +110,7 @@ public class OpenGUI {
} catch (ArrayIndexOutOfBoundsException var24) { } catch (ArrayIndexOutOfBoundsException var24) {
plugin.debug(var24,p); plugin.debug(var24,p);
if (plugin.debug.isEnabled(p)) { if (plugin.debug.isEnabled(p)) {
p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " item: One of the items does not fit in the Panel!")); p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " item: One of the items does not fit in the Panel!"));
p.closeInventory(); p.closeInventory();
plugin.openPanels.closePanelForLoader(p.getName()); plugin.openPanels.closePanelForLoader(p.getName());
} }
@ -149,7 +148,7 @@ public class OpenGUI {
} }
} catch (IllegalArgumentException | NullPointerException var26) { } catch (IllegalArgumentException | NullPointerException var26) {
plugin.debug(var26,p); plugin.debug(var26,p);
p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " empty: " + pconfig.getString("empty"))); p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " empty: " + pconfig.getString("empty")));
p.closeInventory(); p.closeInventory();
plugin.openPanels.closePanelForLoader(p.getName()); plugin.openPanels.closePanelForLoader(p.getName());
return null; return null;

View File

@ -63,6 +63,9 @@ public class HotbarItemLoader {
//return true if found //return true if found
public boolean itemCheckExecute(ItemStack invItem, Player p, boolean openPanel, boolean stationaryOnly){ public boolean itemCheckExecute(ItemStack invItem, Player p, boolean openPanel, boolean stationaryOnly){
if(plugin.nbt.getNBT(invItem,"CommandPanelsHotbar") == null){
return false;
}
for(Panel panel : plugin.panelList) { for(Panel panel : plugin.panelList) {
if(stationaryOnly){ if(stationaryOnly){
if(!panel.getConfig().contains("open-with-item.stationary")){ if(!panel.getConfig().contains("open-with-item.stationary")){
@ -70,13 +73,7 @@ public class HotbarItemLoader {
} }
} }
if(panel.hasHotbarItem()){ if(panel.hasHotbarItem()){
ItemStack panelItem = panel.getHotbarItem(p); if(plugin.nbt.getNBT(invItem,"CommandPanelsHotbar").equals(panel.getName())){
if(invItem != null && panelItem != null) {
panelItem.setAmount(invItem.getAmount());
}else{
return false;
}
if(panelItem.isSimilar(invItem)){
if(openPanel) { if(openPanel) {
//only open panel automatically if there are no commands and if world is not disabled //only open panel automatically if there are no commands and if world is not disabled
if(!plugin.panelPerms.isPanelWorldEnabled(p,panel.getConfig())){ if(!plugin.panelPerms.isPanelWorldEnabled(p,panel.getConfig())){

View File

@ -43,13 +43,8 @@ public class UtilsOpenWithItem implements Listener {
if (plugin.hotbar.stationaryExecute(e.getSlot(), p, true)) { if (plugin.hotbar.stationaryExecute(e.getSlot(), p, true)) {
e.setCancelled(true); e.setCancelled(true);
p.updateInventory(); p.updateInventory();
return;
} }
} }
if (plugin.hotbar.itemCheckExecute(e.getCurrentItem(), p, false,true) || plugin.hotbar.itemCheckExecute(e.getCursor(), p, false,true) || plugin.hotbar.stationaryExecute(e.getHotbarButton(), p, false)) {
e.setCancelled(true);
p.updateInventory();
}
} }
@EventHandler @EventHandler
public void onPlayerUse(PlayerInteractEvent e){ public void onPlayerUse(PlayerInteractEvent e){

View File

@ -26,13 +26,13 @@ public class Commandpanelblocks implements CommandExecutor {
if(args.length >= 2) { if(args.length >= 2) {
if (args[0].equalsIgnoreCase("add")) { if (args[0].equalsIgnoreCase("add")) {
if(!(sender instanceof Player)) { if(!(sender instanceof Player)) {
sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Please execute command as a Player!")); sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Please execute command as a Player!"));
return true; return true;
} }
Player p = (Player)sender; Player p = (Player)sender;
if(p.hasPermission("commandpanel.block.add")){ if(p.hasPermission("commandpanel.block.add")){
if(Objects.requireNonNull(plugin.config.getString("config.panel-blocks")).equalsIgnoreCase("false")){ if(Objects.requireNonNull(plugin.config.getString("config.panel-blocks")).equalsIgnoreCase("false")){
sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Panel blocks disabled in config!")); sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Panel blocks disabled in config!"));
return true; return true;
} }
boolean foundPanel = false; boolean foundPanel = false;
@ -43,12 +43,12 @@ public class Commandpanelblocks implements CommandExecutor {
} }
} }
if(!foundPanel){ if(!foundPanel){
sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.nopanel"))); sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.nopanel")));
return true; return true;
} }
Block blockType = p.getTargetBlock(null, 5); Block blockType = p.getTargetBlock(null, 5);
if(blockType.getType() == Material.AIR){ if(blockType.getType() == Material.AIR){
sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Look at a block to add a panel!")); sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Look at a block to add a panel!"));
return true; return true;
} }
Location blockLocation = blockType.getLocation(); Location blockLocation = blockType.getLocation();
@ -60,15 +60,15 @@ public class Commandpanelblocks implements CommandExecutor {
plugin.blockConfig.save(new File(plugin.getDataFolder() + File.separator + "blocks.yml")); plugin.blockConfig.save(new File(plugin.getDataFolder() + File.separator + "blocks.yml"));
} catch (IOException e) { } catch (IOException e) {
plugin.debug(e,p); plugin.debug(e,p);
sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Could not save to file!")); sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Could not save to file!"));
return true; return true;
} }
//make the material name look okay //make the material name look okay
String materialNameFormatted = blockType.getType().toString().substring(0, 1).toUpperCase() + blockType.getType().toString().substring(1).toLowerCase(); String materialNameFormatted = blockType.getType().toString().substring(0, 1).toUpperCase() + blockType.getType().toString().substring(1).toLowerCase();
materialNameFormatted = materialNameFormatted.replaceAll("_"," "); materialNameFormatted = materialNameFormatted.replaceAll("_"," ");
sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + args[1] + ChatColor.GREEN + " will now open when right clicking " + ChatColor.WHITE + materialNameFormatted)); sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + args[1] + ChatColor.GREEN + " will now open when right clicking " + ChatColor.WHITE + materialNameFormatted));
}else{ }else{
sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.perms"))); sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
} }
return true; return true;
} }
@ -76,13 +76,13 @@ public class Commandpanelblocks implements CommandExecutor {
if(args.length == 1){ if(args.length == 1){
if (args[0].equalsIgnoreCase("remove")) { if (args[0].equalsIgnoreCase("remove")) {
if(!(sender instanceof Player)) { if(!(sender instanceof Player)) {
sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Please execute command as a Player!")); sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Please execute command as a Player!"));
return true; return true;
} }
Player p = (Player)sender; Player p = (Player)sender;
if(p.hasPermission("commandpanel.block.remove")){ if(p.hasPermission("commandpanel.block.remove")){
if(Objects.requireNonNull(plugin.config.getString("config.panel-blocks")).equalsIgnoreCase("false")){ if(Objects.requireNonNull(plugin.config.getString("config.panel-blocks")).equalsIgnoreCase("false")){
sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Panel blocks disabled in config!")); sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Panel blocks disabled in config!"));
return true; return true;
} }
Block blockType = p.getTargetBlock(null, 5); Block blockType = p.getTargetBlock(null, 5);
@ -94,38 +94,38 @@ public class Commandpanelblocks implements CommandExecutor {
plugin.blockConfig.save(new File(plugin.getDataFolder() + File.separator + "blocks.yml")); plugin.blockConfig.save(new File(plugin.getDataFolder() + File.separator + "blocks.yml"));
} catch (IOException e) { } catch (IOException e) {
plugin.debug(e,p); plugin.debug(e,p);
sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Could not save to file!")); sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Could not save to file!"));
return true; return true;
} }
sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.GREEN + "Panel has been removed from block.")); sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.GREEN + "Panel has been removed from block."));
}else{ }else{
sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.nopanel"))); sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.nopanel")));
} }
}else{ }else{
sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.perms"))); sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
} }
return true; return true;
} }
if (args[0].equalsIgnoreCase("list")) { if (args[0].equalsIgnoreCase("list")) {
if(sender.hasPermission("commandpanel.block.list")){ if(sender.hasPermission("commandpanel.block.list")){
if(Objects.requireNonNull(plugin.config.getString("config.panel-blocks")).equalsIgnoreCase("false")){ if(Objects.requireNonNull(plugin.config.getString("config.panel-blocks")).equalsIgnoreCase("false")){
sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Panel blocks disabled in config!")); sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Panel blocks disabled in config!"));
return true; return true;
} }
if(plugin.blockConfig.contains("blocks")){ if(plugin.blockConfig.contains("blocks")){
if(Objects.requireNonNull(plugin.blockConfig.getConfigurationSection("blocks")).getKeys(false).size() == 0){ if(Objects.requireNonNull(plugin.blockConfig.getConfigurationSection("blocks")).getKeys(false).size() == 0){
sender.sendMessage(plugin.tex.papi(plugin.tag) + ChatColor.RED + "No panel blocks found."); sender.sendMessage(plugin.tex.colour(plugin.tag) + ChatColor.RED + "No panel blocks found.");
return true; return true;
} }
sender.sendMessage(plugin.tex.papi(plugin.tag) + ChatColor.DARK_AQUA + "Panel Block Locations:"); sender.sendMessage(plugin.tex.colour(plugin.tag) + ChatColor.DARK_AQUA + "Panel Block Locations:");
for (String location : Objects.requireNonNull(plugin.blockConfig.getConfigurationSection("blocks")).getKeys(false)) { for (String location : Objects.requireNonNull(plugin.blockConfig.getConfigurationSection("blocks")).getKeys(false)) {
sender.sendMessage(ChatColor.GREEN + location.replaceAll("_"," ") + ": " + ChatColor.WHITE + plugin.blockConfig.getString("blocks." + location + ".panel")); sender.sendMessage(ChatColor.GREEN + location.replaceAll("_"," ") + ": " + ChatColor.WHITE + plugin.blockConfig.getString("blocks." + location + ".panel"));
} }
}else{ }else{
sender.sendMessage(plugin.tex.papi(plugin.tag) + ChatColor.RED + "No panel blocks found."); sender.sendMessage(plugin.tex.colour(plugin.tag) + ChatColor.RED + "No panel blocks found.");
} }
}else{ }else{
sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.perms"))); sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
} }
return true; return true;
} }