API

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:
https://github.com/timbru31/SilkSpawnersEcoAddon

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

@EventHandler
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 = 90)
	event.setEntityID(90);
}

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

<repository>
    <id>SilkSpawners-Repo</id>
    <url>https://ci.dustplanet.de/plugin/repository/everything/</url>
</repository>

<dependency>
<groupId>de.dustplanet</groupId>
<artifactId>SilkSpawners</artifactId>
<version>4.0.0-SNAPSHOT</version>
    <exclusions>
        <exclusion>
            <groupId>*</groupId>
            <artifactId>*</artifactId>
        </exclusion>
    </exclusions>
</dependency>

Comments

Posts Quoted:
Reply
Clear All Quotes