Error please help (eclipse) "First Plugin"

Discussion in 'Plugin Development' started by lucabunny77, Jun 1, 2014.

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

    Rocoty

    Yes. All the code works as well. Please do.

    The line I am after is the package line.
     
  2. Offline

    lucabunny77

    here it is: package me.lucabunny77.EasyHub;

    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 EasyHub 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.AQUA + "Returning To Hub!");
    }
    }

    return false;

    }
    }
     
  3. Offline

    Rocoty

    There is no reason for this not to work. Are you sure you are running the latest version?
     
  4. Offline

    lucabunny77

    I'm not sure this is my version:bukkit-1.7.9-R0.2-20140515.034156-1.jar I use this for the server aswell cus I upgraded is that why?
     
  5. Offline

    CXdur

    Hate to be the one who say this, but you won't get anywhere unless you learn some basic java before beginning. If you do that you can develop your skills by coding bukkit plugins etc, but you won't even get anywhere if you have problems just setting up simple packages.
     
    AoH_Ruthless likes this.
  6. Offline

    lucabunny77

    We'll he says there'd no reason why it's not working so it's not my fault ... :(
     
  7. Offline

    Shlobdon

    lucabunny77
    It seems as if you had a space where you're telling the plugin what to do with the /hub command, at: String hub = "spawn " + player.getName();

    I'm not sure if the space actually MATTERS, but we'll try it. If this doesn't work, we'll try another step in which I think it may be.

    If you haven't changed anything in the plugin, just completely paste this as your code and tell us if it works:

    Code:java
    1. package me.lucabunny77.EasyHub;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.ChatColor;
    5. import org.bukkit.command.Command;
    6. import org.bukkit.command.CommandSender;
    7. import org.bukkit.entity.Player;
    8. import org.bukkit.plugin.java.JavaPlugin;
    9.  
    10. public class EasyHub extends JavaPlugin{
    11.  
    12. public void onEnable() {
    13. getLogger().info("Plugin Enabled");
    14. }
    15.  
    16. public void onDisable() {
    17. getLogger().info("Plugin Disabled");
    18. }
    19.  
    20. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    21. if(sender instanceof Player) {
    22. Player player = (Player) sender;
    23. if(cmd.getName().equalsIgnoreCase("hub")){
    24. String hub = "spawn" + player.getName();
    25. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), hub);
    26. player.sendMessage(ChatColor.AQUA + "Returning To Hub!");
    27. }
    28. }
    29.  
    30. return false;
    31.  
    32. }
    33. }


    Copy ALL of that and HIGHLIGHT ALL of your code in that plugin in ECLIPSE and then RIGHT CLICK and LEFT CLICK PASTE.


    Then, once you have done this, click save and then right click your java project folder in the left hand side, then click export -> JAR File -> Make sure only plugin.yml is checked. Then choose the path where you want it saved and click finish. Then, test the plugin and tell us what happens. :)


    IF THERE IS AN ERROR MAKE SURE TO COPY IT AND SHOW US HERE!

    (Yes, some of you may call this spoon feeding, but I'm just helping the guy out.)
     
  8. Offline

    Rocoty

    lucabunny77 I am not saying it can't be your fault. I am saying that based on the information I have gotten from you there is no reason that it should not work. That is not to say that nothing wrong on your end that I do not know.

    I think the space was supposed to be there.........

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

    lucabunny77

    No I was telling him that :)

    Yea because it would of said a error cus I watched a vid and copyed what he did.



    Ok thx but where do you want me to paste it on the second line that you left empty like 2:
    but

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jul 1, 2016
  10. Offline

    Shlobdon

    Rocoty , lucabunny77 Ahhh, the space is suppose to be there? My bad.. :p

    What's happening when you run the plugin? Does the plugin just NOT work? Or are there errors in the console?
    lucabunny77

    Actually, do this for me. RIGHT after this code:
    Code:java
    1. player.sendMessage(ChatColor.AQUA + "Returning To Hub!");

    Add this: getLogger().info("The plugin is running! My code for /hub is not. :(");

    When you run the plugin and are in game, type /hub and if in console it says "The plugin is running! My code for /hub is not. :(", then it's what you're asking your command to do that is not working.

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

    Rocoty

    Shlobdon The problem is the plugin is not enabling at all. Hence the error.
     
    es359 and lucabunny77 like this.
  12. Offline

    lucabunny77

    We'll it says when I start it up: could not load 'plugins/EasyHub.jar' in folder 'plugins' org.bukkit.plugin.InvalidPluginException: Cannont find main class 'me.lucabunny77.EasyHub.EasyHub'
     
  13. Offline

    Shlobdon

    OH! Your plugin.yml.

    Edit your plugin.yml to look like this:

    name: EasyHub
    main: me.lucabunny77.EasyHub.EasyHub
    version: 1.0
    command:
    hub:
    description: This will send you back to spawn.
    usage: /hub


    lucabunny77
     
  14. Offline

    lucabunny77


    Any idea how to fix?
     
  15. Offline

    Shlobdon

    Also, to create a plugin.yml, right click the folder (the java project folder) in the left hand side of Eclipse named "EasyHub" and select new -> file -> name: plugin.yml

    Then, double click it, paste what I sent you, then export the plugin. :)
     
  16. Offline

    lucabunny77

    i
    don't I make it in src folder cus that's what I done can you send me what to put in yml please. :) my package is:me.lucabunny77.EasyHub class:EasyHub project aka folder:EasyHub
     
  17. Offline

    Shlobdon

     
  18. Offline

    lucabunny77

    Ok and the yml is in the src folder that would work right?

    Shlobdon

    Ok will it still work if yml in src folder?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jul 1, 2016
  19. lucabunny77 Yes it will - proof being that your plugin.yml can be found, it's just that the main class can't be.
     
  20. Offline

    Rocoty

    lucabunny77 Yes it will. May I ask why it is you don't test for yourself? You have the code and a compiler in front of you. There is no reason that you couldn't have figured this out on your own.
     
    AdamQpzm likes this.
  21. Offline

    Shlobdon

    If your plugin doesn't work now, you need to watch this.

     
  22. Shlobdon Yes, somehow there's only one way of this problem being solved - a specific youtube video. No other possible solution unfortunately.
     
  23. Offline

    Shlobdon

    Can't tell if you're being sarcastic or not as I've been up for like 16 hours but uh that video teaches you how to setup a java project, package, class, how to make a first command, and how to setup a plugin.yml. If that doesn't help him then there's nothing I can do to help him.. lol
     
  24. Shlobdon It's just that your use of the word "need" implies that there's no other option. :p
     
  25. Offline

    lucabunny77

    I e
    Guys I watched a video that's how I'm making the plugin LOL

    Right I just tried it and guess what same error :(

    I watched a video allready not this vid a different one.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jul 1, 2016
  26. Offline

    Rocoty

    lucabunny77 If your plugin.yml points to the exact same path as your main class, there should be no problem. Are you sure you are running the latest version of your plugin?
     
  27. Offline

    lucabunny77


    I'll just go check for the latest dev build. Also is it ok if I use the same build for my server or no.?

    Oh btw I think I might know why I
    Am using a recommended build is that the problem should I be using dev build?

    Ok I'm gonna try switching jars

    Ok I found the most recent one bukkit api if this dosent work then > :(

    Didont work but you might wanna see my console there's a bit more to it. How do I copy and paste

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jul 1, 2016
  28. lucabunny77 Ooo, quintuple post. And Rocoty didn't mean the latest version of Bukkit, he meant the latest version of your own plugin. Are you using a different version to the code you've given us? Did you export it without any errors? What you could try is opening the jar file, and checking that the plugin.yml in there, and also checking that the path to the EasyHub.class is as expected.
     
  29. Offline

    lucabunny77

    Ok I'll open the jar and yes export without any errors
     
  30. Offline

    fireblast709

    lucabunny77 check if the package of the main class (+class name) matches the plugin.yml in the jar you are using
     
Thread Status:
Not open for further replies.

Share This Page