Skip to content

Commit 887f3bf

Browse files
BrokkonautJoo200
authored andcommitted
Special handling for WindCharges
1 parent 6898ad8 commit 887f3bf

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/listener/EventAbstractionListener.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
import org.bukkit.entity.Player;
8080
import org.bukkit.entity.Tameable;
8181
import org.bukkit.entity.ThrownPotion;
82+
import org.bukkit.entity.WindCharge;
8283
import org.bukkit.entity.minecart.HopperMinecart;
8384
import org.bukkit.event.Cancellable;
8485
import org.bukkit.event.Event;
@@ -357,6 +358,10 @@ public void onEntityChangeBlock(EntityChangeBlockEvent event) {
357358
@EventHandler(ignoreCancelled = true)
358359
public void onEntityExplode(EntityExplodeEvent event) {
359360
Entity entity = event.getEntity();
361+
if (entity instanceof WindCharge) {
362+
Events.fireBulkEventToCancel(event, new UseBlockEvent(event, create(entity), event.getLocation().getWorld(), event.blockList(), Material.AIR));
363+
return;
364+
}
360365
Events.fireBulkEventToCancel(event, new BreakBlockEvent(event, create(entity), event.getLocation().getWorld(), event.blockList(), Material.AIR));
361366
if (entity instanceof Creeper) {
362367
Cause.untrackParentCause(entity);

worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/listener/WorldGuardEntityListener.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
import org.bukkit.entity.Projectile;
6161
import org.bukkit.entity.TNTPrimed;
6262
import org.bukkit.entity.Tameable;
63+
import org.bukkit.entity.WindCharge;
6364
import org.bukkit.entity.Wither;
6465
import org.bukkit.entity.WitherSkull;
6566
import org.bukkit.entity.Wolf;
@@ -522,6 +523,16 @@ public void onEntityExplode(EntityExplodeEvent event) {
522523
}
523524
}
524525
}
526+
} else if (ent instanceof WindCharge) {
527+
if (wcfg.useRegions) {
528+
for (Block block : event.blockList()) {
529+
if (!WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().getApplicableRegions(BukkitAdapter.adapt(block.getLocation())).testState(null, Flags.WIND_CHARGE_BURST)) {
530+
event.blockList().clear();
531+
event.setCancelled(true);
532+
return;
533+
}
534+
}
535+
}
525536
} else {
526537
// unhandled entity
527538
if (wcfg.blockOtherExplosions) {

worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/util/Materials.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,7 @@ private static void putMaterialTag(Tag<Material> tag, Integer value) {
835835

836836
MATERIAL_FLAGS.put(Material.ARMADILLO_SCUTE, 0);
837837
MATERIAL_FLAGS.put(Material.WOLF_ARMOR, 0);
838+
MATERIAL_FLAGS.put(Material.WIND_CHARGE, 0);
838839

839840
// 1.21
840841
MATERIAL_FLAGS.put(Material.CHISELED_TUFF, 0);

worldguard-core/src/main/java/com/sk89q/worldguard/protection/flags/Flags.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ public final class Flags {
9393
public static final StateFlag ENDERDRAGON_BLOCK_DAMAGE = register(new StateFlag("enderdragon-block-damage", true));
9494
public static final StateFlag GHAST_FIREBALL = register(new StateFlag("ghast-fireball", true));
9595
public static final StateFlag OTHER_EXPLOSION = register(new StateFlag("other-explosion", true));
96+
public static final StateFlag WIND_CHARGE_BURST = register(new StateFlag("wind-charge-burst", true));
9697
public static final StateFlag WITHER_DAMAGE = register(new StateFlag("wither-damage", true));
9798
public static final StateFlag ENDER_BUILD = register(new StateFlag("enderman-grief", true));
9899
public static final StateFlag SNOWMAN_TRAILS = register(new StateFlag("snowman-trails", true));

0 commit comments

Comments
 (0)