Advertisement
Guest User

Untitled

a guest
Sep 27th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.99 KB | None | 0 0
  1. package io.github.thediamondpicks.bans;
  2.  
  3. import org.bukkit.Bukkit;
  4. import org.bukkit.ChatColor;
  5. import org.bukkit.command.CommandExecutor;
  6. import org.bukkit.command.CommandSender;
  7. import org.bukkit.entity.Player;
  8.  
  9. import java.util.Objects;
  10. import java.util.UUID;
  11.  
  12. import static org.bukkit.Bukkit.getPlayer;
  13.  
  14. /**
  15.  * Created by TheDiamondPicks on 28/09/2016
  16.  */
  17. public class BanCommand implements CommandExecutor {
  18.     Main main = new Main();
  19.     public boolean onCommand(CommandSender cs, org.bukkit.command.Command cmd, String command, String[] args) {
  20.         if (command.equalsIgnoreCase("ban")) {
  21.             Player s = (Player) cs;
  22.             Player p = getPlayer(args[0]);
  23.             UUID u = p.getUniqueId();
  24.             Main main = new Main();
  25.             boolean id = main.playerExists(p.toString(), u.toString());
  26.             if (!id) {
  27.                 s.sendMessage(ChatColor.RED + "That player is not in the database, please check the spelling or use /banuuid along with a UUID if you are certain.");
  28.             }
  29.             else {
  30.                 String timestamp = Long.toString(System.currentTimeMillis());
  31.                 if (args.length == 2) {
  32.                     main.execute("INSERT INTO PermBans (PLAYERNAME, UUID, BANNEDBY, REASON, DATE) VALUES ('" + p.toString() + "', '" + u.toString() + "', " + s.toString() + "', '" + args[1] + "', " + timestamp + "')");
  33.                     for (Player player : Bukkit.getOnlinePlayers()) {
  34.                         if (player.hasPermission("bans.notify")) {
  35.                             player.sendMessage("§5[J&J Bans] §f" + p.toString() + " §dwas permanently banned by §f" + s.toString() + "§d for §f" + args[1]);
  36.  
  37.                         }
  38.                     }
  39.                     if (p.isOnline()) {
  40.                         p.kickPlayer("§4§lYou have been permanently banned from the server!\n\n§cReason: " + "");
  41.                     }
  42.                 }
  43.             }
  44.         }
  45.  
  46.         return false;
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement