fix xp tag order

This commit is contained in:
rockyhawk64 2025-07-15 10:32:45 +10:00
parent 4f02c76e79
commit e52a7dd49d
2 changed files with 24 additions and 6 deletions

View File

@ -22,6 +22,7 @@ public class Converter {
public void convertPanels(CommandSender sender) {
File oldPanelsDir = new File(ctx.plugin.getDataFolder(), "old_panels"); // e.g. plugins/CommandPanels/old_panels
if (!oldPanelsDir.exists()) {
ctx.text.sendError(sender, "Converts v3 -> v4 Panel config layouts");
ctx.text.sendError(sender, "Old panels directory not found: " + oldPanelsDir.getPath());
return;
}
@ -113,7 +114,8 @@ public class Converter {
Map<String, Object> leftClick = new HashMap<>();
List<String> cmdList = new ArrayList<>();
for (String cmd : cmds) {
cmdList.add("[msg] " + cmd);
// Do command tag convert attempts
cmdList.add(commandTagConverter(cmd));
}
leftClick.put("commands", cmdList);
convertedItem.put("actions", leftClick);
@ -140,6 +142,10 @@ public class Converter {
}
}
}
if(oldPanel.contains("empty")){
layout.put("fill", new ArrayList<>(Collections.singletonList("empty_item")));
items.put("empty_item.material", oldPanel.getString("empty"));
}
newPanel.put("layout", layout);
newPanel.put("items", items);
@ -179,6 +185,18 @@ public class Converter {
return item;
}
private String commandTagConverter(String command){
command = command.replace("server=", "[server]");
command = command.replace("open=", "[open]");
command = command.replace("cpc", "[close]");
command = command.replace("console=", "[console]");
command = command.replace("refresh", "[refresh]");
command = command.replace("data=", "[data]");
command = command.replace("msg=", "[msg]");
command = command.replace("teleport=", "[teleport]");
return command;
}
private boolean hasNestedConditions(ConfigurationSection itemConfig) {
for (String key : itemConfig.getKeys(false)) {
if (key.startsWith("has")) return true;

View File

@ -16,19 +16,19 @@ public class XpTag implements RequirementTagResolver {
public boolean check(Context ctx, Panel panel, Player player, String args) {
String[] split = args.trim().split(" ");
if (split.length != 2) {
ctx.text.sendError(player, "Invalid XP requirement. Use: [xp] <amount> <levels|points>");
ctx.text.sendError(player, "Invalid XP requirement. Use: [xp] <levels|points> <amount>");
return false;
}
int amount;
try {
amount = Integer.parseInt(split[0]);
amount = Integer.parseInt(split[1]);
} catch (NumberFormatException e) {
ctx.text.sendError(player, "Invalid XP amount.");
return false;
}
String type = split[1].toLowerCase();
String type = split[0].toLowerCase();
return switch (type) {
case "levels" -> player.getLevel() >= amount;
@ -47,12 +47,12 @@ public class XpTag implements RequirementTagResolver {
int amount;
try {
amount = Integer.parseInt(split[0]);
amount = Integer.parseInt(split[1]);
} catch (NumberFormatException e) {
return;
}
String type = split[1].toLowerCase();
String type = split[0].toLowerCase();
switch (type) {
case "levels" -> player.setLevel(player.getLevel() - amount);