mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-12-24 17:47:38 +01:00
Fix #877
This commit is contained in:
parent
7fc195336f
commit
1e552ea4eb
@ -59,6 +59,10 @@ public class AuthMeEntityListener implements Listener {
|
||||
public void onDamage(EntityDamageByEntityEvent event) {
|
||||
if (listenerService.shouldCancelEvent(event)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (listenerService.shouldCancelEvent(event.getDamager())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,10 +44,19 @@ class ListenerService implements SettingsDependent {
|
||||
*/
|
||||
public boolean shouldCancelEvent(EntityEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
return shouldCancelEvent(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns, based on the entity associated with the event, whether or not the event should be canceled.
|
||||
*
|
||||
* @param entity the player entity to verify
|
||||
* @return true if the associated event should be canceled, false otherwise
|
||||
*/
|
||||
public boolean shouldCancelEvent(Entity entity) {
|
||||
if (entity == null || !(entity instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Player player = (Player) entity;
|
||||
return shouldCancelEvent(player);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user