Custom /ban Help

Discussion in 'Plugin Development' started by TRNWes_, Aug 17, 2014.

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

    TRNWes_

    Well, as from the title, I'm in need of help with this /ban command. My problem is that how am I supposed to kick the player after you run /ban on them?

    Code:java
    1. if(cmd.getName().equalsIgnoreCase("ban")) {
    2. if(sender.hasPermission("retron.staff.ban")) {
    3. if(args.length == 0) {
    4. sender.sendMessage(ChatColor.RED + "Usage: /ban <player>");
    5. } else {
    6. if(args.length == 1) {
    7. bannedFromServer.add(args[0]);
    8. sender.sendMessage(ChatColor.RED + "You have banned " + ChatColor.YELLOW + "" + args[0] + "" + ChatColor.RED + " from the server!");
    9. }
    10.  
    11. }
    12. }


    Thanks in advance,
    Wes
     
  2. Offline

    ElliottOlson

    Cast the Argument to a Player through the Bukkit.getOnlinePlayer(args[0]);. Then if the player != null, kick the player.

    You may want to ban them in the config using their UUID, so in 1.8 they can't change their name and join back.
     
  3. Offline

    _Filip

  4. Offline

    ElliottOlson

    TheSpherret What new system? It looks like he is just going to add the player to a List, which is not the best because it is cleared on Server reloads and if the player leaves. If he is creating a custom ban system and just putting their names in a config, it is best to put their UUID and then crosscheck a joining player's UUID with the results in the config to check if they are banned.
     
  5. Offline

    _Filip

    ElliottOlson the new json system when adding the player's GameProfile to the ban list.....
     
  6. Offline

    LightMC

    You need to get the player from the arguments then you need to kick them.
    Code:java
    1. Player p = Bukkit.getServer().getPlayer(args[0]);
    2. p.kickPlayer(kickMSG);
     
Thread Status:
Not open for further replies.

Share This Page