Update 3.7.0

This commit is contained in:
rockyhawk64 2020-07-29 22:03:13 +10:00
parent a8745b8de7
commit d49732ff0a
30 changed files with 741 additions and 1013 deletions

View File

@ -0,0 +1,9 @@
<component name="libraryTable">
<library name="HeadDatabaseAPI">
<CLASSES>
<root url="jar://$PROJECT_DIR$/../../Tools/Build Tools/Jar Libraries/HeadDatabaseAPI.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

View File

@ -1,9 +0,0 @@
<component name="libraryTable">
<library name="HeadDatabaseAPI1">
<CLASSES>
<root url="jar://$APPLICATION_HOME_DIR$/Tools/Build Tools/Jar Libraries/HeadDatabaseAPI.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

View File

@ -1,7 +1,7 @@
<component name="libraryTable">
<library name="PlaceholderAPI-2.10.21">
<CLASSES>
<root url="jar://$APPLICATION_HOME_DIR$/Tools/Build Tools/Jar Libraries/PlaceholderAPI-2.10.2.jar!/" />
<root url="jar://$PROJECT_DIR$/../../Tools/Build Tools/Jar Libraries/PlaceholderAPI-2.10.2.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />

View File

@ -1,7 +1,7 @@
<component name="libraryTable">
<library name="TokenManager-3.2.4">
<CLASSES>
<root url="jar://$APPLICATION_HOME_DIR$/Tools/Build Tools/Jar Libraries/TokenManager-3.2.4.jar!/" />
<root url="jar://$PROJECT_DIR$/../../Tools/Build Tools/Jar Libraries/TokenManager-3.2.4.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />

View File

@ -1,7 +1,7 @@
<component name="libraryTable">
<library name="Vault">
<CLASSES>
<root url="jar://$APPLICATION_HOME_DIR$/Tools/Build Tools/Jar Libraries/Vault.jar!/" />
<root url="jar://$PROJECT_DIR$/../../Tools/Build Tools/Jar Libraries/Vault.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />

View File

@ -1,7 +1,7 @@
<component name="libraryTable">
<library name="VotingPlugin">
<CLASSES>
<root url="jar://$APPLICATION_HOME_DIR$/Tools/Build Tools/Jar Libraries/VotingPlugin.jar!/" />
<root url="jar://$PROJECT_DIR$/../../Tools/Build Tools/Jar Libraries/VotingPlugin.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />

View File

@ -1,11 +1,11 @@
<component name="libraryTable">
<library name="spigot-1.16.1">
<CLASSES>
<root url="jar://$APPLICATION_HOME_DIR$/Tools/Build Tools/Jar Libraries/spigot-1.16.1.jar!/" />
<root url="jar://$PROJECT_DIR$/../../Tools/Build Tools/Jar Libraries/spigot-1.16.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$APPLICATION_HOME_DIR$/Tools/Build Tools/Jar Libraries/spigot-1.16.1.jar!/" />
<root url="jar://$PROJECT_DIR$/../../Tools/Build Tools/Jar Libraries/spigot-1.16.1.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -8,7 +8,7 @@
</content>
<orderEntry type="jdk" jdkName="adopt-openjdk-1.8" jdkType="JavaSDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="HeadDatabaseAPI1" level="project" />
<orderEntry type="library" name="HeadDatabaseAPI" level="project" />
<orderEntry type="library" name="PlaceholderAPI-2.10.21" level="project" />
<orderEntry type="library" name="TokenManager-3.2.4" level="project" />
<orderEntry type="library" name="Vault" level="project" />

View File

@ -18,6 +18,7 @@ config:
- '%cp-tag%&aEnter Input for Command'
- '&cType &4%cp-args% &cto Cancel the command'
format:
tag: '&6[&bCommandPanels&6]'
perms: '&cNo permission.'
reload: '&aReloaded.'
nopanel: '&cPanel not found.'
@ -28,6 +29,5 @@ config:
needitems: '&cInsufficient Items!'
bought: '&aSuccessfully Bought For $%cp-args%'
sold: '&aSuccessfully Sold For $%cp-args%'
tag: '&6[&bCommandPanels&6]'
offline: 'Offline'
offlineHeadValue: 'eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNmU1Mjg2YzQ3MGY2NmZmYTFhMTgzMzFjYmZmYjlhM2MyYTQ0MjRhOGM3MjU5YzQ0MzZmZDJlMzU1ODJhNTIyIn19fQ=='

View File

@ -24,14 +24,17 @@ panels:
material: LEATHER_HELMET
name: '&d&lPURPLE'
leatherarmor: PURPLE
damage: 30
'9':
material: LEATHER_CHESTPLATE
name: '&9&lBLUE'
leatherarmor: BLUE
damage: 20
'18':
material: LEATHER_LEGGINGS
name: '&a&lLIME'
leatherarmor: LIME
damage: 40
'2':
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZGJiMjczN2VjYmY5MTBlZmUzYjI2N2RiN2Q0YjMyN2YzNjBhYmM3MzJjNzdiZDBlNGVmZjFkNTEwY2RlZiJ9fX0=
name: '&e&lE'
@ -85,6 +88,7 @@ panels:
material: LEATHER_BOOTS
name: '&e&lYELLOW'
leatherarmor: YELLOW
damage: 50
'32':
material: COMPASS
stack: 12

View File

@ -1,4 +1,4 @@
version: 3.6.0
version: 3.7.0
main: me.rockyhawk.commandPanels.commandpanels
name: CommandPanels
author: RockyHawk

File diff suppressed because it is too large Load Diff

View File

