forked from Upstream/CommandPanels
v3.14.0.0
This commit is contained in:
parent
c5074bcd6b
commit
6226c146f8
@ -1,4 +1,4 @@
|
||||
version: 3.13.1.1
|
||||
version: 3.14.0.0
|
||||
main: me.rockyhawk.commandpanels.CommandPanels
|
||||
name: CommandPanels
|
||||
author: RockyHawk
|
||||
|
@ -363,7 +363,6 @@ public class CommandPanels extends JavaPlugin {
|
||||
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]);
|
||||
|
@ -4,6 +4,7 @@ import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import me.realized.tokenmanager.api.TokenManager;
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
@ -24,8 +25,9 @@ public class CommandTags {
|
||||
@SuppressWarnings("deprecation")
|
||||
public void commandTags(Player p, String command) {
|
||||
String tag = plugin.config.getString("config.format.tag") + " ";
|
||||
//set cp placeholders
|
||||
command = plugin.papi(p, plugin.setCpPlaceholders(p, command));
|
||||
//set cp placeholders, commandRAW is without placeholders
|
||||
String commandRAW = command;
|
||||
command = plugin.papi(p, command);
|
||||
if (command.split("\\s")[0].equalsIgnoreCase("server=")) {
|
||||
//this contacts bungee and tells it to send the server change command
|
||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||
@ -36,13 +38,23 @@ public class CommandTags {
|
||||
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
|
||||
} else if (command.split("\\s")[0].equalsIgnoreCase("open=")) {
|
||||
//if player uses open= it will open the panel, with the option to add custom placeholders
|
||||
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]);
|
||||
String panelName = commandRAW.split("\\s")[1];
|
||||
String cmd = commandRAW.replace("open= " + panelName,"");
|
||||
panelName = plugin.papi(p,panelName);
|
||||
|
||||
Character[] cm = ArrayUtils.toObject(cmd.toCharArray());
|
||||
for(int i = 0; i < cm.length; i++){
|
||||
if(cm[i].equals('[')){
|
||||
String contents = cmd.substring(i+1, i+cmd.substring(i).indexOf(']'));
|
||||
//do not change the placeholder
|
||||
String placeholder = contents.substring(0,contents.indexOf(':'));
|
||||
//only convert placeholders for the value
|
||||
String value = plugin.papi(p,contents.substring(contents.indexOf(':')+1));
|
||||
plugin.customCommand.addCCP(panelName,p.getName(),placeholder,value);
|
||||
i = i+contents.length()-1;
|
||||
}
|
||||
}
|
||||
|
||||
for(String[] tempName : plugin.panelNames){
|
||||
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);
|
||||
@ -50,6 +62,24 @@ public class CommandTags {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}else if (command.split("\\s")[0].equalsIgnoreCase("placeholder=")) {
|
||||
//if player uses placeholder= it will only change the placeholders for the panel
|
||||
String panelName = commandRAW.split("\\s")[1];
|
||||
String cmd = commandRAW.replace("placeholder= " + panelName,"");
|
||||
panelName = plugin.papi(p,panelName);
|
||||
|
||||
Character[] cm = ArrayUtils.toObject(cmd.toCharArray());
|
||||
for(int i = 0; i < cm.length; i++){
|
||||
if(cm[i].equals('[')){
|
||||
String contents = cmd.substring(i+1, i+cmd.substring(i).indexOf(']'));
|
||||
//do not change the placeholder
|
||||
String placeholder = contents.substring(0,contents.indexOf(':'));
|
||||
//only convert placeholders for the value
|
||||
String value = plugin.papi(p,contents.substring(contents.indexOf(':')+1));
|
||||
plugin.customCommand.editCCP(panelName,p.getName(),placeholder,value);
|
||||
i = i+contents.length()-1;
|
||||
}
|
||||
}
|
||||
}else if (command.split("\\s")[0].equalsIgnoreCase("op=")) {
|
||||
//if player uses op= it will perform command as op
|
||||
boolean isop = p.isOp();
|
||||
@ -405,6 +435,7 @@ public class CommandTags {
|
||||
|
||||
public int commandPayWall(Player p, String command) { //return 0 means no funds, 1 is they passed and 2 means paywall is not this command
|
||||
String tag = plugin.config.getString("config.format.tag") + " ";
|
||||
command = plugin.papi(p,command);
|
||||
if (command.split("\\s")[0].equalsIgnoreCase("paywall=")) {
|
||||
//if player uses paywall= [price]
|
||||
try {
|
||||
|
@ -282,7 +282,7 @@ public class ItemCreation {
|
||||
}
|
||||
if (itemSection.contains("stack")) {
|
||||
//change the stack amount (placeholders accepted)
|
||||
s.setAmount(Integer.parseInt(Objects.requireNonNull(plugin.papi(p,itemSection.getString("stack")))));
|
||||
s.setAmount((int)Double.parseDouble(Objects.requireNonNull(plugin.papi(p,itemSection.getString("stack")))));
|
||||
}
|
||||
} catch (IllegalArgumentException | NullPointerException var33) {
|
||||
plugin.debug(var33);
|
||||
|
@ -36,4 +36,17 @@ public class CommandPlaceholderLoader {
|
||||
}
|
||||
return returnPlaceholders;
|
||||
}
|
||||
|
||||
//change a placeholder for a panel
|
||||
public void editCCP(String panelName, String playerName, String placeholder, String argument){
|
||||
for(int i = 0; i < pendingPlaceholders.size(); i++){
|
||||
if(playerName.equals(pendingPlaceholders.get(i)[1]) && panelName.equals(pendingPlaceholders.get(i)[0]) && placeholder.equals(pendingPlaceholders.get(i)[2])){
|
||||
pendingPlaceholders.remove(i);
|
||||
pendingPlaceholders.add(new String[]{panelName,playerName,placeholder,argument});
|
||||
return;
|
||||
}
|
||||
}
|
||||
//if it reaches here it has not found the placeholder, add it manually
|
||||
pendingPlaceholders.add(new String[]{panelName,playerName,placeholder,argument});
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.rockyhawk.commandpanels.ingameeditor;
|
||||
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
@ -261,6 +262,12 @@ public class EditorUtils implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
if(e.getSlot() == -999){
|
||||
if(e.getCurrentItem() == null) {
|
||||
clearTemp(p, panelName);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(e.getClickedInventory().getType() != InventoryType.CHEST){
|
||||
clearTemp(p, panelName);
|
||||
return;
|
||||
@ -320,6 +327,11 @@ public class EditorUtils implements Listener {
|
||||
for(int i = 0; i < plugin.openPanels.openPanelsPN.size(); i++){
|
||||
if(plugin.openPanels.openPanelsPN.get(i)[0].equals(e.getPlayer().getName())){
|
||||
plugin.customCommand.removeCCP(plugin.openPanels.openPanelsPN.get(i)[1], e.getPlayer().getName());
|
||||
if (plugin.config.contains("config.panel-snooper")) {
|
||||
if (Objects.requireNonNull(plugin.config.getString("config.panel-snooper")).trim().equalsIgnoreCase("true")) {
|
||||
Bukkit.getConsoleSender().sendMessage("[CommandPanels] " + e.getPlayer().getName() + " Closed " + plugin.openPanels.openPanelsPN.get(i)[1]);
|
||||
}
|
||||
}
|
||||
plugin.openPanels.openPanelsPN.remove(i);
|
||||
plugin.openPanels.openPanelsCF.remove(i);
|
||||
return;
|
||||
|
@ -53,11 +53,6 @@ public class Commandpanelrefresher implements Listener {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (plugin.config.contains("config.panel-snooper")) {
|
||||
if (Objects.requireNonNull(plugin.config.getString("config.panel-snooper")).trim().equalsIgnoreCase("true")) {
|
||||
Bukkit.getConsoleSender().sendMessage("[CommandPanels] " + p.getName() + " Opened " + panelName);
|
||||
}
|
||||
}
|
||||
|
||||
final ConfigurationSection cfFinal = cf;
|
||||
ItemStack[] panelItemList = plugin.createGUI.openGui(null, p, cf,2, -1).getContents();
|
||||
@ -92,6 +87,9 @@ public class Commandpanelrefresher implements Listener {
|
||||
plugin.createGUI.openGui(null, p, cfFinal, 0,animatecount);
|
||||
} catch (Exception e) {
|
||||
//error opening gui
|
||||
p.closeInventory();
|
||||
plugin.openPanels.closePanelForLoader(p.getName(),panelName);
|
||||
this.cancel();
|
||||
}
|
||||
}
|
||||
}else{
|
||||
@ -131,11 +129,6 @@ public class Commandpanelrefresher implements Listener {
|
||||
//oof
|
||||
}
|
||||
this.cancel();
|
||||
if (plugin.config.contains("config.panel-snooper")) {
|
||||
if (Objects.requireNonNull(plugin.config.getString("config.panel-snooper")).trim().equalsIgnoreCase("true")) {
|
||||
Bukkit.getConsoleSender().sendMessage("[CommandPanels] " + p.getName() + " Closed " + panelName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(this.plugin, 5, 5); //20 ticks == 1 second (5 ticks = 0.25 of a second)
|
||||
|
@ -92,12 +92,16 @@ public class OpenGUI {
|
||||
}
|
||||
}catch(NullPointerException nullp){
|
||||
plugin.debug(nullp);
|
||||
p.closeInventory();
|
||||
plugin.openPanels.closePanelForLoader(p.getName(),panels);
|
||||
}
|
||||
}
|
||||
} catch (ArrayIndexOutOfBoundsException var24) {
|
||||
plugin.debug(var24);
|
||||
if (plugin.debug) {
|
||||
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " item: One of the items does not fit in the Panel!"));
|
||||
p.closeInventory();
|
||||
plugin.openPanels.closePanelForLoader(p.getName(),panels);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -128,6 +132,8 @@ public class OpenGUI {
|
||||
} catch (IllegalArgumentException | NullPointerException var26) {
|
||||
plugin.debug(var26);
|
||||
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " empty: " + pconfig.getString("empty")));
|
||||
p.closeInventory();
|
||||
plugin.openPanels.closePanelForLoader(p.getName(),panels);
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -157,6 +163,8 @@ public class OpenGUI {
|
||||
return i;
|
||||
} else {
|
||||
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " rows: " + pconfig.getString("rows")));
|
||||
p.closeInventory();
|
||||
plugin.openPanels.closePanelForLoader(p.getName(),panels);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,12 @@
|
||||
package me.rockyhawk.commandpanels.openpanelsmanager;
|
||||
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class OpenPanelsLoader {
|
||||
CommandPanels plugin;
|
||||
@ -72,6 +74,11 @@ public class OpenPanelsLoader {
|
||||
}
|
||||
openPanelsCF.add(cf);
|
||||
openPanelsPN.add(new String[]{playerName,panelName});
|
||||
if (plugin.config.contains("config.panel-snooper")) {
|
||||
if (Objects.requireNonNull(plugin.config.getString("config.panel-snooper")).trim().equalsIgnoreCase("true")) {
|
||||
Bukkit.getConsoleSender().sendMessage("[CommandPanels] " + playerName + " Opened " + panelName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//tell loader that the panel is closed
|
||||
@ -83,5 +90,10 @@ public class OpenPanelsLoader {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (plugin.config.contains("config.panel-snooper")) {
|
||||
if (Objects.requireNonNull(plugin.config.getString("config.panel-snooper")).trim().equalsIgnoreCase("true")) {
|
||||
Bukkit.getConsoleSender().sendMessage("[CommandPanels] " + playerName + " Closed " + panelName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.rockyhawk.commandpanels.openpanelsmanager;
|
||||
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
@ -20,6 +21,11 @@ public class UtilsPanelsLoader implements Listener {
|
||||
for(int i = 0; i < plugin.openPanels.openPanelsPN.size(); i++){
|
||||
if(plugin.openPanels.openPanelsPN.get(i)[0].equals(e.getPlayer().getName())){
|
||||
plugin.customCommand.removeCCP(plugin.openPanels.openPanelsPN.get(i)[1], e.getPlayer().getName());
|
||||
if (plugin.config.contains("config.panel-snooper")) {
|
||||
if (Objects.requireNonNull(plugin.config.getString("config.panel-snooper")).trim().equalsIgnoreCase("true")) {
|
||||
Bukkit.getConsoleSender().sendMessage("[CommandPanels] " + e.getPlayer().getName() + " Closed " + plugin.openPanels.openPanelsPN.get(i)[1]);
|
||||
}
|
||||
}
|
||||
plugin.openPanels.openPanelsPN.remove(i);
|
||||
plugin.openPanels.openPanelsCF.remove(i);
|
||||
return;
|
||||
@ -36,6 +42,11 @@ public class UtilsPanelsLoader implements Listener {
|
||||
for (int i = 0; i < plugin.openPanels.openPanelsPN.size(); i++) {
|
||||
if (plugin.openPanels.openPanelsPN.get(i)[0].equals(e.getPlayer().getName())) {
|
||||
plugin.customCommand.removeCCP(plugin.openPanels.openPanelsPN.get(i)[1], e.getPlayer().getName());
|
||||
if (plugin.config.contains("config.panel-snooper")) {
|
||||
if (Objects.requireNonNull(plugin.config.getString("config.panel-snooper")).trim().equalsIgnoreCase("true")) {
|
||||
Bukkit.getConsoleSender().sendMessage("[CommandPanels] " + e.getPlayer().getName() + " Closed " + plugin.openPanels.openPanelsPN.get(i)[1]);
|
||||
}
|
||||
}
|
||||
plugin.openPanels.openPanelsPN.remove(i);
|
||||
plugin.openPanels.openPanelsCF.remove(i);
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user