SilkSpawners comes with 2 ways to hook into/integrate

Variant 1
Use the custom event which is called when a spawner is changed via

  • Commands, either
    • in view distance
    • or when holding
  • Changing the spawner with a spawn egg

You can see it in action here:

Just listen to the SilkSpawnersSpawnerChangeEvent. You can get the spawner block, entityID and can cancel it or change the ID, too

public void onSpawnerChange(SilkSpawnersSpawnerChangeEvent event) {
	// Get information
	Player player = event.getPlayer();
	short entityID = event.getEntityID();
	CreatureSpawner spawner = event.getSpawner();
	Block block = event.getBlock();
	// Set new ID (pig)

Variant 2
Hook into SilkUtil.
This class handles nearly all relevant things to modify Spawners.
Hooking into it is easy!


Make sure to add depend: [SilkSpawners] or softdepend: [SilkSpawners] to your plugin.yml!

ALWAYS call SilkUtil.hookIntoSilkSpanwers() in your onEnable() method, NOT before, since SilkSpawners isn't initialized otherwise!

SilkUtil su = SilkUtil.hookIntoSilkSpanwers();

Or the more complicated way by casting the SilkSpawners instance yourself and create your own SilkUtil:

SilkUtil su = new SilkUtil(SilkSpawnersInstance);

JavaDocs are here too: JavaDocs
(currently broken due to new multi module project :/)

Maven repo




Posts Quoted:
Clear All Quotes