@ -2,15 +2,12 @@ package me.rockyhawk.commandPanels.commands;
import me.rockyhawk.commandPanels.commandpanels;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.inventory.ItemStack;
import java.io.File;
import java.util.*;
@ -35,10 +32,10 @@ public class commandpanel implements CommandExecutor {
for(String fileName : plugin.panelFiles) { //will loop through all the files in folder
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
if(!plugin.checkPanels(temp)){
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.error") + ": Panel with syntax error found!"));
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + ": Panel with syntax error found!"));
return true;
}
for (String key : temp.getConfigurationSection("panels").getKeys(false)) {
for (String key : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)) {
apanels.add(temp.getString("panels." + key + ".title"));
opanels.add(key);
if (args[0].equalsIgnoreCase(key)){
@ -53,530 +50,131 @@ public class commandpanel implements CommandExecutor {
return true;
}
if(!found){
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.nopanel")));
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.nopanel")));
return true;
}
//below will start the command, once it got the right file and panel
if (cmd.getName().equalsIgnoreCase("cp") || cmd.getName().equalsIgnoreCase("commandpanel") || cmd.getName().equalsIgnoreCase("cpanel")) {
//if command executed from console
boolean nfound = true;
for (int i = 0; panels.split("\\s").length - 1 >= i; ++i) {
if (args[0].equalsIgnoreCase(panels.split("\\s")[i])) {
panels = panels.split("\\s")[i];
nfound = false;
}
}
if (nfound) {
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.nopanel")));
return true;
}else if (!checkconfig(panels, sender, cf)) {
//if the config is missing an element (message will be sent to user via the public boolean)
return true;
}
checkDuplicatePanel(sender,opanels,apanels);
if(!(sender instanceof Player)) {
//do console command command
if(args.length == 2){
if(!args[1].equals("item")){
boolean nfound = true;
for (int i = 0; panels.split("\\s").length - 1 >= i; ++i) {
if (args[0].equalsIgnoreCase(panels.split("\\s")[i])) {
panels = panels.split("\\s")[i];
nfound = false;
}
}
Player sp;
try {
sp = plugin.getServer().getPlayer(args[1]);
}catch(Exception e){
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.notitem")));
return true;
}
if (nfound) {
if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.papi(sp, plugin.config.getString("config.format.nopanel"))));
} else {
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.nopanel")));
}
return true;
}else if (!checkconfig(panels, sp, cf)) {
//if the config is missing an element (message will be sent to user via the public boolean)
return true;
}
if (sender.hasPermission("commandpanel.panel." + cf.getString("panels." + panels + ".perm"))) {
if(sender.hasPermission("commandpanel.other")) {
try {
if (cf.contains("panels." + panels + ".disabled-worlds")) {
List<String> disabledWorlds = cf.getStringList("panels." + panels + ".disabled-worlds");
if (disabledWorlds.contains(sp.getWorld().getName())) {
//panel cannot be used in the players world!
if (Objects.requireNonNull(plugin.config.getString("config.disabled-world-message")).equalsIgnoreCase("true")) {
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.RED + "Panel is disabled in players world!"));
}
return true;
}
}
}catch(NullPointerException offlinePlayer){
//SKIP because player is offline
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.notitem")));
return true;
}
try {
if (cf.contains("panels." + panels + ".sound-on-open")) {
//play sound when panel is opened
if(!Objects.requireNonNull(cf.getString("panels." + panels + ".sound-on-open")).equalsIgnoreCase("off")) {
try {
sp.playSound(sp.getLocation(), Sound.valueOf(Objects.requireNonNull(cf.getString("panels." + panels + ".sound-on-open")).toUpperCase()), 1F, 1F);
} catch (Exception s) {
sp.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + plugin.papi(sp, plugin.config.getString("config.format.error") + " " + "sound-on-open: " + cf.getString("panels." + panels + ".sound-on-open"))));
}
}
}
if (cf.contains("panels." + panels + ".commands-on-open")) {
//execute commands on panel open
try {
List<String> commands = cf.getStringList("panels." + panels + ".commands-on-open");
for (int i = 0; commands.size() - 1 >= i; i++) {
int val = plugin.commandPayWall(sp,commands.get(i));
if(val == 0){
break;
}
if(val == 2){
plugin.commandTags(sp, commands.get(i));
}
}
}catch(Exception s){
sp.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + plugin.papi(sp, plugin.config.getString("config.format.error") + " " + "commands-on-open: " + cf.getString("panels." + panels + ".commands-on-open"))));
}
}
plugin.openGui(panels, sp, cf,1,0);
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.GREEN + "Panel Opened for " + sp.getDisplayName()));
} catch (Exception r) {
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.notitem")));
}
}else{
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.perms")));
}
return true;
}
if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.papi(sp, plugin.config.getString("config.format.perms"))));
return true;
} else {
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.perms")));
return true;
}
plugin.openCommandPanel(sender,plugin.getServer().getPlayer(args[1]),panels,cf,true);
return true;
}else{
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.RED + "Usage: /cp <panel> [item] [player]"));
sender.sendMessage(plugin.papi(tag + ChatColor.RED + "Usage: /cp <panel> [item] [player]"));
return true;
}
}else if(args.length == 3){
if (args[1].equals("item")) {
boolean nfound = true;
for (int i = 0; panels.split("\\s").length - 1 >= i; ++i) {
if (args[0].equalsIgnoreCase(panels.split("\\s")[i])) {
panels = panels.split("\\s")[i];
nfound = false;
}
}
Player sp;
try {
sp = plugin.getServer().getPlayer(args[2]);
}catch(Exception e){
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.notitem")));
return true;
}
if (nfound) {
if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.papi(sp, plugin.config.getString("config.format.nopanel"))));
} else {
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.nopanel")));
}
return true;
}
if (sender.hasPermission("commandpanel.item." + cf.getString("panels." + panels + ".perm")) && cf.contains("panels." + panels + ".open-with-item")) {
if(cf.contains("panels." + panels + ".disabled-worlds")){
List<String> disabledWorlds = cf.getStringList("panels." + panels + ".disabled-worlds");
if(disabledWorlds.contains(sp.getWorld().getName())){
//panel cannot be used in the players world!
if(Objects.requireNonNull(plugin.config.getString("config.disabled-world-message")).equalsIgnoreCase("true")){
sp.sendMessage(ChatColor.RED + "Panel is disabled in this world!");
}
return true;
}
}
ItemStack s;
try {
s = new ItemStack(Objects.requireNonNull(Material.matchMaterial(Objects.requireNonNull(cf.getString("panels." + panels + ".open-with-item.material")))), 1);
}catch(Exception n){
if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.papi(sp, plugin.config.getString("config.format.error") + " open-with-item: material")));
} else {
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.error") + " open-with-item: material"));
}
return true;
}
plugin.setName(s, cf.getString("panels." + panels + ".open-with-item.name"), cf.getList("panels." + panels + ".open-with-item.lore"),sp,true);
if(sender.hasPermission("commandpanel.other")) {
try {
if(cf.contains("panels." + panels + ".open-with-item.stationary")) {
sp.getInventory().setItem(Integer.parseInt(Objects.requireNonNull(cf.getString("panels." + panels + ".open-with-item.stationary"))), s);
}else{
sp.getInventory().addItem(s);
}
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.GREEN + "Item Given to " + plugin.getServer().getPlayer(args[2]).getDisplayName()));
} catch (Exception r) {
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.notitem")));
}
}else{
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.perms")));
}
return true;
}
if (!cf.contains("panels." + panels + ".open-with-item")) {
if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.papi(sp, plugin.config.getString("config.format.noitem"))));
return true;
} else {
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.noitem")));
return true;
}
}
if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.papi(sp, plugin.config.getString("config.format.perms"))));
return true;
} else {
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.perms")));
return true;
}
plugin.giveHotbarItem(sender,plugin.getServer().getPlayer(args[2]),panels,cf,true);
return true;
}else{
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.RED + "Usage: /cp <panel> item [player]"));
sender.sendMessage(plugin.papi(tag + ChatColor.RED + "Usage: /cp <panel> item [player]"));
return true;
}
} else {
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.RED + "Please execute command directed to a Player!"));
sender.sendMessage(plugin.papi( tag + ChatColor.RED + "Please execute command directed to a Player!"));
return true;
}
}
Player p = (Player) sender;
//names is a list of the titles for the Panels
Set<String> oset = new HashSet<String>(opanels);
if (oset.size() < opanels.size()) {
//there are duplicate panel names
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.papi(p, plugin.config.getString("config.format.error") + " panels: You cannot have duplicate panel names!")));
if(plugin.debug){
ArrayList<String> opanelsTemp = new ArrayList<String>();
for(String tempName : opanels){
if(opanelsTemp.contains(tempName)){
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.RED + " The duplicate panel is: " + tempName));
return true;
}
opanelsTemp.add(tempName);
}
}
return true;
}
Set<String> set = new HashSet<String>(apanels);
if (set.size() < apanels.size()) {
//there are duplicate panel titles
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.papi(p, plugin.config.getString("config.format.error") + " title: You cannot have duplicate title names!")));
if(plugin.debug){
ArrayList<String> apanelsTemp = new ArrayList<String>();
for(String tempName : apanels){
if(apanelsTemp.contains(tempName)){
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.RED + " The duplicate title is: " + tempName));
return true;
}
apanelsTemp.add(tempName);
}
}
return true;
}
if (args.length == 1) {
boolean nfound = true;
for (int i = 0; panels.split("\\s").length - 1 >= i; ++i) {
if (args[0].equalsIgnoreCase(panels.split("\\s")[i])) {
panels = panels.split("\\s")[i];
nfound = false;
}
}
if (nfound) {
if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.papi(p, plugin.config.getString("config.format.nopanel"))));
} else {
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.nopanel")));
}else{
//get player
Player p = (Player) sender;
//do player command
if (args.length == 1) {
plugin.openCommandPanel(sender, p, panels, cf,false);
return true;
}else if(args.length == 2){
if (args[1].equals("item")) {
plugin.giveHotbarItem(sender, p, panels, cf, false);
}else{
plugin.openCommandPanel(sender, plugin.getServer().getPlayer(args[1]), panels, cf,true);
}
return true;
}else if (!checkconfig(panels, p, cf)) {
//if the config is missing an element (message will be sent to user via the public boolean)
}else if(args.length == 3){
plugin.giveHotbarItem(sender, plugin.getServer().getPlayer(args[2]), panels, cf,true);
return true;
}
if (p.hasPermission("commandpanel.panel." + cf.getString("panels." + panels + ".perm"))) {
if(cf.contains("panels." + panels + ".disabled-worlds")){
List<String> disabledWorlds = cf.getStringList("panels." + panels + ".disabled-worlds");
if(disabledWorlds.contains(p.getWorld().getName())){
//panel cannot be used in the players world!
if(Objects.requireNonNull(plugin.config.getString("config.disabled-world-message")).equalsIgnoreCase("true")){
p.sendMessage(ChatColor.RED + "Panel is disabled in this world!");
}
return true;
}
}
if (cf.contains("panels." + panels + ".sound-on-open")) {
//play sound when panel is opened
if(!Objects.requireNonNull(cf.getString("panels." + panels + ".sound-on-open")).equalsIgnoreCase("off")) {
try {
p.playSound(p.getLocation(), Sound.valueOf(Objects.requireNonNull(cf.getString("panels." + panels + ".sound-on-open")).toUpperCase()), 1F, 1F);
} catch (Exception s) {
plugin.debug(s);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + plugin.papi(p, plugin.config.getString("config.format.error") + " " + "sound-on-open: " + cf.getString("panels." + panels + ".sound-on-open"))));
}
}
}
if (cf.contains("panels." + panels + ".commands-on-open")) {
//execute commands on panel open
try {
List<String> commands = cf.getStringList("panels." + panels + ".commands-on-open");
for (int i = 0; commands.size() - 1 >= i; i++) {
int val = plugin.commandPayWall(p,commands.get(i));
if(val == 0){
break;
}
if(val == 2){
plugin.commandTags(p, commands.get(i));
}
}
}catch(Exception s){
plugin.debug(s);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + plugin.papi(p, plugin.config.getString("config.format.error") + " " + "commands-on-open: " + cf.getString("panels." + panels + ".commands-on-open"))));
}
}
plugin.openGui(panels, p, cf, 1,0);
return true;
}
if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.papi(p, plugin.config.getString("config.format.perms"))));
return true;
} else {
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.perms")));
return true;
}
}
if (args.length == 2) {
if (args[1].equals("item")) {
boolean nfound = true;
for (int i = 0; panels.split("\\s").length - 1 >= i; ++i) {
if (args[0].equalsIgnoreCase(panels.split("\\s")[i])) {
panels = panels.split("\\s")[i];
nfound = false;
}
}
if (nfound) {
if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.papi(p, plugin.config.getString("config.format.nopanel"))));
} else {
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.nopanel")));
}
return true;
}
if (p.hasPermission("commandpanel.item." + cf.getString("panels." + panels + ".perm")) && cf.contains("panels." + panels + ".open-with-item")) {
if(cf.contains("panels." + panels + ".disabled-worlds")){
List<String> disabledWorlds = cf.getStringList("panels." + panels + ".disabled-worlds");
if(disabledWorlds.contains(p.getWorld().getName())){
//panel cannot be used in the players world!
if(Objects.requireNonNull(plugin.config.getString("config.disabled-world-message")).equalsIgnoreCase("true")){
p.sendMessage(ChatColor.RED + "Panel is disabled in this world!");
}
return true;
}
}
ItemStack s;
try {
s = new ItemStack(Objects.requireNonNull(Material.matchMaterial(cf.getString("panels." + panels + ".open-with-item.material"))), 1);
}catch(Exception n){
plugin.debug(n);
if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.papi(p, plugin.config.getString("config.format.error") + " open-with-item: material")));
} else {
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.error") + " open-with-item: material"));
}
return true;
}
plugin.setName(s, cf.getString("panels." + panels + ".open-with-item.name"), cf.getList("panels." + panels + ".open-with-item.lore"),p,true);
if(cf.contains("panels." + panels + ".open-with-item.stationary")) {
p.getInventory().setItem(Integer.parseInt(Objects.requireNonNull(cf.getString("panels." + panels + ".open-with-item.stationary"))), s);
}else{
p.getInventory().addItem(s);
}
return true;
}
if (!cf.contains("panels." + panels + ".open-with-item")) {
if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.papi(p, plugin.config.getString("config.format.noitem"))));
return true;
} else {
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.noitem")));
return true;
}
}
if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.papi(p, plugin.config.getString("config.format.perms"))));
return true;
} else {
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.perms")));
return true;
}
}else { //player name here eg /cp example RockyHawk to get rockyhawk to open panel
boolean nfound = true;
for (int i = 0; panels.split("\\s").length - 1 >= i; ++i) {
if (args[0].equalsIgnoreCase(panels.split("\\s")[i])) {
panels = args[0];
nfound = false;
break;
}
}
if (nfound) {
if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.papi(p, plugin.config.getString("config.format.nopanel"))));
} else {
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.nopanel")));
}
return true;
}else if (!checkconfig(panels, p, cf)) {
//if the config is missing an element (message will be sent to user via the public boolean)
return true;
}
if (p.hasPermission("commandpanel.panel." + cf.getString("panels." + panels + ".perm"))) {
if(p.hasPermission("commandpanel.other")) {
if(cf.contains("panels." + panels + ".disabled-worlds")){
List<String> disabledWorlds = cf.getStringList("panels." + panels + ".disabled-worlds");
if(disabledWorlds.contains(p.getWorld().getName())){
//panel cannot be used in the players world!
if(Objects.requireNonNull(plugin.config.getString("config.disabled-world-message")).equalsIgnoreCase("true")){
p.sendMessage(ChatColor.RED + "Panel is disabled in this world!");
}
return true;
}
}
try {
plugin.openGui(panels, plugin.getServer().getPlayer(args[1]), cf,1,0);
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.GREEN + "Panel Opened for " + plugin.getServer().getPlayer(args[1]).getDisplayName()));
} catch (Exception r) {
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.notitem")));
}
}else{
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.perms")));
}
return true;
}
if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.papi(p, plugin.config.getString("config.format.perms"))));
return true;
} else {
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.perms")));
return true;
}
}
}
if (args.length == 3) {
//if the command is /cp example item <player> to give other player item
if (args[1].equals("item")) {
boolean nfound = true;
for (int i = 0; panels.split("\\s").length - 1 >= i; ++i) {
if (args[0].equalsIgnoreCase(panels.split("\\s")[i])) {
panels = panels.split("\\s")[i];
nfound = false;
}
}
if (nfound) {
if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.papi(p, plugin.config.getString("config.format.nopanel"))));
} else {
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.nopanel")));
}
return true;
}
if (p.hasPermission("commandpanel.item." + cf.getString("panels." + panels + ".perm")) && cf.contains("panels." + panels + ".open-with-item")) {
if(cf.contains("panels." + panels + ".disabled-worlds")){
List<String> disabledWorlds = cf.getStringList("panels." + panels + ".disabled-worlds");
if(disabledWorlds.contains(p.getWorld().getName())){
//panel cannot be used in the players world!
if(Objects.requireNonNull(plugin.config.getString("config.disabled-world-message")).equalsIgnoreCase("true")){
p.sendMessage(ChatColor.RED + "Panel is disabled in this world!");
}
return true;
}
}
ItemStack s;
try {
s = new ItemStack(Objects.requireNonNull(Material.matchMaterial(cf.getString("panels." + panels + ".open-with-item.material"))), 1);
}catch(Exception n){
plugin.debug(n);
if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.papi(p, plugin.config.getString("config.format.error") + " open-with-item: material")));
} else {
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.error") + " open-with-item: material"));
}
return true;
}
plugin.setName(s, cf.getString("panels." + panels + ".open-with-item.name"), cf.getList("panels." + panels + ".open-with-item.lore"),p,true);
if(p.hasPermission("commandpanel.other")) {
try {
if(cf.contains("panels." + panels + ".open-with-item.stationary")) {
p.getInventory().setItem(Integer.parseInt(Objects.requireNonNull(cf.getString("panels." + panels + ".open-with-item.stationary"))), s);
}else{
p.getInventory().addItem(s);
}
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.GREEN + "Item Given to " + plugin.getServer().getPlayer(args[2]).getDisplayName()));
} catch (Exception r) {
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.notitem")));
}
}else{
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.perms")));
}
return true;
}
if (!cf.contains("panels." + panels + ".open-with-item")) {
if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.papi(p, plugin.config.getString("config.format.noitem"))));
return true;
} else {
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.noitem")));
return true;
}
}
if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.papi(p, plugin.config.getString("config.format.perms"))));
return true;
} else {
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.perms")));
return true;
}
}
}
}
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.RED + "Usage: /cp <panel> [player:item] [player]"));
sender.sendMessage(plugin.papi(tag + ChatColor.RED + "Usage: /cp <panel> [player:item] [player]"));
return true;
}
boolean checkconfig(String panels, Player p, YamlConfiguration pconfig) {
boolean checkDuplicatePanel(CommandSender sender, ArrayList<String> opanels, ArrayList<String> apanels){
String tag = plugin.config.getString("config.format.tag") + " ";
//names is a list of the titles for the Panels
Set<String> oset = new HashSet<String>(opanels);
if (oset.size() < opanels.size()) {
//there are duplicate panel names
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " panels: You cannot have duplicate panel names!"));
if(plugin.debug){
ArrayList<String> opanelsTemp = new ArrayList<String>();
for(String tempName : opanels){
if(opanelsTemp.contains(tempName)){
sender.sendMessage(plugin.papi(tag + ChatColor.RED + " The duplicate panel is: " + tempName));
return false;
}
opanelsTemp.add(tempName);
}
}
return false;
}
Set<String> set = new HashSet<String>(apanels);
if (set.size() < apanels.size()) {
//there are duplicate panel titles
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " title: You cannot have duplicate title names!"));
if(plugin.debug){
ArrayList<String> apanelsTemp = new ArrayList<String>();
for(String tempName : apanels){
if(apanelsTemp.contains(tempName)){
sender.sendMessage(plugin.papi(tag + ChatColor.RED + " The duplicate title is: " + tempName));
return false;
}
apanelsTemp.add(tempName);
}
}
return false;
}
return true;
}
boolean checkconfig(String panels, CommandSender sender, YamlConfiguration pconfig) {
//if it is missing a section specified it will return false
String tag = plugin.config.getString("config.format.tag") + " ";
if(!pconfig.contains("panels." + panels)) {
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.papi(p, plugin.config.getString("config.format.nopanel"))));
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.nopanel")));
return false;
}
if(!pconfig.contains("panels." + panels + ".perm")) {
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.papi(p, plugin.config.getString("config.format.error") + " perm: Missing config section!")));
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " perm: Missing config section!"));
return false;
}
if(!pconfig.contains("panels." + panels + ".rows")) {
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.papi(p, plugin.config.getString("config.format.error") + " rows: Missing config section!")));
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " perm: Missing config section!"));
return false;
}
if(!pconfig.contains("panels." + panels + ".title")) {
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.papi(p, plugin.config.getString("config.format.error") + " title: Missing config section!")));
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " perm: Missing config section!"));
return false;
}
if(!pconfig.contains("panels." + panels + ".item")) {
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.papi(p, plugin.config.getString("config.format.error") + " item: Missing config section!")));
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " perm: Missing config section!"));
return false;
}
return true;

