v3.14.0.0

This commit is contained in:
rockyhawk64 2020-11-20 18:53:48 +11:00
parent c5074bcd6b
commit 6226c146f8
10 changed files with 99 additions and 20 deletions

View File

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

View File

@ -363,7 +363,6 @@ 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())){ for(String[] placeholder : customCommand.getCCP(p.getName())){
while (str.contains(placeholder[0])) { while (str.contains(placeholder[0])) {
int start = str.indexOf(placeholder[0]); int start = str.indexOf(placeholder[0]);

View File

@ -4,6 +4,7 @@ import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams; import com.google.common.io.ByteStreams;
import me.realized.tokenmanager.api.TokenManager; import me.realized.tokenmanager.api.TokenManager;
import me.rockyhawk.commandpanels.CommandPanels; import me.rockyhawk.commandpanels.CommandPanels;
import org.apache.commons.lang.ArrayUtils;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
@ -24,8 +25,9 @@ public class CommandTags {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public void commandTags(Player p, String command) { public void commandTags(Player p, String command) {
String tag = plugin.config.getString("config.format.tag") + " "; String tag = plugin.config.getString("config.format.tag") + " ";
//set cp placeholders //set cp placeholders, commandRAW is without placeholders
command = plugin.papi(p, plugin.setCpPlaceholders(p, command)); String commandRAW = command;
command = plugin.papi(p, command);
if (command.split("\\s")[0].equalsIgnoreCase("server=")) { if (command.split("\\s")[0].equalsIgnoreCase("server=")) {
//this contacts bungee and tells it to send the server change command //this contacts bungee and tells it to send the server change command
ByteArrayDataOutput out = ByteStreams.newDataOutput(); ByteArrayDataOutput out = ByteStreams.newDataOutput();
@ -36,13 +38,23 @@ public class CommandTags {
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, with the option to add custom placeholders //if player uses open= it will open the panel, with the option to add custom placeholders
String[] cmd = command.split("\\s"); String panelName = commandRAW.split("\\s")[1];
String panelName = cmd[1]; String cmd = commandRAW.replace("open= " + panelName,"");
for(int i = 2; i < cmd.length; i++){ panelName = plugin.papi(p,panelName);
if(cmd[i].startsWith("%cp-")){
plugin.customCommand.addCCP(panelName,p.getName(),cmd[i].split(":")[0],cmd[i].split(":")[1]); 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){ 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);
@ -50,6 +62,24 @@ public class CommandTags {
return; 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=")) { }else if (command.split("\\s")[0].equalsIgnoreCase("op=")) {
//if player uses op= it will perform command as op //if player uses op= it will perform command as op
boolean isop = p.isOp(); 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 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") + " "; String tag = plugin.config.getString("config.format.tag") + " ";
command = plugin.papi(p,command);
if (command.split("\\s")[0].equalsIgnoreCase("paywall=")) { if (command.split("\\s")[0].equalsIgnoreCase("paywall=")) {
//if player uses paywall= [price] //if player uses paywall= [price]
try { try {

View File

@ -282,7 +282,7 @@ public class ItemCreation {
} }
if (itemSection.contains("stack")) { if (itemSection.contains("stack")) {
//change the stack amount (placeholders accepted) //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) { } catch (IllegalArgumentException | NullPointerException var33) {
plugin.debug(var33); plugin.debug(var33);

View File

@ -36,4 +36,17 @@ public class CommandPlaceholderLoader {
} }
return returnPlaceholders; return returnPlaceholders;
} }
//change a placeholder for a panel
public void editCCP(String panelName, String playerName, String placeholder, String argument){
for(int i = 0; i < pendingPlaceholders.size(); i++){
if(playerName.equals(pendingPlaceholders.get(i)[1]) && panelName.equals(pendingPlaceholders.get(i)[0]) && placeholder.equals(pendingPlaceholders.get(i)[2])){
pendingPlaceholders.remove(i);
pendingPlaceholders.add(new String[]{panelName,playerName,placeholder,argument});
return;
}
}
//if it reaches here it has not found the placeholder, add it manually
pendingPlaceholders.add(new String[]{panelName,playerName,placeholder,argument});
}
} }

View File

@ -1,6 +1,7 @@
package me.rockyhawk.commandpanels.ingameeditor; package me.rockyhawk.commandpanels.ingameeditor;
import me.rockyhawk.commandpanels.CommandPanels; import me.rockyhawk.commandpanels.CommandPanels;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection; 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){ if(e.getClickedInventory().getType() != InventoryType.CHEST){
clearTemp(p, panelName); clearTemp(p, panelName);
return; return;
@ -320,6 +327,11 @@ public class EditorUtils implements Listener {
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.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.openPanelsPN.remove(i);
plugin.openPanels.openPanelsCF.remove(i); plugin.openPanels.openPanelsCF.remove(i);
return; return;

View File

@ -53,11 +53,6 @@ public class Commandpanelrefresher implements Listener {
return; 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; final ConfigurationSection cfFinal = cf;
ItemStack[] panelItemList = plugin.createGUI.openGui(null, p, cf,2, -1).getContents(); 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); plugin.createGUI.openGui(null, p, cfFinal, 0,animatecount);
} catch (Exception e) { } catch (Exception e) {
//error opening gui //error opening gui
p.closeInventory();
plugin.openPanels.closePanelForLoader(p.getName(),panelName);
this.cancel();
} }
} }
}else{ }else{
@ -131,11 +129,6 @@ public class Commandpanelrefresher implements Listener {
//oof //oof
} }
this.cancel(); 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) }.runTaskTimer(this.plugin, 5, 5); //20 ticks == 1 second (5 ticks = 0.25 of a second)

View File

@ -92,12 +92,16 @@ public class OpenGUI {
} }
}catch(NullPointerException nullp){ }catch(NullPointerException nullp){
plugin.debug(nullp); plugin.debug(nullp);
p.closeInventory();
plugin.openPanels.closePanelForLoader(p.getName(),panels);
} }
} }
} catch (ArrayIndexOutOfBoundsException var24) { } catch (ArrayIndexOutOfBoundsException var24) {
plugin.debug(var24); plugin.debug(var24);
if (plugin.debug) { 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.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) { } catch (IllegalArgumentException | NullPointerException var26) {
plugin.debug(var26); plugin.debug(var26);
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " empty: " + pconfig.getString("empty"))); 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; return null;
} }
@ -157,6 +163,8 @@ public class OpenGUI {
return i; return i;
} else { } else {
p.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.error") + " rows: " + pconfig.getString("rows"))); 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; return null;
} }
} }

