#1743 Stop mobs from targetting players when not authenticated

This commit is contained in:
ljacqu
2019-06-22 20:54:01 +02:00
parent d1b6161687
commit ff2f43bdc5
3 changed files with 37 additions and 6 deletions
@@ -56,7 +56,7 @@ public class EntityListener implements Listener {
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onEntityTarget(EntityTargetEvent event) {
if (listenerService.shouldCancelEvent(event)) {
if (listenerService.shouldCancelEvent(event.getTarget())) {
event.setTarget(null);
event.setCancelled(true);
}
@@ -52,11 +52,11 @@ class ListenerService implements SettingsDependent {
* @return true if the associated event should be canceled, false otherwise
*/
public boolean shouldCancelEvent(Entity entity) {
if (entity == null || !(entity instanceof Player)) {
return false;
if (entity instanceof Player) {
Player player = (Player) entity;
return shouldCancelEvent(player);
}
Player player = (Player) entity;
return shouldCancelEvent(player);
return false;
}
/**