Solved Kind of a stupid question, but puzzling nonetheless

Discussion in 'Plugin Development' started by ColonelHedgehog, Jan 25, 2015.

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

    ColonelHedgehog

    *Ahem*

    My plugin, for whatever reason, has decided to throw me a curve-ball. When CraftBukkit launches, it says that the plugin's Main class "does not extend JavaPlugin."

    That'd be fine, if it were right. Here is the decompiled version of my Main class.

    Code:
    package com.ColonelHedgehog.MenuAPI.Core;
    
    import org.bukkit.plugin.java.*;
    import com.ColonelHedgehog.MenuAPI.Libraries.*;
    import com.ColonelHedgehog.MenuAPI.Listeners.*;
    import org.bukkit.event.*;
    import org.bukkit.plugin.*;
    
    public class MenuAPI extends JavaPlugin
    {
        public static String ANSI_RESET;
        public static String ANSI_BLACK;
        public static String ANSI_RED;
        public static String ANSI_GREEN;
        public static String ANSI_YELLOW;
        public static String ANSI_BLUE;
        public static String ANSI_PURPLE;
        public static String ANSI_CYAN;
        public static String ANSI_WHITE;
        public static String ANSI_BOLD_ON;
        public static String ANSI_BOLD_OFF;
        private static MenuAPI plugin;
        private static MenuRegistry menuRegistry;
       
        public void onEnable() {
            MenuAPI.plugin = this;
            MenuAPI.menuRegistry = new MenuRegistry();
            MenuAPI.plugin.getServer().getPluginManager().registerEvents((Listener)new MenuActions(), (Plugin)MenuAPI.plugin);
            MenuAPI.plugin.getLogger().info("Initializing " + MenuAPI.ANSI_BLUE + MenuAPI.ANSI_BOLD_ON + "Colonel" + MenuAPI.ANSI_CYAN + "Hedgehog" + MenuAPI.ANSI_RESET + MenuAPI.ANSI_BOLD_OFF + "'s " + MenuAPI.ANSI_YELLOW + "MenuAPI. All libraries loaded." + MenuAPI.ANSI_RESET);
        }
       
        public MenuRegistry getMenuRegistry() {
            return MenuAPI.menuRegistry;
        }
       
        public static MenuAPI i() {
            return MenuAPI.plugin;
        }
       
        static {
            MenuAPI.ANSI_RESET = "\u001b[0m";
            MenuAPI.ANSI_BLACK = "\u001b[30m";
            MenuAPI.ANSI_RED = "\u001b[31m";
            MenuAPI.ANSI_GREEN = "\u001b[32m";
            MenuAPI.ANSI_YELLOW = "\u001b[33m";
            MenuAPI.ANSI_BLUE = "\u001b[34m";
            MenuAPI.ANSI_PURPLE = "\u001b[35m";
            MenuAPI.ANSI_CYAN = "\u001b[36m";
            MenuAPI.ANSI_WHITE = "\u001b[37m";
            MenuAPI.ANSI_BOLD_ON = "\u001b[1m";
            MenuAPI.ANSI_BOLD_OFF = "\u001b[22m";
        }
    }
    
    I put the jar in my plugins folder through a decompiler to see if it was just my IDE, but clearly the class is extending JavaPlugin. Right? Well, not according to my console:

    Code:
    [15:33:35 ERROR]: Could not load 'plugins/MenuAPI-Bin.jar' in folder 'plugins'
    
    org.bukkit.plugin.InvalidPluginException: main class `com.ColonelHedgehog.MenuAPI.Core.MenuAPI' does not extend JavaPlugin
    Any idea (no pun intended) what's causing this problem?
     
  2. Offline

    LordVakar

    Are you sure in your plugin.yml, it refers to the main class as the one you have posted?
     
  3. Offline

    ColonelHedgehog

    Yes, I'm sure.

    Code:
    main: com.ColonelHedgehog.MenuAPI.Core.MenuAPI
    
     
  4. Offline

    mythbusterma

    @ColonelHedgehog

    Try removing the "static" block, I seem to recall having issues with that.
     
  5. Offline

    ColonelHedgehog

    That was generated by the decompiler. In reality, I just initialize the variables when I write them:

    Code:
    public static String ANSI_RESET = "\u001B[0m";
    public static String ANSI_BLACK = "\u001B[30m";
    public static String ANSI_RED = "\u001B[31m";
    public static String ANSI_GREEN = "\u001B[32m";
    public static String ANSI_YELLOW = "\u001B[33m";
    public static String ANSI_BLUE = "\u001B[34m";
    public static String ANSI_PURPLE = "\u001B[35m";
    public static String ANSI_CYAN = "\u001B[36m";
    public static String ANSI_WHITE = "\u001B[37m";
    public static String ANSI_BOLD_ON = "\u001B[1m";
    public static String ANSI_BOLD_OFF = "\u001B[22m";
    
    However, I'll try and put it in another class. Might do something.

    EDIT: Nope, nothing.

    EDIT 2: Here is my plugin.yml incase you're interested.

    Code:
    name: MenuAPI
    main: com.ColonelHedgehog.MenuAPI.Core.MenuAPI
    version: 1.0
    author: ColonelHedgehog
    description: A powerful API for creating inventory menus with both flexibility and ease.
    
     
    Last edited: Jan 25, 2015
  6. @ColonelHedgehog
    Code:
    import org.bukkit.plugin.*;
    
    import org.bukkit.plugin.java.*;

    Isn't that superfluous?

    Edit:As pointed out by Konato, apparently I'm not goodz at the javaz.

    But for your problem, I really don't know man. =/
    Are you using a dev build or something?
     
    Last edited: Jan 25, 2015
  7. Offline

    Konato_K

    @BorisTheTerrible No, importing "org.bukkit.*" will only import classes in that package, subpackages are ignored.
     
  8. Offline

    ColonelHedgehog

    Besides, that was added by the decompiler.

    Alright, well, I managed to fix it. It's the oddest thing. Something about the name of the Main class matching the project's/plugin's name threw it off. So I renamed it to "MenuAPIMain."
     
    Last edited by a moderator: Jan 25, 2015
  9. Offline

    xTrollxDudex

    @ColonelHedgehog
    Oh crap pressed enter too soon.

    Anyways, not sure if the logger parses ANSI colors? ANSI escapes do not work on windows.
     
  10. Offline

    ColonelHedgehog

    I think they work with Linux consoles, too. Presumably most server owners will be running on Linux, anyway. Although, come to think of it, MenuAPI is, after all, an API, so a lot of Windows developers will be using it.

    At any rate, it's just a little extra fun I threw in for anyone who was able to see it. I'm not sure if there is any sort of universal alternative. I certainly didn't find one when I searched it up.
     
  11. Offline

    xTrollxDudex

    ANSI becomes random characters and an [ in your windows console FYI
     
  12. Offline

    ColonelHedgehog

    Oh, really? :confused: I wonder how MassiveCore did it, then. I'll have to look into that.
     
  13. Offline

    Konato_K

    @ColonelHedgehog I'm not sure what you're trying to do, but if you want to print colors into the server console you can use ChatColor codes with Bukkit#getConsoleSender#sendMessage
     
    xTrollxDudex likes this.
  14. Offline

    ColonelHedgehog

    Ah, I see. Thank you. However, I'm not sure if this works asynchronously (I suspect it does, since most message-sending forms are thread safe).
     
  15. Offline

    Eepmageep

    Why did you decompile your class instead of giving the original?
     
  16. Offline

    ColonelHedgehog

    To clear away any doubt that it was a problem with my IDE's compiler/what it was showing vs what it was outputting. But that problem's fixed now.
     
  17. Offline

    Experminator

  18. Offline

    Konato_K

    Experminator likes this.
  19. Offline

    Experminator

    @Konato_K Development is to write a script for a program or something like that.
    A person that write it, is called 'Developer'.

    - And i know, you are kidding me.
    P.S. My english is not really good, i'm dutch.
     
  20. Offline

    Skionz

    Actually it is making something more advanced/mature, or growing something. In this case we are making a program more advanced, but the definition is not limited to us. Farmers that grow crops can be considered developers :p
     
  21. Offline

    Experminator

    @Skionz Hey Skionz! Always a answer like that! Always.. Love it! xD
     
    Skionz likes this.
  22. Offline

    ColonelHedgehog

    As much as I'm enjoying the comments in this thread, I'm going to request a lock since we're done here. :p Thanks for all the comments and help!
     
Thread Status:
Not open for further replies.

Share This Page