This commit is contained in:
rockyhawk64 2021-04-02 19:49:03 +11:00
parent b26a880b00
commit 1a42ecfb02
32 changed files with 660 additions and 608 deletions

View File

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

View File

@ -7,14 +7,14 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import io.lumine.mythic.lib.api.item.NBTItem; import io.lumine.mythic.lib.api.item.NBTItem;
import me.clip.placeholderapi.PlaceholderAPI;
import me.rockyhawk.commandpanels.api.CommandPanelsAPI; import me.rockyhawk.commandpanels.api.CommandPanelsAPI;
import me.rockyhawk.commandpanels.api.Panel; import me.rockyhawk.commandpanels.api.Panel;
import me.rockyhawk.commandpanels.classresources.*; import me.rockyhawk.commandpanels.classresources.*;
import me.rockyhawk.commandpanels.classresources.item_fall.ItemFallManager; import me.rockyhawk.commandpanels.classresources.item_fall.ItemFallManager;
import me.rockyhawk.commandpanels.classresources.placeholders.CreateText;
import me.rockyhawk.commandpanels.classresources.placeholders.Placeholders;
import me.rockyhawk.commandpanels.commands.*; import me.rockyhawk.commandpanels.commands.*;
import me.rockyhawk.commandpanels.completetabs.CpTabComplete; import me.rockyhawk.commandpanels.completetabs.CpTabComplete;
import me.rockyhawk.commandpanels.customcommands.CommandPlaceholderLoader;
import me.rockyhawk.commandpanels.customcommands.Commandpanelcustom; import me.rockyhawk.commandpanels.customcommands.Commandpanelcustom;
import me.rockyhawk.commandpanels.datamanager.DebugManager; import me.rockyhawk.commandpanels.datamanager.DebugManager;
import me.rockyhawk.commandpanels.datamanager.PanelDataLoader; import me.rockyhawk.commandpanels.datamanager.PanelDataLoader;
@ -75,6 +75,7 @@ public class CommandPanels extends JavaPlugin{
public PanelDataLoader panelData = new PanelDataLoader(this); public PanelDataLoader panelData = new PanelDataLoader(this);
public Placeholders placeholders = new Placeholders(this); public Placeholders placeholders = new Placeholders(this);
public DebugManager debug = new DebugManager(this); public DebugManager debug = new DebugManager(this);
public CreateText tex = new CreateText(this);
public OpenEditorGuis editorGuis = new OpenEditorGuis(this); public OpenEditorGuis editorGuis = new OpenEditorGuis(this);
public ExecuteOpenVoids openVoids = new ExecuteOpenVoids(this); public ExecuteOpenVoids openVoids = new ExecuteOpenVoids(this);
@ -87,7 +88,6 @@ public class CommandPanels extends JavaPlugin{
public OpenPanelsLoader openPanels = new OpenPanelsLoader(this); public OpenPanelsLoader openPanels = new OpenPanelsLoader(this);
public OpenGUI createGUI = new OpenGUI(this); public OpenGUI createGUI = new OpenGUI(this);
public PanelPermissions panelPerms = new PanelPermissions(this); public PanelPermissions panelPerms = new PanelPermissions(this);
public CommandPlaceholderLoader customCommand = new CommandPlaceholderLoader(this);
public HotbarItemLoader hotbar = new HotbarItemLoader(this); public HotbarItemLoader hotbar = new HotbarItemLoader(this);
public File panelsf; public File panelsf;
@ -221,7 +221,10 @@ public class CommandPanels extends JavaPlugin{
})); }));
//get tag //get tag
tag = papi(config.getString("config.format.tag") + " "); tag = tex.papi(config.getString("config.format.tag") + " ");
//set version to latest version
updater.githubNewUpdate(false);
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!");
} }
@ -238,15 +241,15 @@ public class CommandPanels extends JavaPlugin{
return new CommandPanelsAPI(JavaPlugin.getPlugin(CommandPanels.class)); return new CommandPanelsAPI(JavaPlugin.getPlugin(CommandPanels.class));
} }
public void setName(ItemStack renamed, String customName, List<String> lore, Player p, Boolean usePlaceholders, Boolean useColours, Boolean hideAttributes) { public void setName(Panel panel, ItemStack renamed, String customName, List<String> lore, Player p, Boolean usePlaceholders, Boolean useColours, Boolean hideAttributes) {
try { try {
ItemMeta renamedMeta = renamed.getItemMeta(); ItemMeta renamedMeta = renamed.getItemMeta();
//set cp placeholders //set cp placeholders
if(usePlaceholders){ if(usePlaceholders){
customName = papiNoColour(p,customName); customName = tex.papiNoColour(panel,p,customName);
} }
if(useColours){ if(useColours){
customName = papi(customName); customName = tex.papi(customName);
} }
assert renamedMeta != null; assert renamedMeta != null;
@ -261,11 +264,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 = papi(p, lore, true); clore = tex.papi(panel, p, lore, true);
}else if(usePlaceholders){ }else if(usePlaceholders){
clore = papiNoColour(p, lore); clore = tex.papiNoColour(panel,p, lore);
}else if(useColours){ }else if(useColours){
clore = papi(p, lore, false); clore = tex.papi(panel, p, lore, false);
}else{ }else{
clore = lore; clore = lore;
} }
@ -296,94 +299,6 @@ public class CommandPanels extends JavaPlugin{
} }
} }
//regular string papi
public String papi(Player p, String setpapi) {
try {
setpapi = placeholders.setCpPlaceholders(p,setpapi);
if (this.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
OfflinePlayer offp = getServer().getOfflinePlayer(p.getUniqueId());
setpapi = PlaceholderAPI.setPlaceholders(offp, setpapi);
}
setpapi = translateHexColorCodes(ChatColor.translateAlternateColorCodes('&', setpapi));
return setpapi;
}catch(NullPointerException e){
return setpapi;
}
}
//string papi with no colours
public String papiNoColour(Player p, String setpapi) {
try {
setpapi = placeholders.setCpPlaceholders(p,setpapi);
if (this.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
OfflinePlayer offp = getServer().getOfflinePlayer(p.getUniqueId());
setpapi = PlaceholderAPI.setPlaceholders(offp, setpapi);
}
return setpapi;
}catch(NullPointerException e){
return setpapi;
}
}
//regular string papi, but only colours so Player doesn't need to be there
public String papi(String setpapi) {
try {
setpapi = translateHexColorCodes(ChatColor.translateAlternateColorCodes('&', setpapi));
return setpapi;
}catch(NullPointerException e){
return setpapi;
}
}
//papi except if it is a String List
public List<String> papi(Player p, List<String> setpapi, boolean placeholder) {
try {
if(placeholder) {
int tempInt = 0;
for (String temp : setpapi) {
setpapi.set(tempInt, placeholders.setCpPlaceholders(p, temp));
tempInt += 1;
}
if (this.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
OfflinePlayer offp = getServer().getOfflinePlayer(p.getUniqueId());
setpapi = PlaceholderAPI.setPlaceholders(offp, setpapi);
}
}
}catch(Exception ignore){
//this will be ignored as it is probably a null
return null;
}
int tempInt = 0;
//change colour
for(String temp : setpapi){
try {
setpapi.set(tempInt, translateHexColorCodes(ChatColor.translateAlternateColorCodes('&', temp)));
}catch(NullPointerException ignore){
}
tempInt += 1;
}
return setpapi;
}
//papi except if it is a String List
public List<String> papiNoColour(Player p, List<String> setpapi) {
try {
int tempInt = 0;
for (String temp : setpapi) {
setpapi.set(tempInt, placeholders.setCpPlaceholders(p, temp));
tempInt += 1;
}
if (this.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
OfflinePlayer offp = getServer().getOfflinePlayer(p.getUniqueId());
setpapi = PlaceholderAPI.setPlaceholders(offp, setpapi);
}
}catch(Exception ignore){
//this will be ignored as it is probably a null
return null;
}
return setpapi;
}
//check for duplicate panel names //check for duplicate panel names
public boolean checkDuplicatePanel(CommandSender sender){ public boolean checkDuplicatePanel(CommandSender sender){
ArrayList<String> apanels = new ArrayList<>(); ArrayList<String> apanels = new ArrayList<>();
@ -398,7 +313,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(papi(tag) + ChatColor.RED + " Error duplicate panel name: " + tempName); sender.sendMessage(tex.papi(tag) + ChatColor.RED + " Error duplicate panel name: " + tempName);
return false; return false;
} }
opanelsTemp.add(tempName); opanelsTemp.add(tempName);
@ -462,7 +377,7 @@ public class CommandPanels extends JavaPlugin{
} }
public void helpMessage(CommandSender p) { public void helpMessage(CommandSender p) {
p.sendMessage(papi( tag + ChatColor.GREEN + "Commands:")); p.sendMessage(tex.papi( 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

@ -59,7 +59,7 @@ public class Utils implements Listener {
return; return;
} }
String section = plugin.itemCreate.hasSection(panel.getConfig().getConfigurationSection("item." + e.getSlot()), p); String section = plugin.itemCreate.hasSection(panel,panel.getConfig().getConfigurationSection("item." + e.getSlot()), p);
if(panel.getConfig().contains("item." + e.getSlot() + section + ".itemType")){ if(panel.getConfig().contains("item." + e.getSlot() + section + ".itemType")){
if(panel.getConfig().getStringList("item." + e.getSlot() + section + ".itemType").contains("placeable")){ if(panel.getConfig().getStringList("item." + e.getSlot() + section + ".itemType").contains("placeable")){
@ -153,10 +153,10 @@ public class Utils implements Listener {
String command; String command;
if(commands.get(i).split("\\s")[0].equalsIgnoreCase("nopapi=")){ if(commands.get(i).split("\\s")[0].equalsIgnoreCase("nopapi=")){
//won't parse PAPI placeholders //won't parse PAPI placeholders
command = plugin.papi(plugin.placeholders.setCpPlaceholders(p,commands.get(i))).replace("nopapi=","").trim(); command = plugin.tex.papi(plugin.placeholders.setCpPlaceholders(panel,p,commands.get(i))).replace("nopapi=","").trim();
}else{ }else{
//will parse every placeholder //will parse every placeholder
command = plugin.papi(p,commands.get(i)); command = plugin.tex.papi(panel,p,commands.get(i));
} }
int val = plugin.commandTags.commandPayWall(p,command); int val = plugin.commandTags.commandPayWall(p,command);
@ -164,7 +164,7 @@ public class Utils implements Listener {
return; return;
} }
if(val == 2){ if(val == 2){
plugin.commandTags.commandTags(p, command, commands.get(i)); plugin.commandTags.commandTags(panel, p, command, commands.get(i));
} }
} }
} }

View File

@ -63,7 +63,7 @@ public class CommandPanelsAPI {
//make custom item using items section //make custom item using items section
public ItemStack makeItem(Player p, ConfigurationSection itemSection){ public ItemStack makeItem(Player p, ConfigurationSection itemSection){
return plugin.itemCreate.makeCustomItemFromConfig(itemSection, p, true, true, false); return plugin.itemCreate.makeCustomItemFromConfig(null,itemSection, p, true, true, false);
} }
//will return item slots of hotbar stationary items //will return item slots of hotbar stationary items

View File

@ -1,6 +1,7 @@
package me.rockyhawk.commandpanels.api; package me.rockyhawk.commandpanels.api;
import me.rockyhawk.commandpanels.CommandPanels; import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.customcommands.PanelPlaceholders;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -17,6 +18,7 @@ public class Panel{
private ConfigurationSection panelConfig; private ConfigurationSection panelConfig;
private String panelName; private String panelName;
private File panelFile; private File panelFile;
public PanelPlaceholders placeholders = new PanelPlaceholders();
//make the object, using a file is recommended //make the object, using a file is recommended
public Panel(File file, String name){ public Panel(File file, String name){
@ -67,17 +69,17 @@ public class Panel{
public ItemStack getItem(Player p, int slot){ public ItemStack getItem(Player p, int slot){
ConfigurationSection itemSection = panelConfig.getConfigurationSection("item." + slot); ConfigurationSection itemSection = panelConfig.getConfigurationSection("item." + slot);
return plugin.itemCreate.makeItemFromConfig(itemSection, p, true, true, false); return plugin.itemCreate.makeItemFromConfig(this,itemSection, p, true, true, false);
} }
public ItemStack getCustomItem(Player p, String itemName){ public ItemStack getCustomItem(Player p, String itemName){
ConfigurationSection itemSection = panelConfig.getConfigurationSection("custom-item." + itemName); ConfigurationSection itemSection = panelConfig.getConfigurationSection("custom-item." + itemName);
return plugin.itemCreate.makeCustomItemFromConfig(itemSection, p, true, true, false); return plugin.itemCreate.makeCustomItemFromConfig(this,itemSection, p, true, true, false);
} }
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(itemSection, p, true, true, false); return plugin.itemCreate.makeItemFromConfig(this,itemSection, p, true, true, false);
} }
public boolean hasHotbarItem(){ public boolean hasHotbarItem(){
@ -96,4 +98,12 @@ public class Panel{
} }
plugin.openVoids.openCommandPanel(p, p, this, false); plugin.openVoids.openCommandPanel(p, p, this, false);
} }
//create blank clone
public Panel copy(){
if(panelFile != null){
return new Panel(panelFile, panelName);
}
return new Panel(panelConfig, panelName);
}
} }

View File

@ -14,7 +14,6 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.PotionMeta; import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import java.util.Arrays;
import java.util.Objects; import java.util.Objects;
import java.util.UUID; import java.util.UUID;
@ -25,7 +24,7 @@ public class CommandTags {
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public void commandTags(Player p, String command, String commandRAW) { public void commandTags(Panel panel, Player p, String command, String commandRAW) {
//commandRAW is without placeholders //commandRAW is without placeholders
switch(command.split("\\s")[0]){ switch(command.split("\\s")[0]){
case "server=":{ case "server=":{
@ -51,29 +50,29 @@ public class CommandTags {
} }
case "set-data=":{ case "set-data=":{
if(command.split("\\s").length == 4){ if(command.split("\\s").length == 4){
plugin.panelData.setUserData(getOffline(command.split("\\s")[3]),command.split("\\s")[1],command.split("\\s")[2],true); plugin.panelData.setUserData(getOffline(command.split("\\s")[3]),command.split("\\s")[1],plugin.tex.papiNoColour(panel,p,command.split("\\s")[2]),true);
break; break;
} }
//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(p.getUniqueId(),command.split("\\s")[1],command.split("\\s")[2],true); plugin.panelData.setUserData(p.getUniqueId(),command.split("\\s")[1],plugin.tex.papiNoColour(panel,p,command.split("\\s")[2]),true);
break; break;
} }
case "add-data=":{ case "add-data=":{
if(command.split("\\s").length == 4){ if(command.split("\\s").length == 4){
plugin.panelData.setUserData(getOffline(command.split("\\s")[3]),command.split("\\s")[1],command.split("\\s")[2],false); plugin.panelData.setUserData(getOffline(command.split("\\s")[3]),command.split("\\s")[1],plugin.tex.papiNoColour(panel,p,command.split("\\s")[2]),false);
break; break;
} }
//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(p.getUniqueId(),command.split("\\s")[1],command.split("\\s")[2],false); plugin.panelData.setUserData(p.getUniqueId(),command.split("\\s")[1],plugin.tex.papiNoColour(panel,p,command.split("\\s")[2]),false);
break; break;
} }
case "math-data=":{ case "math-data=":{
if(command.split("\\s").length == 4){ if(command.split("\\s").length == 4){
plugin.panelData.doDataMath(getOffline(command.split("\\s")[3]),command.split("\\s")[1],command.split("\\s")[2]); plugin.panelData.doDataMath(getOffline(command.split("\\s")[3]),command.split("\\s")[1],plugin.tex.papiNoColour(panel,p,command.split("\\s")[2]));
break; break;
} }
//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(p.getUniqueId(),command.split("\\s")[1],command.split("\\s")[2]); plugin.panelData.doDataMath(p.getUniqueId(),command.split("\\s")[1],plugin.tex.papiNoColour(panel,p,command.split("\\s")[2]));
break; break;
} }
case "clear-data=":{ case "clear-data=":{
@ -92,7 +91,7 @@ public class CommandTags {
} }
case "give-item=":{ case "give-item=":{
//this will remove data. give-item= [custom item]. //this will remove data. give-item= [custom item].
ItemStack itm = plugin.itemCreate.makeCustomItemFromConfig(plugin.openPanels.getOpenPanel(p.getName()).getConfig().getConfigurationSection("custom-item." + command.split("\\s")[1]), p, true, true, false); ItemStack itm = plugin.itemCreate.makeCustomItemFromConfig(null,plugin.openPanels.getOpenPanel(p.getName()).getConfig().getConfigurationSection("custom-item." + command.split("\\s")[1]), p, true, true, false);
p.getInventory().addItem(itm); p.getInventory().addItem(itm);
break; break;
} }
@ -100,7 +99,17 @@ public class CommandTags {
//if player uses open= it will open the panel, with the option to add custom placeholders //if player uses open= it will open the panel, with the option to add custom placeholders
String panelName = commandRAW.split("\\s")[1]; String panelName = commandRAW.split("\\s")[1];
String cmd = commandRAW.replace("open= " + panelName,""); String cmd = commandRAW.replace("open= " + panelName,"");
panelName = plugin.papi(p,panelName); panelName = plugin.tex.papi(panel,p,panelName);
Panel openPanel = null;
for(Panel pane : plugin.panelList){
if(pane.getName().equals(panelName)){
openPanel = pane.copy();
}
}
if(openPanel == null){
break;
}
Character[] cm = ArrayUtils.toObject(cmd.toCharArray()); Character[] cm = ArrayUtils.toObject(cmd.toCharArray());
for(int i = 0; i < cm.length; i++){ for(int i = 0; i < cm.length; i++){
@ -109,18 +118,12 @@ public class CommandTags {
//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.papi(p,contents.substring(contents.indexOf(':')+1)); String value = plugin.tex.papi(openPanel,p,contents.substring(contents.indexOf(':')+1));
plugin.customCommand.addCCP(panelName,p.getName(),placeholder,value); openPanel.placeholders.addPlaceholder(placeholder,value);
i = i+contents.length()-1; i = i+contents.length()-1;
} }
} }
openPanel.open(p);
for(Panel panel : plugin.panelList){
if(panel.getName().equals(panelName)){
panel.open(p);
return;
}
}
break; break;
} }
case "console=":{ case "console=":{
@ -129,13 +132,14 @@ public class CommandTags {
break; break;
} }
case "placeholder=":{ case "placeholder=":{
//if player uses placeholder= it will only change the placeholders for the panel //placeholder is now placeholder= [place] [value]
String panelName = plugin.openPanels.getOpenPanelName(p.getName());
//placeholder is now placeholder= [place]. Not placeholder= panel [place] which is why this is here
String cmd; String cmd;
cmd = commandRAW.replace("placeholder= ",""); cmd = commandRAW.replace("placeholder= ","");
if(panel == null){
break;
}
Character[] cm = ArrayUtils.toObject(cmd.toCharArray()); Character[] cm = ArrayUtils.toObject(cmd.toCharArray());
for(int i = 0; i < cm.length; i++){ for(int i = 0; i < cm.length; i++){
if(cm[i].equals('[')){ if(cm[i].equals('[')){
@ -143,8 +147,8 @@ public class CommandTags {
//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.papi(p,contents.substring(contents.indexOf(':')+1)); String value = plugin.tex.papi(panel,p,contents.substring(contents.indexOf(':')+1));
plugin.customCommand.editCCP(panelName,p.getName(),placeholder,value); panel.placeholders.addPlaceholder(placeholder,value);
i = i+contents.length()-1; i = i+contents.length()-1;
} }
} }
@ -154,7 +158,7 @@ public class CommandTags {
//if player uses setitem= [custom item] [slot] it will change the item slot to something, used for placeable items //if player uses setitem= [custom item] [slot] it will change the item slot to something, used for placeable items
//make a section in the panel called "custom-item" then whatever the title of the item is, put that here //make a section in the panel called "custom-item" then whatever the title of the item is, put that here
ConfigurationSection panelCF = plugin.openPanels.getOpenPanel(p.getName()).getConfig(); ConfigurationSection panelCF = plugin.openPanels.getOpenPanel(p.getName()).getConfig();
ItemStack s = plugin.itemCreate.makeItemFromConfig(panelCF.getConfigurationSection("custom-item." + command.split("\\s")[1]), p, true, true, true); ItemStack s = plugin.itemCreate.makeItemFromConfig(null,panelCF.getConfigurationSection("custom-item." + command.split("\\s")[1]), p, true, true, true);
p.getOpenInventory().getTopInventory().setItem(Integer.parseInt(command.split("\\s")[2]), s); p.getOpenInventory().getTopInventory().setItem(Integer.parseInt(command.split("\\s")[2]), s);
break; break;
} }
@ -173,7 +177,7 @@ public class CommandTags {
} catch (Exception exc) { } catch (Exception exc) {
p.setOp(isop); p.setOp(isop);
plugin.debug(exc,p); plugin.debug(exc,p);
p.sendMessage(plugin.tag + plugin.papi( plugin.config.getString("config.format.error") + " op=: Error in op command!")); p.sendMessage(plugin.tag + plugin.tex.papi( plugin.config.getString("config.format.error") + " op=: Error in op command!"));
} }
break; break;
} }
@ -185,7 +189,7 @@ public class CommandTags {
@Override @Override
public void run() { public void run() {
try { try {
commandTags(p, finalCommand, commandRAW); commandTags(panel, p, finalCommand, commandRAW);
}catch (Exception ex){ }catch (Exception ex){
//if there are any errors, cancel so that it doesn't loop errors //if there are any errors, cancel so that it doesn't loop errors
plugin.debug(ex,p); plugin.debug(ex,p);
@ -202,7 +206,7 @@ public class CommandTags {
if (plugin.econ != null) { if (plugin.econ != null) {
if (plugin.econ.getBalance(p) >= Double.parseDouble(command.split("\\s")[1])) { if (plugin.econ.getBalance(p) >= Double.parseDouble(command.split("\\s")[1])) {
plugin.econ.withdrawPlayer(p, Double.parseDouble(command.split("\\s")[1])); plugin.econ.withdrawPlayer(p, Double.parseDouble(command.split("\\s")[1]));
p.sendMessage(plugin.papi( plugin.tag + Objects.requireNonNull(plugin.config.getString("purchase.currency.success")).replaceAll("%cp-args%", command.split("\\s")[1]))); p.sendMessage(plugin.tex.papi( plugin.tag + Objects.requireNonNull(plugin.config.getString("purchase.currency.success")).replaceAll("%cp-args%", command.split("\\s")[1])));
//legacy ID //legacy ID
byte id = 0; byte id = 0;
if(plugin.legacy.isLegacy()) { if(plugin.legacy.isLegacy()) {
@ -219,14 +223,14 @@ public class CommandTags {
Objects.requireNonNull(p.getLocation().getWorld()).dropItemNaturally(p.getLocation(), new ItemStack(Objects.requireNonNull(Material.matchMaterial(command.split("\\s")[2])), Integer.parseInt(command.split("\\s")[3]),id)); Objects.requireNonNull(p.getLocation().getWorld()).dropItemNaturally(p.getLocation(), new ItemStack(Objects.requireNonNull(Material.matchMaterial(command.split("\\s")[2])), Integer.parseInt(command.split("\\s")[3]),id));
} }
} else { } else {
p.sendMessage(plugin.papi( plugin.tag + plugin.config.getString("purchase.currency.failure"))); p.sendMessage(plugin.tex.papi( plugin.tag + plugin.config.getString("purchase.currency.failure")));
} }
} else { } else {
p.sendMessage(plugin.papi( plugin.tag + ChatColor.RED + "Buying Requires Vault and an Economy to work!")); p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Buying Requires Vault and an Economy to work!"));
} }
} catch (Exception buy) { } catch (Exception buy) {
plugin.debug(buy,p); plugin.debug(buy,p);
p.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.error") + " " + "commands: " + command)); p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " " + "commands: " + command));
} }
break; break;
} }
@ -239,7 +243,7 @@ public class CommandTags {
int balance = Integer.parseInt(Long.toString(api.getTokens(p).orElse(0))); int balance = Integer.parseInt(Long.toString(api.getTokens(p).orElse(0)));
if (balance >= Double.parseDouble(command.split("\\s")[1])) { if (balance >= Double.parseDouble(command.split("\\s")[1])) {
api.removeTokens(p, Long.parseLong(command.split("\\s")[1])); api.removeTokens(p, Long.parseLong(command.split("\\s")[1]));
p.sendMessage(plugin.papi( plugin.tag + Objects.requireNonNull(plugin.config.getString("purchase.tokens.success")).replaceAll("%cp-args%", command.split("\\s")[1]))); p.sendMessage(plugin.tex.papi( plugin.tag + Objects.requireNonNull(plugin.config.getString("purchase.tokens.success")).replaceAll("%cp-args%", command.split("\\s")[1])));
//legacy ID //legacy ID
byte id = 0; byte id = 0;
if(plugin.legacy.isLegacy()) { if(plugin.legacy.isLegacy()) {
@ -256,14 +260,14 @@ public class CommandTags {
Objects.requireNonNull(p.getLocation().getWorld()).dropItemNaturally(p.getLocation(), new ItemStack(Objects.requireNonNull(Material.matchMaterial(command.split("\\s")[2])), Integer.parseInt(command.split("\\s")[3]),id)); Objects.requireNonNull(p.getLocation().getWorld()).dropItemNaturally(p.getLocation(), new ItemStack(Objects.requireNonNull(Material.matchMaterial(command.split("\\s")[2])), Integer.parseInt(command.split("\\s")[3]),id));
} }
} else { } else {
p.sendMessage(plugin.papi( plugin.tag + plugin.config.getString("purchase.tokens.failure"))); p.sendMessage(plugin.tex.papi( plugin.tag + plugin.config.getString("purchase.tokens.failure")));
} }
} else { } else {
p.sendMessage(plugin.papi( plugin.tag + ChatColor.RED + "Buying Requires TokenManager to work!")); p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Buying Requires TokenManager to work!"));
} }
} catch (Exception buy) { } catch (Exception buy) {
plugin.debug(buy,p); plugin.debug(buy,p);
p.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.error") + " " + "commands: " + command)); p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " " + "commands: " + command));
} }
break; break;
} }
@ -323,16 +327,16 @@ public class CommandTags {
} }
} }
if (!sold) { if (!sold) {
p.sendMessage(plugin.papi( plugin.tag + plugin.config.getString("purchase.item.failure"))); p.sendMessage(plugin.tex.papi( plugin.tag + plugin.config.getString("purchase.item.failure")));
} else { } else {
p.sendMessage(plugin.papi( plugin.tag + Objects.requireNonNull(plugin.config.getString("purchase.item.success")).replaceAll("%cp-args%", command.split("\\s")[2]))); p.sendMessage(plugin.tex.papi( plugin.tag + Objects.requireNonNull(plugin.config.getString("purchase.item.success")).replaceAll("%cp-args%", command.split("\\s")[2])));
} }
} else { } else {
p.sendMessage(plugin.papi( plugin.tag + ChatColor.RED + "Selling Requires Vault and an Economy to work!")); p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Selling Requires Vault and an Economy to work!"));
} }
} catch (Exception sell) { } catch (Exception sell) {
plugin.debug(sell,p); plugin.debug(sell,p);
p.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.error") + " " + "commands: " + command)); p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " " + "commands: " + command));
} }
break; break;
} }
@ -368,7 +372,7 @@ public class CommandTags {
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.papi( plugin.tag + ChatColor.RED + "Your item has the wrong potion effect")); p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Your item has the wrong potion effect"));
return; return;
} }
} }
@ -395,16 +399,16 @@ public class CommandTags {
} }
} }
if (!sold) { if (!sold) {
p.sendMessage(plugin.papi( plugin.tag + plugin.config.getString("purchase.item.failure"))); p.sendMessage(plugin.tex.papi( plugin.tag + plugin.config.getString("purchase.item.failure")));
} else { } else {
p.sendMessage(plugin.papi( plugin.tag + Objects.requireNonNull(plugin.config.getString("purchase.item.success")).replaceAll("%cp-args%", command.split("\\s")[2]))); p.sendMessage(plugin.tex.papi( plugin.tag + Objects.requireNonNull(plugin.config.getString("purchase.item.success")).replaceAll("%cp-args%", command.split("\\s")[2])));
} }
} else { } else {
p.sendMessage(plugin.papi( plugin.tag + ChatColor.RED + "Selling Requires TokenManager to work!")); p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Selling Requires TokenManager to work!"));
} }
} catch (Exception sell) { } catch (Exception sell) {
plugin.debug(sell,p); plugin.debug(sell,p);
p.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.error") + " " + "commands: " + command)); p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " " + "commands: " + command));
} }
break; break;
} }
@ -419,7 +423,7 @@ public class CommandTags {
p.playSound(p.getLocation(), Sound.valueOf(command.split("\\s")[1]), 1F, 1F); p.playSound(p.getLocation(), Sound.valueOf(command.split("\\s")[1]), 1F, 1F);
} catch (Exception s) { } catch (Exception s) {
plugin.debug(s,p); plugin.debug(s,p);
p.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.error") + " " + "commands: " + command)); p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " " + "commands: " + command));
} }
break; break;
} }
@ -434,17 +438,17 @@ public class CommandTags {
commandp = commandp.replace("buycommand=", "").trim(); commandp = commandp.replace("buycommand=", "").trim();
String price = commandp.split(" ", 2)[0]; String price = commandp.split(" ", 2)[0];
commandp = commandp.split(" ", 2)[1]; commandp = commandp.split(" ", 2)[1];
commandTags(p,commandp,commandRAW); commandTags(panel,p,commandp,commandRAW);
p.sendMessage(plugin.papi( plugin.tag + Objects.requireNonNull(plugin.config.getString("purchase.currency.success")).replaceAll("%cp-args%", price))); p.sendMessage(plugin.tex.papi( plugin.tag + Objects.requireNonNull(plugin.config.getString("purchase.currency.success")).replaceAll("%cp-args%", price)));
} else { } else {
p.sendMessage(plugin.papi( plugin.tag + plugin.config.getString("purchase.currency.failure"))); p.sendMessage(plugin.tex.papi( plugin.tag + plugin.config.getString("purchase.currency.failure")));
} }
} else { } else {
p.sendMessage(plugin.papi( plugin.tag + ChatColor.RED + "Buying Requires Vault and an Economy to work!")); p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Buying Requires Vault and an Economy to work!"));
} }
} catch (Exception buyc) { } catch (Exception buyc) {
plugin.debug(buyc,p); plugin.debug(buyc,p);
p.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.error") + " " + "commands: " + command)); p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " " + "commands: " + command));
} }
break; break;
} }
@ -462,17 +466,17 @@ public class CommandTags {
commandp = commandp.replace("tokenbuycommand=", "").trim(); commandp = commandp.replace("tokenbuycommand=", "").trim();
String price = commandp.split(" ", 2)[0]; String price = commandp.split(" ", 2)[0];
commandp = commandp.split(" ", 2)[1]; commandp = commandp.split(" ", 2)[1];
commandTags(p,commandp,commandRAW); commandTags(panel,p,commandp,commandRAW);
p.sendMessage(plugin.papi( plugin.tag + Objects.requireNonNull(plugin.config.getString("purchase.token.success")).replaceAll("%cp-args%", price))); p.sendMessage(plugin.tex.papi( plugin.tag + Objects.requireNonNull(plugin.config.getString("purchase.token.success")).replaceAll("%cp-args%", price)));
} else { } else {
p.sendMessage(plugin.papi( plugin.tag + plugin.config.getString("purchase.token.failure"))); p.sendMessage(plugin.tex.papi( plugin.tag + plugin.config.getString("purchase.token.failure")));
} }
} else { } else {
p.sendMessage(plugin.papi( plugin.tag + ChatColor.RED + "Buying Requires Vault and an Economy to work!")); p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Buying Requires Vault and an Economy to work!"));
} }
} catch (Exception buyc) { } catch (Exception buyc) {
plugin.debug(buyc,p); plugin.debug(buyc,p);
p.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.error") + " " + "commands: " + command)); p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " " + "commands: " + command));
} }
break; break;
} }
@ -523,7 +527,7 @@ public class CommandTags {
p.stopSound(Sound.valueOf(command.split("\\s")[1])); p.stopSound(Sound.valueOf(command.split("\\s")[1]));
} catch (Exception ss) { } catch (Exception ss) {
plugin.debug(ss,p); plugin.debug(ss,p);
p.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.error") + " " + "commands: " + command)); p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " " + "commands: " + command));
} }
break; break;
} }
@ -548,19 +552,19 @@ public class CommandTags {
if (plugin.econ != null) { if (plugin.econ != null) {
if (plugin.econ.getBalance(p) >= Double.parseDouble(command.split("\\s")[1])) { if (plugin.econ.getBalance(p) >= Double.parseDouble(command.split("\\s")[1])) {
plugin.econ.withdrawPlayer(p, Double.parseDouble(command.split("\\s")[1])); plugin.econ.withdrawPlayer(p, Double.parseDouble(command.split("\\s")[1]));
p.sendMessage(plugin.papi(Objects.requireNonNull(plugin.config.getString("purchase.currency.success")).replaceAll("%cp-args%", command.split("\\s")[1]))); p.sendMessage(plugin.tex.papi(Objects.requireNonNull(plugin.config.getString("purchase.currency.success")).replaceAll("%cp-args%", command.split("\\s")[1])));
return 1; return 1;
} else { } else {
p.sendMessage(plugin.papi(plugin.config.getString("purchase.currency.failure"))); p.sendMessage(plugin.tex.papi(plugin.config.getString("purchase.currency.failure")));
return 0; return 0;
} }
} else { } else {
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Paying Requires Vault and an Economy to work!")); p.sendMessage(plugin.tex.papi( tag + ChatColor.RED + "Paying Requires Vault and an Economy to work!"));
return 0; return 0;
} }
} catch (Exception buyc) { } catch (Exception buyc) {
plugin.debug(buyc,p); plugin.debug(buyc,p);
p.sendMessage(plugin.papi( tag + plugin.config.getString("config.format.error") + " " + "commands: " + command)); p.sendMessage(plugin.tex.papi( tag + plugin.config.getString("config.format.error") + " " + "commands: " + command));
return 0; return 0;
} }
} }
@ -574,19 +578,19 @@ public class CommandTags {
if (balance >= Double.parseDouble(command.split("\\s")[1])) { if (balance >= Double.parseDouble(command.split("\\s")[1])) {
api.removeTokens(p, Long.parseLong(command.split("\\s")[1])); api.removeTokens(p, Long.parseLong(command.split("\\s")[1]));
//if the message is empty don't send //if the message is empty don't send
p.sendMessage(plugin.papi(Objects.requireNonNull(plugin.config.getString("purchase.tokens.success")).replaceAll("%cp-args%", command.split("\\s")[1]))); p.sendMessage(plugin.tex.papi(Objects.requireNonNull(plugin.config.getString("purchase.tokens.success")).replaceAll("%cp-args%", command.split("\\s")[1])));
return 1; return 1;
} else { } else {
p.sendMessage(plugin.papi(plugin.config.getString("purchase.tokens.failure"))); p.sendMessage(plugin.tex.papi(plugin.config.getString("purchase.tokens.failure")));
return 0; return 0;
} }
} else { } else {
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Needs TokenManager to work!")); p.sendMessage(plugin.tex.papi( tag + ChatColor.RED + "Needs TokenManager to work!"));
return 0; return 0;
} }
} catch (Exception buyc) { } catch (Exception buyc) {
plugin.debug(buyc,p); plugin.debug(buyc,p);
p.sendMessage(plugin.papi( tag + plugin.config.getString("config.format.error") + " " + "commands: " + command)); p.sendMessage(plugin.tex.papi( tag + plugin.config.getString("config.format.error") + " " + "commands: " + command));
return 0; return 0;
} }
} }
@ -602,7 +606,7 @@ public class CommandTags {
//create the item to be removed //create the item to be removed
ItemStack sellItem; ItemStack sellItem;
if(command.split("\\s").length == 2) { if(command.split("\\s").length == 2) {
sellItem = plugin.itemCreate.makeCustomItemFromConfig(plugin.openPanels.getOpenPanel(p.getName()).getConfig().getConfigurationSection("custom-item." + command.split("\\s")[1]), p, true, true, false); sellItem = plugin.itemCreate.makeCustomItemFromConfig(null,plugin.openPanels.getOpenPanel(p.getName()).getConfig().getConfigurationSection("custom-item." + command.split("\\s")[1]), p, true, true, false);
}else{ }else{
sellItem = new ItemStack(Objects.requireNonNull(Material.matchMaterial(command.split("\\s")[1])), Integer.parseInt(command.split("\\s")[2]), id); sellItem = new ItemStack(Objects.requireNonNull(Material.matchMaterial(command.split("\\s")[1])), Integer.parseInt(command.split("\\s")[2]), id);
} }
@ -659,14 +663,14 @@ public class CommandTags {
//send message and return //send message and return
if(removedItem == 0){ if(removedItem == 0){
p.sendMessage(plugin.papi( tag + plugin.config.getString("purchase.item.failure"))); p.sendMessage(plugin.tex.papi( tag + plugin.config.getString("purchase.item.failure")));
}else{ }else{
p.sendMessage(plugin.papi(Objects.requireNonNull(plugin.config.getString("purchase.item.success")).replaceAll("%cp-args%",sellItem.getType().toString()))); p.sendMessage(plugin.tex.papi(Objects.requireNonNull(plugin.config.getString("purchase.item.success")).replaceAll("%cp-args%",sellItem.getType().toString())));
} }
return removedItem; return removedItem;
} catch (Exception buyc) { } catch (Exception buyc) {
plugin.debug(buyc,p); plugin.debug(buyc,p);
p.sendMessage(plugin.papi( tag + plugin.config.getString("config.format.error") + " " + "commands: " + command)); p.sendMessage(plugin.tex.papi( tag + plugin.config.getString("config.format.error") + " " + "commands: " + command));
return 0; return 0;
} }
} }
@ -677,15 +681,15 @@ public class CommandTags {
if (balance >= Integer.parseInt(command.split("\\s")[1])) { if (balance >= Integer.parseInt(command.split("\\s")[1])) {
p.setLevel(p.getLevel() - Integer.parseInt(command.split("\\s")[1])); p.setLevel(p.getLevel() - Integer.parseInt(command.split("\\s")[1]));
//if the message is empty don't send //if the message is empty don't send
p.sendMessage(plugin.papi(Objects.requireNonNull(plugin.config.getString("purchase.xp.success")).replaceAll("%cp-args%", command.split("\\s")[1]))); p.sendMessage(plugin.tex.papi(Objects.requireNonNull(plugin.config.getString("purchase.xp.success")).replaceAll("%cp-args%", command.split("\\s")[1])));
return 1; return 1;
} else { } else {
p.sendMessage(plugin.papi( plugin.config.getString("purchase.xp.failure"))); p.sendMessage(plugin.tex.papi( plugin.config.getString("purchase.xp.failure")));
return 0; return 0;
} }
} catch (Exception buyc) { } catch (Exception buyc) {
plugin.debug(buyc,p); plugin.debug(buyc,p);
p.sendMessage(plugin.papi( tag + plugin.config.getString("config.format.error") + " " + "commands: " + command)); p.sendMessage(plugin.tex.papi( tag + plugin.config.getString("config.format.error") + " " + "commands: " + command));
return 0; return 0;
} }
} }

