Plugin won't load

Discussion in 'Plugin Development' started by ZanderMan9, Jun 21, 2014.

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

    ZanderMan9

    Hey, I just made my first plugin, a very simple plugin to insert chat via command, but it won't load, and this is the error I get:
    Code:
    [12:40:47] [Server thread/ERROR]: Could not load 'plugins\ChatInsert1.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidDescriptionException: main is not defined
        at org.bukkit.plugin.PluginDescriptionFile.loadMap(PluginDescriptionFile.java:912) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        at org.bukkit.plugin.PluginDescriptionFile.<init>(PluginDescriptionFile.java:232) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:155) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:133) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        at org.bukkit.craftbukkit.v1_7_R3.CraftServer.loadPlugins(CraftServer.java:355) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        at org.bukkit.craftbukkit.v1_7_R3.CraftServer.<init>(CraftServer.java:317) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        at net.minecraft.server.v1_7_R3.PlayerList.<init>(PlayerList.java:68) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        at net.minecraft.server.v1_7_R3.DedicatedPlayerList.<init>(SourceFile:14) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        at net.minecraft.server.v1_7_R3.DedicatedServer.init(DedicatedServer.java:126) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        at net.minecraft.server.v1_7_R3.MinecraftServer.run(MinecraftServer.java:436) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
        at net.minecraft.server.v1_7_R3.ThreadServerApplication.run(SourceFile:628) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    Caused by: java.lang.NullPointerException
        at org.bukkit.plugin.PluginDescriptionFile.loadMap(PluginDescriptionFile.java:907) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-
    Here's my plugin code: http://pastebin.com/kAxQ3Hmw

    Can anyone explain this to me? I don't see much in my simple code that could be causing the issue.
     
  2. Offline

    zakarls

    ZanderMan9
    Please also post your plugin.yml
    That seems to be where the problem is
     
  3. Offline

    ZanderMan9

    OK, this issue has been fixed in the plugin.yml, but now my commands uh... don't exist lol? I may have a fix...

    OK, here's the new problem code:
    Code:java
    1. public boolean onCommand(CommandSender user, Command cmd, String label, String[] args)
    2. {
    3. if (label.equalsIgnoreCase("chatinsert") || label.equalsIgnoreCase("cins"))

    Now as this is my first time making a plugin, I'm not sure whether to use label or cmd.getName. I've tried both, and neither has worked.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  4. Offline

    zakarls

    ZanderMan9
    You have to add them to the plugin.yml
    Example:
    Code:
    name: RandomPlugin
    main: me.zakarls.Main.Path
    version: 1.0
    description: >
                Some Random Description
    commands:
      command1:
        description: Command #1
    ZanderMan9
    I always use label.equalsIgnoreCase but I think either would work.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  5. Offline

    ZanderMan9

    Really? Hm that's interesting. Thanks, and also why is it necessary to add commands to the yml...? That's a bit wierd
    EDIT: Sorry just saw your comment
     
  6. Offline

    zakarls

    ZanderMan9
    You need to add commands to the yml so the server recognizes that they are actual commands and not just other lines of code :p Its weird but thats how it works. And no problem ;)
     
  7. Offline

    ZanderMan9

    OK, all those kinks worked out, and help is working, but when I try to use the meat of it, /cins ins [message], it throws this error at me:
    Code:
    [13:09:51] [Server thread/WARN]: Unexpected exception while parsing console command "cins ins Message Message"
    org.bukkit.command.CommandException: Unhandled exception executing command 'cins' in plugin ChatInsert v1
     at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
     at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:180) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
     at org.bukkit.craftbukkit.v1_7_R3.CraftServer.dispatchCommand(CraftServer.java:701) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
     at org.bukkit.craftbukkit.v1_7_R3.CraftServer.dispatchServerCommand(CraftServer.java:688) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
     at net.minecraft.server.v1_7_R3.DedicatedServer.aB(DedicatedServer.java:296) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
     at net.minecraft.server.v1_7_R3.DedicatedServer.v(DedicatedServer.java:261) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
     at net.minecraft.server.v1_7_R3.MinecraftServer.u(MinecraftServer.java:558) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
     at net.minecraft.server.v1_7_R3.MinecraftServer.run(MinecraftServer.java:469) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
     at net.minecraft.server.v1_7_R3.ThreadServerApplication.run(SourceFile:628) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    Caused by: java.lang.NullPointerException
     at org.bukkit.ChatColor.translateAlternateColorCodes(ChatColor.java:206) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
     at me.Plugin.First.Main.onCommand(Main.java:58) ~[?:?]
     at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
     ... 8 more
    
    See OP for the code for that particular command
     
  8. Offline

    ZodiacTheories

    ZanderMan9

    Use if(cmd.getName() - it demonstrates better understanding of the Bukkit API
     
  9. Offline

    zakarls

    ZanderMan9
    Im not sure if this is a problem but where you put
    Code:
    if (user instanceof Player)
    You might have to use sender instead of user
     
  10. Offline

    ZanderMan9

    My variable for sender is user, so this shouldn't be an issue. Also, ZodiacTheories Yes, I only changed that on a sort of trial/error run. Let me post my most recent code: http://pastebin.com/cAAmePZk

    Ignore the label/cmd.getName() issue for now, I'll change that. I posted the newest one before fixing it, sorry :)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  11. Offline

    zakarls

    ZanderMan9
    Try replacing
    Code:
    String argsConjugated = null;
                                            int i = 1;
                                            while (i >= args.length)
                                            {
                                                    argsConjugated = argsConjugated + args[i] + " ";
                                                    i++;
                                            }
    with
    Code:java
    1. StringBuilder sb = new StringBuilder();
    2. for (int i = 1; i < args.length; i++) {
    3. sb.append(args[i]).append(" ");
    4. }
    5. String argsConjugated = sb.toString().trim();[/i]
     
  12. Offline

    ZanderMan9

    Ahh thank you. I didn't realize there was a function for that. Though would they not both do the same thing?
     
  13. Offline

    zakarls

    Remove the [/i] Its a glitch when pasting code.
    Im not sure if they do the same thing or not. That just seems to be where your error is.
     
  14. Offline

    ZanderMan9

    It works! Thank you all, conjugating the arguments into a string was one of my biggest difficulties. What I'd like to know is what was wrong with the method I used, so I don't make the same mistake again?
     
  15. Offline

    xTigerRebornx

    ZanderMan9 The main thing I noticed is wrong with your method is that you are trying to concat a null String (which would throw a NPE). That, and you should be using a StringBuilder instead of concating the Strings (as concatenation will make a new String everytime, making it a resource-hog)
     
    Mattkx9 likes this.
  16. Offline

    ZanderMan9

    Ah I see.
     
Thread Status:
Not open for further replies.

Share This Page