/com/daveblencowe/cleankraft/CleanKraft.java

https://bitbucket.org/dblencowe/cleankraft · Java · 80 lines · 66 code · 14 blank · 0 comment · 12 complexity · fa2812b43a5a08b8b8c6896c3b8b38ee MD5 · raw file

  1. package com.daveblencowe.cleankraft;
  2. import java.util.logging.Logger;
  3. import org.apache.commons.lang.StringUtils;
  4. import org.bukkit.ChatColor;
  5. import org.bukkit.command.Command;
  6. import org.bukkit.command.CommandSender;
  7. import org.bukkit.plugin.java.JavaPlugin;
  8. public class CleanKraft extends JavaPlugin {
  9. final static String PLUGIN_NAME = "CleanKraft";
  10. final static String AUTHOR = "dblencowe";
  11. final static String VERSION = "1.0";
  12. public static Logger log = Logger.getLogger("Minecraft");
  13. public static ChatListener chatlistener = null;
  14. @Override
  15. public void onEnable () {
  16. Config.loadConfig(this);
  17. chatlistener = new ChatListener(this);
  18. log.info(PLUGIN_NAME+" "+VERSION+" enabled");
  19. }
  20. @Override
  21. public void onDisable () {
  22. log.info(PLUGIN_NAME+" "+VERSION+" disabled");
  23. }
  24. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
  25. if (cmd.getName().toLowerCase().equals("cleankraft")) {
  26. String prefix = "["+ChatColor.GREEN+CleanKraft.PLUGIN_NAME+ChatColor.WHITE+"] ";
  27. if (args.length == 0) {
  28. sender.sendMessage(prefix+CleanKraft.PLUGIN_NAME+" "+CleanKraft.VERSION+" by "+CleanKraft.AUTHOR);
  29. return true;
  30. }
  31. switch (args[0]) {
  32. case "kickweight":
  33. sender.sendMessage(prefix+"Current kick weight is "+Config.kickWeight);
  34. break;
  35. case "add":
  36. if (sender.hasPermission("cleankraft.add")) {
  37. Config.addWord(this, args[1]);
  38. sender.sendMessage(prefix+"Added word to list");
  39. } else sender.sendMessage(Config.permissionDenied);
  40. break;
  41. case "remove":
  42. if (sender.hasPermission("cleankraft.remove")) {
  43. Config.removeWord(this, args[1]);
  44. sender.sendMessage(prefix+"Removed word from list");
  45. } else sender.sendMessage(Config.permissionDenied);
  46. break;
  47. case "list":
  48. if (sender.hasPermission("cleankraft.list")) {
  49. String words = StringUtils.join(Config.naughtyWords, ", ");
  50. sender.sendMessage(prefix+words);
  51. } else sender.sendMessage(Config.permissionDenied);
  52. break;
  53. case "reload":
  54. if (sender.hasPermission("cleankraft.reload")) {
  55. Config.loadConfig(this);
  56. sender.sendMessage(prefix+"Reloaded from configuration file");
  57. } else sender.sendMessage(Config.permissionDenied);
  58. default:
  59. sender.sendMessage(prefix+CleanKraft.PLUGIN_NAME+" "+CleanKraft.VERSION+" by "+CleanKraft.AUTHOR);
  60. break;
  61. }
  62. return true;
  63. }
  64. return false;
  65. }
  66. }