View File

@ -33,14 +33,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.papi(plugin.tag + plugin.config.getString("config.format.perms"))); sender.sendMessage(plugin.tex.papi(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.papi(plugin.tag + plugin.config.getString("config.format.perms"))); sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.perms")));
return; return;
} }
@ -56,27 +56,30 @@ public class ExecuteOpenVoids {
return; return;
} }
//do these commands before the panel loads
beforeLoadCommands(panel,p);
try { try {
//create and open the GUI //create and open the GUI
plugin.createGUI.openGui(panel, p,1,0); plugin.createGUI.openGui(panel, p,1,0);
//open the panel //open the panel
plugin.openPanels.openPanelForLoader(p.getName(), panel); plugin.openPanels.openPanelForLoader(p.getName(), panel);
//execute commands on panel open //execute commands once the panel opens
if (panel.getConfig().contains("commands-on-open")) { if (panel.getConfig().contains("commands-on-open")) {
try { try {
List<String> commands = panel.getConfig().getStringList("commands-on-open"); List<String> commands = panel.getConfig().getStringList("commands-on-open");
for (int i = 0; commands.size() - 1 >= i; i++) { for (String command : commands) {
int val = plugin.commandTags.commandPayWall(p,commands.get(i)); int val = plugin.commandTags.commandPayWall(p, command);
if(val == 0){ if (val == 0) {
break; break;
} }
if(val == 2){ if (val == 2) {
plugin.commandTags.commandTags(p, plugin.papi(p,commands.get(i)),commands.get(i)); plugin.commandTags.commandTags(panel,p, plugin.tex.papi(panel,p, command), command);
} }
} }
}catch(Exception s){ }catch(Exception s){
p.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.error") + " " + "commands-on-open: " + panel.getConfig().getString("commands-on-open"))); p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " " + "commands-on-open: " + panel.getConfig().getString("commands-on-open")));
} }
} }
@ -86,22 +89,22 @@ 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.papi(plugin.tag + plugin.config.getString("config.format.error") + " " + "sound-on-open: " + panel.getConfig().getString("sound-on-open"))); p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " " + "sound-on-open: " + panel.getConfig().getString("sound-on-open")));
} }
} }
} }
if(openForOtherUser) { if(openForOtherUser) {
sender.sendMessage(plugin.papi( plugin.tag + ChatColor.GREEN + "Panel Opened for " + p.getDisplayName())); sender.sendMessage(plugin.tex.papi( 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.papi(plugin.tag + plugin.config.getString("config.format.error"))); sender.sendMessage(plugin.tex.papi(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.papi(plugin.tag + plugin.config.getString("config.format.perms"))); sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.perms")));
} }
} }
@ -110,18 +113,18 @@ public class ExecuteOpenVoids {
if (sender.hasPermission("commandpanel.item." + cf.getString("perm")) && cf.contains("open-with-item")) { if (sender.hasPermission("commandpanel.item." + cf.getString("perm")) && cf.contains("open-with-item")) {
//check for disabled worlds //check for disabled worlds
if(!plugin.panelPerms.isPanelWorldEnabled(p,cf)){ if(!plugin.panelPerms.isPanelWorldEnabled(p,cf)){
sender.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.perms"))); sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.perms")));
return; return;
} }
ItemStack s; ItemStack s;
try { try {
s = plugin.itemCreate.makeItemFromConfig(Objects.requireNonNull(cf.getConfigurationSection("open-with-item")), p, false, true, false); s = plugin.itemCreate.makeItemFromConfig(null,Objects.requireNonNull(cf.getConfigurationSection("open-with-item")), p, false, true, false);
}catch(Exception n){ }catch(Exception n){
sender.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.error") + " open-with-item: material")); sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " open-with-item: material"));
return; return;
} }
plugin.setName(s, cf.getString("open-with-item.name"), cf.getStringList("open-with-item.lore"),p,false, true, true); 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 {
@ -131,20 +134,40 @@ public class ExecuteOpenVoids {
p.getInventory().addItem(s); p.getInventory().addItem(s);
} }
if(sendGiveMessage) { if(sendGiveMessage) {
sender.sendMessage(plugin.papi( plugin.tag + ChatColor.GREEN + "Item Given to " + p.getDisplayName())); sender.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Item Given to " + p.getDisplayName()));
} }
} catch (Exception r) { } catch (Exception r) {
sender.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.notitem"))); sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.notitem")));
} }
}else{ }else{
sender.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.perms"))); sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.perms")));
} }
return; return;
} }
if (!cf.contains("open-with-item")) { if (!cf.contains("open-with-item")) {
sender.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.noitem"))); sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.noitem")));
return; return;
} }
sender.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.perms"))); sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.perms")));
}
public void beforeLoadCommands(Panel panel, Player p){
if (panel.getConfig().contains("pre-load-commands")) {
try {
List<String> commands = panel.getConfig().getStringList("pre-load-commands");
for (String command : commands) {
int val = plugin.commandTags.commandPayWall(p, command);
if (val == 0) {
break;
}
if (val == 2) {
plugin.commandTags.commandTags(panel,p, plugin.tex.papi(panel,p, command), command);
}
}
}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")));
plugin.debug(s,p);
}
}
} }
} }

