Plugin to kill NPCs (villagers)

Is there a plugin to kill NPCs like villagers?

If not for Sponge then is there something for Forge?

Kill them how? With an item? Every x seconds? Prevent all of them from spawning?
Does “NPC” include just Villagers? What about animals and iron golems?

thing is, we have a pixelmon server and we loaded a map from vanilla minecraft.
I turned NPC spawning off but some NPCs still remain in the world and I have to kill them.

If you just want to kill them once you can just use /kill @e[type=Villager]

well that just kills myself.
I’m using essentials cmds, maybe command is overwritten?

Try using /minecraft:kill instead of /kill

Ok I did
/minecraft:kill @e[type=Villager]

but that did nothing, villagers are still there

1 Like

You could write a really simple plugin like so:

public void onSpawn(SpawnEntityEvent event) {
  event.filterEntities(entity -> !(entity instanceof Villager));

This will prevent any Villager entities from spawning for any reason whatsoever.

well isn’t that what NPC=false in the server preferences does?

I’m pretty sure it doesn’t. It just prevents them from being spawned naturally, but doesn’t prevent them from being loaded from existing chunks, which is what this does.