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>8.3.0</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
-
View User Profile
-
Send Message
Posted Nov 29, 2015How do iknow what id for what mob
-
View User Profile
-
Send Message
Posted Jun 9, 2016@Caspermartijn
http://minecraft.gamepedia.com/Data_values#Entity_IDs
-
View User Profile
-
Send Message
Posted Jul 4, 2016Can you add a way to cancel the spawner drop without using the eventhandler?
-
View User Profile
-
Send Message
Posted Jul 29, 2016@SP3NC3RXD
Can you be more precise?
-
View User Profile
-
Send Message
Posted Nov 19, 2016Would 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)?
-
View User Profile
-
Send Message
Posted Nov 20, 2016@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
-
View User Profile
-
Send Message
Posted Nov 22, 2016@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.
-
View User Profile
-
Send Message
Posted Dec 8, 2016I need all the permissions i can't find can you send me then thank you
-
View User Profile
-
Send Message
Posted Dec 22, 2016yeah...... what are the permissions then
-
View User Profile
-
Send Message
Posted Oct 16, 2017How do you get an iron and snow golem spawner
-
View User Profile
-
Send Message
Posted Dec 9, 2017What are the permissions?
-
View User Profile
-
Send Message
Posted Mar 29, 2019This needs to be updated. SilkUtil no longer exists.
-
View User Profile
-
Send Message
Posted Apr 25, 2020Page updated (April 2020)!
-
View User Profile
-
Send Message
Posted May 18, 2020WARNING - The repo has moved to https://repo.dustplanet.de/artifactory/libs-release-local !
-
View User Profile
-
Send Message
Posted Feb 6, 2021pleas 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
-
View User Profile
-
Send Message
Posted Sep 24, 2021how do you make the mobs npc
-
View User Profile
-
Send Message
Posted Dec 22, 2021In reply to s1gnet:
Out of scope for this plugin
-
View User Profile
-
Send Message
Posted Nov 24, 2022How do I let someone buy a silkspawner spawner through ShopGUIplus? Like what would the item name/material be for a cow spawner?