Solved Plugin not working! please tell me why [eclipse]

Discussion in 'Plugin Development' started by Tabbin, Jul 19, 2014.

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

    Tabbin

    So, i've been learning how to code plugins for bukkit. Heres my code.

    Code:java
    1. package me.oliversmith7.Hub;
    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 Main extends JavaPlugin{
    11.  
    12. public void onEnable() {
    13. getLogger().info("Plugin Enabled!");
    14.  
    15. }
    16.  
    17. public void onDisable() {
    18. getLogger().info("Plugin Disabled!");
    19.  
    20. }
    21.  
    22. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    23. if(sender instanceof Player) {
    24. Player player = (Player) sender;
    25. if(cmd.getName().equalsIgnoreCase("hub")) {
    26. String hub = "spawn " + player.getName();
    27. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), hub);
    28. player.sendMessage (ChatColor.GOLD + "Returning to hub!");
    29.  
    30. }
    31.  
    32. }
    33. return false;
    34. }
    35.  
    36. }
    37.  


    But when i load this up in console it says this:

    [​IMG]
     
  2. Offline

    Traks

    Your main class is me.oliversmith7.Hub.Main, not me.oliversmith7.Hub, that's the package it is in.
     
  3. Offline

    Tabbin

    I've try'd what you said, but could you explain what i need to do? Thanks!


    Btw:I try'd doing this and it failed :l (said same thing)
     
  4. Offline

    ZodiacTheories

    Tabbin

    Change your plugin.yml to look like this:

    Code:
    main: me.oliversmith7.Hub.Main
    instead of

    Code:
    main: me.oliversmith7.Hub
     
  5. Offline

    Tabbin

    Nope, not working.

    Code:
    name: Spawn2Hub
    author: oliversmith7
    version: 1
    description: Allows User to Teleport To Spawn via /hub
    main: me.oliversmith7.Hub.main
    commands:
      hub:
        description: Teleport To Hub!
     
  6. Offline

    ZodiacTheories

    Tabbin

    You did

    me.oliversmith7.Hub.main

    do

    me.oliversmith7.Hub.Main
     
  7. Offline

    Tabbin

    Hmm, it's still saying the same thing in console.


    This is what i see on eclipse:

    [​IMG]
    [​IMG]
     
  8. Offline

    ZodiacTheories

    Tabbin

    Ooh, put this then instead:

    Code:
    main: me.oliversmith7.Hub.main.Core
     
  9. Offline

    Traks

    ZodiacTheories Where did you find 'Core'?
    The package your main class is in, is me.oliversmith7.Hub.main, your main class' name is Main. So the path to your main class would be equivalent to me.oliversmith7.Hub.main.Main. So in your plugin.yml include the following
    Code:
    main: me.oliversmith7.Hub.main.Main
    You changed the package 'Main' is in by the way, in the first post it was me.oliversmith7.Hub
     
  10. Offline

    Tabbin

    So, i've done this and it says the same exact thing :

    [​IMG]
    Traks
     
  11. In your plugin.yml you have main: me.oliversmith7.Hub.main.Main
    And do you have package me.oliversmith7.Hub.main;
    In your main file?
     
  12. Offline

    Tabbin

    Yep:
    Code:
    me.oliversmith7.Hub.main
    And i got told to make it me.oliversmith7.Hub.main.Main
     
  13. Offline

    teej107

    No no no no no. Tabbin isn't getting it.

    Let me explain.
    The main: in your yml points to your JavaPlugin extended class.

    This is what the main: of your yml should look like. yourpackagename.YourClassName

    Since your package is
    Code:java
    1. me.oliversmith7.Hub;

    and your JavaPlugin extended class is named
    Code:java
    1. Main



    your main: in your yml should be "me.oliversmith7.Hub.Main" (without quotes) It is case sensitive
    You don't need to change the package name in your code, just in your yml.
     
  14. Offline

    Tabbin

    Okay, what i've done is call my package me.oliversmith7.Hub.main and then call my class name Main. So it should be
    Code:
    me.oliversmith7.Hub.main.Main
    ? But that isnt working
     
  15. makethis.png Can you make it like this?
     
  16. Offline

    teej107

    Tabbin Make sure you spelled everything right. And it is case sensitive. If that isn't working, make sure your main: in your yml is yourpackagename.YourClassName If that dosen't work refresh your project and export it again.
     
  17. Offline

    GlacialCreeper

    Uhm, eheh, not in a bad way, but are you actually saving the files (use ctrl+shift+s to save all), and then exporting the jar (replacing the old one) ? The problem should've been fixed already, so it seems you're (maybe) not exporting the jar.
     
  18. Tabbin Can you do what GlacialCreeper say?
    D0 you export the file? Replace the old file? And make sure when you export the plugin.yml exports also.
     
  19. Offline

    Tabbin

    Okay it's working now. I made it again and it worked for some reason! :)
     
  20. Okey! Nice to here!
     
  21. Offline

    GlacialCreeper

    Yay, I helped someone :D
    It worked because the server didn't recognize the new code (that was never exported)
     
  22. Offline

    ZodiacTheories

Thread Status:
Not open for further replies.

Share This Page