SHARE
TWEET

Untitled

a guest Jun 16th, 2019 60 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.  
  15. public class BanLogger implements Listener, CommandExecutor {
  16.    
  17.    
  18.     @Override
  19.     public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
  20.         Player target = Bukkit.getServer().getPlayer(args[0]);
  21.         if (cmd.getName().equalsIgnoreCase("kick")) {
  22.             if (!(args.length == 0)) {
  23.                 sender.sendMessage(ChatColor.RED + "Usage: /kick <player>");
  24.                 return true;
  25.             }
  26.             if (target == null) {
  27.                 sender.sendMessage(ChatColor.RED + "That player does not exist!");
  28.                 return true;
  29.             }
  30.             target.kickPlayer(ChatColor.RED + "Kicked by an Operator");
  31.             Bukkit.getServer().broadcastMessage(ChatColor.DARK_RED + target.getName() + ChatColor.GRAY + " has been kicked by " + ChatColor.GREEN + sender.getName());
  32.             return true;
  33.         }
  34.         if (cmd.getName().equalsIgnoreCase("ban")) {
  35.                 if (!(sender instanceof Player)) {
  36.                     sender.sendMessage(ChatColor.RED + "Please execute this command in-game!");
  37.                 }
  38.                 if (!(args.length == 0)) {
  39.                     sender.sendMessage(ChatColor.DARK_RED + "Usage: /ban <player>");
  40.                 }
  41.                 if (target == null) {
  42.                     sender.sendMessage(ChatColor.DARK_RED + "That player doesn't exist!");
  43.                 }
  44.                 Bukkit.getBanList(Type.NAME).addBan(target.getName(), "Breaking the rules", new Date(System.currentTimeMillis() + 604800000), sender.getName());
  45.                 target.kickPlayer(ChatColor.RED + "Breaking the rules");
  46.                 Bukkit.getServer().broadcastMessage(ChatColor.RED + target.getName() + ChatColor.GRAY + "has been banned by" + ChatColor.GREEN + sender.getName());
  47.                 return true;   
  48.         }
  49.         return true;
  50.     }
  51. }
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top