View File

@ -3,6 +3,7 @@ package me.rockyhawk.commandpanels.classresources;
import com.jojodmo.customitems.api.CustomItemsAPI; import com.jojodmo.customitems.api.CustomItemsAPI;
import me.arcaniax.hdb.api.HeadDatabaseAPI; import me.arcaniax.hdb.api.HeadDatabaseAPI;
import me.rockyhawk.commandpanels.CommandPanels; import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.Panel;
import me.rockyhawk.commandpanels.ioclasses.NBTEditor; import me.rockyhawk.commandpanels.ioclasses.NBTEditor;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem; import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
@ -36,15 +37,15 @@ public class ItemCreation {
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public ItemStack makeItemFromConfig(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.papiNoColour(p,itemSection.getString("material")); String material = plugin.tex.papiNoColour(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.papi(plugin.tag + plugin.config.getString("config.format.error") + " material: could not load material!")); p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " material: could not load material!"));
return null; return null;
} }
ItemStack s = null; ItemStack s = null;
@ -78,7 +79,7 @@ public class ItemCreation {
if(itemSection.contains("ID")){ if(itemSection.contains("ID")){
id = Short.parseShort(itemSection.getString("ID")); id = Short.parseShort(itemSection.getString("ID"));
} }
if (matraw.split("\\s")[0].toLowerCase().equals("cps=") || matraw.split("\\s")[0].toLowerCase().equals("cpo=")) { if (matraw.split("\\s")[0].equalsIgnoreCase("cps=") || matraw.split("\\s")[0].toLowerCase().equals("cpo=")) {
skullname = p.getUniqueId().toString(); skullname = p.getUniqueId().toString();
mat = plugin.getHeads.playerHeadString(); mat = plugin.getHeads.playerHeadString();
if(plugin.legacy.isLegacy()){ if(plugin.legacy.isLegacy()){
@ -86,7 +87,7 @@ public class ItemCreation {
} }
} }
if (matraw.split("\\s")[0].toLowerCase().equals("hdb=")) { if (matraw.split("\\s")[0].equalsIgnoreCase("hdb=")) {
skullname = "hdb"; skullname = "hdb";
mat = plugin.getHeads.playerHeadString(); mat = plugin.getHeads.playerHeadString();
if(plugin.legacy.isLegacy()){ if(plugin.legacy.isLegacy()){
@ -95,7 +96,7 @@ public class ItemCreation {
} }
//creates custom MMOItems items //creates custom MMOItems items
if(matraw.split("\\s")[0].toLowerCase().equals("mmo=") && plugin.getServer().getPluginManager().isPluginEnabled("MMOItems")){ if(matraw.split("\\s")[0].equalsIgnoreCase("mmo=") && plugin.getServer().getPluginManager().isPluginEnabled("MMOItems")){
String itemType = matraw.split("\\s")[1]; String itemType = matraw.split("\\s")[1];
String itemID = matraw.split("\\s")[2]; String itemID = matraw.split("\\s")[2];
ItemManager itemManager = MMOItems.plugin.getItems(); ItemManager itemManager = MMOItems.plugin.getItems();
@ -105,18 +106,18 @@ public class ItemCreation {
} }
//creates Custom Items items //creates Custom Items items
if(matraw.split("\\s")[0].toLowerCase().equals("cui=") && plugin.getServer().getPluginManager().isPluginEnabled("CustomItems")){ if(matraw.split("\\s")[0].equalsIgnoreCase("cui=") && plugin.getServer().getPluginManager().isPluginEnabled("CustomItems")){
s = CustomItemsAPI.getCustomItem("cui:" + matraw.split("\\s")[1]); s = CustomItemsAPI.getCustomItem("cui:" + matraw.split("\\s")[1]);
normalCreation = false; normalCreation = false;
} }
//creates a written book item //creates a written book item
if(matraw.split("\\s")[0].toLowerCase().equals("book=")){ if(matraw.split("\\s")[0].equalsIgnoreCase("book=")){
s = new ItemStack(Material.WRITTEN_BOOK); s = new ItemStack(Material.WRITTEN_BOOK);
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.papi(p,itemSection.getStringList("write"),true); List<String> bookLines = plugin.tex.papi(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);
@ -124,8 +125,8 @@ public class ItemCreation {
} }
//creates item from custom-items section of panel //creates item from custom-items section of panel
if(matraw.split("\\s")[0].toLowerCase().equals("cpi=")){ if(matraw.split("\\s")[0].equalsIgnoreCase("cpi=")){
s = makeCustomItemFromConfig(plugin.openPanels.getOpenPanel(p.getName()).getConfig().getConfigurationSection("custom-item." + matraw.split("\\s")[1]), p, true, true, true); s = makeCustomItemFromConfig(panel,plugin.openPanels.getOpenPanel(p.getName()).getConfig().getConfigurationSection("custom-item." + matraw.split("\\s")[1]), p, true, true, true);
normalCreation = false; normalCreation = false;
} }
@ -144,22 +145,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.papi(plugin.tag + plugin.config.getString("config.format.error") + " material: cps= self")); p.sendMessage(plugin.tex.papi(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.papiNoColour(p,matraw.split("\\s")[1]).length() <= 16) { }else if (plugin.tex.papiNoColour(panel,p,matraw.split("\\s")[1]).length() <= 16) {
//if cps= username //if cps= username
s = plugin.customHeads.getPlayerHead(plugin.papiNoColour(p,matraw.split("\\s")[1])); s = plugin.customHeads.getPlayerHead(plugin.tex.papiNoColour(panel,p,matraw.split("\\s")[1]));
} else { } else {
//custom data cps= base64 //custom data cps= base64
s = plugin.customHeads.getCustomHead(plugin.papiNoColour(p,matraw.split("\\s")[1])); s = plugin.customHeads.getCustomHead(plugin.tex.papiNoColour(panel,p,matraw.split("\\s")[1]));
} }
} catch (Exception var32) { } catch (Exception var32) {
p.sendMessage(plugin.papi( plugin.tag + plugin.config.getString("config.format.error") + " head material: Could not load skull")); p.sendMessage(plugin.tex.papi( plugin.tag + plugin.config.getString("config.format.error") + " head material: Could not load skull"));
plugin.debug(var32,p); plugin.debug(var32,p);
} }
} }
@ -177,11 +178,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.papi(plugin.tag + plugin.config.getString("config.format.error") + " hdb: could not load skull!")); p.sendMessage(plugin.tex.papi(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.papi(plugin.tag + "Download HeadDatabaseHook from Spigot to use this feature!")); p.sendMessage(plugin.tex.papi(plugin.tag + "Download HeadDatabaseHook from Spigot to use this feature!"));
} }
} }
@ -231,10 +232,10 @@ public class ItemCreation {
meta.setMapView(map); meta.setMapView(map);
s.setItemMeta(meta); s.setItemMeta(meta);
}else{ }else{
p.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.error") + " map: File not found.")); p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " map: File not found."));
} }
}catch(Exception map){ }catch(Exception map){
p.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.error") + " map: " + itemSection.getString("map"))); p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " map: " + itemSection.getString("map")));
plugin.debug(map,p); plugin.debug(map,p);
} }
} }
@ -254,7 +255,7 @@ public class ItemCreation {
s.setItemMeta(EnchantMeta); s.setItemMeta(EnchantMeta);
} }
} catch (Exception ench) { } catch (Exception ench) {
p.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.error") + " enchanted: " + itemSection.getString("enchanted"))); p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " enchanted: " + itemSection.getString("enchanted")));
plugin.debug(ench,p); plugin.debug(ench,p);
} }
} }
@ -306,7 +307,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.papi(plugin.tag + plugin.config.getString("config.format.error") + " leatherarmor: " + itemSection.getString("leatherarmor"))); p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " leatherarmor: " + itemSection.getString("leatherarmor")));
} }
} }
@ -323,7 +324,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.papi(plugin.tag + ChatColor.RED + plugin.config.getString("config.format.error") + " potion: " + itemSection.getString("potion"))); p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + plugin.config.getString("config.format.error") + " potion: " + itemSection.getString("potion")));
} }
} }
if (itemSection.contains("damage")) { if (itemSection.contains("damage")) {
@ -331,10 +332,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.isLegacy()) { if (plugin.legacy.isLegacy()) {
try { try {
s.setDurability(Short.parseShort(Objects.requireNonNull(plugin.papi(p, itemSection.getString("damage"))))); s.setDurability(Short.parseShort(Objects.requireNonNull(plugin.tex.papi(panel,p, itemSection.getString("damage")))));
} catch (Exception e) { } catch (Exception e) {
plugin.debug(e, p); plugin.debug(e, p);
p.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.error") + " damage: " + itemSection.getString("damage"))); p.sendMessage(plugin.tex.papi(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")){
@ -346,38 +347,38 @@ public class ItemCreation {
try { try {
Damageable itemDamage = (Damageable) s.getItemMeta(); Damageable itemDamage = (Damageable) s.getItemMeta();
itemDamage.setDamage(Integer.parseInt(Objects.requireNonNull(plugin.papi(p, itemSection.getString("damage"))))); itemDamage.setDamage(Integer.parseInt(Objects.requireNonNull(plugin.tex.papi(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.papi(plugin.tag + plugin.config.getString("config.format.error") + " damage: " + itemSection.getString("damage"))); p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " damage: " + itemSection.getString("damage")));
} }
} }
} }
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.papi(p,itemSection.getString("stack"))))); s.setAmount((int)Double.parseDouble(Objects.requireNonNull(plugin.tex.papi(panel,p,itemSection.getString("stack")))));
} }
} catch (IllegalArgumentException | NullPointerException var33) { } catch (IllegalArgumentException | NullPointerException var33) {
plugin.debug(var33,p); plugin.debug(var33,p);
p.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.error") + " material: " + itemSection.getString("material"))); p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " material: " + itemSection.getString("material")));
return null; return null;
} }
plugin.setName(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);
return s; return s;
} }
//do custom-item items, they have an additional hasSection requirement //do custom-item items, they have an additional hasSection requirement
public ItemStack makeCustomItemFromConfig(ConfigurationSection itemSection, Player p, boolean placeholders, boolean colours, boolean addNBT){ public ItemStack makeCustomItemFromConfig(Panel panel, ConfigurationSection itemSection, Player p, boolean placeholders, boolean colours, boolean addNBT){
String section = plugin.itemCreate.hasSection(itemSection,p); String section = plugin.itemCreate.hasSection(panel,itemSection,p);
if(!section.equals("")){ if(!section.equals("")){
itemSection = itemSection.getConfigurationSection(section.substring(1)); itemSection = itemSection.getConfigurationSection(section.substring(1));
} }
return plugin.itemCreate.makeItemFromConfig(itemSection, p, placeholders, colours, addNBT); return plugin.itemCreate.makeItemFromConfig(panel,itemSection, p, placeholders, colours, addNBT);
} }
//hasperm hasvalue, etc sections will be done here //hasperm hasvalue, etc sections will be done here
public String hasSection(ConfigurationSection cf, Player p){ public String hasSection(Panel panel, ConfigurationSection cf, Player p){
if (cf.isSet("hasvalue")) { if (cf.isSet("hasvalue")) {
//this will do the hasvalue without any numbers //this will do the hasvalue without any numbers
boolean outputValue = true; boolean outputValue = true;
@ -386,11 +387,11 @@ 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.papi(p,plugin.placeholders.setCpPlaceholders(p,cf.getString("hasvalue.value")))); String value = ChatColor.stripColor(plugin.tex.papi(panel,p,cf.getString("hasvalue.value")));
String compare = ChatColor.stripColor(plugin.papi(p,plugin.placeholders.setCpPlaceholders(p,cf.getString("hasvalue.compare")))); String compare = ChatColor.stripColor(plugin.tex.papi(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(Objects.requireNonNull(cf.getConfigurationSection("hasvalue")), p); String section = hasSection(panel,Objects.requireNonNull(cf.getConfigurationSection("hasvalue")), p);
//string section, it executes itself to check for subsections //string section, it executes itself to check for subsections
return ".hasvalue" + section; return ".hasvalue" + section;
} }
@ -403,18 +404,18 @@ 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.papi(p,plugin.placeholders.setCpPlaceholders(p,cf.getString("hasvalue" + count + ".value")))); value = ChatColor.stripColor(plugin.tex.papi(panel,p,cf.getString("hasvalue" + count + ".value")));
compare = ChatColor.stripColor(plugin.papi(p,plugin.placeholders.setCpPlaceholders(p,cf.getString("hasvalue" + count + ".compare")))); compare = ChatColor.stripColor(plugin.tex.papi(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(Objects.requireNonNull(cf.getConfigurationSection("hasvalue" + count)), p); String section = hasSection(panel,Objects.requireNonNull(cf.getConfigurationSection("hasvalue" + count)), p);
//string section, it executes itself to check for subsections //string section, it executes itself to check for subsections
return ".hasvalue" + count + section; return ".hasvalue" + count + section;
} }
} }
} }
} }
if (cf.contains("hasgreater")) { if (cf.isSet("hasgreater")) {
//this will do the hasgreater without any numbers //this will do the hasgreater without any numbers
boolean outputValue = true; boolean outputValue = true;
//outputValue will default to true //outputValue will default to true
@ -422,11 +423,11 @@ 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.papiNoColour(p,cf.getString("hasgreater.value")))); double value = Double.parseDouble(ChatColor.stripColor(plugin.tex.papiNoColour(panel,p,cf.getString("hasgreater.value"))));
double compare = Double.parseDouble(ChatColor.stripColor(plugin.papiNoColour(p,cf.getString("hasgreater.compare")))); double compare = Double.parseDouble(ChatColor.stripColor(plugin.tex.papiNoColour(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(Objects.requireNonNull(cf.getConfigurationSection("hasgreater")), p); String section = hasSection(panel,Objects.requireNonNull(cf.getConfigurationSection("hasgreater")), p);
return ".hasgreater" + section; return ".hasgreater" + section;
} }
//loop through possible hasgreater 1,2,3,etc //loop through possible hasgreater 1,2,3,etc
@ -438,17 +439,17 @@ 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.papiNoColour(p,cf.getString("hasgreater" + count + ".value")))); value = Double.parseDouble(ChatColor.stripColor(plugin.tex.papiNoColour(panel,p,cf.getString("hasgreater" + count + ".value"))));
compare = Double.parseDouble(ChatColor.stripColor(plugin.papiNoColour(p,cf.getString("hasgreater" + count + ".compare")))); compare = Double.parseDouble(ChatColor.stripColor(plugin.tex.papiNoColour(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(Objects.requireNonNull(cf.getConfigurationSection("hasgreater" + count)), p); String section = hasSection(panel,Objects.requireNonNull(cf.getConfigurationSection("hasgreater" + count)), p);
return ".hasgreater" + count + section; return ".hasgreater" + count + section;
} }
} }
} }
} }
if (cf.contains("hasperm")) { if (cf.isSet("hasperm")) {
//this will do hasperm with no numbers //this will do hasperm with no numbers
boolean outputValue = true; boolean outputValue = true;
//outputValue will default to true //outputValue will default to true
@ -457,7 +458,7 @@ public class ItemCreation {
outputValue = cf.getBoolean("hasperm.output"); outputValue = cf.getBoolean("hasperm.output");
} }
if (p.hasPermission(Objects.requireNonNull(cf.getString("hasperm.perm"))) == outputValue) { if (p.hasPermission(Objects.requireNonNull(cf.getString("hasperm.perm"))) == outputValue) {
String section = hasSection(Objects.requireNonNull(cf.getConfigurationSection("hasperm")), p); String section = hasSection(panel,Objects.requireNonNull(cf.getConfigurationSection("hasperm")), p);
return ".hasperm" + section; return ".hasperm" + section;
} }
for(int count = 0; cf.getKeys(false).size() > count; count++){ for(int count = 0; cf.getKeys(false).size() > count; count++){
@ -469,7 +470,7 @@ public class ItemCreation {
outputValue = cf.getBoolean("hasperm" + count + ".output"); outputValue = cf.getBoolean("hasperm" + count + ".output");
} }
if (p.hasPermission(Objects.requireNonNull(cf.getString("hasperm" + count + ".perm"))) == outputValue) { if (p.hasPermission(Objects.requireNonNull(cf.getString("hasperm" + count + ".perm"))) == outputValue) {
String section = hasSection(Objects.requireNonNull(cf.getConfigurationSection("hasperm" + count)), p); String section = hasSection(panel,Objects.requireNonNull(cf.getConfigurationSection("hasperm" + count)), p);
return ".hasperm" + count + section; return ".hasperm" + count + section;
} }
} }

