Added respawn to ArmorListener

This commit is contained in:
Auxilor 2020-11-22 11:41:47 +00:00
parent 3ea77bb1e6
commit bbc10a67ef

View File

@ -19,6 +19,7 @@ import org.bukkit.event.inventory.InventoryType.SlotType;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerItemBreakEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.inventory.ItemStack;
/**
@ -165,6 +166,17 @@ public class ArmorListener implements Listener {
Bukkit.getPluginManager().callEvent(armorEquipEvent);
}
@EventHandler
public void playerRespawnEvent(PlayerRespawnEvent e) {
Player p = e.getPlayer();
for (ItemStack i : p.getInventory().getArmorContents()) {
if (!isAirOrNull(i)) {
Bukkit.getPluginManager().callEvent(new ArmorEquipEvent(p, EquipMethod.DEATH, ArmorType.matchType(i), i, null));
// No way to cancel a death event.
}
}
}
@EventHandler
public void itemBreakEvent(PlayerItemBreakEvent e) {
ArmorType type = ArmorType.matchType(e.getBrokenItem());