mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-27 04:55:37 +01:00
Separate vehicles and animals from INTERACT flag.
Destroying vehicles now checks only the vehicle-destroy flag. Damaging animals checks the new damage-animals flag. These are both allowed for members by default, like other build-dependent flags. Fixes WORLDGUARD-3427 and WORLDGUARD-3358.
This commit is contained in:
parent
a277e69e9c
commit
cf1716ff37
@ -693,7 +693,7 @@ public void onPlayerDropItem(PlayerDropItemEvent event) {
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onVehicleDamage(VehicleDamageEvent event) {
|
||||
Entity attacker = event.getAttacker();
|
||||
Events.fireToCancel(event, new DestroyEntityEvent(event, create(attacker), event.getVehicle()));
|
||||
Events.fireToCancel(event, new DamageEntityEvent(event, create(attacker), event.getVehicle()));
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
|
@ -390,7 +390,8 @@ public void onUseEntity(UseEntityEvent event) {
|
||||
String what;
|
||||
|
||||
/* Hostile / ambient mob override */
|
||||
if (Entities.isHostile(event.getEntity()) || Entities.isAmbient(event.getEntity()) || Entities.isNPC(event.getEntity())) {
|
||||
if (Entities.isHostile(event.getEntity()) || Entities.isAmbient(event.getEntity())
|
||||
|| Entities.isNPC(event.getEntity()) || Entities.isVehicle(event.getEntity().getType())) {
|
||||
canUse = event.getRelevantFlags().isEmpty() || query.queryState(target, associable, combine(event)) != State.DENY;
|
||||
what = "use that";
|
||||
|
||||
@ -439,7 +440,8 @@ public void onDamageEntity(DamageEntityEvent event) {
|
||||
}
|
||||
|
||||
/* Hostile / ambient mob override */
|
||||
if (Entities.isHostile(event.getEntity()) || Entities.isAmbient(event.getEntity())) {
|
||||
if (Entities.isHostile(event.getEntity()) || Entities.isAmbient(event.getEntity())
|
||||
|| Entities.isVehicle(event.getEntity().getType())) {
|
||||
canDamage = event.getRelevantFlags().isEmpty() || query.queryState(target, associable, combine(event)) != State.DENY;
|
||||
what = "hit that";
|
||||
|
||||
@ -467,6 +469,11 @@ public void onDamageEntity(DamageEntityEvent event) {
|
||||
canDamage = event.getRelevantFlags().isEmpty() || query.queryState(target, associable, combine(event)) != State.DENY;
|
||||
what = "damage that";
|
||||
|
||||
/* damage to non-hostile mobs (e.g. animals) */
|
||||
} else if (Entities.isNonHostile(event.getEntity())) {
|
||||
canDamage = query.testBuild(target, associable, combine(event, DefaultFlag.DAMAGE_ANIMALS));
|
||||
what = "harm that";
|
||||
|
||||
/* Everything else */
|
||||
} else {
|
||||
canDamage = query.testBuild(target, associable, combine(event, DefaultFlag.INTERACT));
|
||||
|
@ -133,6 +133,17 @@ public static boolean isHostile(Entity entity) {
|
||||
|| entity instanceof EnderDragon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test whether an entity is a non-hostile creature.
|
||||
*
|
||||
* @param entity
|
||||
* @return true if non-hostile
|
||||
*/
|
||||
public static boolean isNonHostile(Entity entity) {
|
||||
return !isHostile(entity)
|
||||
&& (entity instanceof Creature || entity instanceof WaterMob);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test whether an entity is ambient.
|
||||
*
|
||||
|
@ -49,6 +49,7 @@ public final class DefaultFlag {
|
||||
public static final StateFlag BLOCK_PLACE = new StateFlag("block-place", false);
|
||||
public static final StateFlag USE = new StateFlag("use", false);
|
||||
public static final StateFlag INTERACT = new StateFlag("interact", false);
|
||||
public static final StateFlag DAMAGE_ANIMALS = new StateFlag("damage-animals", false);
|
||||
public static final StateFlag PVP = new StateFlag("pvp", false);
|
||||
public static final StateFlag SLEEP = new StateFlag("sleep", false);
|
||||
public static final StateFlag TNT = new StateFlag("tnt", false);
|
||||
@ -140,7 +141,7 @@ public final class DefaultFlag {
|
||||
|
||||
public static final Flag<?>[] flagsList = new Flag<?>[] {
|
||||
PASSTHROUGH, BUILD, CONSTRUCT, BLOCK_BREAK, BLOCK_PLACE, PVP, CHEST_ACCESS, PISTONS,
|
||||
TNT, LIGHTER, RIDE, USE, INTERACT, PLACE_VEHICLE, DESTROY_VEHICLE, SLEEP,
|
||||
TNT, LIGHTER, RIDE, USE, INTERACT, PLACE_VEHICLE, DESTROY_VEHICLE, DAMAGE_ANIMALS, SLEEP,
|
||||
MOB_DAMAGE, MOB_SPAWNING, DENY_SPAWN, INVINCIBILITY, EXP_DROPS,
|
||||
CREEPER_EXPLOSION, OTHER_EXPLOSION, ENDERDRAGON_BLOCK_DAMAGE, GHAST_FIREBALL, ENDER_BUILD,
|
||||
DENY_MESSAGE, ENTRY_DENY_MESSAGE, EXIT_DENY_MESSAGE, EXIT_OVERRIDE, EXIT_VIA_TELEPORT,
|
||||
|
Loading…
Reference in New Issue
Block a user