TempBan

Discussion in 'Plugin Development' started by badboysteee98, Apr 27, 2014.

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

    badboysteee98

    So I was wondering how to temp ban a player here is my code for the Command

    My command is for people who safezone and on the third time they login I want it to ban them for 2 hours how could I do that


    Code:java
    1. if(cmd.getName().equalsIgnoreCase("safezone")) {
    2. if(args.length < 1) {
    3. player.sendMessage(ChatColor.RED + "/safezone <player>");
    4. }
    5.  
    6. Player target = Bukkit.getServer().getPlayer(args[0]);
    7.  
    8. if(target == null) {
    9. player.sendMessage(ChatColor.RED + "Could not find player " + args[0]);
    10. }
    11.  
    12. String uuid = target.getUniqueId().toString();
    13.  
    14. if (!plugin.getConfig().contains(uuid)) {
    15. target.sendMessage(ChatColor.GOLD + "[Safezone]" + ChatColor.RED + "Warning - 1");
    16. plugin.getConfig().set(uuid, 1);
    17. plugin.saveConfig();
    18. return true;
    19. }
    20.  
    21. int l = this.plugin.getConfig().getInt(uuid);
    22.  
    23. if(l == 1) {
    24. target.kickPlayer(ChatColor.GOLD + "[Safezone] \n" + ChatColor.RED + "Warning - 2");
    25. plugin.getConfig().set(uuid, 2);
    26. plugin.saveConfig();
    27. return true;
    28. }
    29.  
    30. if(l == 2) {
    31. target.kickPlayer(ChatColor.GOLD + "[Safezone] \n" + ChatColor.RED + "Warning - 3 \n" + ChatColor.AQUA + "Banned for: 2 hours");
    32. plugin.getConfig().set(uuid, 3);
    33. plugin.saveConfig();
    34. return true;
    35. }
    36. }


    Code:
        @EventHandler
        public void onPlayerLogin(PlayerLoginEvent e) {
                String uuid = e.getPlayer().getUniqueId().toString();
               
                if (getConfig().contains(uuid) && getConfig().getInt(uuid) == 3) {
                   
                }
        }
    Need to know what goes inside the PlayerLoginEvent please

    Thank you for your help
     
Thread Status:
Not open for further replies.

Share This Page