View File

@ -16,7 +16,7 @@ public class commandpanelclose implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
String tag = plugin.config.getString("config.format.tag") + " ";
if(!(sender instanceof Player)) {
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.RED + "Please execute command as a Player!"));
sender.sendMessage(plugin.papi(tag + ChatColor.RED + "Please execute command as a Player!"));
return true;
}
Player p = (Player)sender;
@ -25,7 +25,7 @@ public class commandpanelclose implements CommandExecutor {
p.closeInventory();
return true;
}
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.RED + "Usage: /cpc"));
p.sendMessage(plugin.papi(tag + ChatColor.RED + "Usage: /cpc"));
return true;
}
}

View File

@ -1,7 +1,6 @@
package me.rockyhawk.commandPanels.commands;
import me.rockyhawk.commandPanels.commandpanels;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
@ -23,7 +22,7 @@ public class commandpanelcustom implements Listener {
public void PlayerCommand(PlayerCommandPreprocessEvent e) {
String panels;
String tag = plugin.config.getString("config.format.tag") + " ";
Player p = (Player)e.getPlayer();
Player p = e.getPlayer();
File panelsf = new File(plugin.getDataFolder() + File.separator + "panels");
try {
if (panelsf.list() == null || Objects.requireNonNull(panelsf.list()).length == 0) {
@ -32,7 +31,7 @@ public class commandpanelcustom implements Listener {
}catch(Exception b){
return;
}
YamlConfiguration cf; //this is the file to use for any panel.* requests
YamlConfiguration cf = null; //this is the file to use for any panel.* requests
ArrayList<String> apanels = new ArrayList<String>(); //all panels from all files (panel names)
String tpanels; //tpanels is the temp to check through the files
String panel = null;
@ -41,11 +40,7 @@ public class commandpanelcustom implements Listener {
String key;
tpanels = "";
if(!plugin.checkPanels(temp)){
if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.papi(p, plugin.config.getString("config.format.error") + ": File with no Panels found!")));
} else {
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.error") + ": File with no Panels found!"));
}
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + ": File with no Panels found!"));
return;
}
for (Iterator var10 = Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") {
@ -58,6 +53,7 @@ public class commandpanelcustom implements Listener {
if(temp.contains("panels." + tpanels.split("\\s")[i] + ".command")) {
for(int c = 0; c < temp.getString("panels." + tpanels.split("\\s")[i] + ".command").split("\\s").length;c++) {
if (("/" + temp.getString("panels." + tpanels.split("\\s")[i] + ".command").split("\\s")[c]).equalsIgnoreCase(e.getMessage())) {
cf = temp;
panels = tpanels;
panels = panels.trim();
panel = panels.split("\\s")[i];
@ -72,10 +68,10 @@ public class commandpanelcustom implements Listener {
}
e.setCancelled(true);
try {
Bukkit.dispatchCommand(p, ChatColor.translateAlternateColorCodes('&', "commandpanels:commandpanel " + panel));
plugin.openCommandPanel(p,p,panel,cf,false);
}catch(Exception er){
//do nothing
p.sendMessage(ChatColor.translateAlternateColorCodes('&',plugin.papi(p,tag + ChatColor.RED + "Error opening panel!")));
p.sendMessage(plugin.papi(tag + ChatColor.RED + "Error opening panel!"));
}
}
}

View File

@ -20,20 +20,20 @@ public class commandpanelsdebug implements CommandExecutor {
//command /cpd
plugin.debug = !plugin.debug;
if(plugin.debug){
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.GREEN + "Debug Mode Enabled!"));
sender.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Debug Mode Enabled!"));
}else{
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.GREEN + "Debug Mode Disabled!"));
sender.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Debug Mode Disabled!"));
}
}else{
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.RED + "Usage: /cpd"));
sender.sendMessage(plugin.papi(tag + ChatColor.RED + "Usage: /cpd"));
}
return true;
}else{
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.perms")));
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.perms")));
return true;
}
}
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.RED + "Usage: /cpd"));
sender.sendMessage(plugin.papi(tag + ChatColor.RED + "Usage: /cpd"));
return true;
}
}

View File

