/src/main/java/org/shinji257/aOP/aOP.java

https://bitbucket.org/shinji257/aop · Java · 86 lines · 57 code · 8 blank · 21 comment · 12 complexity · 6bd521664d032ec139acad2f69170e10 MD5 · raw file

  1. package org.shinji257.aOP;
  2. import java.util.logging.Logger;
  3. import org.bukkit.plugin.java.JavaPlugin;
  4. public class aOP extends JavaPlugin {
  5. protected final static Logger log = Logger.getLogger("Minecraft");
  6. @Override
  7. public void onDisable() {
  8. aOP.log.info(getDescription().getName() + " has been disabled.");
  9. }
  10. @Override
  11. public void onEnable() {
  12. // save default config if it doesn't exist...
  13. saveDefaultConfig();
  14. // update config... add missing options. :p
  15. updateConfig();
  16. getCommand("opme").setExecutor(new OpmeExecutor(this));
  17. getCommand("deopme").setExecutor(new DeopmeExecutor(this));
  18. getCommand("aop").setExecutor(new aOPExecutor(this));
  19. // register events
  20. getServer().getPluginManager().registerEvents(new CommandPreprocessListener(this), this);
  21. getServer().getPluginManager().registerEvents(new PlayerListener(this), this);
  22. aOP.log.info(getDescription().getName() + " has been enabled.");
  23. }
  24. public void updateConfig() {
  25. getConfig().options().copyDefaults(true);
  26. // This is the default configuration -- includes config migrations... :p
  27. if (!getConfig().contains("op.block")) {
  28. if (getConfig().contains("opblock")) {
  29. getConfig().set("op.block", getConfig().getBoolean("opblock"));
  30. getConfig().set("opblock", null);
  31. } else
  32. getConfig().set("op.block", true);
  33. }
  34. if (!getConfig().contains("op.drop")) {
  35. if (getConfig().contains("opdrop")) {
  36. getConfig().set("op.drop", getConfig().getBoolean("opdrop"));
  37. getConfig().set("opdrop", null);
  38. } else
  39. getConfig().set("op.drop", true);
  40. }
  41. if (!getConfig().contains("op.intercept")) getConfig().set("op.intercept", false);
  42. if (!getConfig().contains("op.me")) getConfig().set("op.me", true);
  43. if (!getConfig().contains("notify.enabled")) {
  44. if (getConfig().contains("notify")) {
  45. getConfig().set("notify.enabled", getConfig().getBoolean("notify"));
  46. getConfig().set("notify", null);
  47. } else
  48. getConfig().set("notify.enabled", true);
  49. }
  50. if (!getConfig().contains("notify.shownick")) {
  51. if (getConfig().contains("shownick")) {
  52. getConfig().set("notify.shownick", getConfig().getBoolean("shownick"));
  53. getConfig().set("shownick", null);
  54. } else
  55. getConfig().set("notify.shownick", true);
  56. }
  57. if (!getConfig().contains("silent")) getConfig().set("silent", false);
  58. if (!getConfig().contains("opmetrap.enabled")) getConfig().set("opmetrap.enabled", false);
  59. // New stuff for opme trap above... opme is still being worked on ofc.
  60. // Vault was added for possible functionality for opme trap...
  61. /*
  62. if (!getConfig().contains("opmetrap.teleport.enabled")) getConfig().set("opmetrap.teleport.enabled", false);
  63. if (!getConfig().contains("opmetrap.teleport.posx")) getConfig().set("opmetrap.teleport.posx", 0);
  64. if (!getConfig().contains("opmetrap.teleport.posy")) getConfig().set("opmetrap.teleport.posy", -200);
  65. if (!getConfig().contains("opmetrap.teleport.posz")) getConfig().set("opmetrap.teleport.posz", 0);
  66. if (!getConfig().contains("opmetrap.godmode")) getConfig().set("opmetrap.godmode", true);
  67. if (!getConfig().contains("opmetrap.blockchat")) getConfig().set("opmetrap.blockchat", 2);
  68. if (!getConfig().contains("opmetrap.eco.enabled")) getConfig().set("opmetrap.eco.enabled", false);
  69. if (!getConfig().contains("opmetrap.eco.cost")) getConfig().set("opmetrap.eco.cost", 50);
  70. if (!getConfig().contains("opmetrap.explosion")) getConfig().set("opmetrap.explosion", false);
  71. if (!getConfig().contains("opmetrap.lightning")) getConfig().set("opmetrap.lightning", false);
  72. if (!getConfig().contains("opmetrap.kill")) getConfig().set("opmetrap.kill", false);
  73. if (!getConfig().contains("opmetrap.kick")) getConfig().set("opmetrap.kick", false);
  74. */
  75. // Save default values to config.yml
  76. saveConfig();
  77. }
  78. }