Solved InvalidPluginException error after adding NMS code to plugin

Discussion in 'Plugin Development' started by UNC00KED, Dec 11, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    UNC00KED

    The title pretty much says it tall. I threw this new code in my plugin to do a little testing on the NMS code for 1.8 titles.

    Error from logs:
    Code:
    Could not load 'plugins\OreRunner.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: java.lang.NoClassDefFoundError: net/minecraft/server/v1_8_R1/Packet
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:135) ~[spigot.jar:git-Spigot-f928e7a-f27339c]
        at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:329) ~[spigot.jar:git-Spigot-f928e7a-f27339c]
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:251) [spigot.jar:git-Spigot-f928e7a-f27339c]
        at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugins(CraftServer.java:291) [spigot.jar:git-Spigot-f928e7a-f27339c]
        at org.bukkit.craftbukkit.v1_8_R3.CraftServer.reload(CraftServer.java:740) [spigot.jar:git-Spigot-f928e7a-f27339c]
        at org.bukkit.Bukkit.reload(Bukkit.java:534) [spigot.jar:git-Spigot-f928e7a-f27339c]
        at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:25) [spigot.jar:git-Spigot-f928e7a-f27339c]
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) [spigot.jar:git-Spigot-f928e7a-f27339c]
        at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:642) [spigot.jar:git-Spigot-f928e7a-f27339c]
        at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1135) [spigot.jar:git-Spigot-f928e7a-f27339c]
        at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:970) [spigot.jar:git-Spigot-f928e7a-f27339c]
        at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:45) [spigot.jar:git-Spigot-f928e7a-f27339c]
        at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:1) [spigot.jar:git-Spigot-f928e7a-f27339c]
        at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [spigot.jar:git-Spigot-f928e7a-f27339c]
        at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_66]
        at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_66]
        at net.minecraft.server.v1_8_R3.SystemUtils.a(SystemUtils.java:19) [spigot.jar:git-Spigot-f928e7a-f27339c]
        at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:718) [spigot.jar:git-Spigot-f928e7a-f27339c]
        at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:367) [spigot.jar:git-Spigot-f928e7a-f27339c]
        at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:657) [spigot.jar:git-Spigot-f928e7a-f27339c]
        at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:560) [spigot.jar:git-Spigot-f928e7a-f27339c]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_66]
    Caused by: java.lang.NoClassDefFoundError: net/minecraft/server/v1_8_R1/Packet
        at java.lang.Class.forName0(Native Method) ~[?:1.8.0_66]
        at java.lang.Class.forName(Unknown Source) ~[?:1.8.0_66]
        at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:64) ~[spigot.jar:git-Spigot-f928e7a-f27339c]
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:131) ~[spigot.jar:git-Spigot-f928e7a-f27339c]
        ... 21 more
    Caused by: java.lang.ClassNotFoundException: net.minecraft.server.v1_8_R1.Packet
        at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:91) ~[spigot.jar:git-Spigot-f928e7a-f27339c]
        at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:86) ~[spigot.jar:git-Spigot-f928e7a-f27339c]
        at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_66]
        at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_66]
        at java.lang.Class.forName0(Native Method) ~[?:1.8.0_66]
        at java.lang.Class.forName(Unknown Source) ~[?:1.8.0_66]
        at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:64) ~[spigot.jar:git-Spigot-f928e7a-f27339c]
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:131) ~[spigot.jar:git-Spigot-f928e7a-f27339c]
        ... 21 more
    Did I put down something wrong?
    Code:
    String text = player.getName();
               
    IChatBaseComponent chatTitle = ChatSerializer.a("{\"text\": \"" + text + "\",color:" + ChatColor.GOLD.name().toLowerCase() + "}");
               
    PacketPlayOutTitle title = new PacketPlayOutTitle(EnumTitleAction.TITLE, chatTitle);
    PacketPlayOutTitle length = new PacketPlayOutTitle(5, 20, 5);
               
    ((CraftPlayer) player).getHandle().playerConnection.sendPacket(title);
    ((CraftPlayer) player).getHandle().playerConnection.sendPacket(length);
    Would appreciate some help, thanks!
     
  2. Offline

    mine-care

    I bet your imports are from a jar that is not the same version as the one on your server...
    It has to be the same version in both to work. Otherwise you can use Reflection to bypass this issue (comes with Some risks) or use other techniques ;)
     
  3. Offline

    Zombie_Striker

    These imports do not exist. Are you sure your jar file is the same as the jar file you're building your plugin with?
     
  4. Offline

    UNC00KED

    Yes! Got it. Yep, you were correct @Zombie_Striker. I was using a different jar to build with then the jar that my server is running off of. Thanks for the help guys! Never would've thought it would be that. I thought I just coded something wrong. ;)
     
  5. Offline

    Mrs. bwfctower

    timtower likes this.
Thread Status:
Not open for further replies.

Share This Page