View File

@ -27,8 +27,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.papi(panel.getName())); panelNames.add(plugin.tex.papi(panel.getName()));
panelTitles.add(plugin.papi(panel.getConfig().getString("title"))); panelTitles.add(plugin.tex.papi(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 {
@ -56,10 +56,10 @@ public class OpenEditorGuis {
//make all the bottom bar items //make all the bottom bar items
ItemStack temp; ItemStack temp;
temp = new ItemStack(Material.SLIME_BALL, 1); temp = new ItemStack(Material.SLIME_BALL, 1);
plugin.setName(temp, ChatColor.WHITE + "Page " + pageNumber, null, p, true, true, true); plugin.setName(null,temp, ChatColor.WHITE + "Page " + pageNumber, null, p, true, true, true);
i.setItem(49, temp); i.setItem(49, temp);
temp = new ItemStack(Material.BARRIER, 1); temp = new ItemStack(Material.BARRIER, 1);
plugin.setName(temp, ChatColor.RED + "Exit Menu", null, p, true, true, true); plugin.setName(null,temp, ChatColor.RED + "Exit Menu", null, p, true, true, true);
i.setItem(45, temp); i.setItem(45, temp);
temp = new ItemStack(Material.BOOK, 1); temp = new ItemStack(Material.BOOK, 1);
List<String> lore = new ArrayList(); List<String> lore = new ArrayList();
@ -71,18 +71,18 @@ public class OpenEditorGuis {
lore.add(ChatColor.GRAY + " type 'remove' to set a"); lore.add(ChatColor.GRAY + " type 'remove' to set a");
lore.add(ChatColor.GRAY + " value to default, and use"); lore.add(ChatColor.GRAY + " value to default, and use");
lore.add(ChatColor.GRAY + " '" + plugin.config.getString("config.input-cancel") + "' to cancel."); lore.add(ChatColor.GRAY + " '" + plugin.config.getString("config.input-cancel") + "' to cancel.");
plugin.setName(temp, ChatColor.WHITE + "Panel Editor Tips", lore, p, true, true, true); plugin.setName(null,temp, ChatColor.WHITE + "Panel Editor Tips", lore, p, true, true, true);
i.setItem(53, temp); i.setItem(53, temp);
if (pageNumber != 1) { if (pageNumber != 1) {
//only show previous page button if number is not one //only show previous page button if number is not one
temp = new ItemStack(Material.PAPER, 1); temp = new ItemStack(Material.PAPER, 1);
plugin.setName(temp, ChatColor.WHITE + "Previous Page", null, p, true, true, true); plugin.setName(null,temp, ChatColor.WHITE + "Previous Page", null, p, true, true, true);
i.setItem(48, temp); i.setItem(48, temp);
} }
if (pageNumber < pagesAmount) { if (pageNumber < pagesAmount) {
//if page number is under pages amount //if page number is under pages amount
temp = new ItemStack(Material.PAPER, 1); temp = new ItemStack(Material.PAPER, 1);
plugin.setName(temp, ChatColor.WHITE + "Next Page", null, p, true, true, true); plugin.setName(null,temp, ChatColor.WHITE + "Next Page", null, p, true, true, true);
i.setItem(50, temp); i.setItem(50, temp);
} }
int count = 0; int count = 0;
@ -92,7 +92,7 @@ public class OpenEditorGuis {
//count is +1 because count starts at 0 not 1 //count is +1 because count starts at 0 not 1
if ((pageNumber * 45 - 45) < (count + 1) && (pageNumber * 45) > (count)) { if ((pageNumber * 45 - 45) < (count + 1) && (pageNumber * 45) > (count)) {
temp = panelItems.get(count); temp = panelItems.get(count);
plugin.setName(temp, ChatColor.WHITE + panelName, lore, p, false, true, true); plugin.setName(null,temp, ChatColor.WHITE + panelName, lore, p, false, true, true);
i.setItem(slot, temp); i.setItem(slot, temp);
slot += 1; slot += 1;
} }
@ -121,7 +121,7 @@ public class OpenEditorGuis {
lore.add(ChatColor.WHITE + "--------------------------------"); lore.add(ChatColor.WHITE + "--------------------------------");
lore.add(ChatColor.WHITE + "commandpanel.panel." + cf.getString("perm")); lore.add(ChatColor.WHITE + "commandpanel.panel." + cf.getString("perm"));
} }
plugin.setName(temp, ChatColor.WHITE + "Panel Permission", lore, p, true, true, true); plugin.setName(null,temp, ChatColor.WHITE + "Panel Permission", lore, p, true, true, true);
i.setItem(1, temp); i.setItem(1, temp);
temp = new ItemStack(Material.NAME_TAG, 1); temp = new ItemStack(Material.NAME_TAG, 1);
@ -131,7 +131,7 @@ public class OpenEditorGuis {
lore.add(ChatColor.WHITE + "------------------"); lore.add(ChatColor.WHITE + "------------------");
lore.add(ChatColor.WHITE + cf.getString("title")); lore.add(ChatColor.WHITE + cf.getString("title"));
} }
plugin.setName(temp, ChatColor.WHITE + "Panel Title", lore, p, true, true, true); plugin.setName(null,temp, ChatColor.WHITE + "Panel Title", lore, p, true, true, true);
i.setItem(3, temp); i.setItem(3, temp);
temp = new ItemStack(Material.JUKEBOX, 1); temp = new ItemStack(Material.JUKEBOX, 1);
@ -141,7 +141,7 @@ public class OpenEditorGuis {
lore.add(ChatColor.WHITE + "------------------------"); lore.add(ChatColor.WHITE + "------------------------");
lore.add(ChatColor.WHITE + Objects.requireNonNull(cf.getString("sound-on-open")).toUpperCase()); lore.add(ChatColor.WHITE + Objects.requireNonNull(cf.getString("sound-on-open")).toUpperCase());
} }
plugin.setName(temp, ChatColor.WHITE + "Panel Sound", lore, p, true, true, true); plugin.setName(null,temp, ChatColor.WHITE + "Panel Sound", lore, p, true, true, true);
i.setItem(5, temp); i.setItem(5, temp);
temp = new ItemStack(Material.IRON_DOOR, 1); temp = new ItemStack(Material.IRON_DOOR, 1);
@ -157,20 +157,20 @@ public class OpenEditorGuis {
count += 1; count += 1;
} }
} }
plugin.setName(temp, ChatColor.WHITE + "Panel Command", lore, p, true, true, true); plugin.setName(null,temp, ChatColor.WHITE + "Panel Command", lore, p, true, true, true);
i.setItem(7, temp); i.setItem(7, temp);
temp = new ItemStack(Material.LAVA_BUCKET, 1); temp = new ItemStack(Material.LAVA_BUCKET, 1);
lore.clear(); lore.clear();
lore.add(ChatColor.DARK_RED + "Permanently delete Panel"); lore.add(ChatColor.DARK_RED + "Permanently delete Panel");
plugin.setName(temp, ChatColor.RED + "Delete Panel", lore, p, true, true, true); plugin.setName(null,temp, ChatColor.RED + "Delete Panel", lore, p, true, true, true);
i.setItem(21, temp); i.setItem(21, temp);
temp = new ItemStack(Material.LADDER, 1); temp = new ItemStack(Material.LADDER, 1);
lore.clear(); lore.clear();
lore.add(ChatColor.GRAY + "How many rows the panel will be"); lore.add(ChatColor.GRAY + "How many rows the panel will be");
lore.add(ChatColor.GRAY + "choose an integer from 1 to 6"); lore.add(ChatColor.GRAY + "choose an integer from 1 to 6");
plugin.setName(temp, ChatColor.WHITE + "Panel Rows", lore, p, true, true, true); plugin.setName(null,temp, ChatColor.WHITE + "Panel Rows", lore, p, true, true, true);
i.setItem(23, temp); i.setItem(23, temp);
temp = new ItemStack(Material.STONE, 1); temp = new ItemStack(Material.STONE, 1);
@ -186,7 +186,7 @@ public class OpenEditorGuis {
count += 1; count += 1;
} }
} }
plugin.setName(temp, ChatColor.WHITE + "Disabled Worlds", lore, p, true, true, true); plugin.setName(null,temp, ChatColor.WHITE + "Disabled Worlds", lore, p, true, true, true);
i.setItem(25, temp); i.setItem(25, temp);
temp = new ItemStack(Material.GLASS, 1); temp = new ItemStack(Material.GLASS, 1);
@ -196,7 +196,7 @@ public class OpenEditorGuis {
lore.add(ChatColor.WHITE + "-----------------------"); lore.add(ChatColor.WHITE + "-----------------------");
lore.add(ChatColor.WHITE + Objects.requireNonNull(cf.getString("empty")).toUpperCase()); lore.add(ChatColor.WHITE + Objects.requireNonNull(cf.getString("empty")).toUpperCase());
} }
plugin.setName(temp, ChatColor.WHITE + "Panel Empty Item", lore, p, true, true, true); plugin.setName(null,temp, ChatColor.WHITE + "Panel Empty Item", lore, p, true, true, true);
i.setItem(13, temp); i.setItem(13, temp);
temp = new ItemStack(Material.ANVIL, 1); temp = new ItemStack(Material.ANVIL, 1);
@ -212,7 +212,7 @@ public class OpenEditorGuis {
count += 1; count += 1;
} }
} }
plugin.setName(temp, ChatColor.WHITE + "Panel Commands", lore, p, true, true, true); plugin.setName(null,temp, ChatColor.WHITE + "Panel Commands", lore, p, true, true, true);
i.setItem(15, temp); i.setItem(15, temp);
temp = new ItemStack(Material.STRING, 1); temp = new ItemStack(Material.STRING, 1);
@ -228,7 +228,7 @@ public class OpenEditorGuis {
count += 1; count += 1;
} }
} }
plugin.setName(temp, ChatColor.WHITE + "Panel Types", lore, p, true, true, true); plugin.setName(null,temp, ChatColor.WHITE + "Panel Types", lore, p, true, true, true);
i.setItem(17, temp); i.setItem(17, temp);
temp = new ItemStack(Material.ITEM_FRAME, 1); temp = new ItemStack(Material.ITEM_FRAME, 1);
@ -237,11 +237,11 @@ public class OpenEditorGuis {
lore.add(ChatColor.GRAY + "/cp [name]"); lore.add(ChatColor.GRAY + "/cp [name]");
lore.add(ChatColor.WHITE + "-----------------------"); lore.add(ChatColor.WHITE + "-----------------------");
lore.add(ChatColor.WHITE + panelName); lore.add(ChatColor.WHITE + panelName);
plugin.setName(temp, ChatColor.WHITE + "Panel Name", lore, p, true, true, true); plugin.setName(null,temp, ChatColor.WHITE + "Panel Name", lore, p, true, true, true);
i.setItem(11, temp); i.setItem(11, temp);
temp = new ItemStack(Material.BARRIER, 1); temp = new ItemStack(Material.BARRIER, 1);
plugin.setName(temp, ChatColor.RED + "Back", null, p, true, true, true); plugin.setName(null,temp, ChatColor.RED + "Back", null, p, true, true, true);
i.setItem(18, temp); i.setItem(18, temp);
//This will create a wall of glass panes, separating panel settings with hotbar settings //This will create a wall of glass panes, separating panel settings with hotbar settings
@ -250,7 +250,7 @@ public class OpenEditorGuis {
}else{ }else{
temp = new ItemStack(Material.matchMaterial("BLACK_STAINED_GLASS_PANE"), 1); temp = new ItemStack(Material.matchMaterial("BLACK_STAINED_GLASS_PANE"), 1);
} }
plugin.setName(temp, ChatColor.WHITE + "", null, p,false, true, true); plugin.setName(null,temp, ChatColor.WHITE + "", null, p,false, true, true);
for(int d = 27; d < 36; d++){ for(int d = 27; d < 36; d++){
i.setItem(d, temp); i.setItem(d, temp);
} }
@ -259,7 +259,7 @@ public class OpenEditorGuis {
if(cf.contains("open-with-item.material")){ if(cf.contains("open-with-item.material")){
hotbarItems = true; hotbarItems = true;
temp = plugin.itemCreate.makeItemFromConfig(cf.getConfigurationSection("open-with-item"), p, false, true, false); temp = plugin.itemCreate.makeItemFromConfig(null,cf.getConfigurationSection("open-with-item"), p, false, true, false);
}else{ }else{
temp = new ItemStack(Material.REDSTONE_BLOCK, 1); temp = new ItemStack(Material.REDSTONE_BLOCK, 1);
} }
@ -272,7 +272,7 @@ public class OpenEditorGuis {
lore.add(ChatColor.WHITE + "-----------------------"); lore.add(ChatColor.WHITE + "-----------------------");
lore.add(ChatColor.RED + "DISABLED"); lore.add(ChatColor.RED + "DISABLED");
} }
plugin.setName(temp, ChatColor.WHITE + "Panel Hotbar Item", lore, p, true, true, true); plugin.setName(null,temp, ChatColor.WHITE + "Panel Hotbar Item", lore, p, true, true, true);
i.setItem(40, temp); i.setItem(40, temp);
if(hotbarItems) { if(hotbarItems) {
@ -283,7 +283,7 @@ public class OpenEditorGuis {
lore.add(ChatColor.WHITE + "----------"); lore.add(ChatColor.WHITE + "----------");
lore.add(ChatColor.WHITE + Objects.requireNonNull(cf.getString("open-with-item.name"))); lore.add(ChatColor.WHITE + Objects.requireNonNull(cf.getString("open-with-item.name")));
} }
plugin.setName(temp, ChatColor.WHITE + "Hotbar Item Name", lore, p, true, true, true); plugin.setName(null,temp, ChatColor.WHITE + "Hotbar Item Name", lore, p, true, true, true);
i.setItem(38, temp); i.setItem(38, temp);
temp = new ItemStack(Material.FEATHER, 1); temp = new ItemStack(Material.FEATHER, 1);
@ -299,7 +299,7 @@ public class OpenEditorGuis {
count += 1; count += 1;
} }
} }
plugin.setName(temp, ChatColor.WHITE + "Hotbar Lore", lore, p, true, true, true); plugin.setName(null,temp, ChatColor.WHITE + "Hotbar Lore", lore, p, true, true, true);
i.setItem(36, temp); i.setItem(36, temp);
temp = new ItemStack(Material.BEDROCK, 1); temp = new ItemStack(Material.BEDROCK, 1);
@ -311,7 +311,7 @@ public class OpenEditorGuis {
int location = cf.getInt("open-with-item.stationary"); int location = cf.getInt("open-with-item.stationary");
lore.add(ChatColor.WHITE + String.valueOf(location)); lore.add(ChatColor.WHITE + String.valueOf(location));
} }
plugin.setName(temp, ChatColor.WHITE + "Hotbar Item Location", lore, p, true, true, true); plugin.setName(null,temp, ChatColor.WHITE + "Hotbar Item Location", lore, p, true, true, true);
i.setItem(42, temp); i.setItem(42, temp);
temp = new ItemStack(Material.BOOK, 1); temp = new ItemStack(Material.BOOK, 1);
@ -329,7 +329,7 @@ public class OpenEditorGuis {
count += 1; count += 1;
} }
} }
plugin.setName(temp, ChatColor.WHITE + "Hotbar Item Commands", lore, p, true, true,true); plugin.setName(null,temp, ChatColor.WHITE + "Hotbar Item Commands", lore, p, true, true,true);
i.setItem(44, temp); i.setItem(44, temp);
} }
@ -357,7 +357,7 @@ public class OpenEditorGuis {
lore.add(ChatColor.WHITE + cf.getString("name")); lore.add(ChatColor.WHITE + cf.getString("name"));
} }
} }
plugin.setName(temp, ChatColor.WHITE + "Item Name", lore, p, true, true, true); plugin.setName(null,temp, ChatColor.WHITE + "Item Name", lore, p, true, true, true);
i.setItem(1, temp); i.setItem(1, temp);
temp = new ItemStack(Material.ANVIL, 1); temp = new ItemStack(Material.ANVIL, 1);
@ -373,7 +373,7 @@ public class OpenEditorGuis {
count += 1; count += 1;
} }
} }
plugin.setName(temp, ChatColor.WHITE + "Item Commands", lore, p, true, true, true); plugin.setName(null,temp, ChatColor.WHITE + "Item Commands", lore, p, true, true, true);
i.setItem(3, temp); i.setItem(3, temp);
temp = new ItemStack(Material.ENCHANTED_BOOK, 1); temp = new ItemStack(Material.ENCHANTED_BOOK, 1);
@ -388,7 +388,7 @@ public class OpenEditorGuis {
lore.add(ChatColor.WHITE + "--------------------------------"); lore.add(ChatColor.WHITE + "--------------------------------");
lore.add(ChatColor.WHITE + "false"); lore.add(ChatColor.WHITE + "false");
} }
plugin.setName(temp, ChatColor.WHITE + "Item Enchantment", lore, p, true, true, true); plugin.setName(null,temp, ChatColor.WHITE + "Item Enchantment", lore, p, true, true, true);
i.setItem(5, temp); i.setItem(5, temp);
temp = new ItemStack(Material.POTION, 1); temp = new ItemStack(Material.POTION, 1);
@ -400,7 +400,7 @@ public class OpenEditorGuis {
lore.add(ChatColor.WHITE + cf.getString("potion")); lore.add(ChatColor.WHITE + cf.getString("potion"));
} }
} }
plugin.setName(temp, ChatColor.WHITE + "Item Potion Effect", lore, p, true, true, true); plugin.setName(null,temp, ChatColor.WHITE + "Item Potion Effect", lore, p, true, true, true);
i.setItem(7, temp); i.setItem(7, temp);
temp = new ItemStack(Material.PAPER, 1); temp = new ItemStack(Material.PAPER, 1);
@ -416,7 +416,7 @@ public class OpenEditorGuis {
count += 1; count += 1;
} }
} }
plugin.setName(temp, ChatColor.WHITE + "Item Duplicates", lore, p, true, true, true); plugin.setName(null,temp, ChatColor.WHITE + "Item Duplicates", lore, p, true, true, true);
i.setItem(13, temp); i.setItem(13, temp);
temp = new ItemStack(Material.FEATHER, 1); temp = new ItemStack(Material.FEATHER, 1);
@ -432,7 +432,7 @@ public class OpenEditorGuis {
count += 1; count += 1;
} }
} }
plugin.setName(temp, ChatColor.WHITE + "Item Lores", lore, p, true, true, true); plugin.setName(null,temp, ChatColor.WHITE + "Item Lores", lore, p, true, true, true);
i.setItem(19, temp); i.setItem(19, temp);
temp = new ItemStack(Material.ITEM_FRAME, 2); temp = new ItemStack(Material.ITEM_FRAME, 2);
@ -448,7 +448,7 @@ public class OpenEditorGuis {
lore.add(ChatColor.WHITE + cf.getString("stack")); lore.add(ChatColor.WHITE + cf.getString("stack"));
} }
} }
plugin.setName(temp, ChatColor.WHITE + "Item Stack Size", lore, p, true, true, true); plugin.setName(null,temp, ChatColor.WHITE + "Item Stack Size", lore, p, true, true, true);
i.setItem(21, temp); i.setItem(21, temp);
if(!plugin.legacy.isLegacy()) { if(!plugin.legacy.isLegacy()) {
@ -461,7 +461,7 @@ public class OpenEditorGuis {
lore.add(ChatColor.WHITE + cf.getString("customdata")); lore.add(ChatColor.WHITE + cf.getString("customdata"));
} }
} }
plugin.setName(temp, ChatColor.WHITE + "Custom Model Data", lore, p, true, true, true); plugin.setName(null,temp, ChatColor.WHITE + "Custom Model Data", lore, p, true, true, true);
i.setItem(23, temp); i.setItem(23, temp);
} }
@ -476,7 +476,7 @@ public class OpenEditorGuis {
lore.add(ChatColor.GRAY + "Sections and add complex values."); lore.add(ChatColor.GRAY + "Sections and add complex values.");
lore.add(ChatColor.WHITE + "--------------------------------"); lore.add(ChatColor.WHITE + "--------------------------------");
lore.add(ChatColor.WHITE + section); lore.add(ChatColor.WHITE + section);
plugin.setName(temp, ChatColor.WHITE + "Item Sections", lore, p, true, true, true); plugin.setName(null,temp, ChatColor.WHITE + "Item Sections", lore, p, true, true, true);
i.setItem(31, temp); i.setItem(31, temp);
temp = new ItemStack(Material.LEATHER_HELMET, 1); temp = new ItemStack(Material.LEATHER_HELMET, 1);
@ -489,18 +489,18 @@ public class OpenEditorGuis {
lore.add(ChatColor.WHITE + cf.getString("leatherarmor")); lore.add(ChatColor.WHITE + cf.getString("leatherarmor"));
} }
} }
plugin.setName(temp, ChatColor.WHITE + "Leather Armor Colour", lore, p, true, true, true); plugin.setName(null,temp, ChatColor.WHITE + "Leather Armor Colour", lore, p, true, true, true);
i.setItem(25, temp); i.setItem(25, temp);
temp = new ItemStack(Material.BARRIER, 1); temp = new ItemStack(Material.BARRIER, 1);
plugin.setName(temp, ChatColor.RED + "Back", null, p, true, true, true); plugin.setName(null,temp, ChatColor.RED + "Back", null, p, true, true, true);
i.setItem(27, temp); i.setItem(27, temp);
temp = plugin.itemCreate.makeItemFromConfig(cf,p,false,false, false); temp = plugin.itemCreate.makeItemFromConfig(null,cf,p,false,false, false);
lore.clear(); lore.clear();
lore.add(ChatColor.GRAY + "Click to set custom material"); lore.add(ChatColor.GRAY + "Click to set custom material");
lore.add(ChatColor.GRAY + "typically for custom heads"); lore.add(ChatColor.GRAY + "typically for custom heads");
plugin.setName(temp, ChatColor.WHITE + "Item Section " + section + " Preview", lore, p, true, true, true); plugin.setName(null,temp, ChatColor.WHITE + "Item Section " + section + " Preview", lore, p, true, true, true);
i.setItem(35, temp); i.setItem(35, temp);
p.openInventory(i); p.openInventory(i);
@ -535,23 +535,23 @@ public class OpenEditorGuis {
lore.add(ChatColor.WHITE + "Compare: " + ChatColor.GRAY + cf.getString(section + ".compare")); lore.add(ChatColor.WHITE + "Compare: " + ChatColor.GRAY + cf.getString(section + ".compare"));
} }
temp = plugin.itemCreate.makeItemFromConfig(cf.getConfigurationSection(section),p,false,false, false); temp = plugin.itemCreate.makeItemFromConfig(null,cf.getConfigurationSection(section),p,false,false, false);
plugin.setName(temp, ChatColor.AQUA + section, lore, p,false, true, true); plugin.setName(null,temp, ChatColor.AQUA + section, lore, p,false, true, true);
i.setItem(slot, temp); i.setItem(slot, temp);
slot++; slot++;
} }
} }
temp = new ItemStack(Material.REDSTONE, 1); temp = new ItemStack(Material.REDSTONE, 1);
plugin.setName(temp, ChatColor.WHITE + "Remove Section", null, p, true, true, true); plugin.setName(null,temp, ChatColor.WHITE + "Remove Section", null, p, true, true, true);
i.setItem(38, temp); i.setItem(38, temp);
temp = new ItemStack(Material.SLIME_BALL, 1); temp = new ItemStack(Material.SLIME_BALL, 1);
plugin.setName(temp, ChatColor.WHITE + "Add Section", null, p, true, true, true); plugin.setName(null,temp, ChatColor.WHITE + "Add Section", null, p, true, true, true);
i.setItem(42, temp); i.setItem(42, temp);
temp = new ItemStack(Material.BARRIER, 1); temp = new ItemStack(Material.BARRIER, 1);
plugin.setName(temp, ChatColor.RED + "Back", null, p, true, true, true); plugin.setName(null,temp, ChatColor.RED + "Back", null, p, true, true, true);
i.setItem(36, temp); i.setItem(36, temp);
temp = new ItemStack(Material.BOOK, 1); temp = new ItemStack(Material.BOOK, 1);
@ -560,7 +560,7 @@ public class OpenEditorGuis {
lore.add(ChatColor.GRAY + "- hasperm"); lore.add(ChatColor.GRAY + "- hasperm");
lore.add(ChatColor.GRAY + "- hasvalue"); lore.add(ChatColor.GRAY + "- hasvalue");
lore.add(ChatColor.GRAY + "- hasgreater"); lore.add(ChatColor.GRAY + "- hasgreater");
plugin.setName(temp, ChatColor.WHITE + "Item Section " + itemSection, lore, p, true, true, true); plugin.setName(null,temp, ChatColor.WHITE + "Item Section " + itemSection, lore, p, true, true, true);
i.setItem(44, temp); i.setItem(44, temp);
p.openInventory(i); p.openInventory(i);

View File

@ -0,0 +1,106 @@
package me.rockyhawk.commandpanels.classresources.placeholders;
import me.clip.placeholderapi.PlaceholderAPI;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.Panel;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import java.util.List;
public class CreateText {
CommandPanels plugin;
public CreateText(CommandPanels pl) {
this.plugin = pl;
}
//papi except if it is a String List
public List<String> papiNoColour(Panel panel, Player p, List<String> setpapi) {
try {
int tempInt = 0;
for (String temp : setpapi) {
setpapi.set(tempInt, plugin.placeholders.setCpPlaceholders(panel, p, temp));
tempInt += 1;
}
if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
OfflinePlayer offp = plugin.getServer().getOfflinePlayer(p.getUniqueId());
setpapi = PlaceholderAPI.setPlaceholders(offp, setpapi);
}
}catch(Exception ignore){
//this will be ignored as it is probably a null
return null;
}
return setpapi;
}
//papi except if it is a String List
public List<String> papi(Panel panel, Player p, List<String> setpapi, boolean placeholder) {
try {
if(placeholder) {
int tempInt = 0;
for (String temp : setpapi) {
setpapi.set(tempInt, plugin.placeholders.setCpPlaceholders(panel, p, temp));
tempInt += 1;
}
if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
OfflinePlayer offp = plugin.getServer().getOfflinePlayer(p.getUniqueId());
setpapi = PlaceholderAPI.setPlaceholders(offp, setpapi);
}
}
}catch(Exception ignore){
//this will be ignored as it is probably a null
return null;
}
int tempInt = 0;
//change colour
for(String temp : setpapi){
try {
setpapi.set(tempInt, plugin.translateHexColorCodes(ChatColor.translateAlternateColorCodes('&', temp)));
}catch(NullPointerException ignore){
}
tempInt += 1;
}
return setpapi;
}
//regular string papi, but only colours so Player doesn't need to be there
public String papi(String setpapi) {
try {
setpapi = plugin.translateHexColorCodes(ChatColor.translateAlternateColorCodes('&', setpapi));
return setpapi;
}catch(NullPointerException e){
return setpapi;
}
}
//string papi with no colours
public String papiNoColour(Panel panel, Player p, String setpapi) {
try {
setpapi = plugin.placeholders.setCpPlaceholders(panel, p,setpapi);
if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
OfflinePlayer offp = plugin.getServer().getOfflinePlayer(p.getUniqueId());
setpapi = PlaceholderAPI.setPlaceholders(offp, setpapi);
}
return setpapi;
}catch(NullPointerException e){
return setpapi;
}
}
//regular string papi
public String papi(Panel panel, Player p, String setpapi) {
try {
setpapi = plugin.placeholders.setCpPlaceholders(panel, p,setpapi);
if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
OfflinePlayer offp = plugin.getServer().getOfflinePlayer(p.getUniqueId());
setpapi = PlaceholderAPI.setPlaceholders(offp, setpapi);
}
setpapi = plugin.translateHexColorCodes(ChatColor.translateAlternateColorCodes('&', setpapi));
return setpapi;
}catch(NullPointerException e){
return setpapi;
}
}
}