@ -26,11 +26,11 @@ public class commandpanelslist implements CommandExecutor {
//check to make sure the panels isn't empty
try {
if (plugin.panelFiles == null) {
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.RED + "No panels found!"));
sender.sendMessage(plugin.papi(tag + ChatColor.RED + "No panels found!"));
return true;
}
}catch(Exception b){
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.RED + "No panels found!"));
sender.sendMessage(plugin.papi(tag + ChatColor.RED + "No panels found!"));
return true;
}
ArrayList<String> apanels = new ArrayList<String>(); //all panels from all files (panel names)
@ -42,7 +42,7 @@ public class commandpanelslist implements CommandExecutor {
temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + plugin.panelFiles.get(f)));
apanels.add("%file%" + plugin.panelFiles.get(f));
if(!plugin.checkPanels(temp)){
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.error") + ": File with no Panels found!"));
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + ": File with no Panels found!"));
return true;
}
for (Iterator var10 = temp.getConfigurationSection("panels").getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") {
@ -57,7 +57,7 @@ public class commandpanelslist implements CommandExecutor {
page = Integer.parseInt(args[0]);
skip = page*9-9;
}catch (Exception e){
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.RED + "Inaccessible Page"));
sender.sendMessage(plugin.papi(tag + ChatColor.RED + "Inaccessible Page"));
}
}
for (int f = skip; apanels.size() > f; f++) {
@ -67,7 +67,7 @@ public class commandpanelslist implements CommandExecutor {
break;
}
}
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.DARK_AQUA + "Panels: (Page " + page + ")"));
sender.sendMessage(plugin.papi(tag + ChatColor.DARK_AQUA + "Panels: (Page " + page + ")"));
for (int f = skip; apanels.size() > f; f++) {
if(apanels.get(f).contains("%file%")){
if(skip+9 <= f){
@ -81,11 +81,11 @@ public class commandpanelslist implements CommandExecutor {
}
return true;
}else{
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.perms")));
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.perms")));
return true;
}
}
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.RED + "Usage: /cpl"));
sender.sendMessage(plugin.papi(tag + ChatColor.RED + "Usage: /cpl"));
return true;
}
}

View File

@ -22,14 +22,14 @@ public class commandpanelsreload implements CommandExecutor {
plugin.config = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder() + File.separator + "config.yml"));
plugin.reloadPanelFiles();
tag = plugin.config.getString("config.format.tag") + " ";
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.reload")));
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.reload")));
return true;
}else{
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.perms")));
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.perms")));
return true;
}
}
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.RED + "Usage: /cpr"));
sender.sendMessage(plugin.papi(tag + ChatColor.RED + "Usage: /cpr"));
return true;
}
}

View File

@ -18,17 +18,17 @@ public class commandpanelversion implements CommandExecutor {
if (label.equalsIgnoreCase("cpv") || label.equalsIgnoreCase("commandpanelversion") || label.equalsIgnoreCase("cpanelv")) {
if (sender.hasPermission("commandpanel.version")) {
//version command
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag));
sender.sendMessage(plugin.papi(tag));
sender.sendMessage(ChatColor.GREEN + "Version " + ChatColor.GRAY + plugin.getDescription().getVersion());
sender.sendMessage(ChatColor.GREEN + "Developer " + ChatColor.GRAY + "RockyHawk");
sender.sendMessage(ChatColor.GREEN + "Command " + ChatColor.GRAY + "/cp");
return true;
}else{
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.perms")));
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.perms")));
return true;
}
}
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.RED + "Usage: /cpv"));
sender.sendMessage(plugin.papi(tag + ChatColor.RED + "Usage: /cpv"));
return true;
}
}

View File

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

View File

@ -81,7 +81,7 @@ public class newGenUtils implements Listener {
}
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
p.sendMessage(plugin.papi(p,tag + ChatColor.RED + "Cancelled Panel!"));
p.sendMessage(plugin.papi(tag + ChatColor.RED + "Cancelled Panel!"));
return;
}
YamlConfiguration file;
@ -132,9 +132,9 @@ public class newGenUtils implements Listener {
try {
file.save(new File(plugin.panelsf + File.separator + date + ".yml"));
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Saved Generated File To: " + date + ".yml"));
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Saved Generated File To: " + date + ".yml"));
} catch (IOException var16) {
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.RED + "Could Not Save Generated Panel!"));
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Could Not Save Generated Panel!"));
}
plugin.reloadPanelFiles();
}

View File

@ -23,16 +23,16 @@ public class cpIngameEditCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
String tag = plugin.config.getString("config.format.tag") + " ";
if(!sender.hasPermission("commandpanel.edit")){
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.perms")));
sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.perms")));
return true;
}
if(Objects.requireNonNull(plugin.config.getString("config.ingame-editor")).equalsIgnoreCase("false")){
//this will cancel every /cpe command if ingame-editor is set to false
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.RED + "Editor disabled!"));
sender.sendMessage(plugin.papi(tag + ChatColor.RED + "Editor disabled!"));
return true;
}
if(!(sender instanceof Player)) {
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.RED + "Please execute command as a Player!"));
sender.sendMessage(plugin.papi( tag + ChatColor.RED + "Please execute command as a Player!"));
return true;
}
File panelscf = new File(plugin.getDataFolder() + File.separator + "panels" + File.separator + "example.yml"); //cf == correct file
@ -49,7 +49,7 @@ public class cpIngameEditCommand implements CommandExecutor {
tpanels = "";
temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + filename));
if (!plugin.checkPanels(temp)) {
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + plugin.config.getString("config.format.error") + ": File with no Panels found!"));
sender.sendMessage(plugin.papi( tag + plugin.config.getString("config.format.error") + ": File with no Panels found!"));
return true;
}
for (Iterator var10 = temp.getConfigurationSection("panels").getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") {
@ -82,16 +82,12 @@ public class cpIngameEditCommand implements CommandExecutor {
Set<String> oset = new HashSet<String>(opanels);
if (oset.size() < opanels.size()) {
//there are duplicate panel names
if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.papi(p, plugin.config.getString("config.format.error") + " panels: You cannot have duplicate panel names!")));
} else {
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.error") + " panels: You cannot have duplicate panel names!"));
}
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " panels: You cannot have duplicate panel names!"));
if(plugin.debug){
ArrayList<String> opanelsTemp = new ArrayList<String>();
for(String tempName : opanels){
if(opanelsTemp.contains(tempName)){
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.RED + " The duplicate panel is: " + tempName));
p.sendMessage(plugin.papi(tag + ChatColor.RED + " The duplicate panel is: " + tempName));
return true;
}
opanelsTemp.add(tempName);
@ -102,16 +98,12 @@ public class cpIngameEditCommand implements CommandExecutor {
Set<String> set = new HashSet<String>(apanels);
if (set.size() < apanels.size()) {
//there are duplicate panel names
if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.papi(p, plugin.config.getString("config.format.error") + " title: You cannot have duplicate title names!")));
} else {
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.error") + " title: You cannot have duplicate title names!"));
}
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " title: You cannot have duplicate title names!"));
if(plugin.debug){
ArrayList<String> apanelsTemp = new ArrayList<String>();
for(String tempName : apanels){
if(apanelsTemp.contains(tempName)){
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.RED + " The duplicate title is: " + tempName));
p.sendMessage(plugin.papi(tag + ChatColor.RED + " The duplicate title is: " + tempName));
return true;
}
apanelsTemp.add(tempName);
@ -134,7 +126,7 @@ public class cpIngameEditCommand implements CommandExecutor {
}
if (nfound) {
//if the panel was not found in the message
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.papi(p, plugin.config.getString("config.format.nopanel"))));
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.nopanel")));
return true;
}else if (!checkconfig(panels, p, cf)) {
//if the config is missing an element (message will be sent to user via the public boolean)
@ -145,50 +137,30 @@ public class cpIngameEditCommand implements CommandExecutor {
return true;
}
}
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.RED + "Usage: /cpe <panel>"));
sender.sendMessage(plugin.papi(tag + ChatColor.RED + "Usage: /cpe <panel>"));
return true;
}
boolean checkconfig(String panels, Player p, YamlConfiguration pconfig) {
//if it is missing a section specified it will return false
String tag = plugin.config.getString("config.format.tag") + " ";
if(!pconfig.contains("panels." + panels)) {
if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.papi(p, plugin.config.getString("config.format.nopanel"))));
} else {
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.nopanel")));
}
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.nopanel")));
return false;
}
if(!pconfig.contains("panels." + panels + ".perm")) {
if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.papi(p, plugin.config.getString("config.format.error") + " perm: Missing config section!")));
} else {
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.error") + " perm: Missing config section!"));
}
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " perm: Missing config section!"));
return false;
}
if(!pconfig.contains("panels." + panels + ".rows")) {
if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.papi(p, plugin.config.getString("config.format.error") + " rows: Missing config section!")));
} else {
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.error") + " rows: Missing config section!"));
}
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " perm: Missing config section!"));
return false;
}
if(!pconfig.contains("panels." + panels + ".title")) {
if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.papi(p, plugin.config.getString("config.format.error") + " title: Missing config section!")));
} else {
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.error") + " title: Missing config section!"));
}
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " perm: Missing config section!"));
return false;
}
if(!pconfig.contains("panels." + panels + ".item")) {
if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.papi(p, plugin.config.getString("config.format.error") + " item: Missing config section!")));
} else {
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.config.getString("config.format.error") + " item: Missing config section!"));
}
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " perm: Missing config section!"));
return false;
}
return true;

View File

