v3.14.6.0

This commit is contained in:
rockyhawk64 2021-01-08 22:47:37 +11:00
parent 4682cfec08
commit be52c1fa9d
6 changed files with 85 additions and 18 deletions

View File

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

View File

@ -91,8 +91,8 @@ public class CommandTags {
break; break;
} }
case "give-item=":{ case "give-item=":{
//this will remove data. give-item= [custom item] //this will remove data. give-item= [custom item].
ItemStack itm = plugin.itemCreate.makeItemFromConfig(plugin.openPanels.getOpenPanel(p.getName()).getConfigurationSection("custom-item." + command.split("\\s")[1]), p, true, true, false); ItemStack itm = plugin.itemCreate.makeCustomItemFromConfig(plugin.openPanels.getOpenPanel(p.getName()).getConfigurationSection("custom-item." + command.split("\\s")[1]), p, true, true, false);
p.getInventory().addItem(itm); p.getInventory().addItem(itm);
break; break;
} }
@ -134,9 +134,17 @@ public class CommandTags {
} }
case "placeholder=":{ case "placeholder=":{
//if player uses placeholder= it will only change the placeholders for the panel //if player uses placeholder= it will only change the placeholders for the panel
String panelName = commandRAW.split("\\s")[1]; String panelName = plugin.openPanels.getOpenPanelName(p.getName());
String cmd = commandRAW.replace("placeholder= " + panelName,"");
panelName = plugin.papi(p,panelName); //placeholder is now placeholder= [place]. Not placeholder= panel [place] which is why this is here
String cmd;
if(command.split("\\s").length == 3){
cmd = commandRAW.replace("placeholder= " + panelName,"").trim();
plugin.getServer().getConsoleSender().sendMessage(plugin.tag + ChatColor.RED + "placeholder= <panel> <placeholder> will be deprecated");
plugin.getServer().getConsoleSender().sendMessage(plugin.tag + ChatColor.RED + "use " + ChatColor.WHITE + "placeholder= " + cmd + ChatColor.RED + " instead of " + ChatColor.GRAY + commandRAW + ChatColor.RED + "!");
}else{
cmd = commandRAW.replace("placeholder= ","");
}
Character[] cm = ArrayUtils.toObject(cmd.toCharArray()); Character[] cm = ArrayUtils.toObject(cmd.toCharArray());
for(int i = 0; i < cm.length; i++){ for(int i = 0; i < cm.length; i++){
@ -627,7 +635,7 @@ public class CommandTags {
//create the item to be removed //create the item to be removed
ItemStack sellItem; ItemStack sellItem;
if(command.split("\\s").length == 2) { if(command.split("\\s").length == 2) {
sellItem = plugin.itemCreate.makeItemFromConfig(plugin.openPanels.getOpenPanel(p.getName()).getConfigurationSection("custom-item." + command.split("\\s")[1]), p, true, true, false); sellItem = plugin.itemCreate.makeCustomItemFromConfig(plugin.openPanels.getOpenPanel(p.getName()).getConfigurationSection("custom-item." + command.split("\\s")[1]), p, true, true, false);
}else{ }else{
sellItem = new ItemStack(Objects.requireNonNull(Material.matchMaterial(command.split("\\s")[1])), Integer.parseInt(command.split("\\s")[2]), id); sellItem = new ItemStack(Objects.requireNonNull(Material.matchMaterial(command.split("\\s")[1])), Integer.parseInt(command.split("\\s")[2]), id);
} }

View File

@ -71,8 +71,12 @@ public class ExecuteOpenVoids {
} }
} }
} }
if (cf.contains("commands-on-open")) {
//open the panel
plugin.openPanels.openPanelForLoader(p.getName(), panelName, cf);
//execute commands on panel open //execute commands on panel open
if (cf.contains("commands-on-open")) {
try { try {
List<String> commands = cf.getStringList("commands-on-open"); List<String> commands = cf.getStringList("commands-on-open");
for (int i = 0; commands.size() - 1 >= i; i++) { for (int i = 0; commands.size() - 1 >= i; i++) {
@ -89,8 +93,7 @@ public class ExecuteOpenVoids {
} }
} }
//open the panel //create and open the GUI
plugin.openPanels.openPanelForLoader(p.getName(), panelName, cf);
plugin.createGUI.openGui(panelName, p, cf,1,0); plugin.createGUI.openGui(panelName, p, cf,1,0);
if(sendOpenedMessage) { if(sendOpenedMessage) {
sender.sendMessage(plugin.papi( plugin.tag + ChatColor.GREEN + "Panel Opened for " + p.getDisplayName())); sender.sendMessage(plugin.papi( plugin.tag + ChatColor.GREEN + "Panel Opened for " + p.getDisplayName()));

View File

@ -112,6 +112,12 @@ public class ItemCreation {
normalCreation = false; normalCreation = false;
} }
//creates item from custom-items section of panel
if(matraw.split("\\s")[0].toLowerCase().equals("cpi=")){
s = makeCustomItemFromConfig(plugin.openPanels.getOpenPanel(p.getName()).getConfigurationSection("custom-item." + matraw.split("\\s")[1]), p, true, true, true);
normalCreation = false;
}
if(normalCreation) { if(normalCreation) {
s = new ItemStack(Objects.requireNonNull(Material.matchMaterial(mat)), 1, id); s = new ItemStack(Objects.requireNonNull(Material.matchMaterial(mat)), 1, id);
} }
@ -340,6 +346,16 @@ public class ItemCreation {
return s; return s;
} }
//do custom-item items, they have an additional hasSection requirement
public ItemStack makeCustomItemFromConfig(ConfigurationSection itemSection, Player p, boolean placeholders, boolean colours, boolean addNBT){
String section = plugin.itemCreate.hasSection(itemSection,p);
if(!section.equals("")){
itemSection = itemSection.getConfigurationSection(section.substring(1));
}
return plugin.itemCreate.makeItemFromConfig(itemSection, p, placeholders, colours, addNBT);
}
//hasperm hasvalue, etc sections will be done here //hasperm hasvalue, etc sections will be done here
public String hasSection(ConfigurationSection cf, Player p){ public String hasSection(ConfigurationSection cf, Player p){
if (cf.contains("hasvalue")) { if (cf.contains("hasvalue")) {

View File

@ -22,7 +22,7 @@ public class Placeholders {
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public String setCpPlaceholders(Player p, String str) { public String setCpPlaceholders(Player p, String str){
//replace nodes with PlaceHolders //replace nodes with PlaceHolders
str = str.replaceAll("%cp-player-displayname%", p.getDisplayName()); str = str.replaceAll("%cp-player-displayname%", p.getDisplayName());
str = str.replaceAll("%cp-player-name%", p.getName()); str = str.replaceAll("%cp-player-name%", p.getName());
@ -50,9 +50,14 @@ public class Placeholders {
//set custom placeholders to their values //set custom placeholders to their values
for(String[] placeholder : plugin.customCommand.getCCP(p.getName())){ for(String[] placeholder : plugin.customCommand.getCCP(p.getName())){
while (str.contains(placeholder[0])) { while (str.contains(placeholder[0])) {
try {
int start = str.indexOf(placeholder[0]); int start = str.indexOf(placeholder[0]);
int end = start+placeholder[0].length()-1; int end = start + placeholder[0].length() - 1;
str = str.replace(str.substring(start, end) + "%", placeholder[1]); str = str.replace(str.substring(start, end) + "%", placeholder[1]);
}catch (Exception ex){
plugin.debug(ex);
break;
}
} }
} }
@ -66,7 +71,7 @@ public class Placeholders {
String material; String material;
try { try {
material = p.getOpenInventory().getTopInventory().getItem(Integer.parseInt(matNumber)).getType().toString(); material = p.getOpenInventory().getTopInventory().getItem(Integer.parseInt(matNumber)).getType().toString();
if(plugin.legacy.isLegacy()){ if (plugin.legacy.isLegacy()) {
//add the ID to the end if it is legacy (eg, material:id) //add the ID to the end if it is legacy (eg, material:id)
material = material + ":" + p.getOpenInventory().getTopInventory().getItem(Integer.parseInt(matNumber)).getType().getId(); material = material + ":" + p.getOpenInventory().getTopInventory().getItem(Integer.parseInt(matNumber)).getType().getId();
} }
@ -74,7 +79,7 @@ public class Placeholders {
material = "AIR"; material = "AIR";
} }
str = str.replace(str.substring(start, end) + "%", material); str = str.replace(str.substring(start, end) + "%", material);
}catch(Exception ex){ } catch (Exception ex) {
plugin.debug(ex); plugin.debug(ex);
break; break;
} }
@ -188,6 +193,35 @@ public class Placeholders {
break; break;
} }
} }
//edits data via placeholder execution (will return empty output)
while (str.contains("%cp-setdata-")) {
try {
int start = str.indexOf("%cp-setdata-");
int end = str.indexOf("%", str.indexOf("%cp-setdata-") + 1);
String point_value = str.substring(start, end).replace("%cp-setdata-", "").replace("%", "");
String command = "set-data= " + point_value.split(",")[0] + " " + point_value.split(",")[1];
plugin.commandTags.commandTags(p,plugin.papi(p,command),command);
str = str.replace(str.substring(start, end) + "%", "");
}catch (Exception ex){
plugin.debug(ex);
break;
}
}
//math data via placeholder execution (will return empty output)
while (str.contains("%cp-mathdata-")) {
try {
int start = str.indexOf("%cp-mathdata-");
int end = str.indexOf("%", str.indexOf("%cp-mathdata-") + 1);
String point_value = str.substring(start, end).replace("%cp-mathdata-", "").replace("%", "");
String command = "math-data= " + point_value.split(",")[0] + " " + point_value.split(",")[1];
plugin.commandTags.commandTags(p,plugin.papi(p,command),command);
str = str.replace(str.substring(start, end) + "%", "");
}catch (Exception ex){
plugin.debug(ex);
break;
}
}
//checks for players online //checks for players online
while (str.contains("%cp-player-online-")) { while (str.contains("%cp-player-online-")) {
try { try {

View File

@ -7,7 +7,6 @@ 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.InventoryOpenEvent; import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import java.util.Objects; import java.util.Objects;
@ -40,6 +39,13 @@ public class Commandpanelrefresher implements Listener {
} }
} }
//if panel has custom refresh delay
int tempRefreshDelay = plugin.config.getInt("config.refresh-delay");
if(cf.contains("refresh-delay")){
tempRefreshDelay = cf.getInt("refresh-delay");
}
final int refreshDelay = tempRefreshDelay;
if(cf.contains("panelType")) { if(cf.contains("panelType")) {
if (cf.getStringList("panelType").contains("static")) { if (cf.getStringList("panelType").contains("static")) {
//do not update temporary panels, only default panels //do not update temporary panels, only default panels
@ -58,7 +64,7 @@ public class Commandpanelrefresher implements Listener {
animatevalue = cfFinal.getInt("animatevalue"); animatevalue = cfFinal.getInt("animatevalue");
} }
//counter counts to refresh delay (in seconds) then restarts //counter counts to refresh delay (in seconds) then restarts
if(c < Double.parseDouble(Objects.requireNonNull(plugin.config.getString("config.refresh-delay")).trim())){ if(c < refreshDelay){
c+=1; c+=1;
}else{ }else{
c=0; c=0;