v3.14.4.4

This commit is contained in:
rockyhawk64 2020-12-29 21:59:36 +11:00
parent f630b180fb
commit 2652704a9d
3 changed files with 64 additions and 33 deletions

View File

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

View File

@ -79,38 +79,46 @@ public class Utils implements Listener {
commands = commandsAfterSequence; commands = commandsAfterSequence;
for (int i = 0; commands.size() - 1 >= i; i++) { for (int i = 0; commands.size() - 1 >= i; i++) {
try { try {
if (commands.get(i).split("\\s")[0].equalsIgnoreCase("right=")) { switch(commands.get(i).split("\\s")[0]){
//if commands is for right clicking, remove the 'right=' and continue case "right=":{
commands.set(i, commands.get(i).replace("right=", "").trim()); //if commands is for right clicking, remove the 'right=' and continue
commands.set(i, commands.get(i).replace("RIGHT=", "").trim()); commands.set(i, commands.get(i).replace("right=", "").trim());
if (e.isLeftClick() || (e.isShiftClick() && e.isLeftClick()) || (e.isShiftClick() && e.isRightClick())) { if (e.getClick() != ClickType.RIGHT) {
continue; continue;
}
break;
} }
} else if (commands.get(i).split("\\s")[0].equalsIgnoreCase("rightshift=")) { case "rightshift=":{
//if commands is for right clicking, remove the 'right=' and continue //if commands is for right clicking, remove the 'right=' and continue
commands.set(i, commands.get(i).replace("rightshift=", "").trim()); commands.set(i, commands.get(i).replace("rightshift=", "").trim());
commands.set(i, commands.get(i).replace("RIGHTSHIFT=", "").trim()); if (e.getClick() != ClickType.SHIFT_RIGHT) {
if (e.isLeftClick() || (!e.isShiftClick() && e.isRightClick())) { continue;
continue; }
break;
} }
} case "left=":{
if (commands.get(i).split("\\s")[0].equalsIgnoreCase("left=")) { //if commands is for right clicking, remove the 'right=' and continue
//if commands is for right clicking, remove the 'right=' and continue commands.set(i, commands.get(i).replace("left=", "").trim());
commands.set(i, commands.get(i).replace("left=", "").trim()); if (e.getClick() != ClickType.LEFT) {
commands.set(i, commands.get(i).replace("LEFT=", "").trim()); continue;
if (e.isRightClick() || (e.isShiftClick() && e.isRightClick()) || (e.isShiftClick() && e.isLeftClick())) { }
continue; break;
} }
} else if (commands.get(i).split("\\s")[0].equalsIgnoreCase("leftshift=")) { case "leftshift=":{
//if commands is for right clicking, remove the 'right=' and continue //if commands is for right clicking, remove the 'right=' and continue
commands.set(i, commands.get(i).replace("leftshift=", "").trim()); commands.set(i, commands.get(i).replace("leftshift=", "").trim());
commands.set(i, commands.get(i).replace("LEFTSHIFT=", "").trim()); if (e.getClick() != ClickType.SHIFT_LEFT) {
if (e.isRightClick() || (!e.isShiftClick() && e.isLeftClick())) { continue;
continue; }
break;
}
case "middle=":{
commands.set(i, commands.get(i).replace("middle=", "").trim());
if (e.getClick() != ClickType.MIDDLE) {
continue;
}
break;
} }
}
if (!e.isLeftClick() && !e.isRightClick()) {
continue;
} }
} catch (Exception click) { } catch (Exception click) {
//skip if you can't do this //skip if you can't do this

View File

@ -15,6 +15,7 @@ import org.bukkit.scheduler.BukkitRunnable;
import java.io.File; import java.io.File;
import java.util.Objects; import java.util.Objects;
import java.util.UUID;
public class CommandTags { public class CommandTags {
CommandPanels plugin; CommandPanels plugin;
@ -42,17 +43,29 @@ public class CommandTags {
break; break;
} }
case "set-data=":{ case "set-data=":{
//this will overwrite data. set-data= [data point] [data value] if(command.split("\\s").length == 4){
plugin.panelData.setUserData(getOffline(command.split("\\s")[3]),command.split("\\s")[1],command.split("\\s")[2],true);
break;
}
//this will overwrite data. set-data= [data point] [data value] [optional player]
plugin.panelData.setUserData(p.getUniqueId(),command.split("\\s")[1],command.split("\\s")[2],true); plugin.panelData.setUserData(p.getUniqueId(),command.split("\\s")[1],command.split("\\s")[2],true);
break; break;
} }
case "add-data=":{ case "add-data=":{
//this will not overwrite existing data. add-data= [data point] [data value] if(command.split("\\s").length == 4){
plugin.panelData.setUserData(getOffline(command.split("\\s")[3]),command.split("\\s")[1],command.split("\\s")[2],true);
break;
}
//this will not overwrite existing data. add-data= [data point] [data value] [optional player]
plugin.panelData.setUserData(p.getUniqueId(),command.split("\\s")[1],command.split("\\s")[2],false); plugin.panelData.setUserData(p.getUniqueId(),command.split("\\s")[1],command.split("\\s")[2],false);
break; break;
} }
case "math-data=":{ case "math-data=":{
//only works if data is number, goes math-data= [data point] [operator:number] eg, math-data= -1 OR /3 if(command.split("\\s").length == 4){
plugin.panelData.setUserData(getOffline(command.split("\\s")[3]),command.split("\\s")[1],command.split("\\s")[2],true);
break;
}
//only works if data is number, goes math-data= [data point] [operator:number] [optional player] eg, math-data= -1 OR /3
plugin.panelData.doDataMath(p.getUniqueId(),command.split("\\s")[1],command.split("\\s")[2]); plugin.panelData.doDataMath(p.getUniqueId(),command.split("\\s")[1],command.split("\\s")[2]);
break; break;
} }
@ -62,7 +75,11 @@ public class CommandTags {
break; break;
} }
case "del-data=":{ case "del-data=":{
//this will remove data. del-data= [data point] if(command.split("\\s").length == 3){
plugin.panelData.setUserData(getOffline(command.split("\\s")[3]),command.split("\\s")[1],command.split("\\s")[2],true);
break;
}
//this will remove data. del-data= [data point] [optional player]
plugin.panelData.delUserData(p.getUniqueId(),command.split("\\s")[1]); plugin.panelData.delUserData(p.getUniqueId(),command.split("\\s")[1]);
break; break;
} }
@ -522,6 +539,12 @@ public class CommandTags {
} }
} }
@SuppressWarnings("deprecation")
private UUID getOffline(String playerName){
//making this a separate function as it is long and deprecated
return Bukkit.getOfflinePlayer(playerName).getUniqueId();
}
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
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") + " ";