Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-4890

EntityDeathEvent fires twice when breaking an armor stand in survival mode

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • This server is running CraftBukkit version git-Spigot-1eece4f-d203283 (MC: 1.14) (Implementing API version 1.14-R0.1-SNAPSHOT)
    • Yes

      When breaking an armor stand in survival mode, the EntityDeathEvent is triggered twice. This doesn't occur if the armor stand is broken in creative mode. This issue also doesn't occur in 1.13.

      The first time the event is run, the armor stand is still listed as having it's armor equipped. The second time the event is run, the armor stand entity is listed as empty.
       
      Example code:

      package com.minerealm;
      
      import org.bukkit.Location;
      import org.bukkit.entity.ArmorStand;
      import org.bukkit.entity.Entity;
      import org.bukkit.event.EventHandler;
      import org.bukkit.event.Listener;
      import org.bukkit.event.entity.EntityDeathEvent;
      import org.bukkit.plugin.PluginDescriptionFile;
      import org.bukkit.plugin.java.JavaPlugin;
      
      public class ArmorStandBreakExample extends JavaPlugin {
      
          protected static ArmorStandBreakExample instance;
      
          @Override
          public void onEnable() {
              instance = this;
              getServer().getPluginManager().registerEvents(new PluginListener(), this);
              PluginDescriptionFile pluginDescription = this.getDescription();
              System.out.println(pluginDescription.getName() + " version " + pluginDescription.getVersion() + " is enabled!");
          }
      
          public class PluginListener implements Listener {
      
              @EventHandler
              public void onEntityDeath(EntityDeathEvent event) {
                  Entity entity = event.getEntity();
                  if (entity instanceof ArmorStand) {
                      Location location = entity.getLocation();
                      System.out.println(System.currentTimeMillis() + " - Armor stand broken at " + location.getWorld().getName() + "/" + location.getBlockX() + "/" + location.getBlockY() + "/" + location.getBlockZ());
                  }
              }
          }
      }
      

      Output (1.14):

      [11:40:41] [Server thread/INFO]: 1557250841555 - Armor stand broken at world/-34/65/-103
      [11:40:41] [Server thread/INFO]: 1557250841555 - Armor stand broken at world/-34/65/-103

      Output (1.13):

      [11:48:21 INFO]: 1557251301318 - Armor stand broken at world/68/66/47

      Thanks!

            Unassigned Unassigned
            Intelli Intelli
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: