Skip to content

Commit

Permalink
Don't fire EntityDamageByEntityEvent when renaming (#7)
Browse files Browse the repository at this point in the history
Fixes incompatiblity with mcMMO's health bar displays
  • Loading branch information
Jikoo authored Dec 5, 2021
1 parent 861d417 commit 52498e7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ public class GriefPrevention extends JavaPlugin
//this handles data storage, like player and region data
public DataStore dataStore;

// Event handlers with common functionality
EntityEventHandler entityEventHandler;

//this tracks item stacks expected to drop which will need protection
ArrayList<PendingItemProtection> pendingItemWatchList = new ArrayList<>();

Expand Down Expand Up @@ -359,7 +362,7 @@ public void onEnable()
pluginManager.registerEvents(blockEventHandler, this);

//entity events
EntityEventHandler entityEventHandler = new EntityEventHandler(this.dataStore, this);
entityEventHandler = new EntityEventHandler(this.dataStore, this);
pluginManager.registerEvents(entityEventHandler, this);

//siege events
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1350,7 +1350,7 @@ public void onPlayerInteractEntity(PlayerInteractEntityEvent event)
if (itemInHand.getType() == Material.NAME_TAG)
{
EntityDamageByEntityEvent damageEvent = new EntityDamageByEntityEvent(player, entity, EntityDamageEvent.DamageCause.CUSTOM, 0);
instance.getServer().getPluginManager().callEvent(damageEvent);
instance.entityEventHandler.onEntityDamage(damageEvent);
if (damageEvent.isCancelled())
{
event.setCancelled(true);
Expand Down

0 comments on commit 52498e7

Please sign in to comment.