forked from Upstream/CommandPanels
v3.14.6.0
This commit is contained in:
parent
4682cfec08
commit
be52c1fa9d
@ -1,4 +1,4 @@
|
||||
version: 3.14.5.3
|
||||
version: 3.14.6.0
|
||||
main: me.rockyhawk.commandpanels.CommandPanels
|
||||
name: CommandPanels
|
||||
author: RockyHawk
|
||||
|
@ -91,8 +91,8 @@ public class CommandTags {
|
||||
break;
|
||||
}
|
||||
case "give-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);
|
||||
//this will remove data. give-item= [custom item].
|
||||
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);
|
||||
break;
|
||||
}
|
||||
@ -134,9 +134,17 @@ public class CommandTags {
|
||||
}
|
||||
case "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);
|
||||
String panelName = plugin.openPanels.getOpenPanelName(p.getName());
|
||||
|
||||
//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());
|
||||
for(int i = 0; i < cm.length; i++){
|
||||
@ -627,7 +635,7 @@ public class CommandTags {
|
||||
//create the item to be removed
|
||||
ItemStack sellItem;
|
||||
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{
|
||||
sellItem = new ItemStack(Objects.requireNonNull(Material.matchMaterial(command.split("\\s")[1])), Integer.parseInt(command.split("\\s")[2]), id);
|
||||
}
|
||||
|
@ -71,8 +71,12 @@ public class ExecuteOpenVoids {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//open the panel
|
||||
plugin.openPanels.openPanelForLoader(p.getName(), panelName, cf);
|
||||
|
||||
//execute commands on panel open
|
||||
if (cf.contains("commands-on-open")) {
|
||||
//execute commands on panel open
|
||||
try {
|
||||
List<String> commands = cf.getStringList("commands-on-open");
|
||||
for (int i = 0; commands.size() - 1 >= i; i++) {
|
||||
@ -89,8 +93,7 @@ public class ExecuteOpenVoids {
|
||||
}
|
||||
}
|
||||
|
||||
//open the panel
|
||||
plugin.openPanels.openPanelForLoader(p.getName(), panelName, cf);
|
||||
//create and open the GUI
|
||||
plugin.createGUI.openGui(panelName, p, cf,1,0);
|
||||
if(sendOpenedMessage) {
|
||||
sender.sendMessage(plugin.papi( plugin.tag + ChatColor.GREEN + "Panel Opened for " + p.getDisplayName()));
|
||||
|
@ -112,6 +112,12 @@ public class ItemCreation {
|
||||
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) {
|
||||
s = new ItemStack(Objects.requireNonNull(Material.matchMaterial(mat)), 1, id);
|
||||
}
|
||||
@ -340,6 +346,16 @@ public class ItemCreation {
|
||||
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
|
||||
public String hasSection(ConfigurationSection cf, Player p){
|
||||
if (cf.contains("hasvalue")) {
|
||||
|
@ -22,7 +22,7 @@ public class Placeholders {
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public String setCpPlaceholders(Player p, String str) {
|
||||
public String setCpPlaceholders(Player p, String str){
|
||||
//replace nodes with PlaceHolders
|
||||
str = str.replaceAll("%cp-player-displayname%", p.getDisplayName());
|
||||
str = str.replaceAll("%cp-player-name%", p.getName());
|
||||
@ -50,9 +50,14 @@ public class Placeholders {
|
||||
//set custom placeholders to their values
|
||||
for(String[] placeholder : plugin.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]);
|
||||
try {
|
||||
int start = str.indexOf(placeholder[0]);
|
||||
int end = start + placeholder[0].length() - 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;
|
||||
try {
|
||||
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)
|
||||
material = material + ":" + p.getOpenInventory().getTopInventory().getItem(Integer.parseInt(matNumber)).getType().getId();
|
||||
}
|
||||
@ -74,7 +79,7 @@ public class Placeholders {
|
||||
material = "AIR";
|
||||
}
|
||||
str = str.replace(str.substring(start, end) + "%", material);
|
||||
}catch(Exception ex){
|
||||
} catch (Exception ex) {
|
||||
plugin.debug(ex);
|
||||
break;
|
||||
}
|
||||
@ -188,6 +193,35 @@ public class Placeholders {
|
||||
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
|
||||
while (str.contains("%cp-player-online-")) {
|
||||
try {
|
||||
|
@ -7,7 +7,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
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.getStringList("panelType").contains("static")) {
|
||||
//do not update temporary panels, only default panels
|
||||
@ -58,7 +64,7 @@ public class Commandpanelrefresher implements Listener {
|
||||
animatevalue = cfFinal.getInt("animatevalue");
|
||||
}
|
||||
//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;
|
||||
}else{
|
||||
c=0;
|
||||
|
Loading…
Reference in New Issue
Block a user