Closed SupaHam closed 9 years ago
@DarkShimy00 Without this commit, a spigot server would throw the following:
'protocol_version' is already in use
net.minecraft.util.io.netty.util.UniqueName.
net.minecraft.util.io.netty.util.AttributeKey.
com.supaham.internal.com.lenis0012.bukkit.npc.NPCNetworkManager.
com.supaham.internal.com.lenis0012.bukkit.npc.NPCFactory.
com.supaham.plugin.Plugin.onEnable(Plugin.java:76)
org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:316)
org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:332)
org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:412)
org.bukkit.craftbukkit.v1_7_R4.CraftServer.loadPlugin(CraftServer.java:476)
org.bukkit.craftbukkit.v1_7_R4.CraftServer.enablePlugins(CraftServer.java:394)
net.minecraft.server.v1_7_R4.MinecraftServer.n(MinecraftServer.java:360)
net.minecraft.server.v1_7_R4.MinecraftServer.g(MinecraftServer.java:334)
net.minecraft.server.v1_7_R4.MinecraftServer.a(MinecraftServer.java:290)
net.minecraft.server.v1_7_R4.DedicatedServer.init(DedicatedServer.java:210)
net.minecraft.server.v1_7_R4.MinecraftServer.run(MinecraftServer.java:458)
net.minecraft.server.v1_7_R4.ThreadServerApplication.run(SourceFile:628)
I'm not sure how you managed to avoid it, but that's what happens on a original spigot jar (with and without the binary patches)
As for my current reflection usage, it's not heavy at all, it reflects when the NPCNetworkManager is instantiated ONCE in the NPCFactory. As for the error above, the AttributeKey javadocs does not seem to hint anything about it, but I have no reason to lie about it.
I don't recall saying that I got a null attributeKey.
On 21/10/2014 23:13, DarkShimy00 wrote:
The previous code worked fine.
With the previous fix, if the server wasn't a Spigot server, it would simply have set the value but the server would have ignored it.
Here you use reflection which is a heavy process instead of creating a new reference to the AttributeKey. AttributeKeys can't be duplicated, it will always refer to the same no matter how many times you create a new AttributeKey. (http://netty.io/4.0/api/io/netty/util/AttributeKey.html)
If you think that getting a null attributeKey is bad, see the Netty API Reference: http://netty.io/4.0/api/io/netty/util/AttributeMap.html#attr%28io.netty.util.AttributeKey%29
— Reply to this email directly or view it on GitHub https://github.com/lenis0012/NPCFactory/pull/21#issuecomment-60007739.
This PR fixes the current master branch state to work with spigot servers. This PR also works with other implementation as it simply ignores the protocol_version setting task if spigot is not present as opposed to my #18 .
P.S. Submitting broken code doesn't help fix anything.