mirror of
https://github.com/YouHaveTrouble/Stand-in.git
synced 2026-05-12 06:26:56 +00:00
drop all items equipped and armor stand item when stand-in mannequin is killed
This commit is contained in:
@@ -3,6 +3,7 @@ package me.youhavetrouble.standin;
|
||||
import me.youhavetrouble.standin.entity.ArmorStandHandler;
|
||||
import me.youhavetrouble.standin.entity.EntityHandler;
|
||||
import me.youhavetrouble.standin.entity.MannequinHandler;
|
||||
import me.youhavetrouble.standin.stand.MiscHandlerListener;
|
||||
import me.youhavetrouble.standin.stand.StandinInteractionListener;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.entity.Entity;
|
||||
@@ -46,6 +47,7 @@ public final class StandIn extends JavaPlugin {
|
||||
});
|
||||
|
||||
getServer().getPluginManager().registerEvents(new StandinInteractionListener(this), this);
|
||||
getServer().getPluginManager().registerEvents(new MiscHandlerListener(), this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package me.youhavetrouble.standin.stand;
|
||||
|
||||
import me.youhavetrouble.standin.entity.EntityHandler;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Mannequin;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MiscHandlerListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onMannequinDeath(EntityDeathEvent event) {
|
||||
if (!(event.getEntity() instanceof Mannequin mannequin)) return;
|
||||
if (!EntityHandler.isStandinEntity(mannequin)) return;
|
||||
// Clear any default drops and drop all items equipped on the mannequin
|
||||
event.getDrops().clear();
|
||||
event.getDrops().addAll(List.of(mannequin.getEquipment().getArmorContents()));
|
||||
event.getDrops().add(mannequin.getEquipment().getItemInMainHand());
|
||||
event.getDrops().add(mannequin.getEquipment().getItemInOffHand());
|
||||
event.getDrops().add(new ItemStack(Material.ARMOR_STAND));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user