Banning a Player

Discussion in 'Spigot Plugin Help' started by HoverTechV2, Jun 9, 2017.

  1. How do I make a command to ban a player? I am happy to say I am rapidly learning plugin development, but I do need help with this.
     
  2. Still need help with this.
     
  3. So, Glad you are learning plugin development =D So for a lot of people this is confusing because you cannot ban a player with a method.
    So what you would kick the player and save the data somewhere such as the config;
    Code (Text):
    player.kick(player.getName, "Reason");
    plugin.getConfig().setBoolean(player.getName, true);
    Then when the player joins check to see if they are banned, (By using the OnJoinEvent);
    Code (Text):
    if(plugin.getConfig().getBoolean(player.getName).equals(True){
    player.kick(player.getName(), "You are banned");
    }
    Hope I helped! =D
     
    • Optimistic Optimistic x 1
  4. Why not just use setBanned()...
     
  5. @TheBlackTeddy with setbanned() you can't only send a massage one time. If you cick him on join he get it evry time.
     
  6. It would be better to use the PlayerPreLoginEvent event
     
  7. how about Bukkit.getBanList#addBan (...)?
     
    • Like Like x 1
    • Agree Agree x 1
    • Optimistic Optimistic x 1
  8. There are undoubtedly a variety of methods that can be used to ban a player. None of them are better than eachother. Use whichever you prefer
     
  9. I think this is the best way...
     
    • Like Like x 1