View File

@ -1,8 +1,9 @@
package me.rockyhawk.commandpanels.classresources; package me.rockyhawk.commandpanels.classresources.placeholders;
import com.bencodez.votingplugin.user.UserManager; import com.bencodez.votingplugin.user.UserManager;
import me.realized.tokenmanager.api.TokenManager; import me.realized.tokenmanager.api.TokenManager;
import me.rockyhawk.commandpanels.CommandPanels; import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.Panel;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -22,7 +23,7 @@ public class Placeholders {
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public String setCpPlaceholders(Player p, String str){ public String setCpPlaceholders(Panel panel, Player p, String str){
//replace nodes with PlaceHolders //replace nodes with PlaceHolders
str = str.replaceAll("%cp-player-displayname%", p.getDisplayName()); str = str.replaceAll("%cp-player-displayname%", p.getDisplayName());
str = str.replaceAll("%cp-player-name%", p.getName()); str = str.replaceAll("%cp-player-name%", p.getName());
@ -31,18 +32,20 @@ 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.papi(plugin.tag)); str = str.replaceAll("%cp-tag%", plugin.tex.papi(plugin.tag));
//set custom placeholders to their values //set custom placeholders to their values
for(String[] placeholder : plugin.customCommand.getCCP(p.getName())){ if(panel != null) {
while (str.contains(placeholder[0])) { for (String placeholder : panel.placeholders.keys.keySet()) {
try { while (str.contains(placeholder)) {
int start = str.indexOf(placeholder[0]); try {
int end = start + placeholder[0].length() - 1; int start = str.indexOf(placeholder);
str = str.replace(str.substring(start, end) + "%", placeholder[1]); int end = start + placeholder.length() - 1;
}catch (Exception ex){ str = str.replace(str.substring(start, end) + "%", panel.placeholders.keys.get(placeholder));
plugin.debug(ex,p); } catch (Exception ex) {
break; plugin.debug(ex, p);
break;
}
} }
} }
} }
@ -103,6 +106,24 @@ public class Placeholders {
break; break;
} }
} }
//get stack amount from slot in current open inventory (panel)
while (str.contains("%cp-modeldata-")) {
try {
int start = str.indexOf("%cp-modeldata-");
int end = str.indexOf("%", str.indexOf("%cp-modeldata-") + 1);
String matNumber = str.substring(start, end).replace("%cp-modeldata-", "").replace("%", "");
int modelData;
try {
modelData = p.getOpenInventory().getTopInventory().getItem(Integer.parseInt(matNumber)).getItemMeta().getCustomModelData();
} catch (NullPointerException er) {
modelData = 0;
}
str = str.replace(str.substring(start, end) + "%", String.valueOf(modelData));
}catch(Exception ex){
plugin.debug(ex,p);
break;
}
}
//is an item damaged //is an item damaged
while (str.contains("%cp-damaged-")) { while (str.contains("%cp-damaged-")) {
try { try {
@ -148,7 +169,7 @@ public class Placeholders {
try { try {
//if it is a regular custom item //if it is a regular custom item
ItemStack confItm = plugin.itemCreate.makeItemFromConfig(plugin.openPanels.getOpenPanel(p.getName()).getConfig().getConfigurationSection("custom-item." + matLoc),p,true,true, false); ItemStack confItm = plugin.itemCreate.makeItemFromConfig(panel,plugin.openPanels.getOpenPanel(p.getName()).getConfig().getConfigurationSection("custom-item." + matLoc),p,true,true, false);
if(plugin.itemCreate.isIdentical(confItm,itm)){ if(plugin.itemCreate.isIdentical(confItm,itm)){
isIdentical = true; isIdentical = true;
} }
@ -214,7 +235,7 @@ public class Placeholders {
int end = str.indexOf("%", str.indexOf("%cp-setdata-") + 1); int end = str.indexOf("%", str.indexOf("%cp-setdata-") + 1);
String point_value = str.substring(start, end).replace("%cp-setdata-", "").replace("%", ""); String point_value = str.substring(start, end).replace("%cp-setdata-", "").replace("%", "");
String command = "set-data= " + point_value.split(",")[0] + " " + point_value.split(",")[1]; String command = "set-data= " + point_value.split(",")[0] + " " + point_value.split(",")[1];
plugin.commandTags.commandTags(p,plugin.papi(p,command),command); plugin.commandTags.commandTags(panel,p, plugin.tex.papi(panel,p,command),command);
str = str.replace(str.substring(start, end) + "%", ""); str = str.replace(str.substring(start, end) + "%", "");
}catch (Exception ex){ }catch (Exception ex){
plugin.debug(ex,p); plugin.debug(ex,p);
@ -228,7 +249,7 @@ public class Placeholders {
int end = str.indexOf("%", str.indexOf("%cp-mathdata-") + 1); int end = str.indexOf("%", str.indexOf("%cp-mathdata-") + 1);
String point_value = str.substring(start, end).replace("%cp-mathdata-", "").replace("%", ""); String point_value = str.substring(start, end).replace("%cp-mathdata-", "").replace("%", "");
String command = "math-data= " + point_value.split(",")[0] + " " + point_value.split(",")[1]; String command = "math-data= " + point_value.split(",")[0] + " " + point_value.split(",")[1];
plugin.commandTags.commandTags(p,plugin.papi(p,command),command); plugin.commandTags.commandTags(panel,p, plugin.tex.papi(panel,p,command),command);
str = str.replace(str.substring(start, end) + "%", ""); str = str.replace(str.substring(start, end) + "%", "");
}catch (Exception ex){ }catch (Exception ex){
plugin.debug(ex,p); plugin.debug(ex,p);
@ -244,7 +265,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.papi(Objects.requireNonNull(plugin.config.getString("config.format.offline")))); str = str.replace(str.substring(start, end) + "-find%", plugin.tex.papi(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());
} }
@ -280,7 +301,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.papi(p, temp)); p.sendMessage(plugin.tex.papi(panel,p, temp));
} }
str = "cpc"; str = "cpc";
} }

View File

@ -32,7 +32,7 @@ public class Commandpanel implements CommandExecutor {
return true; return true;
} }
if(panel == null){ if(panel == null){
sender.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.nopanel"))); sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.nopanel")));
return true; return true;
} }
boolean disableCommand = false; boolean disableCommand = false;
@ -49,21 +49,21 @@ public class Commandpanel implements CommandExecutor {
if(args.length == 2){ if(args.length == 2){
if(!args[1].equals("item")){ if(!args[1].equals("item")){
if(!disableCommand) { if(!disableCommand) {
plugin.openVoids.openCommandPanel(sender, plugin.getServer().getPlayer(args[1]), panel, true); plugin.openVoids.openCommandPanel(sender, plugin.getServer().getPlayer(args[1]), panel.copy(), true);
} }
}else{ }else{
sender.sendMessage(plugin.papi(plugin.tag + ChatColor.RED + "Usage: /cp <panel> [item] [player]")); sender.sendMessage(plugin.tex.papi(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.getConfig(),true);
}else{ }else{
sender.sendMessage(plugin.papi(plugin.tag + ChatColor.RED + "Usage: /cp <panel> item [player]")); sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Usage: /cp <panel> item [player]"));
} }
return true; return true;
} else { } else {
sender.sendMessage(plugin.papi( plugin.tag + ChatColor.RED + "Please execute command directed to a Player!")); sender.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Please execute command directed to a Player!"));
return true; return true;
} }
}else{ }else{
@ -72,7 +72,7 @@ public class Commandpanel implements CommandExecutor {
//do player command //do player command
if (args.length == 1) { if (args.length == 1) {
if(!disableCommand) { if(!disableCommand) {
plugin.openVoids.openCommandPanel(sender, p, panel, false); plugin.openVoids.openCommandPanel(sender, p, panel.copy(), false);
} }
return true; return true;
}else if(args.length == 2){ }else if(args.length == 2){
@ -80,7 +80,7 @@ public class Commandpanel implements CommandExecutor {
plugin.openVoids.giveHotbarItem(sender, p, panel.getConfig(), false); plugin.openVoids.giveHotbarItem(sender, p, panel.getConfig(), false);
}else{ }else{
if(!disableCommand) { if(!disableCommand) {
plugin.openVoids.openCommandPanel(sender, plugin.getServer().getPlayer(args[1]), panel, true); plugin.openVoids.openCommandPanel(sender, plugin.getServer().getPlayer(args[1]), panel.copy(), true);
} }
} }
return true; return true;
@ -90,7 +90,7 @@ public class Commandpanel implements CommandExecutor {
} }
} }
} }
sender.sendMessage(plugin.papi(plugin.tag + ChatColor.RED + "Usage: /cp <panel> [player:item] [player]")); sender.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.GREEN + "Global Debug Mode: " + plugin.debug.consoleDebug)); sender.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.GREEN + "Personal Debug Mode Disabled!")); sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.GREEN + "Personal Debug Mode Disabled!"));
}else{ }else{
plugin.debug.debugSet.add(p); plugin.debug.debugSet.add(p);
sender.sendMessage(plugin.papi(plugin.tag + ChatColor.GREEN + "Personal Debug Mode Enabled!")); sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.GREEN + "Personal Debug Mode Enabled!"));
} }
}else{ }else{
sender.sendMessage(plugin.papi(plugin.tag + ChatColor.RED + "Usage: /cpd")); sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Usage: /cpd"));
} }
}else{ }else{
sender.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.perms"))); sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.perms")));
} }
return true; return true;
} }
sender.sendMessage(plugin.papi(plugin.tag + ChatColor.RED + "Usage: /cpd")); sender.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.RED + "No panels found!")); sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "No panels found!"));
return true; return true;
} }
}catch(Exception b){ }catch(Exception b){
sender.sendMessage(plugin.papi(plugin.tag + ChatColor.RED + "No panels found!")); sender.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.RED + "Inaccessible Page")); sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Inaccessible Page"));
} }
} }
sender.sendMessage(plugin.papi(plugin.tag + ChatColor.DARK_AQUA + "Panels: (Page " + page + ")")); sender.sendMessage(plugin.tex.papi(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.papi(plugin.tag + plugin.config.getString("config.format.perms"))); sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.perms")));
} }
return true; return true;
} }
sender.sendMessage(plugin.papi(plugin.tag + ChatColor.RED + "Usage: /cpl")); sender.sendMessage(plugin.tex.papi(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.papi(plugin.config.getString("config.format.tag") + " "); plugin.tag = plugin.tex.papi(plugin.config.getString("config.format.tag") + " ");
sender.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.reload"))); sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.reload")));
}else{ }else{
sender.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.perms"))); sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.perms")));
} }
return true; return true;
} }
sender.sendMessage(plugin.papi(plugin.tag + ChatColor.RED + "Usage: /cpr")); sender.sendMessage(plugin.tex.papi(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.papi(plugin.tag)); sender.sendMessage(plugin.tex.papi(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.papi(plugin.tag + plugin.config.getString("config.format.perms"))); sender.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.GREEN + "Will not download a new version on restart.")); sender.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.GREEN + "Downloading version " + ChatColor.GRAY + args[0] + ChatColor.GREEN + " upon server restart.")); sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.GREEN + "Downloading version " + ChatColor.GRAY + args[0] + ChatColor.GREEN + " upon server restart."));
} }
}else{ }else{
sender.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.perms"))); sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.perms")));
} }
}else{ }else{
sender.sendMessage(plugin.papi(plugin.tag + ChatColor.RED + "Usage: /cpv [update:latest:cancel]")); sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Usage: /cpv [update:latest:cancel]"));
} }
return true; return true;
} }

