Or which InteractEvent do I need for this or can it not be prevented at all? With
PlayerArmorStandManipulateEvent
you should be able to prevent that according to the Internet, but not funzt. I have already tried several different EntityEvents…
In the EntitySpawnEvent you have to query whether event.getEntity () is an instance of ArmorStand and then cancel that
I already have that in
@EventHandler
public void onPlayerInteract (PlayerInteractEvent e) {
Player p = e.getPlayer ();
if ((e.getAction () == Action.RIGHT_CLICK_BLOCK) && (p.getItemInHand (). GetType () == Material.ARMOR_STAND)) {
e.setCancelled (true);
}
written in because
@EventHandler
public void onEntitySpawn (EntitySpawnEvent e) {
if (e.getEntity () instanceof ArmorStand) {
e.setCancelled (true);
Bukkit.broadcastMessage ("§5ARMORSTANDDD");
}
}
is much longer than
… P.getItemInHand (). GetType () == Material.ARMOR_STAND
But to be honest, your idea occurred to me shortly after asking the question xD What can I say at this time
You could set a command block to always active and repeat with the command / kill @e [type = armor_stand]
@EventHandler (priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerInteract (PlayerInteractEvent e) {
Player p = e.getPlayer ();
if (Action.RIGHT_CLICK_BLOCK.equals (e.getAction ()) && Material.ARMOR_STAND.equals (p.getItemInHand (). GetType ()) {
e.setCancelled (true);
}
}
Don't forget to register the event handler, otherwise it won't work.