@ -44,7 +44,7 @@ public class editorUserInput implements Listener {
if (key.equals(panelName)) {
cf = tempConf;
panelFile = new File(plugin.panelsf + File.separator + tempFile);
panelTitle = ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(tempConf.getString("panels." + key + ".title")));
panelTitle = plugin.papi( Objects.requireNonNull(tempConf.getString("panels." + key + ".title")));
break;
}
}
@ -56,7 +56,7 @@ public class editorUserInput implements Listener {
if(e.getMessage().equalsIgnoreCase(plugin.config.getString("config.input-cancel"))){
plugin.editorInputStrings.remove(temp);
plugin.reloadPanelFiles();
e.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(plugin.config.getString("config.input-cancelled"))));
e.getPlayer().sendMessage(plugin.papi( Objects.requireNonNull(plugin.config.getString("config.input-cancelled"))));
return;
}
if(section.startsWith("panel.")) {
@ -101,112 +101,112 @@ public class editorUserInput implements Listener {
//if the file has more than one panel in it
cf.set("panels." + panelName, null);
if(savePanelFile(cf, panelFile)){
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Deleted Panel!"));
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Deleted Panel!"));
}else{
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.RED + "Could Not Delete Panel!"));
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Could Not Delete Panel!"));
}
}else {
//if the file only has one panel in it
if (panelFile.delete()) {
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Deleted Panel!"));
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Deleted Panel!"));
}else{
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.RED + "Could Not Delete Panel!"));
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Could Not Delete Panel!"));
}
}
}
break;
case "panel.perm":
if(e.getMessage().contains(" ")){
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.RED + "Permission cannot contain spaces!"));
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Permission cannot contain spaces!"));
break;
}
cf.set("panels." + panelName + ".perm", e.getMessage());
savePanelFile(cf, panelFile);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Permission required is now " + "commandpanel.panel." + e.getMessage()));
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Permission required is now " + "commandpanel.panel." + e.getMessage()));
break;
case "panel.rows":
try {
int rows = Integer.parseInt(e.getMessage());
if (rows >= 7 || rows <= 0) {
//if the number isn't between 1-6
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Choose an integer between 1 to 6!"));
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Choose an integer between 1 to 6!"));
return;
}
cf.set("panels." + panelName + ".rows", rows);
cf.save(panelFile);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Set Panel to " + rows + " rows!"));
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Set Panel to " + rows + " rows!"));
} catch (Exception io) {
plugin.debug(io);
}
break;
case "panel.title":
if(panelTitle.equals(ChatColor.translateAlternateColorCodes('&',e.getMessage()))){
p.sendMessage(plugin.papi(p,tag + e.getMessage() + ChatColor.RED + " is in use from another panel!"));
if(panelTitle.equals(plugin.papi(e.getMessage()))){
p.sendMessage(plugin.papi(tag + e.getMessage() + ChatColor.RED + " is in use from another panel!"));
break;
}
cf.set("panels." + panelName + ".title", e.getMessage());
savePanelFile(cf, panelFile);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Set new Title to " + ChatColor.WHITE + e.getMessage()));
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Set new Title to " + ChatColor.WHITE + e.getMessage()));
break;
case "panel.name":
if(e.getMessage().contains(" ")){
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.RED + "Panel name cannot contain spaces!"));
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Panel name cannot contain spaces!"));
break;
}
if(panelName.equals(e.getMessage())){
p.sendMessage(plugin.papi(p,tag + ChatColor.RED + e.getMessage() + " is in use from another panel!"));
p.sendMessage(plugin.papi(tag + ChatColor.RED + e.getMessage() + " is in use from another panel!"));
break;
}
cf.set("panels." + e.getMessage(), cf.get("panels." + panelName));
cf.set("panels." + panelName, null);
savePanelFile(cf, panelFile);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Set new Name to " + e.getMessage()));
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Set new Name to " + e.getMessage()));
break;
case "panel.empty":
if(e.getMessage().trim().equalsIgnoreCase("remove")){
cf.set("panels." + panelName + ".empty", null);
savePanelFile(cf, panelFile);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Empty materials have been removed."));
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Empty materials have been removed."));
break;
}
String materialTemp = null;
try {
materialTemp = Objects.requireNonNull(Material.matchMaterial(e.getMessage())).toString();
}catch(NullPointerException ex){
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.RED + e.getMessage() + " is not a valid Material!"));
p.sendMessage(plugin.papi( tag + ChatColor.RED + e.getMessage() + " is not a valid Material!"));
}
cf.set("panels." + panelName + ".empty", materialTemp);
savePanelFile(cf, panelFile);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Set Empty material to " + materialTemp));
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Set Empty material to " + materialTemp));
break;
case "panel.sound-on-open":
if(e.getMessage().trim().equalsIgnoreCase("remove")){
cf.set("panels." + panelName + ".sound-on-open", null);
savePanelFile(cf, panelFile);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Sounds have been removed."));
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Sounds have been removed."));
break;
}
String tempSound;
try {
tempSound = Sound.valueOf(e.getMessage()).toString();
}catch(Exception ex){
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.RED + e.getMessage() + " is not a valid Sound!"));
p.sendMessage(plugin.papi( tag + ChatColor.RED + e.getMessage() + " is not a valid Sound!"));
return;
}
cf.set("panels." + panelName + ".sound-on-open", tempSound);
savePanelFile(cf, panelFile);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Sound when opening is now " + tempSound));
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Sound when opening is now " + tempSound));
break;
case "panel.command":
if(e.getMessage().trim().equalsIgnoreCase("remove")){
cf.set("panels." + panelName + ".command", null);
savePanelFile(cf, panelFile);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Custom commands have been removed."));
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Custom commands have been removed."));
break;
}
cf.set("panels." + panelName + ".command", e.getMessage());
savePanelFile(cf, panelFile);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Set new custom commands to " + ChatColor.WHITE + "/" + e.getMessage().trim().replace(" ", " /")));
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Set new custom commands to " + ChatColor.WHITE + "/" + e.getMessage().trim().replace(" ", " /")));
break;
case "panel.commands-on-open.add":
List<String> commandsOnOpenAdd = new ArrayList<>();
@ -216,20 +216,20 @@ public class editorUserInput implements Listener {
commandsOnOpenAdd.add(e.getMessage());
cf.set("panels." + panelName + ".commands-on-open", commandsOnOpenAdd);
savePanelFile(cf, panelFile);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Added new command: " + e.getMessage()));
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Added new command: " + e.getMessage()));
break;
case "panel.commands-on-open.remove":
List<String> commandsOnOpenRemove;
if(cf.contains("panels." + panelName + ".commands-on-open")){
commandsOnOpenRemove = cf.getStringList("panels." + panelName + ".commands-on-open");
}else{
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.RED + "No commands found to remove!"));
p.sendMessage(plugin.papi( tag + ChatColor.RED + "No commands found to remove!"));
break;
}
try {
commandsOnOpenRemove.remove(Integer.parseInt(e.getMessage())-1);
}catch (Exception ex){
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.RED + "Could not find command!"));
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Could not find command!"));
break;
}
if(commandsOnOpenRemove.size() == 0){
@ -238,13 +238,13 @@ public class editorUserInput implements Listener {
cf.set("panels." + panelName + ".commands-on-open", commandsOnOpenRemove);
}
savePanelFile(cf, panelFile);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Removed command line " + e.getMessage()));
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Removed command line " + e.getMessage()));
break;
case "panel.hotbar.material":
if(e.getMessage().trim().equalsIgnoreCase("remove")){
cf.set("panels." + panelName + ".open-with-item", null);
savePanelFile(cf, panelFile);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Hotbar item have been removed."));
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Hotbar item have been removed."));
//after an open-with-item has been altered, reload after changes
plugin.reloadPanelFiles();
break;
@ -255,7 +255,7 @@ public class editorUserInput implements Listener {
cf.set("panels." + panelName + ".open-with-item.name", panelName + " Item");
}
savePanelFile(cf, panelFile);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Set new Material to " + ChatColor.WHITE + temp.toString()));
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Set new Material to " + ChatColor.WHITE + temp.toString()));
//after an open-with-item has been altered, reload after changes
plugin.reloadPanelFiles();
break;
@ -263,17 +263,17 @@ public class editorUserInput implements Listener {
if(e.getMessage().trim().equalsIgnoreCase("remove")){
cf.set("panels." + panelName + ".open-with-item.stationary", null);
savePanelFile(cf, panelFile);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Hotbar item can now be moved."));
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Hotbar item can now be moved."));
break;
}
try {
int loc = Integer.parseInt(e.getMessage());
if (loc >= 10 || loc <= 0) {
//if the number isn't between 1-9
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Choose an integer between 1 to 9!"));
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Choose an integer between 1 to 9!"));
return;
}
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Set Hotbar Location to " + loc + "!"));
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Set Hotbar Location to " + loc + "!"));
//because it needs to convert 1-9 to 0-8 for in the panel
loc -= 1;
cf.set("panels." + panelName + ".open-with-item.stationary", loc);
@ -285,7 +285,7 @@ public class editorUserInput implements Listener {
case "panel.hotbar.name":
cf.set("panels." + panelName + ".open-with-item.name",e.getMessage());
savePanelFile(cf, panelFile);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Set new Name to " + ChatColor.WHITE + e.getMessage()));
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Set new Name to " + ChatColor.WHITE + e.getMessage()));
break;
case "panel.hotbar.lore.add":
List<String> loreAdd = new ArrayList<>();
@ -295,20 +295,20 @@ public class editorUserInput implements Listener {
loreAdd.add(e.getMessage());
cf.set("panels." + panelName + ".open-with-item.lore", loreAdd);
savePanelFile(cf, panelFile);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Added new lore: " + e.getMessage()));
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Added new lore: " + e.getMessage()));
break;
case "panel.hotbar.lore.remove":
List<String> loreRemove;
if(cf.contains("panels." + panelName + ".open-with-item.lore")){
loreRemove = cf.getStringList("panels." + panelName + ".open-with-item.lore");
}else{
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.RED + "No lore found to remove!"));
p.sendMessage(plugin.papi( tag + ChatColor.RED + "No lore found to remove!"));
break;
}
try {
loreRemove.remove(Integer.parseInt(e.getMessage())-1);
}catch (Exception ex){
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.RED + "Could not find lore!"));
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Could not find lore!"));
break;
}
if(loreRemove.size() == 0){
@ -317,7 +317,7 @@ public class editorUserInput implements Listener {
cf.set("panels." + panelName + ".open-with-item.lore", loreRemove);
}
savePanelFile(cf, panelFile);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Removed lore line " + e.getMessage()));
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Removed lore line " + e.getMessage()));
break;
}
}
@ -330,41 +330,41 @@ public class editorUserInput implements Listener {
if(e.getMessage().trim().equalsIgnoreCase("remove")){
cf.set("panels." + panelName + ".item." + itemSlot + ".name", "");
savePanelFile(cf, panelFile);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Name is now default."));
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Name is now default."));
break;
}
cf.set("panels." + panelName + ".item." + itemSlot + ".name", e.getMessage());
savePanelFile(cf, panelFile);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Set new name to " + ChatColor.WHITE + e.getMessage()));
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Set new name to " + ChatColor.WHITE + e.getMessage()));
break;
case "head":
if(e.getMessage().trim().equalsIgnoreCase("remove")){
cf.set("panels." + panelName + ".item." + itemSlot + ".material", "PLAYER_HEAD");
savePanelFile(cf, panelFile);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Material is now default."));
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Material is now default."));
break;
}
cf.set("panels." + panelName + ".item." + itemSlot + ".material", e.getMessage());
savePanelFile(cf, panelFile);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Set Material value to " + ChatColor.WHITE + e.getMessage()));
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Set Material value to " + ChatColor.WHITE + e.getMessage()));
break;
case "stack":
if(e.getMessage().trim().equalsIgnoreCase("remove")){
cf.set("panels." + panelName + ".item." + itemSlot + ".stack", null);
savePanelFile(cf, panelFile);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Item has been unstacked."));
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Item has been unstacked."));
break;
}
try {
int rows = Integer.parseInt(e.getMessage());
if (rows >= 65 || rows <= 0) {
//if the number isn't between 1-64
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Choose an integer between 1 to 64!"));
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Choose an integer between 1 to 64!"));
return;
}
cf.set("panels." + panelName + ".item." + itemSlot + ".stack", rows);
cf.save(panelFile);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Set stack to " + rows + "!"));
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Set stack to " + rows + "!"));
} catch (Exception io) {
plugin.debug(io);
}
@ -373,45 +373,45 @@ public class editorUserInput implements Listener {
if(e.getMessage().trim().equalsIgnoreCase("remove")){
cf.set("panels." + panelName + ".item." + itemSlot + ".enchanted", null);
savePanelFile(cf, panelFile);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Enchantments have been removed."));
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Enchantments have been removed."));
break;
}
cf.set("panels." + panelName + ".item." + itemSlot + ".enchanted", e.getMessage());
savePanelFile(cf, panelFile);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Set new Enchantment to " + ChatColor.WHITE + e.getMessage()));
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Set new Enchantment to " + ChatColor.WHITE + e.getMessage()));
break;
case "potion":
if(e.getMessage().trim().equalsIgnoreCase("remove")){
cf.set("panels." + panelName + ".item." + itemSlot + ".potion", null);
savePanelFile(cf, panelFile);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Potion effects have been removed."));
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Potion effects have been removed."));
break;
}
cf.set("panels." + panelName + ".item." + itemSlot + ".potion", e.getMessage());
savePanelFile(cf, panelFile);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Set new Potion to " + e.getMessage().toUpperCase()));
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Set new Potion to " + e.getMessage().toUpperCase()));
break;
case "customdata":
if(e.getMessage().trim().equalsIgnoreCase("remove")){
cf.set("panels." + panelName + ".item." + itemSlot + ".customdata", null);
savePanelFile(cf, panelFile);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Custom Model Data has been removed."));
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Custom Model Data has been removed."));
break;
}
cf.set("panels." + panelName + ".item." + itemSlot + ".customdata", e.getMessage());
savePanelFile(cf, panelFile);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Custom Model Data set to " + e.getMessage()));
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Custom Model Data set to " + e.getMessage()));
break;
case "leatherarmor":
if(e.getMessage().trim().equalsIgnoreCase("remove")){
cf.set("panels." + panelName + ".item." + itemSlot + ".leatherarmor", null);
savePanelFile(cf, panelFile);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Leather armor colour has been removed."));
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Leather armor colour has been removed."));
break;
}
cf.set("panels." + panelName + ".item." + itemSlot + ".leatherarmor", e.getMessage());
savePanelFile(cf, panelFile);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Leather armor colour set to " + e.getMessage()));
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Leather armor colour set to " + e.getMessage()));
break;
case "commands.add":
List<String> commandsOnOpenAdd = new ArrayList<>();
@ -421,20 +421,20 @@ public class editorUserInput implements Listener {
commandsOnOpenAdd.add(e.getMessage());
cf.set("panels." + panelName + ".item." + itemSlot + ".commands", commandsOnOpenAdd);
savePanelFile(cf, panelFile);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Added new command: " + e.getMessage()));
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Added new command: " + e.getMessage()));
break;
case "commands.remove":
List<String> commandsOnOpenRemove;
if(cf.contains("panels." + panelName + ".item." + itemSlot + ".commands")){
commandsOnOpenRemove = cf.getStringList("panels." + panelName + ".item." + itemSlot + ".commands");
}else{
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.RED + "No commands found to remove!"));
p.sendMessage(plugin.papi( tag + ChatColor.RED + "No commands found to remove!"));
break;
}
try {
commandsOnOpenRemove.remove(Integer.parseInt(e.getMessage())-1);
}catch (Exception ex){
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.RED + "Could not find command!"));
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Could not find command!"));
break;
}
if(commandsOnOpenRemove.size() == 0){
@ -443,7 +443,7 @@ public class editorUserInput implements Listener {
cf.set("panels." + panelName + ".item." + itemSlot + ".commands", commandsOnOpenRemove);
}
savePanelFile(cf, panelFile);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Removed command line " + e.getMessage()));
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Removed command line " + e.getMessage()));
break;
case "lore.add":
List<String> loreOnOpenAdd = new ArrayList<>();
@ -453,20 +453,20 @@ public class editorUserInput implements Listener {
loreOnOpenAdd.add(e.getMessage());
cf.set("panels." + panelName + ".item." + itemSlot + ".lore", loreOnOpenAdd);
savePanelFile(cf, panelFile);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Added new lore: " + e.getMessage()));
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Added new lore: " + e.getMessage()));
break;
case "lore.remove":
List<String> loreOnOpenRemove;
if(cf.contains("panels." + panelName + ".item." + itemSlot + ".lore")){
loreOnOpenRemove = cf.getStringList("panels." + panelName + ".item." + itemSlot + ".lore");
}else{
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.RED + "No lore found to remove!"));
p.sendMessage(plugin.papi( tag + ChatColor.RED + "No lore found to remove!"));
break;
}
try {
loreOnOpenRemove.remove(Integer.parseInt(e.getMessage())-1);
}catch (Exception ex){
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.RED + "Could not find lore!"));
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Could not find lore!"));
break;
}
if(loreOnOpenRemove.size() == 0){
@ -475,7 +475,7 @@ public class editorUserInput implements Listener {
cf.set("panels." + panelName + ".item." + itemSlot + ".lore", loreOnOpenRemove);
}
savePanelFile(cf, panelFile);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + ChatColor.GREEN + "Removed lore line " + e.getMessage()));
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Removed lore line " + e.getMessage()));
break;
}
}

