/src/main/java/com/crimsonrpg/core/admin/CrimsonAdmin.java

https://bitbucket.org/DylanHolmes/crimsoncore · Java · 92 lines · 68 code · 13 blank · 11 comment · 0 complexity · 7d959ef99915af6f0f46a4b06bfc69ee MD5 · raw file

  1. /*1
  2. * To change this template, choose Tools | Templates
  3. * and open the template in the editor.
  4. */
  5. package com.crimsonrpg.core.admin;
  6. import com.crimsonrpg.core.CrimsonRPG;
  7. import com.crimsonrpg.core.admin.listeners.CABlockListener;
  8. import java.util.HashMap;
  9. import java.util.logging.Logger;
  10. import org.bukkit.Bukkit;
  11. import org.bukkit.event.Event.Priority;
  12. import org.bukkit.event.Event.Type;
  13. import org.bukkit.event.entity.EntityListener;
  14. import org.bukkit.event.player.PlayerListener;
  15. import org.bukkit.plugin.PluginManager;
  16. import com.crimsonrpg.core.admin.commands.CommandBring;
  17. import com.crimsonrpg.core.admin.commands.CommandClear;
  18. import com.crimsonrpg.core.admin.commands.CommandCustomBlock;
  19. import com.crimsonrpg.core.admin.commands.CommandCustomItem;
  20. import com.crimsonrpg.core.admin.commands.CommandFakeGameMode;
  21. import com.crimsonrpg.core.admin.commands.CommandForceLoad;
  22. import com.crimsonrpg.core.admin.commands.CommandForceSave;
  23. import com.crimsonrpg.core.admin.commands.CommandGetPos;
  24. import com.crimsonrpg.core.admin.commands.CommandHelp;
  25. import com.crimsonrpg.core.admin.commands.CommandItem;
  26. import com.crimsonrpg.core.admin.commands.CommandSetSpawn;
  27. import com.crimsonrpg.core.admin.commands.CommandSun;
  28. import com.crimsonrpg.core.admin.commands.CommandTeleport;
  29. import com.crimsonrpg.core.admin.commands.CommandTeleportPosition;
  30. import com.crimsonrpg.core.admin.listeners.CAEntityListener;
  31. import com.crimsonrpg.core.admin.listeners.CAPlayerListener;
  32. import com.crimsonrpg.util.CrimsonCommand;
  33. import org.bukkit.event.block.BlockListener;
  34. import org.getspout.spoutapi.SpoutManager;
  35. /**
  36. * The CrimsonAdmin plugin.
  37. */
  38. public class CrimsonAdmin {
  39. public static final Logger LOGGER = Logger.getLogger("Minecraft");
  40. private CrimsonRPG crimson;
  41. public CrimsonAdmin(CrimsonRPG plugin) {
  42. super();
  43. this.crimson = plugin;
  44. }
  45. public void onDisable() {
  46. LOGGER.info("[CrimsonAdmin] Plugin disabled.");
  47. }
  48. public void onEnable() {
  49. HashMap<String, CrimsonCommand> commands = new HashMap<String, CrimsonCommand>();
  50. commands.put("bring", new CommandBring());
  51. commands.put("customitem", new CommandCustomItem());
  52. commands.put("fakegamemode", new CommandFakeGameMode());
  53. commands.put("forceload", new CommandForceLoad());
  54. // commands.put("forcesave", new CommandForceReload(this));
  55. commands.put("forcesave", new CommandForceSave());
  56. commands.put("getpos", new CommandGetPos());
  57. commands.put("item", new CommandItem());
  58. commands.put("teleport", new CommandTeleport());
  59. commands.put("tpos", new CommandTeleportPosition());
  60. commands.put("setspawn", new CommandSetSpawn());
  61. // commands.put("spawn", new CommandSpawn());
  62. commands.put("customblock", new CommandCustomBlock());
  63. commands.put("clearinventory", new CommandClear());
  64. commands.put("sun", new CommandSun());
  65. commands.put("help", new CommandHelp());
  66. CrimsonCommand.registerAll(commands, crimson);
  67. EntityListener entityListener = new CAEntityListener(crimson);
  68. PlayerListener playerListener = new CAPlayerListener(crimson);
  69. BlockListener blockListener = new CABlockListener(crimson);
  70. //Registers the events
  71. PluginManager pluginManager = Bukkit.getServer().getPluginManager();
  72. pluginManager.registerEvent(Type.ENTITY_DAMAGE, entityListener, Priority.Normal, crimson);
  73. pluginManager.registerEvent(Type.PLAYER_INTERACT_ENTITY, playerListener, Priority.Normal, crimson);
  74. pluginManager.registerEvent(Type.BLOCK_DAMAGE, blockListener, Priority.Normal, crimson);
  75. //Add to the spout cache
  76. SpoutManager.getFileManager().addToPreLoginCache(crimson, "http://resources.crimsonrpg.com/s/audio/audiobanhammer.ogg");
  77. LOGGER.info("[CrimsonAdmin] Plugin enabled.");
  78. }
  79. }