SHARE
TWEET

Untitled

a guest Jun 16th, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package me.plugins.VaultCore;
  2.  
  3. import org.bukkit.BanList.Type;
  4. import org.bukkit.Bukkit;
  5. import org.bukkit.ChatColor;
  6. import org.bukkit.command.Command;
  7. import org.bukkit.command.CommandExecutor;
  8. import org.bukkit.command.CommandSender;
  9. import org.bukkit.entity.Player;
  10. import org.bukkit.event.Listener;
  11.  
  12.  
  13. public class BanLogger implements Listener, CommandExecutor {
  14.    
  15.    
  16.     @Override
  17.     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
  18.         Player target = Bukkit.getServer().getPlayer(args[0]);
  19.         if (cmd.getName().equalsIgnoreCase("kick")) {
  20.             if (!(args.length == 0)) {
  21.                 sender.sendMessage(ChatColor.RED + "Usage: /kick <player>");
  22.                 return true;
  23.             }
  24.             if (target == null) {
  25.                 sender.sendMessage(ChatColor.RED + "That player does not exist!");
  26.                 return true;
  27.             }
  28.             target.kickPlayer(ChatColor.RED + "Kicked by an Operator");
  29.             Bukkit.getServer().broadcastMessage(ChatColor.DARK_RED + target.getName() + ChatColor.GRAY + " has been kicked by " + ChatColor.GREEN + sender.getName());
  30.             return true;
  31.         }
  32.         if (cmd.getName().equalsIgnoreCase("ban")) {
  33.                 if (!(sender instanceof Player)) {
  34.                     sender.sendMessage(ChatColor.RED + "Please execute this command in-game!");
  35.                 }
  36.                 if (args.length == 0) {
  37.                     sender.sendMessage(ChatColor.DARK_RED + "Usage: /ban <player>");
  38.                 }
  39.                 if (target == null) {
  40.                     sender.sendMessage(ChatColor.DARK_RED + "That player doesn't exist!");
  41.                 }
  42.                 Bukkit.getBanList(Type.NAME).addBan(target, "Breaking the rules", new Date(System.currentTimeMillis() + 864000000), sender);
  43.                 target.kickPlayer(ChatColor.RED + "Breaking the rules");
  44.                 Bukkit.getServer().broadcastMessage(ChatColor.RED + target.getName() + ChatColor.GRAY + "has been banned by" + ChatColor.GREEN + sender.getName());
  45.                 return true;
  46.     }
  47.         return true;
  48.     }
  49. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top