View File

@ -34,7 +34,7 @@ public class editorUtils implements Listener {
return;
}
}catch(NullPointerException nu){return;}
if(!p.getOpenInventory().getTitle().equals(ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&',"Command Panels Editor")))){
if(!p.getOpenInventory().getTitle().equals(ChatColor.stripColor(plugin.papi("Command Panels Editor")))){
return;
}
e.setCancelled(true);
@ -53,8 +53,8 @@ public class editorUtils implements Listener {
}
for (String s : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)) {
key = s;
panelNames.add(ChatColor.translateAlternateColorCodes('&', key));
panelTitles.add(ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(temp.getString("panels." + key + ".title"))));
panelNames.add(plugin.papi( key));
panelTitles.add(plugin.papi( Objects.requireNonNull(temp.getString("panels." + key + ".title"))));
panelYaml.add(temp);
}
}
@ -150,7 +150,7 @@ public class editorUtils implements Listener {
}
for (String s : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)) {
key = s;
if (e.getView().getTitle().equals(ChatColor.GRAY + "Editing Panel: " + ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(temp.getString("panels." + key + ".title"))))) {
if (e.getView().getTitle().equals(ChatColor.GRAY + "Editing Panel: " + plugin.papi( Objects.requireNonNull(temp.getString("panels." + key + ".title"))))) {
panelName = key;
fileName = fileTempName;
file = temp;
@ -217,7 +217,7 @@ public class editorUtils implements Listener {
}
for (String s : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)) {
key = s;
if (e.getView().getTitle().equals(ChatColor.GRAY + "Editing Panel: " + ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(temp.getString("panels." + key + ".title"))))) {
if (e.getView().getTitle().equals(ChatColor.GRAY + "Editing Panel: " + plugin.papi( Objects.requireNonNull(temp.getString("panels." + key + ".title"))))) {
panelName = key;
fileName = new File(plugin.panelsf + File.separator + tempName);
file = temp;
@ -355,53 +355,53 @@ public class editorUtils implements Listener {
}
if(e.getSlot() == 1){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.perm"});
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.GREEN + "Enter New Permission"));
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Permission"));
p.closeInventory();
}
if(e.getSlot() == 3){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.title"});
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.GREEN + "Enter New Title"));
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Title"));
p.closeInventory();
}
if(e.getSlot() == 5){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.sound-on-open"});
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.GREEN + "Enter New Sound ID"));
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Sound ID"));
p.closeInventory();
}
if(e.getSlot() == 7){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.command"});
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.GREEN + "Enter New Command"));
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Command"));
p.closeInventory();
}
if(e.getSlot() == 21){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.delete"});
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.GREEN + "Are you sure? (yes/no)"));
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Are you sure? (yes/no)"));
p.closeInventory();
}
if(e.getSlot() == 23){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.rows"});
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.GREEN + "Enter Row Amount (1 to 6)"));
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter Row Amount (1 to 6)"));
p.closeInventory();
}
if(e.getSlot() == 13){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.empty"});
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.GREEN + "Enter New Material ID"));
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Material ID"));
p.closeInventory();
}
if(e.getSlot() == 15){
//adds abilities to add and remove lines
if(e.getClick().isLeftClick()) {
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.commands-on-open.add"});
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.GREEN + "Enter New Command"));
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Command"));
}else{
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.commands-on-open.remove"});
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.GREEN + "Enter command line to remove (must be an integer)"));
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter command line to remove (must be an integer)"));
}
p.closeInventory();
}
if(e.getSlot() == 11){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.name"});
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.GREEN + "Enter New Name"));
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Name"));
p.closeInventory();
}
if(e.getSlot() == 18){
@ -410,28 +410,28 @@ public class editorUtils implements Listener {
}
if(e.getSlot() == 40){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.material"});
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.GREEN + "Enter New Material"));
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Material"));
p.closeInventory();
}
if(e.getSlot() == 38 && hotbarItems){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.name"});
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.GREEN + "Enter New Name"));
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Name"));
p.closeInventory();
}
if(e.getSlot() == 36 && hotbarItems){
//adds abilities to add and remove lines
if(e.getClick().isLeftClick()) {
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.lore.add"});
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.GREEN + "Enter New Item Lore"));
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Item Lore"));
}else{
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.lore.remove"});
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.GREEN + "Enter lore line to remove (must be an integer)"));
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter lore line to remove (must be an integer)"));
}
p.closeInventory();
}
if(e.getSlot() == 42 && hotbarItems){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.stationary"});
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.GREEN + "Enter Location (1 to 9)"));
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter Location (1 to 9)"));
p.closeInventory();
}
}
@ -488,59 +488,59 @@ public class editorUtils implements Listener {
}
if(e.getSlot() == 1){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item." + itemSlot + ".name"});
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.GREEN + "Enter New Item Name"));
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Item Name"));
p.closeInventory();
}
if(e.getSlot() == 3){
//adds abilities to add and remove lines
if(e.getClick().isLeftClick()) {
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "item." + itemSlot + ".commands.add"});
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.GREEN + "Enter New Item Command"));
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Item Command"));
}else{
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "item." + itemSlot + ".commands.remove"});
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.GREEN + "Enter command line to remove (must be an integer)"));
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter command line to remove (must be an integer)"));
}
p.closeInventory();
}
if(e.getSlot() == 5){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item." + itemSlot + ".enchanted"});
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.GREEN + "Enter New Item Enchantment"));
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Item Enchantment"));
p.closeInventory();
}
if(e.getSlot() == 7){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item." + itemSlot + ".potion"});
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.GREEN + "Enter New Item Potion Effect"));
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Item Potion Effect"));
p.closeInventory();
}
if(e.getSlot() == 19){
//adds abilities to add and remove lines
if(e.getClick().isLeftClick()) {
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "item." + itemSlot + ".lore.add"});
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.GREEN + "Enter New Item Lore"));
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Item Lore"));
}else{
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "item." + itemSlot + ".lore.remove"});
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.GREEN + "Enter lore line to remove (must be an integer)"));
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter lore line to remove (must be an integer)"));
}
p.closeInventory();
}
if(e.getSlot() == 21){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item." + itemSlot + ".stack"});
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.GREEN + "Enter New Item Stack (must be an integer)"));
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Item Stack (must be an integer)"));
p.closeInventory();
}
if(e.getSlot() == 23){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item." + itemSlot + ".customdata"});
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.GREEN + "Enter New Custom Model Data"));
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Custom Model Data"));
p.closeInventory();
}
if(e.getSlot() == 25){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item." + itemSlot + ".leatherarmor"});
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.GREEN + "Enter New Leather Armor Colour"));
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Leather Armor Colour"));
p.closeInventory();
}
if(e.getSlot() == 35){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item." + itemSlot + ".head"});
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.GREEN + "Enter New Custom Material (eg. cps= self)"));
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Enter New Custom Material (eg. cps= self)"));
p.closeInventory();
}
if(e.getSlot() == 27){
@ -598,7 +598,7 @@ public class editorUtils implements Listener {
}
for (String s : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)) {
key = s;
if (invView.getTitle().equals(ChatColor.GRAY + "Editing Panel: " + ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(temp.getString("panels." + key + ".title"))))) {
if (invView.getTitle().equals(ChatColor.GRAY + "Editing Panel: " + plugin.papi( Objects.requireNonNull(temp.getString("panels." + key + ".title"))))) {
panelName = key;
fileName = tempFile;
file = temp;
@ -670,9 +670,9 @@ public class editorUtils implements Listener {
try {
file.save(new File(plugin.panelsf + File.separator + fileName));
tempEdit.save(new File(plugin.getDataFolder() + File.separator + "temp.yml"));
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.GREEN + "Saved Changes!"));
p.sendMessage(plugin.papi(tag + ChatColor.GREEN + "Saved Changes!"));
} catch (IOException s) {
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + ChatColor.RED + "Could Not Save Changes!"));
p.sendMessage(plugin.papi(tag + ChatColor.RED + "Could Not Save Changes!"));
plugin.debug(s);
}
plugin.reloadPanelFiles();

