adminmode ignore world blacklist close #166, fix addclaim ignoring world blacklist

This commit is contained in:
Flemmli97 2022-07-01 14:32:41 +02:00
parent c9c31ddd5e
commit 56cec73cbc
3 changed files with 24 additions and 8 deletions

View File

@ -2,6 +2,8 @@ Flan 1.7.10
================ ================
- Check for keep inventory when deciding if drops should be locked or not - Check for keep inventory when deciding if drops should be locked or not
Stops unlock cmd message when keep inventory is on 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 Flan 1.7.9
================ ================

View File

@ -16,6 +16,7 @@ import io.github.flemmli97.flan.claim.Claim;
import io.github.flemmli97.flan.claim.ClaimStorage; import io.github.flemmli97.flan.claim.ClaimStorage;
import io.github.flemmli97.flan.claim.PermHelper; import io.github.flemmli97.flan.claim.PermHelper;
import io.github.flemmli97.flan.config.ConfigHandler; 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.ClaimMenuScreenHandler;
import io.github.flemmli97.flan.gui.PersonalGroupScreenHandler; import io.github.flemmli97.flan.gui.PersonalGroupScreenHandler;
import io.github.flemmli97.flan.platform.integration.permissions.PermissionNodeHandler; import io.github.flemmli97.flan.platform.integration.permissions.PermissionNodeHandler;
@ -144,6 +145,8 @@ public class CommandClaim {
private static int addClaim(CommandContext<CommandSourceStack> context) throws CommandSyntaxException { private static int addClaim(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
ServerPlayer player = context.getSource().getPlayerOrException(); ServerPlayer player = context.getSource().getPlayerOrException();
if (!ItemInteractEvents.canClaimWorld(player.getLevel(), player))
return 0;
ClaimStorage storage = ClaimStorage.get(player.getLevel()); ClaimStorage storage = ClaimStorage.get(player.getLevel());
BlockPos from = BlockPosArgument.getLoadedBlockPos(context, "from"); BlockPos from = BlockPosArgument.getLoadedBlockPos(context, "from");
BlockPos to = BlockPosArgument.getLoadedBlockPos(context, "to"); BlockPos to = BlockPosArgument.getLoadedBlockPos(context, "to");
@ -161,6 +164,8 @@ public class CommandClaim {
private static int addClaimRect(CommandContext<CommandSourceStack> context, int x, int z) throws CommandSyntaxException { private static int addClaimRect(CommandContext<CommandSourceStack> context, int x, int z) throws CommandSyntaxException {
ServerPlayer player = context.getSource().getPlayerOrException(); ServerPlayer player = context.getSource().getPlayerOrException();
if (!ItemInteractEvents.canClaimWorld(player.getLevel(), player))
return 0;
ClaimStorage storage = ClaimStorage.get(player.getLevel()); ClaimStorage storage = ClaimStorage.get(player.getLevel());
boolean evenX = x % 2 == 0; boolean evenX = x % 2 == 0;
boolean evenZ = z % 2 == 0; boolean evenZ = z % 2 == 0;

View File

@ -147,20 +147,29 @@ public class ItemInteractEvents {
return false; 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) { public static void claimLandHandling(ServerPlayer player, BlockPos target) {
if (!PermissionNodeHandler.INSTANCE.perm(player, PermissionNodeHandler.claimCreate, false)) { if (!PermissionNodeHandler.INSTANCE.perm(player, PermissionNodeHandler.claimCreate, false)) {
player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.langManager.get("noPermission"), ChatFormatting.DARK_RED), true); player.displayClientMessage(PermHelper.simpleColoredText(ConfigHandler.langManager.get("noPermission"), ChatFormatting.DARK_RED), true);
return; return;
} }
if (ConfigHandler.config.worldWhitelist) { if (!canClaimWorld(player.getLevel(), player))
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);
return; return;
}
ClaimStorage storage = ClaimStorage.get(player.getLevel()); ClaimStorage storage = ClaimStorage.get(player.getLevel());
Claim claim = storage.getClaimAt(target.offset(0, 255, 0)); Claim claim = storage.getClaimAt(target.offset(0, 255, 0));
PlayerClaimData data = PlayerClaimData.get(player); PlayerClaimData data = PlayerClaimData.get(player);