View File

@ -1,52 +0,0 @@
package me.rockyhawk.commandpanels.customcommands;
import me.rockyhawk.commandpanels.CommandPanels;
import java.util.ArrayList;
public class CommandPlaceholderLoader {
CommandPanels plugin;
public CommandPlaceholderLoader(CommandPanels pl) {
this.plugin = pl;
}
ArrayList<String[]> pendingPlaceholders = new ArrayList<>(); //should read: panelName, playerName, placeholder, argument
//this will be used with the cpPlaceholder void, when the panel is closed it will remove the placeholder
public void addCCP(String panelName, String playerName, String placeholder, String argument){
pendingPlaceholders.add(new String[]{panelName,playerName,placeholder,argument});
}
//will remove all pending placeholders for a certain player & panel
public void removeCCP(String panelName, String playerName){
for(int i = 0; i < pendingPlaceholders.size(); i++){
if(playerName.equals(pendingPlaceholders.get(i)[1]) && panelName.equals(pendingPlaceholders.get(i)[0])){
pendingPlaceholders.remove(i);
i--;
}
}
}
//will return placeholder,argument
public ArrayList<String[]> getCCP(String playerName){
ArrayList<String[]> returnPlaceholders = new ArrayList<>();
for(String[] temp : pendingPlaceholders){
if(temp[1].equals(playerName)){
returnPlaceholders.add(new String[]{temp[2],temp[3]});
}
}
return returnPlaceholders;
}
//change a placeholder for a panel
public void editCCP(String panelName, String playerName, String placeholder, String argument){
for(int i = 0; i < pendingPlaceholders.size(); i++){
if(playerName.equals(pendingPlaceholders.get(i)[1]) && panelName.equals(pendingPlaceholders.get(i)[0]) && placeholder.equals(pendingPlaceholders.get(i)[2])){
pendingPlaceholders.remove(i);
pendingPlaceholders.add(new String[]{panelName,playerName,placeholder,argument});
return;
}
}
//if it reaches here it has not found the placeholder, add it manually
pendingPlaceholders.add(new String[]{panelName,playerName,placeholder,argument});
}
}

