forked from Upstream/CommandPanels
Update v3.13.0
This commit is contained in:
parent
d44c72a68b
commit
b72dcb4956
@ -1,4 +1,4 @@
|
|||||||
version: 3.12.6
|
version: 3.13.0
|
||||||
main: me.rockyhawk.commandpanels.CommandPanels
|
main: me.rockyhawk.commandpanels.CommandPanels
|
||||||
name: CommandPanels
|
name: CommandPanels
|
||||||
author: RockyHawk
|
author: RockyHawk
|
||||||
|
@ -14,6 +14,7 @@ import me.realized.tokenmanager.api.TokenManager;
|
|||||||
import me.rockyhawk.commandpanels.classresources.*;
|
import me.rockyhawk.commandpanels.classresources.*;
|
||||||
import me.rockyhawk.commandpanels.commands.*;
|
import me.rockyhawk.commandpanels.commands.*;
|
||||||
import me.rockyhawk.commandpanels.completetabs.CpTabComplete;
|
import me.rockyhawk.commandpanels.completetabs.CpTabComplete;
|
||||||
|
import me.rockyhawk.commandpanels.customcommands.CommandPlaceholderLoader;
|
||||||
import me.rockyhawk.commandpanels.customcommands.Commandpanelcustom;
|
import me.rockyhawk.commandpanels.customcommands.Commandpanelcustom;
|
||||||
import me.rockyhawk.commandpanels.generatepanels.Commandpanelsgenerate;
|
import me.rockyhawk.commandpanels.generatepanels.Commandpanelsgenerate;
|
||||||
import me.rockyhawk.commandpanels.generatepanels.GenUtils;
|
import me.rockyhawk.commandpanels.generatepanels.GenUtils;
|
||||||
@ -75,6 +76,7 @@ public class CommandPanels extends JavaPlugin {
|
|||||||
public LegacyVersion legacy = new LegacyVersion(this);
|
public LegacyVersion legacy = new LegacyVersion(this);
|
||||||
public OpenPanelsLoader openPanels = new OpenPanelsLoader(this);
|
public OpenPanelsLoader openPanels = new OpenPanelsLoader(this);
|
||||||
public OpenGUI createGUI = new OpenGUI(this);
|
public OpenGUI createGUI = new OpenGUI(this);
|
||||||
|
public CommandPlaceholderLoader customCommand = new CommandPlaceholderLoader(this);
|
||||||
|
|
||||||
public File panelsf;
|
public File panelsf;
|
||||||
public YamlConfiguration blockConfig; //where panel block locations are stored
|
public YamlConfiguration blockConfig; //where panel block locations are stored
|
||||||
@ -361,6 +363,15 @@ public class CommandPanels extends JavaPlugin {
|
|||||||
str = str.replace(str.substring(start, end) + "%", papi(p, "false"));
|
str = str.replace(str.substring(start, end) + "%", papi(p, "false"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for(String[] placeholder : customCommand.getCCP(p.getName())){
|
||||||
|
while (str.contains(placeholder[0])) {
|
||||||
|
int start = str.indexOf(placeholder[0]);
|
||||||
|
int end = start+placeholder[0].length()-1;
|
||||||
|
str = str.replace(str.substring(start, end) + "%", placeholder[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//does %cp-random-MIN,MAX%
|
//does %cp-random-MIN,MAX%
|
||||||
while (str.contains("%cp-random-")) {
|
while (str.contains("%cp-random-")) {
|
||||||
int start = str.indexOf("%cp-random-");
|
int start = str.indexOf("%cp-random-");
|
||||||
@ -381,6 +392,7 @@ public class CommandPanels extends JavaPlugin {
|
|||||||
str = str.replace(str.substring(start, end) + "-find%", playerFind[Integer.parseInt(playerLocation) - 1].getName());
|
str = str.replace(str.substring(start, end) + "-find%", playerFind[Integer.parseInt(playerLocation) - 1].getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (econ != null) {
|
if (econ != null) {
|
||||||
str = str.replaceAll("%cp-player-balance%", String.valueOf(Math.round(econ.getBalance(p))));
|
str = str.replaceAll("%cp-player-balance%", String.valueOf(Math.round(econ.getBalance(p))));
|
||||||
|
@ -1,17 +1,13 @@
|
|||||||
package me.rockyhawk.commandpanels;
|
package me.rockyhawk.commandpanels;
|
||||||
|
|
||||||
import org.bukkit.*;
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.bukkit.event.inventory.InventoryType;
|
import org.bukkit.event.inventory.InventoryType;
|
||||||
import org.bukkit.event.player.*;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class Utils implements Listener {
|
public class Utils implements Listener {
|
||||||
@ -51,7 +47,6 @@ public class Utils implements Listener {
|
|||||||
o=o-1;
|
o=o-1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
redirectPanel(p,cf,section,e.getSlot());
|
|
||||||
if(cf.contains("item." + e.getSlot() + section + ".commands")) {
|
if(cf.contains("item." + e.getSlot() + section + ".commands")) {
|
||||||
List<String> commands = cf.getStringList("item." + e.getSlot() + section + ".commands");
|
List<String> commands = cf.getStringList("item." + e.getSlot() + section + ".commands");
|
||||||
if (commands.size() != 0) {
|
if (commands.size() != 0) {
|
||||||
@ -122,44 +117,4 @@ public class Utils implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerJoin(PlayerJoinEvent e){
|
|
||||||
Player p = e.getPlayer();
|
|
||||||
if(p.isOp() || p.hasPermission("*.*")){
|
|
||||||
if(plugin.update) {
|
|
||||||
p.sendMessage(ChatColor.WHITE + "CommandPanels " + ChatColor.DARK_RED + "is not running the latest version! A new version is available at");
|
|
||||||
p.sendMessage(ChatColor.RED + "https://www.spigotmc.org/resources/command-panels-custom-guis.67788/");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void redirectPanel(Player p, ConfigurationSection cf, String section, int slot){
|
|
||||||
String tag = plugin.config.getString("config.format.tag") + " ";
|
|
||||||
if(!cf.contains("item." + slot + section + ".redirect") || !cf.contains("item." + slot + section + ".redirect.panel")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
String panelName = cf.getString("item." + slot + section + ".redirect.panel");
|
|
||||||
ConfigurationSection panelConfig = null;
|
|
||||||
for(String[] tempName : plugin.panelNames){
|
|
||||||
if(tempName[0].equals(panelName)){
|
|
||||||
panelConfig = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + plugin.panelFiles.get(Integer.parseInt(tempName[1])))).getConfigurationSection("panels." + panelName);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(panelConfig == null){
|
|
||||||
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.nopanel")));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(cf.contains("item." + slot + section + ".redirect.replacements")){
|
|
||||||
if(!panelConfig.getString("panels." + panelName + ".panelType").equalsIgnoreCase("temporary") && plugin.config.getBoolean("config.refresh-panels")){
|
|
||||||
p.sendMessage(plugin.papi(tag + ChatColor.RED + panelName + " panel type needs to be temporary to replace elements."));
|
|
||||||
}
|
|
||||||
for(String sectionName : cf.getConfigurationSection("item." + slot + section + ".redirect.replacements").getKeys(false)){
|
|
||||||
ConfigurationSection temp = cf.getConfigurationSection("item." + slot + section + ".redirect.replacements." + sectionName);
|
|
||||||
panelConfig.set("panels." + panelName + ".item." + sectionName, temp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
plugin.openVoids.openCommandPanel(p, p, panelName, panelConfig, false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -35,8 +35,14 @@ public class CommandTags {
|
|||||||
assert player != null;
|
assert player != null;
|
||||||
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
|
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
|
||||||
} else if (command.split("\\s")[0].equalsIgnoreCase("open=")) {
|
} else if (command.split("\\s")[0].equalsIgnoreCase("open=")) {
|
||||||
//if player uses open= it will open the panel forced
|
//if player uses open= it will open the panel, with the option to add custom placeholders
|
||||||
String panelName = command.split("\\s")[1];
|
String[] cmd = command.split("\\s");
|
||||||
|
String panelName = cmd[1];
|
||||||
|
for(int i = 2; i < cmd.length; i++){
|
||||||
|
if(cmd[i].startsWith("%cp-")){
|
||||||
|
plugin.customCommand.addCCP(panelName,p.getName(),cmd[i].split(":")[0],cmd[i].split(":")[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
for(String[] tempName : plugin.panelNames){
|
for(String[] tempName : plugin.panelNames){
|
||||||
if(tempName[0].equals(panelName)){
|
if(tempName[0].equals(panelName)){
|
||||||
ConfigurationSection panelConfig = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + plugin.panelFiles.get(Integer.parseInt(tempName[1])))).getConfigurationSection("panels." + panelName);
|
ConfigurationSection panelConfig = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + plugin.panelFiles.get(Integer.parseInt(tempName[1])))).getConfigurationSection("panels." + panelName);
|
||||||
|
@ -20,6 +20,10 @@ public class ExecuteOpenVoids {
|
|||||||
//this is the main method to open a panel
|
//this is the main method to open a panel
|
||||||
public void openCommandPanel(CommandSender sender, Player p, String panelName, ConfigurationSection cf, boolean sendOpenedMessage){
|
public void openCommandPanel(CommandSender sender, Player p, String panelName, ConfigurationSection cf, boolean sendOpenedMessage){
|
||||||
String tag = plugin.config.getString("config.format.tag") + " ";
|
String tag = plugin.config.getString("config.format.tag") + " ";
|
||||||
|
if(p.isSleeping()){
|
||||||
|
//avoid plugin glitches when sleeping
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (sender.hasPermission("commandpanel.panel." + cf.getString("perm"))) {
|
if (sender.hasPermission("commandpanel.panel." + cf.getString("perm"))) {
|
||||||
//if the sender has OTHER perms, or if sendOpenedMessage is false, implying it is not for another person
|
//if the sender has OTHER perms, or if sendOpenedMessage is false, implying it is not for another person
|
||||||
if(sender.hasPermission("commandpanel.other") || !sendOpenedMessage) {
|
if(sender.hasPermission("commandpanel.other") || !sendOpenedMessage) {
|
||||||
|
@ -35,9 +35,9 @@ public class ItemCreation {
|
|||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public ItemStack makeItemFromConfig(ConfigurationSection itemSection, Player p, boolean placeholders, boolean colours){
|
public ItemStack makeItemFromConfig(ConfigurationSection itemSection, Player p, boolean placeholders, boolean colours){
|
||||||
String tag = plugin.config.getString("config.format.tag") + " ";
|
String tag = plugin.config.getString("config.format.tag") + " ";
|
||||||
String material = itemSection.getString("material");
|
String material = plugin.papiNoColour(p,itemSection.getString("material"));
|
||||||
try {
|
try {
|
||||||
if (Objects.requireNonNull(itemSection.getString("material")).equalsIgnoreCase("AIR")) {
|
if (Objects.requireNonNull(material).equalsIgnoreCase("AIR")) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}catch(NullPointerException e){
|
}catch(NullPointerException e){
|
||||||
@ -50,7 +50,6 @@ public class ItemCreation {
|
|||||||
String matskull;
|
String matskull;
|
||||||
String skullname;
|
String skullname;
|
||||||
//this will convert the %cp-player-online-1-find% into cps= NAME
|
//this will convert the %cp-player-online-1-find% into cps= NAME
|
||||||
assert material != null;
|
|
||||||
if (material.contains("%cp-player-online-")) {
|
if (material.contains("%cp-player-online-")) {
|
||||||
int start = material.indexOf("%cp-player-online-");
|
int start = material.indexOf("%cp-player-online-");
|
||||||
int end = material.lastIndexOf("-find%");
|
int end = material.lastIndexOf("-find%");
|
||||||
@ -340,8 +339,8 @@ public class ItemCreation {
|
|||||||
//if output is true, and values match it will be this item, vice versa
|
//if output is true, and values match it will be this item, vice versa
|
||||||
outputValue = cf.getBoolean("hasgreater.output");
|
outputValue = cf.getBoolean("hasgreater.output");
|
||||||
}
|
}
|
||||||
int value = Integer.parseInt(ChatColor.stripColor(plugin.papi(p,plugin.setCpPlaceholders(p,cf.getString("hasgreater.value")))));
|
double value = Double.parseDouble(ChatColor.stripColor(plugin.papiNoColour(p,cf.getString("hasgreater.value"))));
|
||||||
double compare = Double.parseDouble(ChatColor.stripColor(plugin.papi(p,plugin.setCpPlaceholders(p,cf.getString("hasgreater.compare")))));
|
double compare = Double.parseDouble(ChatColor.stripColor(plugin.papiNoColour(p,cf.getString("hasgreater.compare"))));
|
||||||
if ((compare >= value) == outputValue) {
|
if ((compare >= value) == outputValue) {
|
||||||
//onOpen being 3 means it is the editor panel.. hasgreater items cannot be included to avoid item breaking
|
//onOpen being 3 means it is the editor panel.. hasgreater items cannot be included to avoid item breaking
|
||||||
String section = hasSection(Objects.requireNonNull(cf.getConfigurationSection("hasgreater")), p);
|
String section = hasSection(Objects.requireNonNull(cf.getConfigurationSection("hasgreater")), p);
|
||||||
@ -356,8 +355,8 @@ public class ItemCreation {
|
|||||||
//if output is true, and values match it will be this item, vice versa
|
//if output is true, and values match it will be this item, vice versa
|
||||||
outputValue = cf.getBoolean("hasgreater" + count + ".output");
|
outputValue = cf.getBoolean("hasgreater" + count + ".output");
|
||||||
}
|
}
|
||||||
value = Integer.parseInt(ChatColor.stripColor(plugin.papi(p,plugin.setCpPlaceholders(p,cf.getString("hasgreater" + count + ".value")))));
|
value = Double.parseDouble(ChatColor.stripColor(plugin.papiNoColour(p,cf.getString("hasgreater" + count + ".value"))));
|
||||||
compare = Double.parseDouble(ChatColor.stripColor(plugin.papi(p,plugin.setCpPlaceholders(p,cf.getString("hasgreater" + count + ".compare")))));
|
compare = Double.parseDouble(ChatColor.stripColor(plugin.papiNoColour(p,cf.getString("hasgreater" + count + ".compare"))));
|
||||||
if ((compare >= value) == outputValue) {
|
if ((compare >= value) == outputValue) {
|
||||||
//onOpen being 3 means it is the editor panel.. hasgreater items cannot be included to avoid item breaking
|
//onOpen being 3 means it is the editor panel.. hasgreater items cannot be included to avoid item breaking
|
||||||
String section = hasSection(Objects.requireNonNull(cf.getConfigurationSection("hasgreater" + count)), p);
|
String section = hasSection(Objects.requireNonNull(cf.getConfigurationSection("hasgreater" + count)), p);
|
||||||
|
@ -388,6 +388,22 @@ public class OpenEditorGuis {
|
|||||||
plugin.setName(temp, ChatColor.WHITE + "Item Potion Effect", lore, p,true, true);
|
plugin.setName(temp, ChatColor.WHITE + "Item Potion Effect", lore, p,true, true);
|
||||||
i.setItem(7, temp);
|
i.setItem(7, temp);
|
||||||
|
|
||||||
|
temp = new ItemStack(Material.PAPER, 1);
|
||||||
|
lore.clear();
|
||||||
|
lore.add(ChatColor.GRAY + "Duplicate item visuals in other slots");
|
||||||
|
lore.add(ChatColor.GRAY + "- Left click to add duplicate item/s");
|
||||||
|
lore.add(ChatColor.GRAY + "- Right click to remove duplicate item/s");
|
||||||
|
if (cf.contains("duplicate")) {
|
||||||
|
lore.add(ChatColor.WHITE + "-----------------------------");
|
||||||
|
int count = 1;
|
||||||
|
for (String tempLore : cf.getString("duplicate").split(",")) {
|
||||||
|
lore.add(ChatColor.WHITE + Integer.toString(count) + ") " + tempLore);
|
||||||
|
count += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
plugin.setName(temp, ChatColor.WHITE + "Item Duplicates", lore, p, true, true);
|
||||||
|
i.setItem(13, temp);
|
||||||
|
|
||||||
temp = new ItemStack(Material.FEATHER, 1);
|
temp = new ItemStack(Material.FEATHER, 1);
|
||||||
lore.clear();
|
lore.clear();
|
||||||
lore.add(ChatColor.GRAY + "Display a lore under the item name");
|
lore.add(ChatColor.GRAY + "Display a lore under the item name");
|
||||||
|
@ -0,0 +1,39 @@
|
|||||||
|
package me.rockyhawk.commandpanels.customcommands;
|
||||||
|
|
||||||
|
import me.rockyhawk.commandpanels.CommandPanels;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class CommandPlaceholderLoader {
|
||||||
|
CommandPanels plugin;
|
||||||
|
public CommandPlaceholderLoader(CommandPanels pl) {
|
||||||
|
this.plugin = pl;
|
||||||
|
}
|
||||||
|
|
||||||
|
ArrayList<String[]> pendingPlaceholders = new ArrayList<>(); //should read: panelName, playerName, placeholder, argument
|
||||||
|
|
||||||
|
//this will be used with the cpPlaceholder void, when the panel is closed it will remove the placeholder
|
||||||
|
public void addCCP(String panelName, String playerName, String placeholder, String argument){
|
||||||
|
pendingPlaceholders.add(new String[]{panelName,playerName,placeholder,argument});
|
||||||
|
}
|
||||||
|
|
||||||
|
//will remove all pending placeholders for a certain player & panel
|
||||||
|
public void removeCCP(String panelName, String playerName){
|
||||||
|
for(int i = 0; i < pendingPlaceholders.size(); i++){
|
||||||
|
if(playerName.equals(pendingPlaceholders.get(i)[1]) && panelName.equals(pendingPlaceholders.get(i)[0])){
|
||||||
|
pendingPlaceholders.remove(i);
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//will return placeholder,argument
|
||||||
|
public ArrayList<String[]> getCCP(String playerName){
|
||||||
|
ArrayList<String[]> returnPlaceholders = new ArrayList<>();
|
||||||
|
for(String[] temp : pendingPlaceholders){
|
||||||
|
if(temp[1].equals(playerName)){
|
||||||
|
returnPlaceholders.add(new String[]{temp[2],temp[3]});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return returnPlaceholders;
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,6 @@
|
|||||||
package me.rockyhawk.commandpanels.customcommands;
|
package me.rockyhawk.commandpanels.customcommands;
|
||||||
|
|
||||||
import me.rockyhawk.commandpanels.CommandPanels;
|
import me.rockyhawk.commandpanels.CommandPanels;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -32,21 +31,37 @@ public class Commandpanelcustom implements Listener {
|
|||||||
tempFile = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + plugin.panelFiles.get(Integer.parseInt(panelName[1])))).getConfigurationSection("panels." + panelName[0]);
|
tempFile = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + plugin.panelFiles.get(Integer.parseInt(panelName[1])))).getConfigurationSection("panels." + panelName[0]);
|
||||||
if (tempFile.contains("commands")) {
|
if (tempFile.contains("commands")) {
|
||||||
List<String> panelCommands = tempFile.getStringList("commands");
|
List<String> panelCommands = tempFile.getStringList("commands");
|
||||||
if (panelCommands.contains(e.getMessage().replace("/", ""))) {
|
for(String cmd : panelCommands){
|
||||||
e.setCancelled(true);
|
if(cmd.equalsIgnoreCase(e.getMessage().replace("/", ""))){
|
||||||
plugin.openVoids.openCommandPanel(e.getPlayer(), e.getPlayer(), panelName[0], tempFile, false);
|
e.setCancelled(true);
|
||||||
return;
|
plugin.openVoids.openCommandPanel(e.getPlayer(), e.getPlayer(), panelName[0], tempFile, false);
|
||||||
}
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//this will be deleted in 3.13.x
|
boolean correctCommand = true;
|
||||||
if (tempFile.contains("command")) {
|
ArrayList<String[]> placeholders = new ArrayList<>(); //should read placeholder,argument
|
||||||
List<String> panelCommands = Arrays.asList(tempFile.getString("command").split("\\s"));
|
String[] args = cmd.split("\\s");
|
||||||
if (panelCommands.contains(e.getMessage().replace("/", ""))) {
|
String[] executedCommand = e.getMessage().replace("/", "").split("\\s"); //command split into args
|
||||||
e.setCancelled(true);
|
if(args.length != executedCommand.length){
|
||||||
plugin.getServer().getConsoleSender().sendMessage(ChatColor.RED + "[CommandPanels] Using command: for custom commands will soon be deprecated. Please use commands: as shown in the wiki instead!");
|
continue;
|
||||||
plugin.openVoids.openCommandPanel(e.getPlayer(), e.getPlayer(), panelName[0], tempFile, false);
|
}
|
||||||
return;
|
|
||||||
|
for(int i = 0; i < cmd.split("\\s").length; i++){
|
||||||
|
if(args[i].startsWith("%cp-")){
|
||||||
|
placeholders.add(new String[]{args[i], executedCommand[i]});
|
||||||
|
}else if(!args[i].equals(executedCommand[i])){
|
||||||
|
correctCommand = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(correctCommand){
|
||||||
|
e.setCancelled(true);
|
||||||
|
for(String[] placeholder : placeholders){
|
||||||
|
plugin.customCommand.addCCP(panelName[0],e.getPlayer().getName(),placeholder[0],placeholder[1]);
|
||||||
|
}
|
||||||
|
plugin.openVoids.openCommandPanel(e.getPlayer(), e.getPlayer(), panelName[0], tempFile, false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ import org.bukkit.event.player.AsyncPlayerChatEvent;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@ -518,6 +519,7 @@ public class EditorUserInput implements Listener {
|
|||||||
commandsOnOpenRemove.remove(Integer.parseInt(e.getMessage())-1);
|
commandsOnOpenRemove.remove(Integer.parseInt(e.getMessage())-1);
|
||||||
}catch (Exception ex){
|
}catch (Exception ex){
|
||||||
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Could not find command!"));
|
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Could not find command!"));
|
||||||
|
plugin.debug(ex);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(commandsOnOpenRemove.size() == 0){
|
if(commandsOnOpenRemove.size() == 0){
|
||||||
@ -550,6 +552,7 @@ public class EditorUserInput implements Listener {
|
|||||||
loreOnOpenRemove.remove(Integer.parseInt(e.getMessage())-1);
|
loreOnOpenRemove.remove(Integer.parseInt(e.getMessage())-1);
|
||||||
}catch (Exception ex){
|
}catch (Exception ex){
|
||||||
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Could not find lore!"));
|
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Could not find lore!"));
|
||||||
|
plugin.debug(ex);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(loreOnOpenRemove.size() == 0){
|
if(loreOnOpenRemove.size() == 0){
|
||||||
@ -560,6 +563,46 @@ public class EditorUserInput implements Listener {
|
|||||||
savePanelFile(cf, cfile, panelName, panelFile);
|
savePanelFile(cf, cfile, panelName, panelFile);
|
||||||
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Removed lore line " + e.getMessage()));
|
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Removed lore line " + e.getMessage()));
|
||||||
break;
|
break;
|
||||||
|
case "duplicate:add":
|
||||||
|
if(cf.contains("item." + itemSlot + ".duplicate")){
|
||||||
|
cf.set("item." + itemSlot + ".duplicate", cf.getString("item." + itemSlot + ".duplicate") + "," + e.getMessage());
|
||||||
|
}else{
|
||||||
|
cf.set("item." + itemSlot + ".duplicate", e.getMessage());
|
||||||
|
}
|
||||||
|
savePanelFile(cf, cfile, panelName, panelFile);
|
||||||
|
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Added new duplicate item/s: " + e.getMessage()));
|
||||||
|
break;
|
||||||
|
case "duplicate:remove":
|
||||||
|
if(cf.contains("item." + itemSlot + ".duplicate")){
|
||||||
|
if(cf.getString("item." + itemSlot + ".duplicate").contains(",")) {
|
||||||
|
try {
|
||||||
|
String[] duplicateItems = cf.getString("item." + itemSlot + ".duplicate").split(",");
|
||||||
|
StringBuilder items = new StringBuilder();
|
||||||
|
for(int s = 0; s < duplicateItems.length; s++){
|
||||||
|
if(Integer.parseInt(e.getMessage()) != s+1) {
|
||||||
|
items.append(duplicateItems[s]);
|
||||||
|
items.append(",");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cf.set("item." + itemSlot + ".duplicate", items.toString());
|
||||||
|
} catch (Exception ex) {
|
||||||
|
p.sendMessage(plugin.papi(tag + ChatColor.RED + "Could not delete or find item!"));
|
||||||
|
plugin.debug(ex);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(cf.getString("item." + itemSlot + ".duplicate").equals("")){
|
||||||
|
cf.set("item." + itemSlot + ".duplicate", null);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
cf.set("item." + itemSlot + ".duplicate", null);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
p.sendMessage(plugin.papi( tag + ChatColor.RED + "No items found to remove!"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
savePanelFile(cf, cfile, panelName, panelFile);
|
||||||
|
p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Removed duplicate item/s: " + e.getMessage()));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -319,6 +319,7 @@ public class EditorUtils implements Listener {
|
|||||||
//this is put here to avoid conflicts, close panel if it is closed
|
//this is put here to avoid conflicts, close panel if it is closed
|
||||||
for(int i = 0; i < plugin.openPanels.openPanelsPN.size(); i++){
|
for(int i = 0; i < plugin.openPanels.openPanelsPN.size(); i++){
|
||||||
if(plugin.openPanels.openPanelsPN.get(i)[0].equals(e.getPlayer().getName())){
|
if(plugin.openPanels.openPanelsPN.get(i)[0].equals(e.getPlayer().getName())){
|
||||||
|
plugin.customCommand.removeCCP(plugin.openPanels.openPanelsPN.get(i)[1], e.getPlayer().getName());
|
||||||
plugin.openPanels.openPanelsPN.remove(i);
|
plugin.openPanels.openPanelsPN.remove(i);
|
||||||
plugin.openPanels.openPanelsCF.remove(i);
|
plugin.openPanels.openPanelsCF.remove(i);
|
||||||
return;
|
return;
|
||||||
@ -556,6 +557,17 @@ public class EditorUtils implements Listener {
|
|||||||
p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Enter New Item Potion Effect"));
|
p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Enter New Item Potion Effect"));
|
||||||
p.closeInventory();
|
p.closeInventory();
|
||||||
}
|
}
|
||||||
|
if(e.getSlot() == 13){
|
||||||
|
//adds abilities to add and remove items
|
||||||
|
if(e.getClick().isLeftClick()) {
|
||||||
|
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "item:" + itemSlot + ":duplicate:add"});
|
||||||
|
p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Enter Duplicate Item Location/s"));
|
||||||
|
}else{
|
||||||
|
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "item:" + itemSlot + ":duplicate:remove"});
|
||||||
|
p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Enter Duplicate Item/s to Remove (must be an integer)"));
|
||||||
|
}
|
||||||
|
p.closeInventory();
|
||||||
|
}
|
||||||
if(e.getSlot() == 19){
|
if(e.getSlot() == 19){
|
||||||
//adds abilities to add and remove lines
|
//adds abilities to add and remove lines
|
||||||
if(e.getClick().isLeftClick()) {
|
if(e.getClick().isLeftClick()) {
|
||||||
|
@ -11,7 +11,6 @@ import org.bukkit.event.inventory.InventoryOpenEvent;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class Commandpanelrefresher implements Listener {
|
public class Commandpanelrefresher implements Listener {
|
||||||
|
@ -9,6 +9,7 @@ import org.bukkit.inventory.Inventory;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@ -60,7 +61,40 @@ public class OpenGUI {
|
|||||||
}
|
}
|
||||||
ItemStack s = plugin.itemCreate.makeItemFromConfig(Objects.requireNonNull(pconfig.getConfigurationSection("item." + item.split("\\s")[c] + section)), p, onOpen != 3, onOpen != 3);
|
ItemStack s = plugin.itemCreate.makeItemFromConfig(Objects.requireNonNull(pconfig.getConfigurationSection("item." + item.split("\\s")[c] + section)), p, onOpen != 3, onOpen != 3);
|
||||||
try {
|
try {
|
||||||
|
//place item into the GUI
|
||||||
i.setItem(Integer.parseInt(item.split("\\s")[c]), s);
|
i.setItem(Integer.parseInt(item.split("\\s")[c]), s);
|
||||||
|
//only place duplicate items in without the editor mode. These are merely visual and will not carry over commands
|
||||||
|
if(pconfig.contains("item." + item.split("\\s")[c] + section + ".duplicate") && onOpen != 3) {
|
||||||
|
try {
|
||||||
|
String[] duplicateItems = pconfig.getString("item." + item.split("\\s")[c] + section + ".duplicate").split(",");
|
||||||
|
for (String tempDupe : duplicateItems) {
|
||||||
|
if (tempDupe.contains("-")) {
|
||||||
|
//if there is multiple dupe items, convert numbers to ints
|
||||||
|
int[] bothNumbers = new int[]{Integer.parseInt(tempDupe.split("-")[0]), Integer.parseInt(tempDupe.split("-")[1])};
|
||||||
|
for(int n = bothNumbers[0]; n <= bothNumbers[1]; n++){
|
||||||
|
try{
|
||||||
|
if(i.getItem(n).getType() == Material.AIR){
|
||||||
|
i.setItem(n, s);
|
||||||
|
}
|
||||||
|
}catch(NullPointerException ignore){
|
||||||
|
i.setItem(n, s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//if there is only one dupe item
|
||||||
|
try{
|
||||||
|
if(i.getItem(Integer.parseInt(tempDupe)).getType() == Material.AIR){
|
||||||
|
i.setItem(Integer.parseInt(tempDupe), s);
|
||||||
|
}
|
||||||
|
}catch(NullPointerException ignore){
|
||||||
|
i.setItem(Integer.parseInt(tempDupe), s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch(NullPointerException nullp){
|
||||||
|
plugin.debug(nullp);
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (ArrayIndexOutOfBoundsException var24) {
|
} catch (ArrayIndexOutOfBoundsException var24) {
|
||||||
plugin.debug(var24);
|
plugin.debug(var24);
|
||||||
if (plugin.debug) {
|
if (plugin.debug) {
|
||||||
|
@ -60,6 +60,7 @@ public class OpenPanelsLoader {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//tell loader that a panel has been opened
|
||||||
public void openPanelForLoader(String playerName, String panelName, ConfigurationSection cf){
|
public void openPanelForLoader(String playerName, String panelName, ConfigurationSection cf){
|
||||||
//just to make sure there are no duplicates
|
//just to make sure there are no duplicates
|
||||||
for(int i = 0; i < openPanelsCF.size(); i++){
|
for(int i = 0; i < openPanelsCF.size(); i++){
|
||||||
@ -73,6 +74,7 @@ public class OpenPanelsLoader {
|
|||||||
openPanelsPN.add(new String[]{playerName,panelName});
|
openPanelsPN.add(new String[]{playerName,panelName});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//tell loader that the panel is closed
|
||||||
public void closePanelForLoader(String playerName, String panelName){
|
public void closePanelForLoader(String playerName, String panelName){
|
||||||
for(int i = 0; i < openPanelsCF.size(); i++){
|
for(int i = 0; i < openPanelsCF.size(); i++){
|
||||||
if(Arrays.equals(openPanelsPN.get(i), new String[]{playerName, panelName})){
|
if(Arrays.equals(openPanelsPN.get(i), new String[]{playerName, panelName})){
|
||||||
|
@ -14,10 +14,12 @@ public class UtilsPanelsLoader implements Listener {
|
|||||||
this.plugin = pl;
|
this.plugin = pl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//tell panel loader that player has opened panel
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerClosePanel(PlayerQuitEvent e){
|
public void onPlayerClosePanel(PlayerQuitEvent e){
|
||||||
for(int i = 0; i < plugin.openPanels.openPanelsPN.size(); i++){
|
for(int i = 0; i < plugin.openPanels.openPanelsPN.size(); i++){
|
||||||
if(plugin.openPanels.openPanelsPN.get(i)[0].equals(e.getPlayer().getName())){
|
if(plugin.openPanels.openPanelsPN.get(i)[0].equals(e.getPlayer().getName())){
|
||||||
|
plugin.customCommand.removeCCP(plugin.openPanels.openPanelsPN.get(i)[1], e.getPlayer().getName());
|
||||||
plugin.openPanels.openPanelsPN.remove(i);
|
plugin.openPanels.openPanelsPN.remove(i);
|
||||||
plugin.openPanels.openPanelsCF.remove(i);
|
plugin.openPanels.openPanelsCF.remove(i);
|
||||||
return;
|
return;
|
||||||
@ -25,6 +27,7 @@ public class UtilsPanelsLoader implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//tell panel loader that player has closed the panel
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerClosePanel(InventoryCloseEvent e){
|
public void onPlayerClosePanel(InventoryCloseEvent e){
|
||||||
//only do this if editor is disabled as it will disabled this code
|
//only do this if editor is disabled as it will disabled this code
|
||||||
@ -32,6 +35,7 @@ public class UtilsPanelsLoader implements Listener {
|
|||||||
//this is put here to avoid conflicts, close panel if it is closed
|
//this is put here to avoid conflicts, close panel if it is closed
|
||||||
for (int i = 0; i < plugin.openPanels.openPanelsPN.size(); i++) {
|
for (int i = 0; i < plugin.openPanels.openPanelsPN.size(); i++) {
|
||||||
if (plugin.openPanels.openPanelsPN.get(i)[0].equals(e.getPlayer().getName())) {
|
if (plugin.openPanels.openPanelsPN.get(i)[0].equals(e.getPlayer().getName())) {
|
||||||
|
plugin.customCommand.removeCCP(plugin.openPanels.openPanelsPN.get(i)[1], e.getPlayer().getName());
|
||||||
plugin.openPanels.openPanelsPN.remove(i);
|
plugin.openPanels.openPanelsPN.remove(i);
|
||||||
plugin.openPanels.openPanelsCF.remove(i);
|
plugin.openPanels.openPanelsCF.remove(i);
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user