SilkTouch is a very simple to use plugin. It allows a tool with the Silk Touch enchantment to break more items! (sorry for the terrible graphic - I made it in about 40 seconds)
Configuration
The configuration file is found in config/net.redstoneore.silktouch/config.json. This is a JSON file, so be sure to run it through a JSON validator before putting it on your server.
// Should permission be required?
"requirePermission": false,
// Which blocks should SilkTouch be enabled for? (add more items at will)
"enableSilkTouchFor": [
"minecraft:mob_spawner",
"minecraft:cake"
]
Permissions
silktouch.item replacing item with the item name - e.g. silktouch.minecraft:mob_spawner
Your server can only use permissions if you have requirePermission set to true in the configuration file. If you do this only items listed in enableSilkTouchFor can be used if the player has the correct permission.
Not sure why you made a Lists class, Google’s Lists class is better; just use Lists.newArrayList. Or you could do Arrays.asList.
Also, just out of curiosity, may I inquire as to why you’re not using Configurate? Sponge gives you a default HoconConfigurationLoader, and JSON is valid HOCON syntax. If you’re dead-set on using JSON only, there’s also a JSONConfigurationLoader and GsonConfigurationLoader.
Thanks for that. This is more so a plugin for me to learn the Sponge API, sorry if it seems a bit dodgy. Didn’t even realise you could do those things - thats so awesome. Cheers
I don’t really know anything about Hocon but my Rson class is just a wrapper around Gson. I don’t really know anything about Hocon either, but my Rson class is to let me use the one standard across Basic, Bukkit, and Sponge projects. If I find a simple way to work it on both Bukkit and Sponge I’ll give it a go.
In your event listener, replace your usage of @First with @Root. @First means the first Player in the cause which can be the Player who did it or the player associated with what is happening!. Root will net you the direct cause and is the replacement for Bukkit’s PlayerPlaceBlockEvent.
Basically it’s JSON, but everything’s optional. Hell, JSON itself is valid HOCON.
Meanwhile, Configurate does not depend on Sponge, it’s @zml’s side project. You can therefore use it anywhere you wish. It supports JSON (using either Gson or Jackson), HOCON, and YAML. In fact, you can @Inject@DefaultConfig a ConfigurationLoader, which will point to your plugin’s default configuration file. It also supports easy serialization, such as:
Once again I forgot about stupid fking Markdown. I meant to say ConfigurationLoader<CommentedConfigurationNode>, but Discourse interpreted it as an HTML tag.
@Quakethorn honestly, not sure. It uses the type name and grabs the type name by going over BlockTypeRegistryModule
I have little experience with Sponge Forge mods, but I know the minecraft names use a minecraft:mob_spawner, so maybe Pixelmon uses pixelmon:healer or something?
I think it should work. Don’t know if you should ignore the case however.
HOWEVER, in you listener you split the name at the : character and use only the later part for permissions. This means that permissions will break for modded items.
The problem here is that you don’t use the domain/modid for the name. So for example if you have two mods that both add a wrench item, and they both use "<modid>:wrench", it will collide and grant permission for both wrenches, even though you might not want that. A simple fix for that is to just use the full name.
Remember, if you switch to Configurate, you can serialize/deserialize things like CatalogTypes or DataHolders directly, using systems that Sponge has already put in place.
Just letting you know I still plan to do add on the backpack feature and storing mob spawner data. I’m just waiting on the API (haven’t checked out inventory API recently, but I’m still waiting on the mob spawner portion).
Unless there is a way to easily extract and apply NBT data I haven’t found!
When I try to run your plugin here it says that there is an error due to it being invalidly named. I’m rather new to plugins and am self teaching how they work by experience mostly. Is there a way that I can fix this so that it will load the plugin?