SHARE
TWEET

Untitled

a guest Jun 16th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package me.plugins.VaultCore;
  2.  
  3. import java.util.Date;
  4.  
  5. import org.bukkit.BanList.Type;
  6. import org.bukkit.Bukkit;
  7. import org.bukkit.ChatColor;
  8. import org.bukkit.command.Command;
  9. import org.bukkit.command.CommandExecutor;
  10. import org.bukkit.command.CommandSender;
  11. import org.bukkit.entity.Player;
  12. import org.bukkit.event.Listener;
  13.  
  14. public class BanLogger implements Listener, CommandExecutor {
  15.     @Override
  16.     public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
  17.         if (cmd.getName().equalsIgnoreCase("kick")) {
  18.             if (!(args.length == 0)) {
  19.                 sender.sendMessage(ChatColor.RED + "Usage: /kick <player>");
  20.                 return true;
  21.             }
  22.             Player target = Bukkit.getServer().getPlayer(args[0]);
  23.             if (target == null) {
  24.                 sender.sendMessage(ChatColor.RED + "That player does not exist!");
  25.                 return true;
  26.             }
  27.             target.kickPlayer(ChatColor.RED + "Kicked by an Operator");
  28.             Bukkit.getServer().broadcastMessage(ChatColor.DARK_RED + target.getName() + ChatColor.GRAY + " has been kicked by " + ChatColor.GREEN + sender.getName());
  29.             return true;
  30.         }
  31.         if (cmd.getName().equalsIgnoreCase("ban")) {
  32.                 if (!(sender instanceof Player)) {
  33.                     sender.sendMessage(ChatColor.RED + "Please execute this command in-game!");
  34.                 }
  35.                 if (!(args.length == 0)) {
  36.                     sender.sendMessage(ChatColor.DARK_RED + "Usage: /ban <player>");
  37.                 }
  38.                 Player target = Bukkit.getServer().getPlayer(args[0]);
  39.                 if (target == null) {
  40.                     sender.sendMessage(ChatColor.DARK_RED + "That player doesn't exist!");
  41.                 }
  42.                 Bukkit.getBanList(Type.NAME).addBan(target.getName(), "Breaking the rules", new Date(System.currentTimeMillis() + 604800000), sender.getName());
  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