Solved My Core.java has errors that I don't know how to fix

Discussion in 'Plugin Development' started by GHOSTmarker256, Feb 23, 2017.

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

    GHOSTmarker256

    This is what I have so far, and I don't know why but where it says

    Code:
            logger.info(pdffile.getName() + " " + pdffile.getVersion() + "was enabled.");


    and

    Code:
            logger.info(pdffile.getName() + " " + pdffile.getVersion() + "was disabled.");

    it gives me an error that reads,


    "The field JavaPlugin.logger is not visible"

    Code:
    package me.Brand0n_.plugin;
    
    import org.apache.logging.log4j.Logger;
    
    import org.bukkit.plugin.Plugin;
    import org.bukkit.plugin.PluginDescriptionFile;
    import org.bukkit.plugin.java.JavaPlugin;
    
    import me.Brand0n_.plugin.command.FixCommand;
    
    public class Core extends JavaPlugin {
    
        private static Plugin plugin;
       
        public void onEnable() {
    //        plugin = this;
            PluginDescriptionFile pdffile = getDescription();
            getLogger().info("Minecraft");
            logger.info(pdffile.getName() + " " + pdffile.getVersion() + "was enabled.");
            registerCommands();
        }
        public void onDisable() {
            PluginDescriptionFile pdffile = getDescription();
            getLogger().info("Minecraft");
            logger.info(pdffile.getName() + " " + pdffile.getVersion() + "was disabled.");
        }
       
    
        private void registerCommands() {
            getCommand("fix").setExecutor(new FixCommand() );
           
        }
       
    }   
        
    Any information that you can offer will be greatly appreciated. Thank your for your time.
     
  2. Offline

    Zombie_Striker

    @GHOSTmarker256
    Please follow Java naming conventions: All package names should be lower case.

    Do you know what exactly the static modifier does to a variable and how to properly manage static objects? If you do not, don't use the static modifier. In this case, this can cause memory leaks and is most likely being used as a hack to get this instance. Remove this.

    Let me guess: You learned Bukkit from TheBcBroz? First, if you are, or learned Java/bukkit through any youtube tutorial, then stop watching them. This is a clear sign they do not know what they are doing.

    Bukkit logs your plugins for you. You do not need any of this. Remove this bit from both the onEnable and onDisable. Doing this will also fix your problem.
     
    Tecno_Wizard and mine-care like this.
  3. Offline

    GHOSTmarker256

    Last edited: Feb 24, 2017
  4. Offline

    Zombie_Striker

    @GHOSTmarker256
    If your problem has been solved, mark this thread as solved.
     
Thread Status:
Not open for further replies.

Share This Page