View File

@ -44,10 +44,11 @@ public class Commandpanelcustom implements Listener {
if(correctCommand){ if(correctCommand){
e.setCancelled(true); e.setCancelled(true);
Panel openPanel = panel.copy();
for(String[] placeholder : placeholders){ for(String[] placeholder : placeholders){
plugin.customCommand.addCCP(panel.getName(),e.getPlayer().getName(),placeholder[0],placeholder[1]); openPanel.placeholders.addPlaceholder(placeholder[0],placeholder[1]);
} }
panel.open(e.getPlayer()); openPanel.open(e.getPlayer());
return; return;
} }
} }

View File

@ -0,0 +1,15 @@
package me.rockyhawk.commandpanels.customcommands;
import java.util.HashMap;
public class PanelPlaceholders {
public HashMap<String,String> keys;
public void addPlaceholder(String placeholder, String argument){
keys.put(placeholder,argument);
}
public PanelPlaceholders(){
keys = new HashMap<>();
}
}

View File

@ -60,7 +60,7 @@ public class PanelDataLoader {
originalValue = new BigDecimal(dataConfig.getString("playerData." + playerUUID + "." + dataPoint)); originalValue = new BigDecimal(dataConfig.getString("playerData." + playerUUID + "." + dataPoint));
}catch(Exception ex){ }catch(Exception ex){
plugin.debug(ex,null); plugin.debug(ex,null);
originalValue = BigDecimal.ONE; originalValue = new BigDecimal("1");
} }
BigDecimal output; BigDecimal output;

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.papi(plugin.tag + ChatColor.RED + "Please execute command as a Player!")); sender.sendMessage(plugin.tex.papi(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.papi( plugin.tag + ChatColor.RED + "Please use integer from 1-6.")); p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Please use integer from 1-6."));
} }
}catch(Exception exc){ }catch(Exception exc){
p.sendMessage(plugin.papi( plugin.tag + ChatColor.RED + "Please use integer from 1-6.")); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Generate Mode Disabled!")); p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Generate Mode Disabled!"));
} else { } else {
this.plugin.generateMode.add(p); this.plugin.generateMode.add(p);
p.sendMessage(plugin.papi( plugin.tag + ChatColor.GREEN + "Generate Mode Enabled!")); p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Generate Mode Enabled!"));
} }
return true; return true;
} }
p.sendMessage(plugin.papi( plugin.tag + ChatColor.RED + "Usage: /cpg [rows]")); p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Usage: /cpg [rows]"));
return true; return true;
}else{ }else{
p.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.perms"))); p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.perms")));
return true; return true;
} }
} }
p.sendMessage(plugin.papi(plugin.tag + ChatColor.RED + "Usage: /cpg [rows]")); p.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.RED + "Cancelled Panel!")); p.sendMessage(plugin.tex.papi(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.papi( plugin.tag + ChatColor.GREEN + "Saved Generated File To: " + date + ".yml")); p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Saved Generated File To: " + date + ".yml"));
} catch (IOException var16) { } catch (IOException var16) {
p.sendMessage(plugin.papi( plugin.tag + ChatColor.RED + "Could Not Save Generated Panel!")); p.sendMessage(plugin.tex.papi( 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.papi(plugin.tag + plugin.config.getString("config.format.perms"))); sender.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.RED + "Editor disabled!")); sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Editor disabled!"));
return true; return true;
} }
if(!(sender instanceof Player)) { if(!(sender instanceof Player)) {
sender.sendMessage(plugin.papi( plugin.tag + ChatColor.RED + "Please execute command as a Player!")); sender.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Please execute command as a Player!"));
return true; return true;
} }
Player p = (Player)sender; Player p = (Player)sender;
@ -39,7 +39,7 @@ public class CpIngameEditCommand implements CommandExecutor {
for(Panel panel : plugin.panelList){ for(Panel panel : plugin.panelList){
if(panel.getName().equals(args[0])) { if(panel.getName().equals(args[0])) {
//below will start the command, once it got the right file and panel //below will start the command, once it got the right file and panel
plugin.createGUI.openGui(panel, p,3,0); plugin.createGUI.openGui(panel.copy(), p,3,0);
return true; return true;
} }
} }
@ -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.papi(plugin.tag + ChatColor.RED + "Usage: /cpe <panel>")); sender.sendMessage(plugin.tex.papi(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.papi(cf.getString("title")); panelTitle = plugin.tex.papi(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.papi( Objects.requireNonNull(plugin.config.getString("config.input-cancelled")))); e.getPlayer().sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Deleted Panel!")); p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Deleted Panel!"));
}else{ }else{
p.sendMessage(plugin.papi( plugin.tag + ChatColor.RED + "Could Not Delete Panel!")); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Deleted Panel!")); p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Deleted Panel!"));
}else{ }else{
p.sendMessage(plugin.papi( plugin.tag + ChatColor.RED + "Could Not Delete Panel!")); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.RED + "Permission cannot contain spaces!")); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Permission required is now " + "commandpanel.panel." + e.getMessage())); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Choose an integer between 1 to 6!")); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Set Panel to " + rows + " rows!")); p.sendMessage(plugin.tex.papi( 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.papi(e.getMessage()))){ if(panelTitle.equals(plugin.tex.papi(e.getMessage()))){
p.sendMessage(plugin.papi(plugin.tag + e.getMessage() + ChatColor.RED + " is in use from another panel!")); p.sendMessage(plugin.tex.papi(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.papi( plugin.tag + ChatColor.GREEN + "Set new Title to " + ChatColor.WHITE + e.getMessage())); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.RED + "Panel name cannot contain spaces!")); p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Panel name cannot contain spaces!"));
break; break;
} }
if(panelName.equals(e.getMessage())){ if(panelName.equals(e.getMessage())){
p.sendMessage(plugin.papi(plugin.tag + ChatColor.RED + e.getMessage() + " is in use from another panel!")); p.sendMessage(plugin.tex.papi(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.papi( plugin.tag + ChatColor.GREEN + "Set new Name to " + e.getMessage())); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Empty materials have been removed.")); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.RED + e.getMessage() + " is not a valid Material!")); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Set Empty material to " + materialTemp)); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Sounds have been removed.")); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.RED + e.getMessage() + " is not a valid Sound!")); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Sound when opening is now " + tempSound)); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Added new panel type: " + e.getMessage().toLowerCase())); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.RED + "No types found to remove!")); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.RED + "Could not find type!")); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Removed panel type " + e.getMessage())); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Added new command: " + e.getMessage())); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.RED + "No commands found to remove!")); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.RED + "Could not find command!")); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Removed command line " + e.getMessage())); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Added new command: " + e.getMessage())); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.RED + "No commands found to remove!")); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.RED + "Could not find command!")); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Removed command line " + e.getMessage())); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Added new World: " + e.getMessage())); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.RED + "No Worlds found to remove!")); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.RED + "Could not find World!")); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Removed World line " + e.getMessage())); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Hotbar item have been removed.")); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Set new Material to " + ChatColor.WHITE + e.getMessage())); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Hotbar item can now be moved.")); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Choose an integer between 0 to 33!")); p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Choose an integer between 0 to 33!"));
return; return;
} }
p.sendMessage(plugin.papi( plugin.tag + ChatColor.GREEN + "Set Hotbar Location to " + loc + "!")); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Set new Name to " + ChatColor.WHITE + e.getMessage())); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Added new lore: " + e.getMessage())); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.RED + "No lore found to remove!")); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.RED + "Could not find lore!")); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Removed lore line " + e.getMessage())); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Added new command: " + e.getMessage())); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.RED + "No commands found to remove!")); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.RED + "Could not find command!")); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Removed command line " + e.getMessage())); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Name is now default.")); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Set new name to " + ChatColor.WHITE + e.getMessage())); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Material is now default.")); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Set Material value to " + ChatColor.WHITE + e.getMessage())); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Item has been unstacked.")); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Choose an integer between 1 to 64!")); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Set stack to " + rows + "!")); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Enchantments have been removed.")); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Set new Enchantment to " + ChatColor.WHITE + e.getMessage())); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Potion effects have been removed.")); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Set new Potion to " + e.getMessage().toUpperCase())); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Custom Model Data has been removed.")); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Custom Model Data set to " + e.getMessage())); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Leather armor colour has been removed.")); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Leather armor colour set to " + e.getMessage())); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Added new command: " + e.getMessage())); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.RED + "No commands found to remove!")); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.RED + "Could not find command!")); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Removed command line " + e.getMessage())); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Added new lore: " + e.getMessage())); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.RED + "No lore found to remove!")); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.RED + "Could not find lore!")); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Removed lore line " + e.getMessage())); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Added new duplicate item/s: " + e.getMessage())); p.sendMessage(plugin.tex.papi( 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.papi(plugin.tag + ChatColor.RED + "Could not delete or find item!")); p.sendMessage(plugin.tex.papi(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.papi( plugin.tag + ChatColor.RED + "No items found to remove!")); p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "No items found to remove!"));
break; break;
} }
savePanelFile(cf, cfile, panelName, panelFile); savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.papi( plugin.tag + ChatColor.GREEN + "Removed duplicate item/s: " + e.getMessage())); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Added Section " + ChatColor.WHITE + playerMessage)); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Removed Section " + ChatColor.WHITE + playerMessage)); p.sendMessage(plugin.tex.papi( 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.papi( plugin.tag + ChatColor.GREEN + "Set " + playerMessage.split(":")[0] + " to " + ChatColor.WHITE + playerMessage.split(":")[1])); p.sendMessage(plugin.tex.papi( 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.papi("Command Panels Editor"))) || plugin.openPanels.hasPanelOpen(p.getName())){ if(!p.getOpenInventory().getTitle().equals(ChatColor.stripColor(plugin.tex.papi("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.papi(panel.getName())); panelNames.add(plugin.tex.papi(panel.getName()));
panelTitles.add(plugin.papi( Objects.requireNonNull(panel.getConfig().getString("title")))); panelTitles.add(plugin.tex.papi( 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.papi(plugin.tag + ChatColor.WHITE + "Enter New Permission")); p.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.WHITE + "Enter New Title")); p.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.WHITE + "Enter New Sound ID")); p.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.WHITE + "Enter New Command")); p.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.WHITE + "Enter Command to remove (must be an integer)")); p.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.WHITE + "Are you sure? (yes/no)")); p.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.WHITE + "Enter Row Amount (1 to 6)")); p.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.WHITE + "Enter New Material ID")); p.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.WHITE + "Enter New Command")); p.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.WHITE + "Enter Command to remove (must be an integer)")); p.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.WHITE + "Enter New Panel type")); p.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.WHITE + "Enter Panel Type to remove (must be an integer)")); p.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.WHITE + "Enter New World Name")); p.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.WHITE + "Enter World line to remove (must be an integer)")); p.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.WHITE + "Enter New Name")); p.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.WHITE + "Enter New Material")); p.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.WHITE + "Enter New Name")); p.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.WHITE + "Enter New Item Lore")); p.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.WHITE + "Enter lore line to remove (must be an integer)")); p.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.WHITE + "Enter Location (1 to 9)")); p.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.WHITE + "Enter New Item Command")); p.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.WHITE + "Enter command line to remove (must be an integer)")); p.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.WHITE + "Enter New Item Name")); p.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.WHITE + "Enter New Item Command")); p.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.WHITE + "Enter command line to remove (must be an integer)")); p.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.WHITE + "Enter New Item Enchantment")); p.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.WHITE + "Enter New Item Potion Effect")); p.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.WHITE + "Enter Duplicate Item Location/s")); p.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.WHITE + "Enter Duplicate Item/s to Remove (must be an integer)")); p.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.WHITE + "Enter New Item Lore")); p.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.WHITE + "Enter lore line to remove (must be an integer)")); p.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.WHITE + "Enter New Item Stack (must be an integer)")); p.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.WHITE + "Enter New Custom Model Data")); p.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.WHITE + "Enter New Leather Armor Colour")); p.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.WHITE + "Enter New Custom Material (eg. cps= self)")); p.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.WHITE + "Enter Setting to change, eg, value:500")); p.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.WHITE + "Enter Section name to remove, eg, hasperm or hasperm0")); p.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.WHITE + "Enter Section name to add, eg, hasperm or hasperm0")); p.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.GREEN + "Saved Changes!")); p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.GREEN + "Saved Changes!"));
} catch (IOException s) { } catch (IOException s) {
p.sendMessage(plugin.papi(plugin.tag + ChatColor.RED + "Could Not Save Changes!")); p.sendMessage(plugin.tex.papi(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.papi( Objects.requireNonNull(plugin.config.getString("config.input-cancelled")))); e.getPlayer().sendMessage(plugin.tex.papi( 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);
@ -35,7 +35,7 @@ public class CommandpanelUserInput implements Listener {
e.setCancelled(true); e.setCancelled(true);
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
public void run() { public void run() {
new CommandTags(plugin).commandTags(e.getPlayer(), plugin.papi(e.getPlayer(),command), command); //I have to do this to run regular Bukkit voids in an ASYNC Event new CommandTags(plugin).commandTags(null,e.getPlayer(), plugin.tex.papi(null,e.getPlayer(),command), command); //I have to do this to run regular Bukkit voids in an ASYNC Event
} }
}); });
} }

