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) event.setEntityID("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
<repository> <id>SilkSpawners-Repo</id> <url>https://repo.dustplanet.de/artifactory/libs-release-local</url> </repository>
<dependency>
<groupId>de.dustplanet</groupId>
<artifactId>silkspawners</artifactId>
<version>7.5.0</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
How do iknow what id for what mob
@Caspermartijn
http://minecraft.gamepedia.com/Data_values#Entity_IDs
Can you add a way to cancel the spawner drop without using the eventhandler?
@SP3NC3RXD
Can you be more precise?
Would there be a way for me to modify the item dropped by a SilkSpawner event (based on conditions within my plugin), and to modify the spawner placed by this (based on the item)?
@oliver276
Currently not, but I can add the possibility to set the item which should be dropped.
You can modify the entity to spawn at the place event though: https://github.com/timbru31/SilkSpawners/blob/master/src/main/java/de/dustplanet/silkspawners/listeners/SilkSpawnersBlockListener.java#L200-L208
@xGh0sTkiLLeRx
Does SilkSpawners always explicitly preserve NBT tags such as SpawnRange or SpawnCount upon being broken and replaced (y'know, with the permissions and SilkTouch)? If this is the case, I shouldn't need the API, only that SilkSpawners is also present on the server.
I need all the permissions i can't find can you send me then thank you
yeah...... what are the permissions then
How do you get an iron and snow golem spawner
What are the permissions?
This needs to be updated. SilkUtil no longer exists.
Page updated (April 2020)!
WARNING - The repo has moved to https://repo.dustplanet.de/artifactory/libs-release-local !
pleas help me, i cant get it to work. all of it resets every time i reset the server and only i (op) can mine the spawners. my friends can not and i dont know how to fix it
how do you make the mobs npc
In reply to s1gnet:
Out of scope for this plugin
How do I let someone buy a silkspawner spawner through ShopGUIplus? Like what would the item name/material be for a cow spawner?