mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2025-01-03 15:08:02 +01:00
Split wind charge into breeze/player flags.
Player flag is build-checked (default false) and breeze flag is not (default true). Having multiple flags is ugly but if we need every bit of behavior to be manipulable this is the only way.
This commit is contained in:
parent
9dd7d7c03e
commit
679b56948f
@ -47,7 +47,6 @@
|
||||
import com.sk89q.worldguard.bukkit.util.Materials;
|
||||
import com.sk89q.worldguard.config.WorldConfiguration;
|
||||
import com.sk89q.worldguard.protection.flags.Flags;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import io.papermc.paper.event.player.PlayerOpenSignEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -68,8 +67,8 @@
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.Waterlogged;
|
||||
import org.bukkit.block.data.type.Dispenser;
|
||||
import org.bukkit.entity.AbstractWindCharge;
|
||||
import org.bukkit.entity.AreaEffectCloud;
|
||||
import org.bukkit.entity.BreezeWindCharge;
|
||||
import org.bukkit.entity.Creeper;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@ -83,6 +82,7 @@
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.entity.ThrownPotion;
|
||||
import org.bukkit.entity.WindCharge;
|
||||
import org.bukkit.entity.minecart.HopperMinecart;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
@ -328,10 +328,10 @@ public void onEntityChangeBlock(EntityChangeBlockEvent event) {
|
||||
|
||||
// Fire two events: one as BREAK and one as PLACE
|
||||
if (toType != Material.AIR && fromType != Material.AIR) {
|
||||
BreakBlockEvent breakDelagate = new BreakBlockEvent(event, cause, block);
|
||||
setDelegateEventMaterialOptions(breakDelagate, fromType, toType);
|
||||
BreakBlockEvent breakDelegate = new BreakBlockEvent(event, cause, block);
|
||||
setDelegateEventMaterialOptions(breakDelegate, fromType, toType);
|
||||
boolean denied;
|
||||
if (!(denied = Events.fireToCancel(event, breakDelagate))) {
|
||||
if (!(denied = Events.fireToCancel(event, breakDelegate))) {
|
||||
PlaceBlockEvent placeDelegate = new PlaceBlockEvent(event, cause, block.getLocation(), toType);
|
||||
setDelegateEventMaterialOptions(placeDelegate, fromType, toType);
|
||||
denied = Events.fireToCancel(event, placeDelegate);
|
||||
@ -364,7 +364,9 @@ public void onEntityKnockbackByEntity(EntityKnockbackByEntityEvent event) {
|
||||
Entity damager = event.getSourceEntity();
|
||||
|
||||
final DamageEntityEvent eventToFire = new DamageEntityEvent(event, create(damager), event.getEntity());
|
||||
if (damager instanceof AbstractWindCharge) {
|
||||
if (damager instanceof BreezeWindCharge) {
|
||||
eventToFire.getRelevantFlags().add(Flags.BREEZE_WIND_CHARGE);
|
||||
} else if (damager instanceof WindCharge) {
|
||||
eventToFire.getRelevantFlags().add(Flags.WIND_CHARGE_BURST);
|
||||
}
|
||||
Events.fireToCancel(event, eventToFire);
|
||||
|
@ -21,11 +21,11 @@
|
||||
|
||||
import com.sk89q.worldguard.protection.flags.Flags;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import org.bukkit.entity.AbstractWindCharge;
|
||||
import org.bukkit.entity.Allay;
|
||||
import org.bukkit.entity.Ambient;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.BreezeWindCharge;
|
||||
import org.bukkit.entity.Creature;
|
||||
import org.bukkit.entity.EnderCrystal;
|
||||
import org.bukkit.entity.EnderDragon;
|
||||
@ -48,6 +48,7 @@
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
import org.bukkit.entity.WindCharge;
|
||||
import org.bukkit.entity.Wither;
|
||||
import org.bukkit.entity.minecart.ExplosiveMinecart;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
@ -260,7 +261,8 @@ public static boolean isPluginSpawning(CreatureSpawnEvent.SpawnReason spawnReaso
|
||||
*/
|
||||
public static @Nonnull StateFlag getExplosionFlag(Entity entity) {
|
||||
return switch (entity) {
|
||||
case AbstractWindCharge abstractWindCharge -> Flags.WIND_CHARGE_BURST;
|
||||
case BreezeWindCharge breezeWindCharge -> Flags.BREEZE_WIND_CHARGE;
|
||||
case WindCharge windCharge -> Flags.WIND_CHARGE_BURST;
|
||||
case Firework firework -> Flags.FIREWORK_DAMAGE;
|
||||
case Fireball fireball -> Flags.GHAST_FIREBALL;
|
||||
case Wither wither -> Flags.WITHER_DAMAGE;
|
||||
|
@ -22,7 +22,6 @@
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.sk89q.worldguard.protection.flags.Flags;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Tag;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
@ -74,6 +74,7 @@ public final class Flags {
|
||||
public static final StateFlag FIREWORK_DAMAGE = register(new StateFlag("firework-damage", false));
|
||||
public static final StateFlag USE_ANVIL = register(new StateFlag("use-anvil", false));
|
||||
public static final StateFlag USE_DRIPLEAF = register(new StateFlag("use-dripleaf", false));
|
||||
public static final StateFlag WIND_CHARGE_BURST = register(new StateFlag("wind-charge-burst", false));
|
||||
|
||||
// These flags are similar to the ones above (used in tandem with BUILD),
|
||||
// but their defaults are set to TRUE because it is more user friendly.
|
||||
@ -93,7 +94,7 @@ public final class Flags {
|
||||
public static final StateFlag ENDERDRAGON_BLOCK_DAMAGE = register(new StateFlag("enderdragon-block-damage", true));
|
||||
public static final StateFlag GHAST_FIREBALL = register(new StateFlag("ghast-fireball", true));
|
||||
public static final StateFlag OTHER_EXPLOSION = register(new StateFlag("other-explosion", true));
|
||||
public static final StateFlag WIND_CHARGE_BURST = register(new StateFlag("wind-charge-burst", true));
|
||||
public static final StateFlag BREEZE_WIND_CHARGE = register(new StateFlag("breeze-charge-explosion", true));
|
||||
public static final StateFlag WITHER_DAMAGE = register(new StateFlag("wither-damage", true));
|
||||
public static final StateFlag ENDER_BUILD = register(new StateFlag("enderman-grief", true));
|
||||
public static final StateFlag SNOWMAN_TRAILS = register(new StateFlag("snowman-trails", true));
|
||||
|
Loading…
Reference in New Issue
Block a user