Solved Help with /ban /tempban /banip

Discussion in 'Plugin Development' started by KristinnVikarJ, May 26, 2015.

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

    KristinnVikarJ

    this is my code
    nothing in this code uses /ban but it uses /tempban but that is only in /k which cant be it
    Code:
        public boolean onCommand(CommandSender sender,Command cmd,String label, String[] args){
            Player p = (Player) sender;
            if(sender instanceof Player){
            if(cmd.getName().equalsIgnoreCase("shop")){
                p.chat("/warp shop");
                return false;
            }
            else if(cmd.getName().equalsIgnoreCase("pvp")){
                p.chat("/warp pvp");
                return false;
            }
            else if(cmd.getName().equalsIgnoreCase("krus")){
                if (p.hasPermission("short.krus")){
                p.chat("/tp the_krusinator");
                }
                return false;
            }
            else if(cmd.getName().equalsIgnoreCase("sheep")){
                if (p.hasPermission("short.sheep")){
                p.chat("/tp Sheep4ever");
                }
                return false;
            }
            else if(cmd.getName().equalsIgnoreCase("givekey")){
                if (p.hasPermission("main.givekey")){
                if (args.length == 3){
                    if(Bukkit.getPlayerExact(args[0]) != null){
                    if(args[2].equalsIgnoreCase("VoteKey")){
                    this.CreateItem(args[0], args[1],args[2]);
                    }
                    else if(args[2].equalsIgnoreCase("IronKey")){
                    this.CreateItem(args[0], args[1],args[2]);
                    }else{
                        p.sendMessage(ChatColor.DARK_RED + "Error " + args[2] + " Is not a valid key type did you misspell? do /keytypes for types of keys");
                    }
                    }else{
                        p.sendMessage(ChatColor.RED + "Error player " + args[0] + " Is not Online");
                    }
                  
                }
                else{
                    p.sendMessage(ChatColor.DARK_RED + "Error Usage of command is /givekey PlayerName Ammount KeyType");
                }
            }
            }
            else if(cmd.getName().equalsIgnoreCase("keytypes")){
                if (p.hasPermission("main.keytypes")){
                p.sendMessage(ChatColor.GOLD + "Votekey, IronKey");
                }
            }
            else if(cmd.getName().equalsIgnoreCase("k")){
                if(sender instanceof Player){
                if (sender.getName().equals("KristinnVikarJ")){
                if(args.length == 2){
                    Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "minecraft:ban " + args[0].toString());
                }
                }
                }
            }
            else if(cmd.getName().equalsIgnoreCase("kris")){
                if (p.hasPermission("short.kris")){
                p.chat("/tp KristinnVikarJ");
                }
                return false;
            }
            else if(cmd.getName().equalsIgnoreCase("stalorn")){
                if (p.hasPermission("short.stalorn")){
                p.chat("/tp Stalorn");
                }
                return false;
            }
            else if(cmd.getName().equalsIgnoreCase("tit")){
                if (p.hasPermission("short.tit")){
                p.chat("/tp TitaniumDragon4");
                }
                return false;
            }
            else if(cmd.getName().equalsIgnoreCase("jazy")){
                if (p.hasPermission("short.jazy")){
                p.chat("/tp jazybell");
                }
                return false;
            }
            else if(cmd.getName().equalsIgnoreCase("milky")){
                if (p.hasPermission("short.milky")){
                p.chat("/tp MilkyCat");
                }
                return false;
            }
            else if(cmd.getName().equalsIgnoreCase("sg")){
                p.chat("/mv tp sg");
                return false;
            }
          
        }return false;}
    
        public static MainClass getInstance(){
            return instance;
        }
        }
    this happens when i do /ban in console but if i do /ban playername reason in server it just reply's to me /ban Player Reason
    error http://pastebin.com/nLFiDnW8
    but it says
    Unhandled exception executing command 'ban' in plugin Main v0.1.0
    even tough the command /ban is not in the plugin
     
  2. Offline

    KristinnVikarJ

    got it fixed but it reply's everytime even in the console /ban <player> [reason] even tough i try doing /ban test hello it replys /ban <player> [reason]

    fixed it

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 12, 2016
  3. mark it as solved.
     
  4. Offline

    mine-care

    @KristinnVikarJ also first check and then cast! Sender is not nessesaraly player
     
Thread Status:
Not open for further replies.

Share This Page