What's wrong with this plugin?

Discussion in 'Plugin Development' started by SayHi2uTube, Sep 15, 2015.

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

    SayHi2uTube

  2. Offline

    mythbusterma

    @SayHi2uTube

    It would be a lot more helpful if you showed us the error.
     
  3. Offline

    teej107

    @SayHi2uTube Just show us the source code. Many things could be wrong. Did you turn on your computer?
     
  4. Offline

    adam753

    Wow what.
     
  5. Offline

    SayHi2uTube

    Code:
    package me.sayhi2utube.noloopholes;
    
    import java.util.logging.Logger;
    
    import org.bukkit.plugin.PluginDescriptionFile;
    import org.bukkit.plugin.java.JavaPlugin;
    
    import me.sayhi2utube.noloopholes.commands.About;
    import me.sayhi2utube.noloopholes.commands.Gc;
    import me.sayhi2utube.noloopholes.commands.Icanhasbukkit;
    import me.sayhi2utube.noloopholes.commands.Lag;
    import me.sayhi2utube.noloopholes.commands.Me;
    import me.sayhi2utube.noloopholes.commands.Pl;
    import me.sayhi2utube.noloopholes.commands.Plugin;
    import me.sayhi2utube.noloopholes.commands.Question;
    import me.sayhi2utube.noloopholes.commands.Ver;
    import me.sayhi2utube.noloopholes.commands.Nlversion;
    
    public class noloopholes extends JavaPlugin {
       
        public void onEnable() {
            PluginDescriptionFile pdfFile = getDescription();
            Logger logger = getLogger();
           
            getCommand("?").setExecutor(new Question());
            getCommand("pl").setExecutor(new Pl());
            getCommand("plugin").setExecutor(new Plugin());
            getCommand("ver").setExecutor(new Ver());
            getCommand("about").setExecutor(new About());
            getCommand("nlversion").setExecutor(new Nlversion());
            getCommand("me").setExecutor(new Me());
            getCommand("icanhasbukkit").setExecutor(new Icanhasbukkit());
            getCommand("me").setExecutor(new Lag());
            getCommand("gc").setExecutor(new Gc());
           
            logger.info(pdfFile.getName() + " Has Been Enabled (V." + pdfFile.getVersion() + ") ");
        }
           
        public void onDisable() {
            PluginDescriptionFile pdfFile = getDescription();
            Logger logger = Logger.getLogger("Minecraft");
               
            logger.info(pdfFile.getName() + " Has Been Disabled (V." + pdfFile.getVersion() + ") ");   
           
        }
    }
    
    
    
    That's My Main

    Code:
    package me.sayhi2utube.noloopholes.commands;
    
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    
    public class Gc implements CommandExecutor {
    
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
           
            if(label.equalsIgnoreCase("gc")){
               if (!(sender instanceof Player)) {
                sender.sendMessage("You must be a player to use this command!");
                return false;
            }
           
               Player player = (Player) sender;
               player.sendMessage(ChatColor.RED + "You expecting something else " + player.getName() + "?");
               return true;
              
            }
            return false;
        }
    
    }
    
    And then there's like 9 other ones. Basically I just changed the

    if(label.equalsIgnoreCase("gc")){

    to whatever command there is.
     
  6. Offline

    rbrick

    @SayHi2uTube so what exactly is not working? What makes you say its "not registering as a plugin". Is it throwing an error in console?
     
  7. Offline

    SkyleTyler1337

  8. Offline

    Boomer

    Its gotta be the plugin.yml as skyle points out, or the location that you include it in your package when compiling (or haven't included) most likely.

    Also, you're gunna run into problems with this;
    getCommand("me").setExecutor(new Me());
    getCommand("me").setExecutor(new Lag());
     
  9. Offline

    RoboticPlayer

    Change
    Code:
    if(label.equalsIgnoreCase(string) {
    
    }
    To
    Code:
    if (cmd.getName().equalsIgnoreCase(string) {
    
    }
    Also, why do you have a new class for every command?
     
  10. Offline

    Boomer

    cmd.getName() vs label is a best-practises thing that should be used, but, it would not prevent his plugin from working.
    Nor are all the other "you can tell he used ancient sources of plugin tutorials to make this" such as the inclusion of the plugin description file and the logging messages onenable/ondisable -- things that have been automatically handled by bukkit for 3 years now and are just redundant...
     
Thread Status:
Not open for further replies.

Share This Page