Solved My plugin not work

Discussion in 'Plugin Development' started by Unfooishly, Dec 1, 2013.

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

    Unfooishly

    Hi I'm new at useing java and am still learning it. Today I was making a plugin and made a command with worked fine when I test on my server. I decided to make a second command, when I finished the and exported it, I ran the server again only this time bukkit was not able to read it. My source code that doesn't work is:
    package me.skilledseal1.hubcommands;
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;
    public class Main extends JavaPlugin {

    public void onEnable(){
    getLogger().info("Plugin Enabled");
    }
    public void onDisable(){
    getLogger().info("Plugin Disabled");
    }

    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if(sender instanceof Player) {
    Player player = (Player) sender;
    if(cmd.getName().equalsIgnoreCase("Sethub")){
    String Sethub = "Setsspawn " + player.getName();
    Bukkit.dispatchCommand(Bukkit.getConsoleSender(), Sethub);
    player.sendMessage(ChatColor.DARK_PURPLE + "Hub Set!");
    }else if(cmd.getName().equalsIgnoreCase("Hub")){
    String Hub = "Spawn " + player.getName();
    Bukkit.dispatchCommand(Bukkit.getConsoleSender(), Hub);
    player.sendMessage(ChatColor.DARK_AQUA + "Returning To Hub!");
    }
    }
    return false;
    }

    }
    O
    And the one that works is:

    package me.skilledseal1.hubcommands;
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;
    public class Main extends JavaPlugin {

    public void onEnable(){
    getLogger().info("Plugin Enabled");
    }
    public void onDisable(){
    getLogger().info("Plugin Disabled");
    }

    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if(sender instanceof Player) {
    Player player = (Player) sender;
    if(cmd.getName().equalsIgnoreCase("Hub")){
    String Hub = "Spawn " + player.getName();
    Bukkit.dispatchCommand(Bukkit.getConsoleSender(), Hub);
    player.sendMessage(ChatColor.DARK_AQUA + "Returning To Hub!");

    }

    }


    return false;
    }


    }

    Sorry not sure if I did the thread New at forum also.........
     
  2. Offline

    icewhisker

    have you put the new one in the plugin.yml
     
  3. Offline

    Sagacious_Zed Bukkit Docs

    Unfooishly How do you know that your plugin did not work? Did it display a stack trace?
     
  4. Offline

    Unfooishly



    Yes the one that doesn't work has the following:

    name: HubCommands
    author: skilledseal1
    version: 1
    description: Allows User to set up spawn via /sethub and to spawn via /hub
    main: me.skilledseal1.hubcommands.Main
    commands:
    hub:
    description: Teleport To Hub!
    sethub:
    Description: Sets hub!
     
  5. Offline

    Ghost_Zombie

    First of all its kind of unclear what you want to do in with your command, also it is hard to read your code cuz you didnt use "code" tag here.

    Hm, as far as i understand you need to set something on the specific location, then you need to use Location class.[/code]
     
  6. Offline

    HyrulesLegend

    Unfooishly Did it display an error in your console?
     
  7. Offline

    Unfooishly

    What i want make the plugin do so far is when i do /sethub it sets the server spawn and when i do /hub it take the user to spawn
    This is my plugin.yml:
    Code:
    Name: HubCommands
    Author: skilledseal1
    Version: 1.1
    Description: Takes User To Hub!
    Main: me.skilledseal1.hubcommands.main
    Commands:
    Sethub:
      Description:Sets hub!
    Hub:
      Description:Takes player to spawn!
    This is the code it:
    Code:java
    1. package me.skilledseal1.hubcommands;
    2. import org.bukkit.Bukkit;
    3. import org.bukkit.ChatColor;
    4. import org.bukkit.command.Command;
    5. import org.bukkit.command.CommandSender;
    6. import org.bukkit.entity.Player;
    7. import org.bukkit.plugin.java.JavaPlugin;
    8. public class Main extends JavaPlugin {
    9.  
    10. public void onEnable(){
    11. getLogger().info("Plugin Enabled");
    12. }
    13. public void onDisable(){
    14. getLogger().info("Plugin Disabled");
    15. }
    16.  
    17. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    18. if(sender instanceof Player) {
    19. Player player = (Player) sender;
    20. if(cmd.getName().equalsIgnoreCase("Sethub ")){
    21. String Sethub = "Setsspawn " + player.getName();
    22. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), Sethub);
    23. player.sendMessage(ChatColor.DARK_PURPLE + "Hub Set!");
    24. }else if(cmd.getName().equalsIgnoreCase("Hub ")){
    25. String Hub = "Spawn " + player.getName();
    26. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), Hub);
    27. player.sendMessage(ChatColor.DARK_AQUA + "Returning To Hub!");
    28. }
    29. }
    30. return false;
    31. }
    32.  
    33. }
    34.  
    35.  



    this is the error log
    Code:java
    1. 12/2/2013 3:21:58 PM [SEVERE] Could not load 'plugins\HubCommands1.1 (failed).jar' in folder 'plugins'
    2. 12/2/2013 3:21:58 PM org.bukkit.plugin.InvalidDescriptionException: name is not defined
    3. 12/2/2013 3:21:58 PM at org.bukkit.plugin.PluginDescriptionFile.loadMap(PluginDescriptionFile.java:801)
    4. 12/2/2013 3:21:58 PM at org.bukkit.plugin.PluginDescriptionFile.<init>(PluginDescriptionFile.java:188)
    5. 12/2/2013 3:21:58 PM at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:252)
    6. 12/2/2013 3:21:58 PM at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:132)
    7. 12/2/2013 3:21:58 PM at org.bukkit.craftbukkit.v1_6_R3.CraftServer.loadPlugins(CraftServer.java:241)
    8. 12/2/2013 3:21:58 PM at org.bukkit.craftbukkit.v1_6_R3.CraftServer.<init>(CraftServer.java:219)
    9. 12/2/2013 3:21:58 PM at net.minecraft.server.v1_6_R3.PlayerList.<init>(PlayerList.java:56)
    10. 12/2/2013 3:21:58 PM at net.minecraft.server.v1_6_R3.DedicatedPlayerList.<init>(SourceFile:11)
    11. 12/2/2013 3:21:58 PM at net.minecraft.server.v1_6_R3.DedicatedServer.init(DedicatedServer.java:107)
    12. 12/2/2013 3:21:59 PM at net.minecraft.server.v1_6_R3.MinecraftServer.run(MinecraftServer.java:393)
    13. 12/2/2013 3:21:59 PM at net.minecraft.server.v1_6_R3.ThreadServerApplication.run(SourceFile:583)
    14. 12/2/2013 3:21:59 PM Caused by: java.lang.NullPointerException
    15. 12/2/2013 3:21:59 PM at org.bukkit.plugin.PluginDescriptionFile.loadMap(PluginDescriptionFile.java:795)
    16.  
     
  8. Offline

    icewhisker

    haha found it, in the second command Sethub there is a space like this: "Sethub " when it should be "Sethub"

    wait no sorry thats not it, it's still better to remove the spaces after it, sorry.
    ok I researched it a bit and it seems that it is coming because you put the plugin.yml in the wrong place?
    it should be in the java project not in the src folder or any of the packages.

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

    sgavster

    Do you nor have .jar as the file extension?​
     
  10. Offline

    Unfooishly

    What do you mean?
     
  11. Offline

    PolarCraft

    Unfooishly He means Do you not have .jar as the file extension?

    file extension = a group of letters occurring after a period in a file name, indicating the format of the file.
    .jar = an archive file format typically used to aggregate many Java class files and associated metadata and resources into one file to distribute application software or libraries on the Java platform.

    If that is what you mean.

    Am the only that notices hes spacing for the plugin.yml is off? Also do not use caps in the plugin.yml. Also make sure to put "Main" instead of "main" for your main class.

    Code:java
    1. name: HubCommands
    2. main: me.skilledseal1.hubcommands.main
    3. version: 1.1
    4. description: Takes User To Hub!
    5. commands:
    6. sethub:
    7. description: Sets hub!
    8. hub:
    9. description: Takes player to spawn!
     
    L33m4n123 likes this.
  12. Offline

    Unfooishly

    It's not that because I fix that before you mentioned and it still doesn't work
     
  13. Offline

    beastman3226

    You are having a problem with the placement of the plugin.yml.
    In eclipse you should see your plugin.yml just lying around inside the project, not in the source (src) folder or in package. Take a snip of the contents of your .jar please.

    Also, please make sure that your compiler isn't corrupting the file (clean and build).

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

    BungeeTheCookie

    Main isn't capatalized in your plugin.yml for the main: part. It has to be me.skilledseall.hubcommands.Main. Keep in mind that the plugin.yml and java code is case sensitive.
     
    sgavster likes this.
  15. Offline

    Unfooishly

    That didn't work, I noticed a while back when look at my working code's files
     
  16. Offline

    PolarCraft

  17. Offline

    Unfooishly

    project file.JPG Is this what you need to see?
     
  18. Offline

    beastman3226

    Unfooishly Move the plugin.yml into the src folder. Compile it then it is will be all good.
     
  19. Offline

    rocket138

    Oh my god format your code. There's a button called tab, and theres a thing called line spacing...

    It's gonna come back to get you if you can't understand what's going on.
     
  20. Offline

    Unfooishly

    this what i got as an error code
    Code:
    12/3/2013 6:28:18 PM [SEVERE] Could not load 'plugins\HubCommands.jar' in folder 'plugins'
    12/3/2013 6:28:18 PM org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
    12/3/2013 6:28:18 PM at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:247)
    12/3/2013 6:28:18 PM at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:132)
    12/3/2013 6:28:19 PM at org.bukkit.craftbukkit.v1_6_R3.CraftServer.loadPlugins(CraftServer.java:241)
    12/3/2013 6:28:19 PM at org.bukkit.craftbukkit.v1_6_R3.CraftServer.<init>(CraftServer.java:219)
    12/3/2013 6:28:19 PM at net.minecraft.server.v1_6_R3.PlayerList.<init>(PlayerList.java:56)
    12/3/2013 6:28:19 PM at net.minecraft.server.v1_6_R3.DedicatedPlayerList.<init>(SourceFile:11)
    12/3/2013 6:28:19 PM at net.minecraft.server.v1_6_R3.DedicatedServer.init(DedicatedServer.java:107)
    12/3/2013 6:28:19 PM at net.minecraft.server.v1_6_R3.MinecraftServer.run(MinecraftServer.java:393)
    12/3/2013 6:28:19 PM at net.minecraft.server.v1_6_R3.ThreadServerApplication.run(SourceFile:583)
    12/3/2013 6:28:19 PM Caused by: java.io.FileNotFoundException: Jar does not contain plugin.yml
    12/3/2013 6:28:19 PM ... 9 more
    
    fixed it i had to delete the description because for some reason bukkit couldn't read it.... Thank you all for your help. :)[diamond]

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
Thread Status:
Not open for further replies.

Share This Page