mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2025-01-12 19:00:37 +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) {
|
public void onDamage(EntityDamageByEntityEvent event) {
|
||||||
if (listenerService.shouldCancelEvent(event)) {
|
if (listenerService.shouldCancelEvent(event)) {
|
||||||
event.setCancelled(true);
|
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) {
|
public boolean shouldCancelEvent(EntityEvent event) {
|
||||||
Entity entity = event.getEntity();
|
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)) {
|
if (entity == null || !(entity instanceof Player)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player player = (Player) entity;
|
Player player = (Player) entity;
|
||||||
return shouldCancelEvent(player);
|
return shouldCancelEvent(player);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user