From 233e75d1419f9abf0b9233a760fbafa453a1e9c7 Mon Sep 17 00:00:00 2001 From: Flemmli97 Date: Tue, 25 Aug 2020 21:32:00 +0200 Subject: [PATCH] fix admin claim, deleteall commands --- src/main/java/com/flemmli97/flan/claim/Claim.java | 8 ++++++-- .../java/com/flemmli97/flan/commands/CommandClaim.java | 4 ++-- src/main/java/com/flemmli97/flan/config/LangConfig.java | 1 + 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/flemmli97/flan/claim/Claim.java b/src/main/java/com/flemmli97/flan/claim/Claim.java index 452524a..70a2449 100644 --- a/src/main/java/com/flemmli97/flan/claim/Claim.java +++ b/src/main/java/com/flemmli97/flan/claim/Claim.java @@ -161,7 +161,7 @@ public class Claim { if (player.getUuid().equals(this.owner)) return true; PlayerClaimData data = PlayerClaimData.get(player); - if (player.hasPermissionLevel(2) || data.isAdminIgnoreClaim()) + if ((this.owner==null && player.hasPermissionLevel(2)) || data.isAdminIgnoreClaim()) return true; for (Claim claim : this.subClaims) { if (claim.insideClaim(pos)) { @@ -196,6 +196,7 @@ public class Claim { } private boolean hasPerm(EnumPermission perm) { + System.out.println("claim " + this + " perm " + perm); if (this.parentClaim() == null) return this.permEnabled(perm) == 1; if (this.permEnabled(perm) == -1) @@ -487,7 +488,10 @@ public class Claim { l.add(PermHelper.simpleColoredText("=============================================", Formatting.GREEN)); GameProfile prof = this.owner != null ? player.getServer().getUserCache().getByUuid(this.owner) : null; String ownerName = this.owner == null ? "Admin" : prof != null ? prof.getName() : ""; - l.add(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.claimBasicInfo, ownerName, this.minX, this.minZ, this.maxX, this.maxZ, this.subClaims.size()), Formatting.GOLD)); + if(this.parent==null) + l.add(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.claimBasicInfo, ownerName, this.minX, this.minZ, this.maxX, this.maxZ, this.subClaims.size()), Formatting.GOLD)); + else + l.add(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.claimBasicInfoSub, ownerName, this.minX, this.minZ, this.maxX, this.maxZ), Formatting.GOLD)); if (perms) { l.add(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.claimInfoPerms, this.globalPerm), Formatting.RED)); l.add(PermHelper.simpleColoredText(ConfigHandler.lang.claimGroupInfoHeader, Formatting.RED)); diff --git a/src/main/java/com/flemmli97/flan/commands/CommandClaim.java b/src/main/java/com/flemmli97/flan/commands/CommandClaim.java index 35c41af..eb389df 100644 --- a/src/main/java/com/flemmli97/flan/commands/CommandClaim.java +++ b/src/main/java/com/flemmli97/flan/commands/CommandClaim.java @@ -57,8 +57,8 @@ public class CommandClaim { CommandManager.literal("setAdminClaim").requires(src -> src.hasPermissionLevel(2)).executes(CommandClaim::setAdminClaim), CommandManager.literal("listAdminClaims").requires(src -> src.hasPermissionLevel(2)).executes(CommandClaim::listAdminClaims), CommandManager.literal("adminDelete").requires(src -> src.hasPermissionLevel(2)).executes(CommandClaim::adminDelete) - .then(CommandManager.literal("all").then(CommandManager.argument("players", GameProfileArgumentType.gameProfile())) - .executes(CommandClaim::adminDeleteAll)), + .then(CommandManager.literal("all").then(CommandManager.argument("players", GameProfileArgumentType.gameProfile()) + .executes(CommandClaim::adminDeleteAll))), CommandManager.literal("giveClaimBlocks").requires(src -> src.hasPermissionLevel(2)).then(CommandManager.argument("players", GameProfileArgumentType.gameProfile()) .then(CommandManager.argument("amount", IntegerArgumentType.integer()).executes(CommandClaim::giveClaimBlocks))), addToMainCommand(CommandManager.literal("group"), diff --git a/src/main/java/com/flemmli97/flan/config/LangConfig.java b/src/main/java/com/flemmli97/flan/config/LangConfig.java index 78829ac..faa3fef 100644 --- a/src/main/java/com/flemmli97/flan/config/LangConfig.java +++ b/src/main/java/com/flemmli97/flan/config/LangConfig.java @@ -62,6 +62,7 @@ public class LangConfig { public String giveClaimBlocks = "Gave following players %2$d claimblocks: %1$s"; public String claimBasicInfo = "Owner: %1$s, from: [x=%2$d,z=%3$d] to [x=%4$d,z=%5$d]; Subclaim-amount: %6$d"; + public String claimBasicInfoSub = "Owner: %1$s, from: [x=%2$d,z=%3$d] to [x=%4$d,z=%5$d]"; public String claimInfoPerms = "Permissions: %s"; public String claimGroupInfoHeader = "Groups: "; public String claimGroupPerms = " Permissions: %s";