Subcommand help

Discussion in 'Spigot Plugin Help' started by Nistua, Jun 28, 2015.

Thread Status:
Not open for further replies.
  1. This is my code, however whenever I use the command in-game, it will just show the /thimble command. No errors are shown in console when I use the command or startup the server.

    Code (Text):

    package dev.realitynetgaming.thimbleminigame;

    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.event.Listener;
    import org.bukkit.plugin.java.JavaPlugin;

    public class main extends JavaPlugin implements Listener{
     
         public void onEnable()
         {
            getLogger().info("This plugin was created by Evoster.");
           getLogger().info("This plugin has been sucessfully enabled.");
           getServer().getPluginManager().registerEvents(this, this);
         }
       
         public void onDisable()
         {
               getLogger().info("RNGDeathMessages");
                getLogger().info("This plugin was created by Evoster.");
               getLogger().info("This plugin has been sucessfully disabled.");
               getServer().getPluginManager().registerEvents(this, this);
             }
       
         public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
             Player s = (Player)sender;
             if(cmd.getName().equalsIgnoreCase("thimble")){
             if (s instanceof Player){
             if (args.length == 0 || args.length < 2){
                                        s.sendMessage("");
                                        s.sendMessage("§3§lThimle Minigame§8 Commands:");
                                        s.sendMessage("");
                                        s.sendMessage("§4* §3/thimble leaderboard");
                                        s.sendMessage("§4* §3/thimble rewards");
                                        s.sendMessage("");
                                        s.sendMessage("§8This plugin was created by §3Evoster§8.");
                                        s.sendMessage("");
             if (args[0].equalsIgnoreCase("leaderboard") || args[0].equalsIgnoreCase("rewards")){
             if (args[0].equalsIgnoreCase("leaderboard") && args.length == 2){
                                          s.sendMessage("");
                                          s.sendMessage("§3§lThimble Minigame§8 >>");
                                          s.sendMessage("§31.");
                                          s.sendMessage("§32.");
                                          s.sendMessage("§33.");
                                          s.sendMessage("§34.");
                                          s.sendMessage("§35.");
                                          s.sendMessage("§36.");
                                          s.sendMessage("§37.");
                                          s.sendMessage("§38.");
                                          s.sendMessage("§39.");
                                          s.sendMessage("§310.");
                                          s.sendMessage("");
                                      if (args[0].equalsIgnoreCase("rewards") && args.length == 2){
                                          s.sendMessage("");
                                          s.sendMessage("§3§lThimble Minigame§8 >>");
                                          s.sendMessage("§31.");
                                          s.sendMessage("§32.");
                                          s.sendMessage("§33.");
                                          s.sendMessage("§34.");
                                          s.sendMessage("§35.");
                                          s.sendMessage("§36.");
                                          s.sendMessage("§37.");
                                          s.sendMessage("§38.");
                                          s.sendMessage("§39.");
                                          s.sendMessage("§310.");
                                          s.sendMessage("");
           
               
          }
        }
    }
             }
             }
             }
            return false;
         }
    }
               
     
    #1 Nistua, Jun 28, 2015
    Last edited: Jun 28, 2015
  2. It's incomplete. You have no else's, and there's no ends to your if's..
     
    • Funny Funny x 1
  3. Well, I thought a snipet would have been good enough but I have updated with the FULL code of the plugin.
     
  4. These two lines of code are definitly wrong:
    Code (Text):
              if (s instanceof Player){
              if (args.length == 0 || args.length < 2){
    The first one must be before
    Player s = (Player)sender;
    otherwise it doesn't make any sense at all.
    The second one catches all cases that have an argument of 1 or lower, therefore your if-closes below can't work. You probably switched < and >.
    Edit: Learn to use loops, using lots of sendMessage lines of code is considered ugly code.
    Also, if you allow argument aliases in the first clause then you have to allow them in the second one, too.
     
    • Like Like x 1
  5. On your ubdisable is there a method called unregisterEvents you can call?
     
Thread Status:
Not open for further replies.