diff --git a/Changelog.md b/Changelog.md index b1adbda..a4169b4 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,6 +2,8 @@ Flan 1.7.10 ================ - Check for keep inventory when deciding if drops should be locked or not Stops unlock cmd message when keep inventory is on +- Fix addClaim cmd bypassing world blacklist +- Make admin mode ignore world blacklist Flan 1.7.9 ================ diff --git a/common/src/main/java/io/github/flemmli97/flan/commands/CommandClaim.java b/common/src/main/java/io/github/flemmli97/flan/commands/CommandClaim.java index 1dbaa51..222d164 100644 --- a/common/src/main/java/io/github/flemmli97/flan/commands/CommandClaim.java +++ b/common/src/main/java/io/github/flemmli97/flan/commands/CommandClaim.java @@ -16,6 +16,7 @@ import io.github.flemmli97.flan.claim.Claim; import io.github.flemmli97.flan.claim.ClaimStorage; import io.github.flemmli97.flan.claim.PermHelper; import io.github.flemmli97.flan.config.ConfigHandler; +import io.github.flemmli97.flan.event.ItemInteractEvents; import io.github.flemmli97.flan.gui.ClaimMenuScreenHandler; import io.github.flemmli97.flan.gui.PersonalGroupScreenHandler; import io.github.flemmli97.flan.platform.integration.permissions.PermissionNodeHandler; @@ -144,6 +145,8 @@ public class CommandClaim { private static int addClaim(CommandContext context) throws CommandSyntaxException { ServerPlayer player = context.getSource().getPlayerOrException(); + if (!ItemInteractEvents.canClaimWorld(player.getLevel(), player)) + return 0; ClaimStorage storage = ClaimStorage.get(player.getLevel()); BlockPos from = BlockPosArgument.getLoadedBlockPos(context, "from"); BlockPos to = BlockPosArgument.getLoadedBlockPos(context, "to"); @@ -161,6 +164,8 @@ public class CommandClaim { private static int addClaimRect(CommandContext context, int x, int z) throws CommandSyntaxException { ServerPlayer player = context.getSource().getPlayerOrException(); + if (!ItemInteractEvents.canClaimWorld(player.getLevel(), player)) + return 0; ClaimStorage storage = ClaimStorage.get(player.getLevel()); boolean evenX = x % 2 == 0; boolean evenZ = z % 2 == 0; diff --git a/common/src/main/java/io/github/flemmli97/flan/event/ItemInteractEvents.java b/common/src/main/java/io/github/flemmli97/flan/event/ItemInteractEvents.java index 881dd18..5e326c7 100644 --- a/common/src/main/java/io/github/flemmli97/flan/event/ItemInteractEvents.java +++ b/common/src/main/java/io/github/flemmli97/flan/event/ItemInteractEvents.java @@ -147,20 +147,29 @@ public class ItemInteractEvents { return false; } + public static boolean canClaimWorld(ServerLevel world, ServerPlayer player) { + PlayerClaimData data = PlayerClaimData.get(player); + if (data.isAdminIgnoreClaim()) + return true; + if (ConfigHandler.config.worldWhitelist) { + if (!cantClaimInWorld(player.getLevel())) { + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.langManager.get("landClaimDisabledWorld"), ChatFormatting.DARK_RED), false); + return false; + } + } else if (cantClaimInWorld(player.getLevel())) { + player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.langManager.get("landClaimDisabledWorld"), ChatFormatting.DARK_RED), false); + return false; + } + return true; + } + public static void claimLandHandling(ServerPlayer player, BlockPos target) { if (!PermissionNodeHandler.INSTANCE.perm(player, PermissionNodeHandler.claimCreate, false)) { player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.langManager.get("noPermission"), ChatFormatting.DARK_RED), true); return; } - if (ConfigHandler.config.worldWhitelist) { - if (!cantClaimInWorld(player.getLevel())) { - player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.langManager.get("landClaimDisabledWorld"), ChatFormatting.DARK_RED), false); - return; - } - } else if (cantClaimInWorld(player.getLevel())) { - player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.langManager.get("landClaimDisabledWorld"), ChatFormatting.DARK_RED), false); + if (!canClaimWorld(player.getLevel(), player)) return; - } ClaimStorage storage = ClaimStorage.get(player.getLevel()); Claim claim = storage.getClaimAt(target.offset(0, 255, 0)); PlayerClaimData data = PlayerClaimData.get(player);