Advertisement
Guest User

main

a guest
Jul 30th, 2014
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.64 KB | None | 0 0
  1. package punishments;
  2.  
  3. import java.util.HashMap;
  4. import java.util.Map;
  5. import java.util.UUID;
  6. import java.util.logging.Logger;
  7.  
  8. import org.bukkit.Bukkit;
  9. import org.bukkit.ChatColor;
  10. import org.bukkit.command.Command;
  11. import org.bukkit.command.CommandSender;
  12. import org.bukkit.entity.Player;
  13. import org.bukkit.plugin.PluginDescriptionFile;
  14. import org.bukkit.plugin.PluginManager;
  15. import org.bukkit.plugin.java.JavaPlugin;
  16.  
  17.  
  18. public class main extends JavaPlugin {
  19. public final Logger logger = Logger.getLogger("Minecraft");
  20. public static main plugin;
  21. public static Map<UUID, Boolean> hash = new HashMap<UUID, Boolean>();
  22. public final events ev = new events();
  23.  
  24. public void onDisable() {
  25. PluginDescriptionFile pdfFile = this.getDescription();
  26. this.logger.info(pdfFile.getName() + " Has been disabled!");
  27. }
  28.  
  29. public void onEnable() {
  30. plugin = this;
  31. PluginDescriptionFile pdfFile = this.getDescription();
  32. this.logger.info(pdfFile.getName() + " Version: "
  33. + pdfFile.getVersion() + " Has been Enabled!");
  34. PluginManager pm = getServer().getPluginManager();
  35. pm.registerEvents(ev, this);
  36. }
  37. public static Map<UUID, Boolean> getHash() {
  38. return hash;
  39. }
  40.  
  41. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
  42. if(commandLabel.equalsIgnoreCase("punish")){
  43. Player player = (Player) sender;
  44. if(args.length == 0){
  45. player.sendMessage(ChatColor.RED + "Invalid args! type /punish <Playername>");
  46. } else if(args.length == 1){
  47. if(player.isOp()){
  48. player.sendMessage(ChatColor.RED + "Player is OP! Cannot punish that player!");
  49. } else {
  50. player.sendMessage(ChatColor.RED + "Player has been punished!");
  51. Player targetPlayer = player.getServer().getPlayer(args[0]);
  52. hash.put(targetPlayer.getUniqueId(), true);
  53. targetPlayer.sendMessage(ChatColor.RED + "You have been punished!");
  54. }
  55. } else {
  56. player.sendMessage(ChatColor.RED + "Player is not online!");
  57. }
  58. } else if(commandLabel.equalsIgnoreCase("unpunish")){
  59. Player player = (Player) sender;
  60. Player targetPlayer = player.getServer().getPlayer(args[0]);
  61. if(args.length == 0){
  62. player.sendMessage(ChatColor.RED + "Invalid Args! /unpunish <Playername>");
  63. } else if(args.length == 1){
  64. if(player.isOp()){
  65. player.sendMessage(ChatColor.RED + "Player is OP! Cannot unpunish that player!");
  66. } else {
  67. hash.remove(targetPlayer.getUniqueId());
  68. player.sendMessage(ChatColor.GREEN + "Player has been unpunished!");
  69. targetPlayer.sendMessage(ChatColor.GREEN + "You have been unpunished! You are free to go!");
  70. }
  71. }
  72. }
  73. return false;
  74. }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement