Main class doen 't work

Discussion in 'Plugin Development' started by ramptoetsenbord, Aug 1, 2017.

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

    ramptoetsenbord

    Hello, I am making a plugin and i found out that the main class doesn 't work.
    Whenever i try to call an event it doesn 't do it.

    My main code:
    Code:
    package me.bukkit.ServerSurvival;
    
    import java.util.logging.Logger;
    
    import org.bukkit.plugin.PluginDescriptionFile;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;
    
    import me.bukkit.ServerSurvival.events.Block.BlockBreak;
    import me.bukkit.ServerSurvival.events.player.PlayerJoin;
    
    public class SurvivalServer extends JavaPlugin {
    
        public void onEnable() {
            PluginDescriptionFile pdfFile = getDescription();
            Logger logger = getLogger();
    
            registerCommands();
            registerEvents();
            registerConfig();
    
            logger.info(pdfFile.getName() + " has been enabled!, version: " + pdfFile.getVersion() + "!");
        }
    
        public void onDisable() {
    
        }
    
        public void registerCommands() {
    
        }
    
    
        public void registerEvents() {
            PluginManager pm = getServer().getPluginManager();
    
            pm.registerEvents(new PlayerJoin(), this);
            pm.registerEvents(new BlockBreak(), this);
       
        }
    
        private void registerConfig() {
    
            getConfig().options().copyDefaults(true);
            saveConfig();
    
        }
    
    }
    
    If you need the code of one of my events to just ask!
     
  2. Offline

    timtower Administrator Administrator Moderator

    Moved to plugin development
    @ramptoetsenbord
    1. Don't log your own plugins, Bukkit does this for you.
    2. Your onDisable does nothing, please remove it. Same for registerCommands
    3. Please post your full server log using http://pastebin.com
     
  3. Offline

    FrostDevStudios

    @timtower @ramptoetsenbord
    Maybe a staff member can verify this for me but i believe that there was a article on here about having .bukkit inside of your package declaration. If i remember correctly it said something about bukkit ignoring packages containing .bukkit inside of this that aren't directly from the bukkit staff.

    Is your whole plugin unresponsive, or only the main class. If your whole plugin is unresponsive, try changing your package declaration to something similar to this
    Code:
    package me.<yourusername>.<pluginname>
    For Example yours should look like this
    Code:
    package me.ramptoetsenbord.serversurvival
    If its just your event classes that do not work, we will need to see them via pastebin
     
  4. Offline

    Jeyge

    https://bukkit.org/threads/on-namespaces-please-do-not-use-bukkit-in-your-plugins.3732/ third sticky from the top.
     
    FrostDevStudios likes this.
  5. @FrostDevStudios
    Actually, 'me' is very bad practice for packages. If you don't have a website, use the country code for your country as the tld, followed by your name. You can also alternatively reverse your email address if you find that the countrycode.yourname package was taken.

    From the Java Language Specification:
     
    FrostDevStudios and Jeyge like this.
  6. Offline

    ramptoetsenbord

    Thanks y 'all!
    it works!
     
  7. Offline

    FrostDevStudios

    @AlvinB
    Good to know! When i was learning to program, I saw a-lot of tutorials that suggested using 'me' inside of your namespace (package declaration) so i assumed it was good practice. Anyways, I will no longer suggest this to anyone.

    Also,

    @ramptoetsenbord
    No problem! Please make sure you mark this thread as solved
     
    Last edited: Aug 1, 2017
Thread Status:
Not open for further replies.

Share This Page