mirror of
https://github.com/bloodmc/GriefDefender.git
synced 2024-12-01 13:43:28 +01:00
Fix explosions not respecting inheritance. Fixes #265
* Remove 'explosion-cancel-block-limit' as it breaks inheritance functionality.
This commit is contained in:
parent
771d6eb7e5
commit
6b056d936e
@ -41,10 +41,6 @@ public class ClaimCategory extends ConfigCategory {
|
|||||||
+ "\nEx. If you add 'minecraft:creeper' to the list, creepers would not be able to hurt entities above sea level."
|
+ "\nEx. If you add 'minecraft:creeper' to the list, creepers would not be able to hurt entities above sea level."
|
||||||
+ "\nNote: This will have higher priority than 'explosion-entity' flag.")
|
+ "\nNote: This will have higher priority than 'explosion-entity' flag.")
|
||||||
public List<String> explosionEntitySurfaceBlacklist = new ArrayList<>();
|
public List<String> explosionEntitySurfaceBlacklist = new ArrayList<>();
|
||||||
@Setting(value = "explosion-cancel-block-limit", comment = "The affected explosion block size limit to cancel events in order to improve performance."
|
|
||||||
+ "\nEx. If set to '50' and an explosion affects 51+ blocks, the event will cancel when the first protected block is found."
|
|
||||||
+ "\nNote: To disable, set value to '0'.")
|
|
||||||
public int explosionCancelBlockLimit = 50;
|
|
||||||
@Setting(value = "piston-protection-in-claims", comment = "Whether piston protection should be enabled within claims. Note: This does not affect pistons crossing into another claim, that is always protected. This only determines whether or not GD should process pistons if it doesn't cross into another claim.")
|
@Setting(value = "piston-protection-in-claims", comment = "Whether piston protection should be enabled within claims. Note: This does not affect pistons crossing into another claim, that is always protected. This only determines whether or not GD should process pistons if it doesn't cross into another claim.")
|
||||||
public boolean pistonProtectionInClaims = false;
|
public boolean pistonProtectionInClaims = false;
|
||||||
@Setting(value = "auto-chest-claim-block-radius", comment = "Radius used (in blocks) for auto-created claim when a chest is placed. Set to -1 to disable chest claim creation.")
|
@Setting(value = "auto-chest-claim-block-radius", comment = "Radius used (in blocks) for auto-created claim when a chest is placed. Set to -1 to disable chest claim creation.")
|
||||||
|
@ -499,7 +499,6 @@ public void onExplosionEvent(BlockExplodeEvent event) {
|
|||||||
GDClaim targetClaim = null;
|
GDClaim targetClaim = null;
|
||||||
final List<Block> filteredLocations = new ArrayList<>();
|
final List<Block> filteredLocations = new ArrayList<>();
|
||||||
final String sourceId = GDPermissionManager.getInstance().getPermissionIdentifier(source);
|
final String sourceId = GDPermissionManager.getInstance().getPermissionIdentifier(source);
|
||||||
final int cancelBlockLimit = GriefDefenderPlugin.getGlobalConfig().getConfig().claim.explosionCancelBlockLimit;
|
|
||||||
boolean denySurfaceExplosion = GriefDefenderPlugin.getActiveConfig(world.getUID()).getConfig().claim.explosionBlockSurfaceBlacklist.contains(sourceId);
|
boolean denySurfaceExplosion = GriefDefenderPlugin.getActiveConfig(world.getUID()).getConfig().claim.explosionBlockSurfaceBlacklist.contains(sourceId);
|
||||||
if (!denySurfaceExplosion) {
|
if (!denySurfaceExplosion) {
|
||||||
denySurfaceExplosion = GriefDefenderPlugin.getActiveConfig(world.getUID()).getConfig().claim.explosionBlockSurfaceBlacklist.contains("any");
|
denySurfaceExplosion = GriefDefenderPlugin.getActiveConfig(world.getUID()).getConfig().claim.explosionBlockSurfaceBlacklist.contains("any");
|
||||||
@ -517,11 +516,6 @@ public void onExplosionEvent(BlockExplodeEvent event) {
|
|||||||
}
|
}
|
||||||
Tristate result = GDPermissionManager.getInstance().getFinalPermission(event, location, targetClaim, Flags.EXPLOSION_BLOCK, source, block, user, true);
|
Tristate result = GDPermissionManager.getInstance().getFinalPermission(event, location, targetClaim, Flags.EXPLOSION_BLOCK, source, block, user, true);
|
||||||
if (result == Tristate.FALSE) {
|
if (result == Tristate.FALSE) {
|
||||||
// Avoid lagging server from large explosions.
|
|
||||||
if (event.blockList().size() > cancelBlockLimit) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
filteredLocations.add(block);
|
filteredLocations.add(block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -198,6 +198,12 @@ public void onExplosionPrimeEvent(ExplosionPrimeEvent event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final Location location = event.getEntity().getLocation();
|
final Location location = event.getEntity().getLocation();
|
||||||
|
final GDClaim targetClaim = GriefDefenderPlugin.getInstance().dataStore.getClaimAt(location);
|
||||||
|
// If affected claim does not inherit parent, skip logic
|
||||||
|
if (!targetClaim.isWilderness() && targetClaim.getParent().isPresent() && !targetClaim.getInternalClaimData().doesInheritParent()) {
|
||||||
|
GDTimings.ENTITY_EXPLOSION_PRE_EVENT.stopTiming();
|
||||||
|
return;
|
||||||
|
}
|
||||||
final GDClaim radiusClaim = NMSUtil.getInstance().createClaimFromCenter(location, event.getRadius());
|
final GDClaim radiusClaim = NMSUtil.getInstance().createClaimFromCenter(location, event.getRadius());
|
||||||
final GDClaimManager claimManager = GriefDefenderPlugin.getInstance().dataStore.getClaimWorldManager(location.getWorld().getUID());
|
final GDClaimManager claimManager = GriefDefenderPlugin.getInstance().dataStore.getClaimWorldManager(location.getWorld().getUID());
|
||||||
final Set<Claim> surroundingClaims = claimManager.findOverlappingClaims(radiusClaim);
|
final Set<Claim> surroundingClaims = claimManager.findOverlappingClaims(radiusClaim);
|
||||||
@ -248,7 +254,6 @@ public void onEntityExplodeEvent(EntityExplodeEvent event) {
|
|||||||
}
|
}
|
||||||
GDTimings.EXPLOSION_EVENT.startTiming();
|
GDTimings.EXPLOSION_EVENT.startTiming();
|
||||||
GDClaim targetClaim = null;
|
GDClaim targetClaim = null;
|
||||||
final int cancelBlockLimit = GriefDefenderPlugin.getGlobalConfig().getConfig().claim.explosionCancelBlockLimit;
|
|
||||||
final List<Block> filteredLocations = new ArrayList<>();
|
final List<Block> filteredLocations = new ArrayList<>();
|
||||||
boolean clearAll = false;
|
boolean clearAll = false;
|
||||||
for (Block block : event.blockList()) {
|
for (Block block : event.blockList()) {
|
||||||
@ -261,13 +266,6 @@ public void onEntityExplodeEvent(EntityExplodeEvent event) {
|
|||||||
}
|
}
|
||||||
final Tristate result = GDPermissionManager.getInstance().getFinalPermission(event, location, targetClaim, Flags.EXPLOSION_BLOCK, source, block, user, true);
|
final Tristate result = GDPermissionManager.getInstance().getFinalPermission(event, location, targetClaim, Flags.EXPLOSION_BLOCK, source, block, user, true);
|
||||||
if (result == Tristate.FALSE) {
|
if (result == Tristate.FALSE) {
|
||||||
// Avoid lagging server from large explosions.
|
|
||||||
if (event.blockList().size() > cancelBlockLimit) {
|
|
||||||
// Avoid cancelling as it causing clients not to receive explosion sound
|
|
||||||
//event.setCancelled(true);
|
|
||||||
clearAll = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
filteredLocations.add(block);
|
filteredLocations.add(block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,10 +41,6 @@ public class ClaimCategory extends ConfigCategory {
|
|||||||
+ "\nEx. If you add 'minecraft:creeper' to the list, creepers would not be able to hurt entities above sea level."
|
+ "\nEx. If you add 'minecraft:creeper' to the list, creepers would not be able to hurt entities above sea level."
|
||||||
+ "\nNote: This will have higher priority than 'explosion-entity' flag.")
|
+ "\nNote: This will have higher priority than 'explosion-entity' flag.")
|
||||||
public List<String> explosionEntitySurfaceBlacklist = new ArrayList<>();
|
public List<String> explosionEntitySurfaceBlacklist = new ArrayList<>();
|
||||||
@Setting(value = "explosion-cancel-block-limit", comment = "The affected explosion block size limit to cancel events."
|
|
||||||
+ "\nEx. If set to '50', and a creeper explodes which affects 51+ blocks, the event will cancel when the first protected block is found."
|
|
||||||
+ "\nNote: To disable, set value to '0'.")
|
|
||||||
public int explosionCancelBlockLimit = 50;
|
|
||||||
@Setting(value = "worldedit-schematics", comment = "Whether to use WorldEdit for schematics. Default: false"
|
@Setting(value = "worldedit-schematics", comment = "Whether to use WorldEdit for schematics. Default: false"
|
||||||
+ "\nNote: If you were using schematics in older GD/GP versions and want old schematics to work then you should keep this setting disabled.")
|
+ "\nNote: If you were using schematics in older GD/GP versions and want old schematics to work then you should keep this setting disabled.")
|
||||||
public boolean useWorldEditSchematics = false;
|
public boolean useWorldEditSchematics = false;
|
||||||
|
@ -598,6 +598,12 @@ public void onExplosionPre(ExplosionEvent.Pre event) {
|
|||||||
GDTimings.EXPLOSION_PRE_EVENT.startTimingIfSync();
|
GDTimings.EXPLOSION_PRE_EVENT.startTimingIfSync();
|
||||||
final User user = CauseContextHelper.getEventUser(event);
|
final User user = CauseContextHelper.getEventUser(event);
|
||||||
final Location<World> location = event.getExplosion().getLocation();
|
final Location<World> location = event.getExplosion().getLocation();
|
||||||
|
final GDClaim targetClaim = GriefDefenderPlugin.getInstance().dataStore.getClaimAt(location);
|
||||||
|
// If affected claim does not inherit parent, skip logic
|
||||||
|
if (!targetClaim.isWilderness() && targetClaim.getParent().isPresent() && !targetClaim.getInternalClaimData().doesInheritParent()) {
|
||||||
|
GDTimings.EXPLOSION_PRE_EVENT.stopTimingIfSync();
|
||||||
|
return;
|
||||||
|
}
|
||||||
final GDClaim radiusClaim = NMSUtil.getInstance().createClaimFromCenter(location, event.getExplosion().getRadius());
|
final GDClaim radiusClaim = NMSUtil.getInstance().createClaimFromCenter(location, event.getExplosion().getRadius());
|
||||||
final GDClaimManager claimManager = GriefDefenderPlugin.getInstance().dataStore.getClaimWorldManager(location.getExtent().getUniqueId());
|
final GDClaimManager claimManager = GriefDefenderPlugin.getInstance().dataStore.getClaimWorldManager(location.getExtent().getUniqueId());
|
||||||
final Set<Claim> surroundingClaims = claimManager.findOverlappingClaims(radiusClaim);
|
final Set<Claim> surroundingClaims = claimManager.findOverlappingClaims(radiusClaim);
|
||||||
@ -646,7 +652,6 @@ public void onExplosionDetonate(ExplosionEvent.Detonate event) {
|
|||||||
GDClaim targetClaim = null;
|
GDClaim targetClaim = null;
|
||||||
final List<Location<World>> filteredLocations = new ArrayList<>();
|
final List<Location<World>> filteredLocations = new ArrayList<>();
|
||||||
final String sourceId = GDPermissionManager.getInstance().getPermissionIdentifier(source);
|
final String sourceId = GDPermissionManager.getInstance().getPermissionIdentifier(source);
|
||||||
final int cancelBlockLimit = GriefDefenderPlugin.getGlobalConfig().getConfig().claim.explosionCancelBlockLimit;
|
|
||||||
boolean denySurfaceExplosion = GriefDefenderPlugin.getActiveConfig(world.getUniqueId()).getConfig().claim.explosionBlockSurfaceBlacklist.contains(sourceId);
|
boolean denySurfaceExplosion = GriefDefenderPlugin.getActiveConfig(world.getUniqueId()).getConfig().claim.explosionBlockSurfaceBlacklist.contains(sourceId);
|
||||||
if (!denySurfaceExplosion) {
|
if (!denySurfaceExplosion) {
|
||||||
denySurfaceExplosion = GriefDefenderPlugin.getActiveConfig(world.getUniqueId()).getConfig().claim.explosionBlockSurfaceBlacklist.contains("any");
|
denySurfaceExplosion = GriefDefenderPlugin.getActiveConfig(world.getUniqueId()).getConfig().claim.explosionBlockSurfaceBlacklist.contains("any");
|
||||||
@ -665,11 +670,6 @@ public void onExplosionDetonate(ExplosionEvent.Detonate event) {
|
|||||||
Tristate result = GDPermissionManager.getInstance().getFinalPermission(event, location, targetClaim, Flags.EXPLOSION_BLOCK, source, location.getBlock(), user, true);
|
Tristate result = GDPermissionManager.getInstance().getFinalPermission(event, location, targetClaim, Flags.EXPLOSION_BLOCK, source, location.getBlock(), user, true);
|
||||||
|
|
||||||
if (result == Tristate.FALSE) {
|
if (result == Tristate.FALSE) {
|
||||||
// Avoid lagging server from large explosions.
|
|
||||||
if (event.getAffectedLocations().size() > cancelBlockLimit) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
filteredLocations.add(location);
|
filteredLocations.add(location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user