/src/com/ACStache/ArenaGodPlus/ArenaGodPlus.java

https://github.com/acstache/MobArenaGod · Java · 140 lines · 124 code · 16 blank · 0 comment · 22 complexity · c6331ae376f0f5b151d234ba2088bf0a MD5 · raw file

  1. package com.ACStache.ArenaGodPlus;
  2. import java.io.File;
  3. import java.util.logging.Logger;
  4. import org.bukkit.Bukkit;
  5. import org.bukkit.ChatColor;
  6. import org.bukkit.World;
  7. import org.bukkit.entity.Player;
  8. import org.bukkit.plugin.PluginDescriptionFile;
  9. import org.bukkit.plugin.PluginManager;
  10. import org.bukkit.plugin.java.JavaPlugin;
  11. import com.ACStache.ArenaGodPlus.PluginListeners.HeroesListener;
  12. import com.ACStache.ArenaGodPlus.PluginListeners.MobArenaListener;
  13. import com.ACStache.ArenaGodPlus.PluginListeners.MobDungeonListener;
  14. import com.ACStache.ArenaGodPlus.PluginListeners.PvPArenaListener;
  15. import com.ACStache.ArenaGodPlus.PluginListeners.WarListener;
  16. import com.garbagemule.MobArena.framework.ArenaMaster;
  17. import com.garbagemule.MobArena.MobArena;
  18. import com.herocraftonline.heroes.Heroes;
  19. import net.slipcor.pvparena.PVPArena;
  20. import com.tommytony.war.War;
  21. import de.kumpelblase2.mobdungeon.MobDungeonMain;
  22. public class ArenaGodPlus extends JavaPlugin
  23. {
  24. private static Logger log = Logger.getLogger("Minecraft");
  25. private static PluginDescriptionFile info;
  26. private static AGPCommandExecutor agpExecutor;
  27. private static File dir, file;
  28. public static ArenaMaster am;
  29. private static boolean foundMA = false, foundPVP = false, foundWar = false, foundMD = false;
  30. public void onEnable()
  31. {
  32. info = getDescription();
  33. agpExecutor = new AGPCommandExecutor(this);
  34. getCommand("god").setExecutor(agpExecutor);
  35. getCommand("agp").setExecutor(agpExecutor);
  36. dir = getDataFolder();
  37. file = new File(dir, "config.yml");
  38. if(!dir.exists()) {
  39. dir.mkdir();
  40. AGPConfig.loadConfig(file);
  41. }
  42. else {
  43. AGPConfig.loadConfig(file);
  44. }
  45. for(World w : Bukkit.getWorlds())
  46. for(Player p : w.getPlayers())
  47. if(AGPConfig.getPersGod(p))
  48. AGPSetter.addGod(p);
  49. setupListeners();
  50. printToConsole("v" + info.getVersion() + " Successfully Enabled! By: " + info.getAuthors(), false);
  51. }
  52. public void onDisable()
  53. {
  54. printToConsole("Sucessfully Disabled", false);
  55. }
  56. private void setupListeners()
  57. {
  58. PluginManager pm = this.getServer().getPluginManager();
  59. Heroes heroPlugin = (Heroes)pm.getPlugin("Heroes");
  60. MobArena maPlugin = (MobArena)pm.getPlugin("MobArena");
  61. PVPArena pvpPlugin = (PVPArena)pm.getPlugin("pvparena");
  62. MobDungeonMain mdPlugin = (MobDungeonMain)pm.getPlugin("MobDungeon");
  63. War warPlugin = (War)pm.getPlugin("War");
  64. pm.registerEvents(new AGPListener(), this);
  65. if(heroPlugin != null && heroPlugin.isEnabled()) {
  66. pm.registerEvents(new HeroesListener(), this);
  67. printToConsole("Found Heroes!", false);
  68. }
  69. if(maPlugin != null && maPlugin.isEnabled()) {
  70. am = maPlugin.getArenaMaster();
  71. pm.registerEvents(new MobArenaListener(this), this);
  72. foundMA = true;
  73. printToConsole("Found Mob Arena!", false);
  74. }
  75. if(pvpPlugin != null && pvpPlugin.isEnabled()) {
  76. pm.registerEvents(new PvPArenaListener(this), this);
  77. foundPVP = true;
  78. printToConsole("Found PvP Arena!", false);
  79. }
  80. if(warPlugin != null && warPlugin.isEnabled()) {
  81. pm.registerEvents(new WarListener(), this);
  82. foundWar = true;
  83. printToConsole("Found War!", false);
  84. }
  85. if(mdPlugin != null && mdPlugin.isEnabled()) {
  86. pm.registerEvents(new MobDungeonListener(this), this);
  87. foundMD = true;
  88. printToConsole("Found Mob Dungeon!", false);
  89. }
  90. }
  91. public static void printToConsole(String msg, boolean warn)
  92. {
  93. if(warn)
  94. log.warning("[" + info.getName() + "] " + msg);
  95. else
  96. log.info("[" + info.getName() + "] " + msg);
  97. }
  98. public static void printToPlayer(Player p, String msg, boolean warn)
  99. {
  100. String color = "";
  101. if(warn)
  102. color += ChatColor.RED + "";
  103. else
  104. color += ChatColor.AQUA + "";
  105. color += "[ArenaGodPlus]";
  106. p.sendMessage(color + ChatColor.WHITE + msg);
  107. }
  108. public static boolean foundMA()
  109. {
  110. return foundMA;
  111. }
  112. public static boolean foundPVP()
  113. {
  114. return foundPVP;
  115. }
  116. public static boolean foundWar()
  117. {
  118. return foundWar;
  119. }
  120. public static boolean foundMD()
  121. {
  122. return foundMD;
  123. }
  124. }