mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2025-01-12 19:30:48 +01:00
Don't apply USE to hanging entities.
This commit is contained in:
parent
cb0844c64d
commit
841cc8e033
@ -370,6 +370,11 @@ public void onUseEntity(UseEntityEvent event) {
|
||||
canUse = true;
|
||||
what = "use that";
|
||||
|
||||
/* Paintings, item frames, etc. */
|
||||
} else if (Entities.isConsideredBuildingIfUsed(event.getEntity())) {
|
||||
canUse = query.testBuild(target, associable);
|
||||
what = "change that";
|
||||
|
||||
/* Everything else */
|
||||
} else {
|
||||
canUse = query.testBuild(target, associable, DefaultFlag.USE);
|
||||
@ -400,6 +405,11 @@ public void onDamageEntity(DamageEntityEvent event) {
|
||||
canDamage = true;
|
||||
what = "hit that";
|
||||
|
||||
/* Paintings, item frames, etc. */
|
||||
} else if (Entities.isConsideredBuildingIfUsed(event.getEntity())) {
|
||||
canDamage = query.testBuild(target, associable);
|
||||
what = "change that";
|
||||
|
||||
/* PVP */
|
||||
} else if (event.getEntity() instanceof Player && (attacker = event.getCause().getFirstPlayer()) != null && !attacker.equals(event.getEntity())) {
|
||||
Player defender = (Player) event.getEntity();
|
||||
|
@ -22,6 +22,7 @@
|
||||
import org.bukkit.entity.Ambient;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Hanging;
|
||||
import org.bukkit.entity.Monster;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
@ -149,4 +150,15 @@ public static boolean isAmbient(Entity entity) {
|
||||
return entity instanceof Ambient;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test whether using the given entity should be considered "building"
|
||||
* rather than merely using an entity.
|
||||
*
|
||||
* @param entity the entity
|
||||
* @return true if considered building
|
||||
*/
|
||||
public static boolean isConsideredBuildingIfUsed(Entity entity) {
|
||||
return entity instanceof Hanging;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user