View File

@ -1,10 +1,8 @@
package me.rockyhawk.commandPanels.openWithItem;
import me.rockyhawk.commandPanels.commandpanels;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -46,14 +44,14 @@ public class utilsOpenWithItem implements Listener {
if(tempFile.contains("panels." + tempName + ".open-with-item") && Objects.requireNonNull(e.getClickedInventory()).getType() == InventoryType.PLAYER) {
try{
assert clicked != null;
if (clicked.getType() == new ItemStack(Objects.requireNonNull(plugin.makeItemFromConfig(Objects.requireNonNull(tempFile.getConfigurationSection("panels." + tempName + ".open-with-item")), p, false).getType()), 1).getType()) {
if ((ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(clicked.getItemMeta()).getDisplayName()).equals(ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(tempFile.getString("panels." + tempName + ".open-with-item.name")))))) {
if (clicked.getType() == new ItemStack(Objects.requireNonNull(plugin.makeItemFromConfig(Objects.requireNonNull(tempFile.getConfigurationSection("panels." + tempName + ".open-with-item")), p, false, true).getType()), 1).getType()) {
if ((plugin.papi( Objects.requireNonNull(clicked.getItemMeta()).getDisplayName()).equals(plugin.papi( Objects.requireNonNull(tempFile.getString("panels." + tempName + ".open-with-item.name")))))) {
//cancel the click item event
if (tempFile.contains("panels." + tempName + ".open-with-item.stationary")) {
if (e.getSlot() == Integer.parseInt(Objects.requireNonNull(tempFile.getString("panels." + tempName + ".open-with-item.stationary")))) {
e.setCancelled(true);
p.updateInventory();
Bukkit.dispatchCommand(p, "commandpanels:commandpanel " + tempName);
plugin.openCommandPanel(p,p,tempName,tempFile,false);
return;
}
}
@ -93,8 +91,8 @@ public class utilsOpenWithItem implements Listener {
if(tempFile.contains("panels." + tempName + ".open-with-item")) {
try{
assert clicked != null;
if (clicked.getType() == new ItemStack(Objects.requireNonNull(plugin.makeItemFromConfig(Objects.requireNonNull(tempFile.getConfigurationSection("panels." + tempName + ".open-with-item")), p, false).getType()), 1).getType()) {
if ((ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(clicked.getItemMeta()).getDisplayName()).equals(ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(tempFile.getString("panels." + tempName + ".open-with-item.name")))))) {
if (clicked.getType() == new ItemStack(Objects.requireNonNull(plugin.makeItemFromConfig(Objects.requireNonNull(tempFile.getConfigurationSection("panels." + tempName + ".open-with-item")), p, false, true).getType()), 1).getType()) {
if ((plugin.papi( Objects.requireNonNull(clicked.getItemMeta()).getDisplayName()).equals(plugin.papi( Objects.requireNonNull(tempFile.getString("panels." + tempName + ".open-with-item.name")))))) {
//cancel the click item event
if (tempFile.contains("panels." + tempName + ".open-with-item.stationary")) {
if (p.getInventory().getHeldItemSlot() != Integer.parseInt(Objects.requireNonNull(tempFile.getString("panels." + tempName + ".open-with-item.stationary")))) {
@ -103,7 +101,7 @@ public class utilsOpenWithItem implements Listener {
}
e.setCancelled(true);
p.updateInventory();
Bukkit.dispatchCommand(p, "commandpanels:commandpanel " + tempName);
plugin.openCommandPanel(p,p,tempName,tempFile,false);
return;
}
}
@ -137,7 +135,6 @@ public class utilsOpenWithItem implements Listener {
}catch(Exception b){
return;
}
YamlConfiguration cf; //this is the file to use for any panel.* requests
String tpanels; //tpanels is the temp to check through the files
for(String fileName : plugin.panelFiles) { //will loop through all the files in folder
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
@ -156,7 +153,7 @@ public class utilsOpenWithItem implements Listener {
}
}
if (p.hasPermission("commandpanel.panel." + temp.getString("panels." + key + ".perm")) && temp.contains("panels." + key + ".open-with-item")) {
ItemStack s = plugin.makeItemFromConfig(Objects.requireNonNull(temp.getConfigurationSection("panels." + key + ".open-with-item")), p, false);
ItemStack s = plugin.makeItemFromConfig(Objects.requireNonNull(temp.getConfigurationSection("panels." + key + ".open-with-item")), p, false, true);
if(temp.contains("panels." + key + ".open-with-item.stationary")) {
if (0 <= Integer.parseInt(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.stationary"))) && 8 >= Integer.parseInt(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.stationary")))) {
p.getInventory().setItem(Integer.parseInt(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.stationary"))), s);
@ -199,7 +196,7 @@ public class utilsOpenWithItem implements Listener {
}
}
if (p.hasPermission("commandpanel.panel." + temp.getString("panels." + key + ".perm")) && temp.contains("panels." + key + ".open-with-item")) {
ItemStack s = plugin.makeItemFromConfig(Objects.requireNonNull(temp.getConfigurationSection("panels." + key + ".open-with-item")), p, false);
ItemStack s = plugin.makeItemFromConfig(Objects.requireNonNull(temp.getConfigurationSection("panels." + key + ".open-with-item")), p, false, true);
if(temp.contains("panels." + key + ".open-with-item.stationary") && 0 <= Integer.parseInt(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.stationary"))) && 8 >= Integer.parseInt(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.stationary")))){
p.getInventory().setItem(Integer.parseInt(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.stationary"))), s);
}
@ -234,7 +231,7 @@ public class utilsOpenWithItem implements Listener {
key = (String) var10.next();
if (p.hasPermission("commandpanel.panel." + temp.getString("panels." + key + ".perm")) && temp.contains("panels." + key + ".open-with-item")) {
if(temp.contains("panels." + key + ".open-with-item.stationary")){
ItemStack s = plugin.makeItemFromConfig(Objects.requireNonNull(temp.getConfigurationSection("panels." + key + ".open-with-item")), p, false);
ItemStack s = plugin.makeItemFromConfig(Objects.requireNonNull(temp.getConfigurationSection("panels." + key + ".open-with-item")), p, false, true);
e.getDrops().remove(s);
}
}
@ -262,7 +259,7 @@ public class utilsOpenWithItem implements Listener {
String key;
tpanels = "";
if(!plugin.checkPanels(temp)){
p.sendMessage(ChatColor.translateAlternateColorCodes('&',tag + plugin.papi(p, plugin.config.getString("config.format.error") + ": Missing required component in panel!")));
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + ": Missing required component in panel!"));
return;
}
for (Iterator var10 = Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") {
@ -275,7 +272,7 @@ public class utilsOpenWithItem implements Listener {
continue;
}
}
ItemStack s = plugin.makeItemFromConfig(Objects.requireNonNull(temp.getConfigurationSection("panels." + key + ".open-with-item")), p, false);
ItemStack s = plugin.makeItemFromConfig(Objects.requireNonNull(temp.getConfigurationSection("panels." + key + ".open-with-item")), p, false, true);
/*ItemStack s;
try {
s = new ItemStack(Objects.requireNonNull(Material.matchMaterial(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.material")))), 1);
@ -294,7 +291,7 @@ public class utilsOpenWithItem implements Listener {
}catch(Exception n){
continue;
}
plugin.setName(s, temp.getString("panels." + key + ".open-with-item.name"), temp.getList("panels." + key + ".open-with-item.lore"),p,true);
plugin.setName(s, temp.getString("panels." + key + ".open-with-item.name"), temp.getStringList("panels." + key + ".open-with-item.lore"),p,true, true);
if(temp.contains("panels." + key + ".open-with-item.stationary") && 0 <= Integer.parseInt(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.stationary"))) && 8 >= Integer.parseInt(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.stationary")))){
try {
if (Objects.requireNonNull(p.getInventory().getItem(Integer.parseInt(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.stationary"))))).isSimilar(s)) {
@ -341,7 +338,7 @@ public class utilsOpenWithItem implements Listener {
//try and catch loop to stop errors with the same material type but different name
try {
if (clicked.getType() == new ItemStack(Objects.requireNonNull(Material.matchMaterial(Objects.requireNonNull(temp.getString("panels." + ekey + ".open-with-item.material")))), 1).getType()) {
if ((ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(clicked.getItemMeta()).getDisplayName()).equals(ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(temp.getString("panels." + ekey + ".open-with-item.name")))))) {
if ((plugin.papi( Objects.requireNonNull(clicked.getItemMeta()).getDisplayName()).equals(plugin.papi( Objects.requireNonNull(temp.getString("panels." + ekey + ".open-with-item.name")))))) {
//cancel the click item event
if(temp.contains("panels." + key + ".open-with-item.stationary")){
if(p.getInventory().getHeldItemSlot() == Integer.parseInt(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.stationary")))){
@ -393,7 +390,7 @@ public class utilsOpenWithItem implements Listener {
//try and catch loop to stop errors with the same material type but different name
try {
if (clicked.getType() == new ItemStack(Objects.requireNonNull(Material.matchMaterial(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.material")))), 1).getType()) {
if ((ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(clicked.getItemMeta()).getDisplayName()).equals(ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.name")))))) {
if ((plugin.papi( Objects.requireNonNull(clicked.getItemMeta()).getDisplayName()).equals(plugin.papi( Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.name")))))) {
//cancel the click item event
if(temp.contains("panels." + key + ".open-with-item.stationary")){
if(p.getInventory().getHeldItemSlot() == Integer.parseInt(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.stationary")))){
@ -444,7 +441,7 @@ public class utilsOpenWithItem implements Listener {
//try and catch loop to stop errors with the same material type but different name
try {
if (clicked.getType() == new ItemStack(Objects.requireNonNull(Material.matchMaterial(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.material")))), 1).getType()) {
if ((ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(clicked.getItemMeta()).getDisplayName()).equals(ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.name")))))) {
if ((plugin.papi( Objects.requireNonNull(clicked.getItemMeta()).getDisplayName()).equals(plugin.papi( Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.name")))))) {
//cancel the click item event
if (temp.contains("panels." + key + ".open-with-item.stationary")) {
if (p.getInventory().getHeldItemSlot() == Integer.parseInt(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.stationary")))) {

View File

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

View File

@ -1,15 +1,16 @@
package me.rockyhawk.commandPanels.panelBlocks;
import me.rockyhawk.commandPanels.commandpanels;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import java.io.File;
import java.util.Objects;
public class panelBlockOnClick implements Listener {
@ -37,7 +38,15 @@ public class panelBlockOnClick implements Listener {
Location tempLocation = new Location(plugin.getServer().getWorld(loc[0]),Double.parseDouble(loc[1]),Double.parseDouble(loc[2]),Double.parseDouble(loc[3]));
if(tempLocation.equals(block.getLocation())){
e.setCancelled(true);
Bukkit.dispatchCommand(p, "commandpanels:commandpanel " + plugin.blockConfig.getString("blocks." + configLocation + ".panel"));
YamlConfiguration cf = null;
String panelName = "";
for(String[] temp : plugin.panelNames){
if(temp[0].equals(plugin.blockConfig.getString("blocks." + configLocation + ".panel"))){
panelName = temp[0];
cf = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + plugin.panelFiles.get(Integer.parseInt(temp[1]))));
}
}
plugin.openCommandPanel(p,p,panelName,cf,false);
return;
}
}

View File

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

View File

@ -49,14 +49,14 @@ public class commandpanelrefresher implements Listener {
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
if (!plugin.checkPanels(temp)) {
assert p != null;
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + plugin.papi(p, plugin.config.getString("config.format.error") + ": File with no Panels found or Panel with syntax error Found!")));
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + ": File with no Panels found or Panel with syntax error Found!"));
return;
}
for (String s : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)) {
key = s;
if (ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(temp.getString("panels." + key + ".title"))).equals(e.getView().getTitle())) {
if (plugin.papi( Objects.requireNonNull(temp.getString("panels." + key + ".title"))).equals(e.getView().getTitle())) {
panel = key;
panelTitle = ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(temp.getString("panels." + key + ".title")));
panelTitle = plugin.papi( Objects.requireNonNull(temp.getString("panels." + key + ".title")));
cf = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
foundPanel = true;
break;

View File

@ -1,15 +1,10 @@
package me.rockyhawk.commandPanels;
import me.clip.placeholderapi.PlaceholderAPI;
import org.bukkit.*;
import org.bukkit.block.*;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.*;
@ -42,6 +37,10 @@ public class utils implements Listener {
//if no panels are present
return;
}
if(clicked == null){
//if itemstack is null
return;
}
}catch(Exception b){
return;
}
@ -52,7 +51,7 @@ public class utils implements Listener {
String key;
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + filename));
if (!plugin.checkPanels(temp)) {
p.sendMessage(ChatColor.translateAlternateColorCodes('&', tag + plugin.papi(p, plugin.config.getString("config.format.error") + ": Syntax error Found or Missing certain element!")));
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + ": Syntax error Found or Missing certain element!"));
return;
}
for (String s : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)) {
@ -89,76 +88,8 @@ public class utils implements Listener {
if(!foundSlot){
return;
}
String section = "";
//this will do the noperm without any numbers
//loop through possible noperm/hasperm 1,2,3,etc
if (cf.contains("panels." + panel + ".item." + e.getSlot() + ".hasvalue")) {
//loop through possible hasvalue 1,2,3,etc
for (int count = 0; Objects.requireNonNull(cf.getConfigurationSection("panels." + panel + ".item." + e.getSlot())).getKeys(false).size() > count; count++) {
if (cf.contains("panels." + panel + ".item." + e.getSlot() + ".hasvalue" + count)) {
boolean outputValue = true;
//outputValue will default to true
if (cf.contains("panels." + panel + ".item." + e.getSlot() + ".hasvalue" + count + ".output")) {
//if output is true, and values match it will be this item, vice versa
outputValue = cf.getBoolean("panels." + panel + ".item." + e.getSlot() + ".hasvalue" + count + ".output");
}
String value = cf.getString("panels." + panel + ".item." + e.getSlot() + ".hasvalue" + count + ".value");
String compare = ChatColor.stripColor(plugin.papi(p,plugin.setCpPlaceholders(p,cf.getString("panels." + panel + ".item." + e.getSlot() + ".hasvalue" + count + ".compare"))));
if (compare.equals(value) == outputValue) {
//onOpen being 3 means it is the editor panel.. hasvalue items cannot be included to avoid item breaking
section = ".hasvalue" + count;
break;
}
}
}
//this will do the hasvalue without any numbers
boolean outputValue = true;
//outputValue will default to true
if (cf.contains("panels." + panel + ".item." + e.getSlot() + ".hasvalue.output")) {
//if output is true, and values match it will be this item, vice versa
outputValue = cf.getBoolean("panels." + panel + ".item." + e.getSlot() + ".hasvalue.output");
}
String value = cf.getString("panels." + panel + ".item." + e.getSlot() + ".hasvalue.value");
String compare = ChatColor.stripColor(plugin.papi(p,plugin.setCpPlaceholders(p,cf.getString("panels." + panel + ".item." + e.getSlot() + ".hasvalue.compare"))));
if (compare.equals(value) == outputValue) {
//onOpen being 3 means it is the editor panel.. hasvalue items cannot be included to avoid item breaking
section = ".hasvalue";
}
}
if (cf.contains("panels." + panel + ".item." + e.getSlot() + ".hasperm") && cf.contains("panels." + panel + ".item." + e.getSlot() + ".hasperm.perm")) {
for(int count = 0; Objects.requireNonNull(cf.getConfigurationSection("panels." + panel + ".item." + e.getSlot())).getKeys(false).size() > count; count++){
if (cf.contains("panels." + panel + ".item." + e.getSlot() + ".hasperm" + count) && cf.contains("panels." + panel + ".item." + e.getSlot() + ".hasperm" + count + ".perm")) {
boolean outputValue = true;
//outputValue will default to true
if (cf.contains("panels." + panel + ".item." + e.getSlot() + ".hasperm" + count + ".output")) {
//if output is true, and values match it will be this item, vice versa
outputValue = cf.getBoolean("panels." + panel + ".item." + e.getSlot() + ".hasperm" + count + ".output");
}
if (p.hasPermission(Objects.requireNonNull(cf.getString("panels." + panel + ".item." + e.getSlot() + ".hasperm" + count + ".perm"))) == outputValue) {
if (cf.contains("panels." + panel + ".item." + e.getSlot() + ".hasperm" + count + ".commands") && !(clicked == null)) {
section = ".hasperm" + count;
break;
} else if (clicked != null) {
return;
}
}
}
}
//this will do hasperm with no numbers
boolean outputValue = true;
//outputValue will default to true
if (cf.contains("panels." + panel + ".item." + e.getSlot() + ".hasperm" + ".output")) {
//if output is true, and values match it will be this item, vice versa
outputValue = cf.getBoolean("panels." + panel + ".item." + e.getSlot() + ".hasperm" + ".output");
}
if (p.hasPermission(Objects.requireNonNull(cf.getString("panels." + panel + ".item." + e.getSlot() + ".hasperm.perm"))) == outputValue) {
if (cf.contains("panels." + panel + ".item." + e.getSlot() + ".hasperm.commands") && !(clicked == null)) {
section = ".hasperm";
} else if (clicked != null) {
return;
}
}
}
//loop through possible hasvalue/hasperm 1,2,3,etc
String section = plugin.hasSection(panel, cf, e.getSlot(),p);
//this will remove any pending user inputs, if there is already something there from a previous item
for(int o = 0; plugin.userInputStrings.size() > o; o++){
if(plugin.userInputStrings.get(o)[0].equals(p.getName())){
@ -167,7 +98,7 @@ public class utils implements Listener {
}
}
if(cf.contains("panels." + panel + ".item." + e.getSlot() + section + ".commands")) {
List<String> commands = (List<String>) cf.getList("panels." + panel + ".item." + e.getSlot() + section + ".commands");
List<String> commands = cf.getStringList("panels." + panel + ".item." + e.getSlot() + section + ".commands");
assert commands != null;
if (commands.size() != 0) {
//this will replace a sequence tag command with the commands from the sequence
@ -175,7 +106,7 @@ public class utils implements Listener {
for (int i = 0; commands.size() - 1 >= i; i++) {
if(commands.get(i).startsWith("sequence=")){
String locationOfSequence = commands.get(i).split("\\s")[1];
List<String> commandsSequence = (List<String>) cf.getList(locationOfSequence);
List<String> commandsSequence = cf.getStringList(locationOfSequence);
commandsAfterSequence.remove(i);
assert commandsSequence != null;
commandsAfterSequence.addAll(i,commandsSequence);