diff --git a/src/main/java/com/cjburkey/claimchunk/chunk/ChunkPlayerPermissions.java b/src/main/java/com/cjburkey/claimchunk/chunk/ChunkPlayerPermissions.java index 506db81..a8b7ee8 100644 --- a/src/main/java/com/cjburkey/claimchunk/chunk/ChunkPlayerPermissions.java +++ b/src/main/java/com/cjburkey/claimchunk/chunk/ChunkPlayerPermissions.java @@ -17,6 +17,7 @@ public static final class Masks { public static int INTERACT_ENTITY = 1 << 5; public static int INTERACT_BLOCK = 1 << 6; public static int CONTAINERS = 1 << 7; + public static int PVP = 1 << 8; } /** @@ -107,6 +108,14 @@ public void allowUseContainers(final boolean allow) { setAllow(Masks.CONTAINERS, allow); } + public boolean canAttackPlayer() { + return checkMask(Masks.PVP); + } + + public void allowAttackPlayer(final boolean allow) { + setAllow(Masks.PVP, allow); + } + public Map toPermissionsMap() { HashMap permissionsMap = new HashMap<>(); @@ -118,6 +127,7 @@ public Map toPermissionsMap() { permissionsMap.put("interactEntities", this.canInteractEntities()); permissionsMap.put("interactBlocks", this.canInteractBlocks()); permissionsMap.put("useContainers", this.canUseContainers()); + permissionsMap.put("pvp", this.canAttackPlayer()); return permissionsMap; } @@ -137,6 +147,7 @@ public Map toPermissionsMap() { case "interactEntities" -> chunkPlayerPermissions.allowInteractEntities(permVal); case "interactBlocks" -> chunkPlayerPermissions.allowInteractBlocks(permVal); case "useContainers" -> chunkPlayerPermissions.allowUseContainers(permVal); + case "pvp" -> chunkPlayerPermissions.allowAttackPlayer(permVal); } } diff --git a/src/main/java/com/cjburkey/claimchunk/event/WorldProfileEventHandler.java b/src/main/java/com/cjburkey/claimchunk/event/WorldProfileEventHandler.java index 4bf8d86..95f11ee 100644 --- a/src/main/java/com/cjburkey/claimchunk/event/WorldProfileEventHandler.java +++ b/src/main/java/com/cjburkey/claimchunk/event/WorldProfileEventHandler.java @@ -592,7 +592,7 @@ private void onEntityEvent( final String permissionNeeded = entityClass != null && entityClass.equalsIgnoreCase("VEHICLES") ? "interactVehicles" - : "interactEntities"; + : (entity instanceof Player ? "pvp" : "interactEntities"); final boolean isOwner = (chunkOwner != null && chunkOwner.equals(ply)); final boolean isOwnerOrAccess = diff --git a/src/main/java/com/cjburkey/claimchunk/i18n/V2JsonMessages.java b/src/main/java/com/cjburkey/claimchunk/i18n/V2JsonMessages.java index cfed28d..42b8913 100644 --- a/src/main/java/com/cjburkey/claimchunk/i18n/V2JsonMessages.java +++ b/src/main/java/com/cjburkey/claimchunk/i18n/V2JsonMessages.java @@ -234,8 +234,9 @@ public final class V2JsonMessages { public String argInteractEntities = "interactEntities"; public String argInteractBlocks = "interactBlocks"; public String argUseContainers = "useContainers"; + public String argPvp = "pvp"; public String argAllChunks = "allChunks"; - public String[] permissionArgs = + public transient String[] permissionArgs = new String[] { argBreak, argPlace, @@ -245,6 +246,7 @@ public final class V2JsonMessages { argInteractEntities, argInteractBlocks, argUseContainers, + argPvp, argAllChunks }; diff --git a/src/main/java/com/cjburkey/claimchunk/smartcommand/sub/ply/AccessCmd.java b/src/main/java/com/cjburkey/claimchunk/smartcommand/sub/ply/AccessCmd.java index c92a155..c0f7d86 100644 --- a/src/main/java/com/cjburkey/claimchunk/smartcommand/sub/ply/AccessCmd.java +++ b/src/main/java/com/cjburkey/claimchunk/smartcommand/sub/ply/AccessCmd.java @@ -29,6 +29,7 @@ public class AccessCmd extends CCSubCommand { "interactEntities", "interactBlocks", "useContainers", + "pvp", "allChunks" }; @@ -55,6 +56,7 @@ public CCArg[] getPermittedArguments() { new CCArg(claimChunk.getMessages().argInteractEntities, CCAutoComplete.PERMISSION), new CCArg(claimChunk.getMessages().argInteractBlocks, CCAutoComplete.PERMISSION), new CCArg(claimChunk.getMessages().argUseContainers, CCAutoComplete.PERMISSION), + new CCArg(claimChunk.getMessages().argPvp, CCAutoComplete.PERMISSION), new CCArg(claimChunk.getMessages().argAllChunks, CCAutoComplete.PERMISSION) }; }