View File

@ -1,10 +1,12 @@
package me.rockyhawk.commandpanels.openpanelsmanager; package me.rockyhawk.commandpanels.openpanelsmanager;
import me.rockyhawk.commandpanels.CommandPanels; import me.rockyhawk.commandpanels.CommandPanels;
import org.bukkit.Bukkit;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Objects;
public class OpenPanelsLoader { public class OpenPanelsLoader {
CommandPanels plugin; CommandPanels plugin;
@ -72,6 +74,11 @@ public class OpenPanelsLoader {
} }
openPanelsCF.add(cf); openPanelsCF.add(cf);
openPanelsPN.add(new String[]{playerName,panelName}); 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 //tell loader that the panel is closed
@ -83,5 +90,10 @@ public class OpenPanelsLoader {
return; 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);
}
}
} }
} }

View File

@ -1,6 +1,7 @@
package me.rockyhawk.commandpanels.openpanelsmanager; package me.rockyhawk.commandpanels.openpanelsmanager;
import me.rockyhawk.commandpanels.CommandPanels; import me.rockyhawk.commandpanels.CommandPanels;
import org.bukkit.Bukkit;
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.InventoryCloseEvent; 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++){ 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.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.openPanelsPN.remove(i);
plugin.openPanels.openPanelsCF.remove(i); plugin.openPanels.openPanelsCF.remove(i);
return; return;
@ -36,6 +42,11 @@ public class UtilsPanelsLoader implements Listener {
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.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.openPanelsPN.remove(i);
plugin.openPanels.openPanelsCF.remove(i); plugin.openPanels.openPanelsCF.remove(i);
return; return;