v3.15.0.1

This commit is contained in:
rockyhawk64 2021-01-11 15:28:24 +11:00
parent afa91269cd
commit 2a64d83138
4 changed files with 29 additions and 21 deletions
resource
src/me/rockyhawk/commandpanels

View File

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

View File

@ -33,9 +33,9 @@ public class CommandPanelsAPI {
//import panel into folder
public void addPanel(Panel panel) throws IOException{
File addedFile = new File(plugin.panelsf + File.separator + panel.getFile().getName());
YamlConfiguration addedYaml = new YamlConfiguration();
addedYaml.set("panels." + panel.getName(), panel.getConfig());
YamlConfiguration addedYaml = YamlConfiguration.loadConfiguration(panel.getFile());
addedYaml.save(addedFile);
plugin.reloadPanelFiles();
}
//remove panel from folder

View File

@ -59,7 +59,7 @@ public class CommandTags {
}
case "add-data=":{
if(command.split("\\s").length == 4){
plugin.panelData.setUserData(getOffline(command.split("\\s")[3]),command.split("\\s")[1],command.split("\\s")[2],true);
plugin.panelData.setUserData(getOffline(command.split("\\s")[3]),command.split("\\s")[1],command.split("\\s")[2],false);
break;
}
//this will not overwrite existing data. add-data= [data point] [data value] [optional player]
@ -68,7 +68,7 @@ public class CommandTags {
}
case "math-data=":{
if(command.split("\\s").length == 4){
plugin.panelData.setUserData(getOffline(command.split("\\s")[3]),command.split("\\s")[1],command.split("\\s")[2],true);
plugin.panelData.doDataMath(getOffline(command.split("\\s")[3]),command.split("\\s")[1],command.split("\\s")[2]);
break;
}
//only works if data is number, goes math-data= [data point] [operator:number] [optional player] eg, math-data= -1 OR /3
@ -82,7 +82,7 @@ public class CommandTags {
}
case "del-data=":{
if(command.split("\\s").length == 3){
plugin.panelData.setUserData(getOffline(command.split("\\s")[3]),command.split("\\s")[1],command.split("\\s")[2],true);
plugin.panelData.delUserData(getOffline(command.split("\\s")[2]),command.split("\\s")[1]);
break;
}
//this will remove data. del-data= [data point] [optional player]

View File

@ -32,20 +32,6 @@ public class Placeholders {
str = str.replaceAll("%cp-player-z%", String.valueOf(Math.round(p.getLocation().getZ())));
str = str.replaceAll("%cp-online-players%", Integer.toString(Bukkit.getServer().getOnlinePlayers().size()));
str = str.replaceAll("%cp-tag%", plugin.papi(plugin.tag));
//placeholder to check for server availability %cp-server-IP:PORT%
while (str.contains("%cp-server-")) {
int start = str.indexOf("%cp-server-");
int end = str.indexOf("%", str.indexOf("%cp-server-")+1);
String ip_port = str.substring(start, end).replace("%cp-server-", "").replace("%","");
Socket s = new Socket();
try {
s.connect(new InetSocketAddress(ip_port.split(":")[0], Integer.parseInt(ip_port.split(":")[1])), plugin.config.getInt("config.server-ping-timeout"));
str = str.replace(str.substring(start, end) + "%", "true");
s.close();
}catch (IOException ex){
str = str.replace(str.substring(start, end) + "%", "false");
}
}
//set custom placeholders to their values
for(String[] placeholder : plugin.customCommand.getCCP(p.getName())){
@ -61,6 +47,21 @@ public class Placeholders {
}
}
//placeholder to check for server availability %cp-server-IP:PORT%
while (str.contains("%cp-server-")) {
int start = str.indexOf("%cp-server-");
int end = str.indexOf("%", str.indexOf("%cp-server-")+1);
String ip_port = str.substring(start, end).replace("%cp-server-", "").replace("%","");
Socket s = new Socket();
try {
s.connect(new InetSocketAddress(ip_port.split(":")[0], Integer.parseInt(ip_port.split(":")[1])), plugin.config.getInt("config.server-ping-timeout"));
str = str.replace(str.substring(start, end) + "%", "true");
s.close();
}catch (IOException ex){
str = str.replace(str.substring(start, end) + "%", "false");
}
}
//DO placeholders for detection of other items in a panel
//get material value from slot in current open inventory (panel)
while (str.contains("%cp-material-")) {
@ -193,7 +194,14 @@ public class Placeholders {
int start = str.indexOf("%cp-data-");
int end = str.indexOf("%", str.indexOf("%cp-data-") + 1);
String dataPoint = str.substring(start, end).replace("%cp-data-", "").replace("%", "");
str = str.replace(str.substring(start, end) + "%", plugin.panelData.getUserData(p.getUniqueId(),dataPoint));
//get data from other user
if(dataPoint.contains(",")){
String dataName = dataPoint.split(",")[0];
String playerName = dataPoint.split(",")[1];
str = str.replace(str.substring(start, end) + "%", plugin.panelData.getUserData(Bukkit.getOfflinePlayer(playerName).getUniqueId(),dataName));
}else{
str = str.replace(str.substring(start, end) + "%", plugin.panelData.getUserData(p.getUniqueId(),dataPoint));
}
}catch (Exception ex){
plugin.debug(ex);
break;