Having problems with loading my plugin in my server

Discussion in 'Plugin Development' started by T-bender, Nov 14, 2014.

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

    T-bender

    Hello developers,

    I have a problem while trying to run this little code:
    Code:java
    1. package me.raichubender.links;
    2.  
    3. import org.bukkit.command.Command;
    4. import org.bukkit.command.CommandSender;
    5. import org.bukkit.plugin.java.JavaPlugin;
    6.  
    7. public class main extends JavaPlugin{
    8. @Override
    9. public void onEnable() {
    10. getLogger().info("Raichu's plugin will be activated");
    11. }
    12.  
    13. @Override
    14. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    15. if (cmd.getName().equalsIgnoreCase("link")) {
    16. if (args[0].equalsIgnoreCase("banappeal")) {
    17. sender.sendMessage("[url]http://<url>/[/url]");
    18. return true;
    19. }
    20. return false;
    21. }
    22. return false;
    23. }
    24.  
    25. @Override
    26. public void onDisable() {
    27. getLogger().info("Raichu's plugin will be deactivated");
    28. }
    29.  
    30. }

    The console says that the plugin cannot be loaded. I've set up the plugin.yml succesfully.

    I also tried to compile this without maven by just creating a normal java file and using bukkit as Referenced Library. But that didn't work either.

    So, can anyone help me, or give me tips please? Thank you.
     
  2. Offline

    mine-care

    Could we see the stacktrace shown on console?
     
  3. Offline

    JordyPwner

    Check if its a player before casting
     
  4. Offline

    rete25iscool

    Why..? He never casted sender to player...
     
  5. Offline

    JordyPwner

    That is the problem ...
     
  6. Offline

    FerusGrim

    You're confused.

    He never casts CommandSender to Player, so why would he check if the CommandSender was an instanceof a Player object?
     
    teej107 and rete25iscool like this.
  7. Offline

    JordyPwner

    Oh! Sorry :p yea i was confused yea
     
  8. Offline

    Gnat008

    T-bender
    Please post both your plugin.yml and the Console stacktrace error.
     
  9. Offline

    T-bender

    Yes, you're right, sorry for the late reaction and all of you, thanks for helping me thinking.

    Anyway, here is the plugin.yml:
    Code:
    name: DDGlinks
    main: raichubender.ddglinks.main
    version: 0.1
    commands:
      link:
          description: Displays a link to the sender.
          usage: /link <link to site>
          permission: ddglinks.link
          permission-message: You don't have "ddglinks.link", ask the owner if this is an error.
    And the stacktrace error:
    (I'm sorry, since craftbukkit is no longer available and "bukkit" does not work on my pc as server jar and my server is currently running on spigot, I cannot show this yet, but I will in a moment.)
     
  10. Offline

    Gnat008

    T-bender
    The package for you main class is:
    Code:
    package me.raichubender.links;
    Whereas in your plugin.yml, the main class is in the raichubender.ddglinks.main package.
     
  11. Offline

    T-bender

    Ah thank you!
    That was the old package name, I am using a new one now, but I didn't change that.
    Thank you for your help. If I still get an error, I'll let ya know :p
     
    Gnat008 likes this.
  12. Offline

    T-bender

    Gnat008 I'm sorry, but I still don't get it to work. When I install it in my "/plugins" folder and I restart my server, it says:
    Here are my main class and plugin.yml again:

    main.java (main.class):
    Code:java
    1. package me.raichubender.links;
    2.  
    3. import org.bukkit.command.Command;
    4. import org.bukkit.command.CommandSender;
    5. import org.bukkit.plugin.java.JavaPlugin;
    6.  
    7. public class main extends JavaPlugin{
    8. @Override
    9. public void onEnable() {
    10. getLogger().info("Raichu's plugin will be activated");
    11. }
    12.  
    13. @Override
    14. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    15. if (cmd.getName().equalsIgnoreCase("link")) {
    16. if (args[0].equalsIgnoreCase("banappeal")) {
    17. sender.sendMessage("http<censored>")
    18. return true;
    19. }
    20. return false;
    21. }
    22. return false;
    23. }
    24.  
    25. @Override
    26. public void onDisable() {
    27. getLogger().info("Raichu's plugin will be deactivated");
    28. }
    29.  
    30. }


    plugin.yml:
    Code:
    name: DDGlinks
    main: me.raichubender.links.main
    version: 0.1
    commands:
      link:
          description: Displays a link
          usage: /link <link to site>
          permission: links.link
          permission-message: You don't have "links.link", please report this to the administrator if this is a bug.
    This is what I did:

    1. I saved my whole project (ctrl+shift+s)
    2. When my code was finished, I rightclicked on my project in eclipse > Maven > Update Project > Ok
    3. Rightclick on project > export
    4. I didn't change anything of the selected files, because everithing I needed was selected (plugin.yml, main.java/main.class)
    5. I saved on my desktop as "Link.jar" and clicked Finish
    6. I uploaded Link.jar to the plugins folder in my server
    7. I restarted my server and it returend that error
     
  13. Offline

    Gnat008

    T-bender
    Can you provide me the full stacktrace?
     
  14. Offline

    ColonelHedgehog

    Code:
    name: DDGlinks
    main: me.raichubender.links.main
    version: 0.1
    commands:
      link:
          description: Displays a link
          usage: /link <link to site>
          permission: links.link
          permission-message: You don't have "links.link", please report this to the administrator if this is a bug.
    The spacing here is inconsistent. Try something more like:

    Code:
    name: DDGlinks
    main: me.raichubender.links.main
    version: 0.1
    commands:
      link:
        description: Displays a link
        usage: /link <link to site>
        permission: links.link
        permission-message: You don't have "links.link", please report this to the administrator if this is a bug.
     
  15. Offline

    T-bender

    Well, as I said before, my server is running on Spigot. I tried to load this plugin on both the Bukkit server jar and Spigot, but neither of them worked.

    Here is the full stacktrace in Spigot: (I can send you the Bukkit version too if you wish, but it is not as different as this one.)

    Please ignore the countless errors, the server currently has some details not installed correctly.
    After the [...] it says that the server is loaded correctly. As you can see, WorlEdit does have some issues which can be fixed in less than a minute :p , but everything works fine, except DDGlinks.

    I saw in the errors that it is caused by the plugin.yml. I was kinda dumb not to see that the first time. [pig]
    @ColonelHedgehog already said that the spacing is not inconsistent. I used the default plugin.yml from the bukkit wiki. Let's see if his version he send me in the reply above will work. I'll reply if it does.

    Anyway, thanks.

    Please excuse my bad English, sometimes I make errors.

    Well, this is embrassing. The PC I am using now does not have Java 1.7 installed :p
    Please wait a bit longer untill I'm at home to test it on my own computer.
     
Thread Status:
Not open for further replies.

Share This Page