Skip to content

Commit 2755e55

Browse files
committed
add bypass permission
1 parent 7d5b19b commit 2755e55

3 files changed

Lines changed: 41 additions & 2 deletions

File tree

  • AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/chunklimits
  • AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/chunklimits
  • shared/src/main/java/me/xginko/aef/utils/permissions

AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/chunklimits/BlockLimit.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import me.xginko.aef.AnarchyExploitFixes;
88
import me.xginko.aef.modules.AEFModule;
99
import me.xginko.aef.utils.LocationUtil;
10+
import me.xginko.aef.utils.permissions.AEFPermission;
1011
import net.kyori.adventure.text.TextReplacementConfig;
1112
import org.bukkit.Chunk;
1213
import org.bukkit.Location;
@@ -35,7 +36,9 @@ public class BlockLimit extends AEFModule implements Listener {
3536
private Cache<@NotNull Chunk, Cache<@NotNull Material, Integer>> chunkMaterialCountCache;
3637

3738
public BlockLimit() {
38-
super("chunk-limits.block-limit", false);
39+
super("chunk-limits.block-limit", false,
40+
"Configure per-chunk block limits." +
41+
"\nBypass permission: " + AEFPermission.BYPASS_CHUNK_LIMITS_BLOCK_LIMIT.node());
3942
this.notifyPlayer = config.getBoolean(configPath + ".notify-player", true,
4043
"Send a message to the player when they cant place a block due to chunk limit.");
4144
this.materialCountCacheMillis = config.getLong(configPath + ".material-count-cache-millis", 1000,
@@ -187,6 +190,14 @@ private void onBlockPlace(BlockPlaceEvent event) {
187190
return;
188191
}
189192

193+
if (AnarchyExploitFixes.permissions().permissionValue(event.getPlayer(), AEFPermission.BYPASS_CHUNK_LIMITS_BLOCK_LIMIT.node()).toBoolean()) {
194+
logger.debug("Ignoring {} for player '{}' because they have bypass permission: {}",
195+
event.getEventName(),
196+
event.getPlayer().getName(),
197+
AEFPermission.BYPASS_CHUNK_LIMITS_BLOCK_LIMIT.node());
198+
return;
199+
}
200+
190201
int materialCount = getMaterialCountForChunk(event.getBlock().getType(), event.getBlock().getChunk());
191202
int limit = blockLimits.get(event.getBlock().getType());
192203

@@ -234,6 +245,14 @@ private void onPlayerInteract(PlayerInteractEvent event) {
234245
return;
235246
}
236247

248+
if (AnarchyExploitFixes.permissions().permissionValue(event.getPlayer(), AEFPermission.BYPASS_CHUNK_LIMITS_BLOCK_LIMIT.node()).toBoolean()) {
249+
logger.debug("Ignoring {} for player '{}' because they have bypass permission: {}",
250+
event.getEventName(),
251+
event.getPlayer().getName(),
252+
AEFPermission.BYPASS_CHUNK_LIMITS_BLOCK_LIMIT.node());
253+
return;
254+
}
255+
237256
// Ignore interactions like for ex. players wanting to flick a lever
238257
if (event.getMaterial().isInteractable() && !event.getPlayer().isSneaking()) {
239258
return; // Let BlockPlaceEvent deal with this

AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/chunklimits/BlockLimit.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import me.xginko.aef.modules.AEFModule;
99
import me.xginko.aef.utils.LocationUtil;
1010
import me.xginko.aef.utils.WorldUtil;
11+
import me.xginko.aef.utils.permissions.AEFPermission;
1112
import org.bukkit.Chunk;
1213
import org.bukkit.Location;
1314
import org.bukkit.Material;
@@ -35,7 +36,9 @@ public class BlockLimit extends AEFModule implements Listener {
3536
private Cache<Chunk, Cache<Material, Integer>> chunkMaterialCountCache;
3637

3738
public BlockLimit() {
38-
super("chunk-limits.block-limit", false);
39+
super("chunk-limits.block-limit", false,
40+
"Configure per-chunk block limits." +
41+
"\nBypass permission: " + AEFPermission.BYPASS_CHUNK_LIMITS_BLOCK_LIMIT.node());
3942
this.notifyPlayer = config.getBoolean(configPath + ".notify-player", true,
4043
"Send a message to the player when they cant place a block due to chunk limit.");
4144
this.materialCountCacheMillis = config.getLong(configPath + ".material-count-cache-millis", 1000,
@@ -187,6 +190,14 @@ private void onBlockPlace(BlockPlaceEvent event) {
187190
return;
188191
}
189192

193+
if (AnarchyExploitFixes.permissions().permissionValue(event.getPlayer(), AEFPermission.BYPASS_CHUNK_LIMITS_BLOCK_LIMIT.node()).toBoolean()) {
194+
logger.debug("Ignoring {} for player '{}' because they have bypass permission: {}",
195+
event.getEventName(),
196+
event.getPlayer().getName(),
197+
AEFPermission.BYPASS_CHUNK_LIMITS_BLOCK_LIMIT.node());
198+
return;
199+
}
200+
190201
int materialCount = getMaterialCountForChunk(event.getBlock().getType(), event.getBlock().getChunk());
191202
int limit = blockLimits.get(event.getBlock().getType());
192203

@@ -224,6 +235,14 @@ private void onPlayerInteract(PlayerInteractEvent event) {
224235
return;
225236
}
226237

238+
if (AnarchyExploitFixes.permissions().permissionValue(event.getPlayer(), AEFPermission.BYPASS_CHUNK_LIMITS_BLOCK_LIMIT.node()).toBoolean()) {
239+
logger.debug("Ignoring {} for player '{}' because they have bypass permission: {}",
240+
event.getEventName(),
241+
event.getPlayer().getName(),
242+
AEFPermission.BYPASS_CHUNK_LIMITS_BLOCK_LIMIT.node());
243+
return;
244+
}
245+
227246
Location placeLocation = event.getClickedBlock().getRelative(event.getBlockFace()).getLocation();
228247
int materialCount = getMaterialCountForChunk(event.getMaterial(), placeLocation.getChunk());
229248
int limit = blockLimits.get(event.getMaterial());

shared/src/main/java/me/xginko/aef/utils/permissions/AEFPermission.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public enum AEFPermission {
1010
BYPASS_HEIGHT_LIMITS("bypass.heightlimits", "Bypass height restrictions if enabled", PermissionDefault.FALSE),
1111
BYPASS_CMD_WHITELIST("bypass.commandwhitelist", "Bypass command whitelist if enabled", PermissionDefault.OP),
1212
BYPASS_CHAT("bypass.chat", "Bypass for any kind of other chat restrictions", PermissionDefault.OP),
13+
BYPASS_CHUNK_LIMITS_BLOCK_LIMIT("bypass.chunk-limit.block-limit", "Bypass per-chunk block limits", PermissionDefault.OP),
1314
BYPASS_PREVENTION_COMMANDSIGN("bypass.prevention.commandsign", "Bypass commandsign prevention", PermissionDefault.FALSE),
1415
BYPASS_ILLEGAL_FIREWORKS("bypass.illegal.firework", "Bypass illegal firework checks", PermissionDefault.FALSE),
1516
BYPASS_ILLEGAL_POTIONS("bypass.illegal.potions", "Bypass illegal potion checks", PermissionDefault.FALSE),

0 commit comments

Comments
 (0)