robinjam / keep-items

Bukkit plugin allowing players to keep their items and experience when they die
http://dev.bukkit.org/server-mods/keep-items
GNU General Public License v3.0
1 stars 7 forks source link

Plugin fails to start on servers running CB 1.7.2 #11

Closed robinjam closed 10 years ago

robinjam commented 10 years ago

Plugin enable fails with error:

java.lang.IllegalArgumentException: The permission keep-items.item.95 is already defined!
at org.bukkit.plugin.SimplePluginManager.addPermission(SimplePluginManager.java:578) ~[craftbukkit-1.7.2-R0.2.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
at net.robinjam.bukkit.keepitems.KeepItems.registerPermissions(KeepItems.java:79) ~[?:?]
at net.robinjam.bukkit.keepitems.KeepItems.onEnable(KeepItems.java:43) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:218) ~[craftbukkit-1.7.2-R0.2.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:457) [craftbukkit-1.7.2-R0.2.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:384) [craftbukkit-1.7.2-R0.2.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
at org.bukkit.craftbukkit.v1_7_R1.CraftServer.loadPlugin(CraftServer.java:298) [craftbukkit-1.7.2-R0.2.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
at org.bukkit.craftbukkit.v1_7_R1.CraftServer.enablePlugins(CraftServer.java:280) [craftbukkit-1.7.2-R0.2.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
at net.minecraft.server.v1_7_R1.MinecraftServer.m(MinecraftServer.java:342) [craftbukkit-1.7.2-R0.2.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
at net.minecraft.server.v1_7_R1.MinecraftServer.g(MinecraftServer.java:319) [craftbukkit-1.7.2-R0.2.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
at net.minecraft.server.v1_7_R1.MinecraftServer.a(MinecraftServer.java:275) [craftbukkit-1.7.2-R0.2.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
at net.minecraft.server.v1_7_R1.DedicatedServer.init(DedicatedServer.java:175) [craftbukkit-1.7.2-R0.2.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java:424) [craftbukkit-1.7.2-R0.2.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:617) [craftbukkit-1.7.2-R0.2.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
markhughes commented 10 years ago

Ok had a look through the code, and I have some thoughts.

First question is.. does this stop the plugin from loading?

If it does, then this can be fixed simply by putting a try { .. } catch(e) { .. } statement in.

E.g. Change:

getServer().getPluginManager().addPermission(p);

To:

try {
    getServer().getPluginManager().addPermission(p);
} catch(IllegalArgumentException e) {
    // ... already defined, so ignore ..? 
}

ALSO you could easily switch this plugin over to using Vault?

robinjam commented 10 years ago

It's a little more complicated than that, I'm afraid. Material.getId() is deprecated since the concept of item IDs is being removed in a future version of Minecraft.

For forward-compatibility the KeepItems permission system really needs to be re-written to use item names rather than item IDs, but that will also require every user of KeepItems to update their permission configuration, which is less than ideal.

This is why I haven't come up with a solution yet. Ideally, I want to allow people to keep using item IDs for now to ease the transition to the next release of KeepItems. But I don't want the plugin to break when Minecraft 1.8 comes out.

robinjam commented 10 years ago

As for Vault support... It's a possibility, but I'm not really sure how useful it'd be. Please open another issue if you wish to discuss it further.

SolarXD commented 10 years ago

I'd be more than happy to redo my permissions. Backwards compatibility isn't a big issue to me compared to a working plugin. :)

markhughes commented 10 years ago

@robinjam if you'd like I could write a small script to go through each Material and make some sort of reference system?

robinjam commented 10 years ago

I've put out a temporary fix for this issue, pending approval on BukkitDev. I'll re-visit the issue when Minecraft 1.8 comes out and the new item system has been finalised.