mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-23 00:21:26 +01:00
[trunk] Monster don't target players.
new config: protect.prevent.entitytarget new permission: essentials.protect.entitytarget.bypass git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1145 e251c2fe-e539-e718-e476-b85c1f46cddb
This commit is contained in:
parent
5dcb5e02fb
commit
79bd8d0b2c
@ -304,6 +304,9 @@ protect:
|
||||
creeper-explosion: false
|
||||
creeper-playerdamage: false
|
||||
creeper-blockdamage: false
|
||||
# Monsters won't follow players
|
||||
# permission essentials.protect.entitytarget.bypass disables this
|
||||
entity-target: false
|
||||
# Prevent the spawning of creatures
|
||||
spawn:
|
||||
creeper: false
|
||||
|
@ -55,6 +55,7 @@ public class EssentialsProtect extends JavaPlugin
|
||||
pm.registerEvent(Type.BLOCK_BURN, blockListener, Priority.Highest, this);
|
||||
pm.registerEvent(Type.ENTITY_EXPLODE, entityListener, Priority.Highest, this);
|
||||
pm.registerEvent(Type.ENTITY_DAMAGE, entityListener, Priority.Highest, this);
|
||||
pm.registerEvent(Type.ENTITY_TARGET, entityListener, Priority.Highest, this);
|
||||
pm.registerEvent(Type.BLOCK_BREAK, blockListener, Priority.Highest, this);
|
||||
pm.registerEvent(Type.CREATURE_SPAWN, entityListener, Priority.Highest, this);
|
||||
|
||||
|
@ -27,6 +27,8 @@ import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.EntityListener;
|
||||
import org.bukkit.event.entity.EntityTargetEvent;
|
||||
import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
|
||||
|
||||
|
||||
public class EssentialsProtectEntityListener extends EntityListener
|
||||
@ -234,4 +236,24 @@ public class EssentialsProtectEntityListener extends EntityListener
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityTarget(EntityTargetEvent event) {
|
||||
if (!(event.getTarget() instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
User user = User.get(event.getTarget());
|
||||
if ((event.getReason() == TargetReason.CLOSEST_PLAYER ||
|
||||
event.getReason() == TargetReason.TARGET_ATTACKED_ENTITY ||
|
||||
event.getReason() == TargetReason.PIG_ZOMBIE_TARGET) &&
|
||||
EssentialsProtect.guardSettings.get("protect.prevent.entitiytarget") &&
|
||||
!user.isAuthorized("essentials.protect.entitytarget.bypass")
|
||||
)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user