View File

@ -28,7 +28,7 @@ public class OpenGUI {
String title; String title;
if (onOpen != 3) { if (onOpen != 3) {
//regular inventory //regular inventory
title = plugin.papi(p,pconfig.getString("title")); title = plugin.tex.papi(panel,p,pconfig.getString("title"));
} else { } else {
//editor inventory //editor inventory
title = "Editing Panel: " + panel.getName(); title = "Editing Panel: " + panel.getName();
@ -46,7 +46,7 @@ public class OpenGUI {
String section = ""; String section = "";
//onOpen needs to not be 3 so the editor won't include hasperm and hasvalue, etc items //onOpen needs to not be 3 so the editor won't include hasperm and hasvalue, etc items
if (onOpen != 3) { if (onOpen != 3) {
section = plugin.itemCreate.hasSection(pconfig.getConfigurationSection("item." + Integer.parseInt(item)), p); section = plugin.itemCreate.hasSection(panel,pconfig.getConfigurationSection("item." + Integer.parseInt(item)), p);
//This section is for animations below here: VISUAL ONLY //This section is for animations below here: VISUAL ONLY
//check for if there is animations inside the items section //check for if there is animations inside the items section
@ -59,7 +59,7 @@ public class OpenGUI {
} }
//will only add NBT if not an editor GUI //will only add NBT if not an editor GUI
ItemStack s = plugin.itemCreate.makeItemFromConfig(Objects.requireNonNull(pconfig.getConfigurationSection("item." + item + section)), p, onOpen != 3, onOpen != 3, onOpen != 3); ItemStack s = plugin.itemCreate.makeItemFromConfig(panel,Objects.requireNonNull(pconfig.getConfigurationSection("item." + item + section)), p, onOpen != 3, onOpen != 3, onOpen != 3);
//This is for CUSTOM ITEMS //This is for CUSTOM ITEMS
if(pconfig.contains("item." + item + section + ".itemType")) { if(pconfig.contains("item." + item + section + ".itemType")) {
@ -111,7 +111,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.papi(plugin.tag + plugin.config.getString("config.format.error") + " item: One of the items does not fit in the Panel!")); 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.closeInventory(); p.closeInventory();
plugin.openPanels.closePanelForLoader(p.getName()); plugin.openPanels.closePanelForLoader(p.getName());
} }
@ -139,7 +139,7 @@ public class OpenGUI {
} }
} catch (IllegalArgumentException | NullPointerException var26) { } catch (IllegalArgumentException | NullPointerException var26) {
plugin.debug(var26,p); plugin.debug(var26,p);
p.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.error") + " empty: " + pconfig.getString("empty"))); p.sendMessage(plugin.tex.papi(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

@ -78,7 +78,6 @@ public class OpenPanelsLoader {
return; return;
} }
panelCloseCommands(playerName,openPanels.get(playerName)); panelCloseCommands(playerName,openPanels.get(playerName));
plugin.customCommand.removeCCP(openPanels.get(playerName).getName(), playerName);
if (plugin.config.contains("config.panel-snooper")) { if (plugin.config.contains("config.panel-snooper")) {
if (Objects.requireNonNull(plugin.config.getString("config.panel-snooper")).equalsIgnoreCase("true")) { if (Objects.requireNonNull(plugin.config.getString("config.panel-snooper")).equalsIgnoreCase("true")) {
Bukkit.getConsoleSender().sendMessage("[CommandPanels] " + playerName + " Closed " + openPanels.get(playerName).getName()); Bukkit.getConsoleSender().sendMessage("[CommandPanels] " + playerName + " Closed " + openPanels.get(playerName).getName());
@ -103,7 +102,7 @@ public class OpenPanelsLoader {
break; break;
} }
if(val == 2){ if(val == 2){
plugin.commandTags.commandTags(Bukkit.getPlayer(playerName), plugin.papi(Bukkit.getPlayer(playerName),command), command); plugin.commandTags.commandTags(panel,Bukkit.getPlayer(playerName), plugin.tex.papi(panel,Bukkit.getPlayer(playerName),command), command);
} }
} }
}catch(Exception s){ }catch(Exception s){

View File

@ -22,7 +22,7 @@ public class HotbarItemLoader {
stationaryItems.clear(); stationaryItems.clear();
for (Panel panel : plugin.panelList) { for (Panel panel : plugin.panelList) {
if(panel.getConfig().contains("open-with-item.stationary")){ if(panel.getConfig().contains("open-with-item.stationary")){
stationaryItems.put(panel.getConfig().getInt("open-with-item.stationary"), panel); stationaryItems.put(panel.getConfig().getInt("open-with-item.stationary"), panel.copy());
} }
} }
} }
@ -49,7 +49,7 @@ public class HotbarItemLoader {
} }
if(panel.getConfig().contains("open-with-item.commands")){ if(panel.getConfig().contains("open-with-item.commands")){
for(String command : panel.getConfig().getStringList("open-with-item.commands")){ for(String command : panel.getConfig().getStringList("open-with-item.commands")){
plugin.commandTags.commandTags(p,plugin.papi(p,command),command); plugin.commandTags.commandTags(panel,p, plugin.tex.papi(null,p,command),command);
} }
return true; return true;
} }
@ -84,7 +84,7 @@ public class HotbarItemLoader {
} }
if(panel.getConfig().contains("open-with-item.commands")){ if(panel.getConfig().contains("open-with-item.commands")){
for(String command : panel.getConfig().getStringList("open-with-item.commands")){ for(String command : panel.getConfig().getStringList("open-with-item.commands")){
plugin.commandTags.commandTags(p,plugin.papi(p,command),command); plugin.commandTags.commandTags(panel,p, plugin.tex.papi(null,p,command),command);
} }
return true; return true;
} }

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.papi(plugin.tag + ChatColor.RED + "Please execute command as a Player!")); sender.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.RED + "Panel blocks disabled in config!")); sender.sendMessage(plugin.tex.papi(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.papi(plugin.tag + plugin.config.getString("config.format.nopanel"))); sender.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.RED + "Look at a block to add a panel!")); sender.sendMessage(plugin.tex.papi(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,16 +60,16 @@ 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.papi(plugin.tag + ChatColor.RED + "Could not save to file!")); sender.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.WHITE + args[1] + ChatColor.GREEN + " will now open when right clicking " + ChatColor.WHITE + materialNameFormatted)); sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + args[1] + ChatColor.GREEN + " will now open when right clicking " + ChatColor.WHITE + materialNameFormatted));
return true; return true;
}else{ }else{
sender.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.perms"))); sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.perms")));
return true; return true;
} }
} }
@ -77,13 +77,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.papi(plugin.tag + ChatColor.RED + "Please execute command as a Player!")); sender.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.RED + "Panel blocks disabled in config!")); sender.sendMessage(plugin.tex.papi(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);
@ -95,40 +95,40 @@ 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.papi(plugin.tag + ChatColor.RED + "Could not save to file!")); sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Could not save to file!"));
return true; return true;
} }
sender.sendMessage(plugin.papi(plugin.tag + ChatColor.GREEN + "Panel has been removed from block.")); sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.GREEN + "Panel has been removed from block."));
}else{ }else{
sender.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.nopanel"))); sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.nopanel")));
} }
return true; return true;
}else{ }else{
sender.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.perms"))); sender.sendMessage(plugin.tex.papi(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.papi(plugin.tag + ChatColor.RED + "Panel blocks disabled in config!")); sender.sendMessage(plugin.tex.papi(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.papi(plugin.tag) + ChatColor.RED + "No panel blocks found."); sender.sendMessage(plugin.tex.papi(plugin.tag) + ChatColor.RED + "No panel blocks found.");
return true; return true;
} }
sender.sendMessage(plugin.papi(plugin.tag) + ChatColor.DARK_AQUA + "Panel Block Locations:"); sender.sendMessage(plugin.tex.papi(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.papi(plugin.tag) + ChatColor.RED + "No panel blocks found."); sender.sendMessage(plugin.tex.papi(plugin.tag) + ChatColor.RED + "No panel blocks found.");
} }
return true; return true;
}else{ }else{
sender.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.perms"))); sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.perms")));
return true; return true;
} }
} }

View File

@ -43,13 +43,13 @@ public class PanelBlockOnClick implements Listener {
e.setCancelled(true); e.setCancelled(true);
if(plugin.blockConfig.contains("blocks." + configLocation + ".commands")){ if(plugin.blockConfig.contains("blocks." + configLocation + ".commands")){
for(String command : plugin.blockConfig.getStringList("blocks." + configLocation + ".commands")){ for(String command : plugin.blockConfig.getStringList("blocks." + configLocation + ".commands")){
plugin.commandTags.commandTags(p,plugin.papi(p,command),command); plugin.commandTags.commandTags(null,p, plugin.tex.papi(null,p,command),command);
} }
return; return;
} }
//uses the open= tag because it will open a panel with panel names, but also works with open= features like placeholders //uses the open= tag because it will open a panel with panel names, but also works with open= features like placeholders
String command = "open= " + plugin.blockConfig.getString("blocks." + configLocation + ".panel"); String command = "open= " + plugin.blockConfig.getString("blocks." + configLocation + ".panel");
plugin.commandTags.commandTags(p, plugin.papi(p, command), command); plugin.commandTags.commandTags(null,p, plugin.tex.papi(null,p, command), command);
} }
} }
} }

View File

@ -3,6 +3,7 @@ package me.rockyhawk.commandpanels.updater;
import me.rockyhawk.commandpanels.CommandPanels; import me.rockyhawk.commandpanels.CommandPanels;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.scheduler.BukkitRunnable;
import java.io.*; import java.io.*;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
@ -19,50 +20,58 @@ public class Updater {
//if this is set to something, it will download that version on restart //if this is set to something, it will download that version on restart
//can be a version number, 'latest' or 'cancel' //can be a version number, 'latest' or 'cancel'
public String downloadVersionManually = null; public String downloadVersionManually = null;
public String catchedLatestVersion = "null";
public String githubNewUpdate(boolean sendMessages){ public String githubNewUpdate(boolean sendMessages){
HttpURLConnection connection; //refresh latest version
String gitVersion; getLatestVersion(sendMessages);
if(plugin.getDescription().getVersion().contains("-")){ if(plugin.getDescription().getVersion().contains("-")){
if(sendMessages) { if(sendMessages) {
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.GREEN + " Running a custom version."); Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.GREEN + " Running a custom version.");
} }
return null; return null;
} }
try{
connection = (HttpURLConnection) new URL("https://raw.githubusercontent.com/rockyhawk64/CommandPanels/master/resource/plugin.yml").openConnection();
connection.connect();
gitVersion = new BufferedReader(new InputStreamReader(connection.getInputStream())).readLine().split("\\s")[1];
if(gitVersion.contains("-")){
if(sendMessages) {
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.RED + " Cannot check for update.");
}
return null;
}
//if update is true there is a new update //if update is true there is a new update
boolean update = false; boolean update = false;
if(!gitVersion.equals(plugin.getDescription().getVersion())){ if(!catchedLatestVersion.equals(plugin.getDescription().getVersion())){
update = true; update = true;
} }
if(update){ if(update){
if(sendMessages) { if(sendMessages) {
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.GOLD + " ================================================"); Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.GOLD + " ================================================");
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.AQUA + " An update for CommandPanels is available."); Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.AQUA + " An update for CommandPanels is available.");
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + " Download CommandPanels " + ChatColor.GOLD + gitVersion + ChatColor.WHITE + " using the"); Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + " Download CommandPanels " + ChatColor.GOLD + catchedLatestVersion + ChatColor.WHITE + " using the");
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.WHITE + " following command:" + ChatColor.AQUA + " /cpv latest" + ChatColor.WHITE + " and restart the server"); Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.WHITE + " following command:" + ChatColor.AQUA + " /cpv latest" + ChatColor.WHITE + " and restart the server");
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.GOLD + " ================================================"); Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.GOLD + " ================================================");
} }
} }
return gitVersion; return catchedLatestVersion;
}catch(IOException e){ }
if(sendMessages) {
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.RED + " Error checking for updates online."); public void getLatestVersion(boolean sendMessages){
} //using an array allows editing while still being final
plugin.debug(e,null); new BukkitRunnable(){
public void run(){
HttpURLConnection connection;
try {
connection = (HttpURLConnection) new URL("https://raw.githubusercontent.com/rockyhawk64/CommandPanels/master/resource/plugin.yml").openConnection();
connection.connect();
catchedLatestVersion = new BufferedReader(new InputStreamReader(connection.getInputStream())).readLine().split("\\s")[1];
connection.disconnect();
} catch (IOException ignore) {
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.RED + " Could not access github.");
}
}
}.runTask(plugin);
if(catchedLatestVersion.contains("-")){
if(sendMessages) {
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.RED + " Cannot check for update.");
}
} }
return null;
} }
//the pluginFileName can only be obtained from the main class //the pluginFileName can only be obtained from the main class