fix admin claim, deleteall commands

This commit is contained in:
Flemmli97 2020-08-25 21:32:00 +02:00
parent 332595028e
commit 233e75d141
3 changed files with 9 additions and 4 deletions

View File

@ -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() : "<UNKNOWN>";
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));

View File

@ -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"),

View File

@ -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";