Multiple onEnable?

Discussion in 'Plugin Development' started by qaman6, Aug 26, 2013.

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

    qaman6

    How can I have multiple things onEnable? Here's what I have

    Code:
    package net.minestrosity.Zombieton;
     
    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 Main extends JavaPlugin{
       
        public void onEnable() {
            getLogger().info(ChatColor.AQUA + "Zombieton created by ElvisPigsley has been successfully enabled!");
            ArenaManager.getInstance().setup();
           
        }
       
        public void onDisable() {
            getLogger().info(ChatColor.RED + "Recieved stop command! Zombieton has been successfully disabled!");
        }
       
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            if(sender instanceof Player) {
                Player player = (Player) sender;
                if(cmd.getName().equalsIgnoreCase("zvs help")) {
                if(player.hasPermission("zvs.help")) {
                    player.sendMessage(ChatColor.BOLD + "Zombieton, for lack of a better name, is created by ElvisPigsley! type /zvs help 2 for a list of commands!");
                } else {
                    player.sendMessage(ChatColor.RED + "You don't have permission to do that!");
                }
                if(cmd.getName().equalsIgnoreCase("zvs help 2")) {   
                if(player.hasPermission("zvs.help.2")) {
                    player.sendMessage(ChatColor.BOLD + "To join a team, type /zvs join <team>");
                } else {
                    player.sendMessage(ChatColor.RED + "You don't have permission to do that! You need the permission: 'zvs.help.2' or 'zvs.help.*'!");
                }
                if(cmd.getName().equalsIgnoreCase("zvs help 3")) {
                if(player.hasPermission("zvs.help.3")) {
                    player.sendMessage(ChatColor.BOLD + "To go to the lobby, type /zvs lobby");
                } else {
                    player.sendMessage(ChatColor.RED + "You don't have permission to do that! You need the permissions: 'zvs.help.3' or 'zvs.help.*'!");
                            }
                        }
                    }
                }
            }
        return false;
        }
     
    }
    
    What having getLogger, and ArenaManger work if they're both just under eachother like that? Eclipse isn't giving me any errors..So..
     
  2. Offline

    metalhedd

    are you asking if it's ok to have 2 lines in a method? because, yes, and where on earth did yo get that code if you didn't already know that?
     
  3. You can have as much as you want in your onEnable() :p
     
  4. Offline

    qaman6

    metalhedd I made the code. I'm very new to java. I just did not know if it would work, or not. I'm not a leecher...
     
    metalhedd likes this.
Thread Status:
Not open for further replies.

Share This Page