use of com.elmakers.mine.bukkit.citizens.CitizensController in project MagicPlugin by elBukkit.
the class MagicPlugin method initialize.
protected void initialize() {
controller.initialize();
TabExecutor magicCommand = new MagicCommandExecutor(this);
getCommand("magic").setExecutor(magicCommand);
getCommand("magic").setTabCompleter(magicCommand);
TabExecutor mageCommand = new MageCommandExecutor(this);
getCommand("mage").setExecutor(mageCommand);
getCommand("mage").setTabCompleter(mageCommand);
TabExecutor magicGiveCommand = new MagicGiveCommandExecutor(this);
getCommand("mgive").setExecutor(magicGiveCommand);
getCommand("mgive").setTabCompleter(magicGiveCommand);
TabExecutor magicItemCommand = new MagicItemCommandExecutor(this);
getCommand("mitem").setExecutor(magicItemCommand);
getCommand("mitem").setTabCompleter(magicItemCommand);
TabExecutor magicMobCommand = new MagicMobCommandExecutor(this);
getCommand("mmob").setExecutor(magicMobCommand);
getCommand("mmob").setTabCompleter(magicMobCommand);
TabExecutor magicMapCommand = new MagicMapCommandExecutor(this);
getCommand("mmap").setExecutor(magicMapCommand);
getCommand("mmap").setTabCompleter(magicMapCommand);
TabExecutor magicServerCommand = new MagicServerCommandExecutor(this);
getCommand("mserver").setExecutor(magicServerCommand);
getCommand("mserver").setTabCompleter(magicServerCommand);
TabExecutor magicSaveCommand = new MagicSaveCommandExecutor(this);
getCommand("msave").setExecutor(magicSaveCommand);
getCommand("msave").setTabCompleter(magicSaveCommand);
TabExecutor magicSkillsCommand = new MagicSkillsCommandExecutor(this);
getCommand("mskills").setExecutor(magicSkillsCommand);
getCommand("mskills").setTabCompleter(magicSkillsCommand);
TabExecutor castCommand = new CastCommandExecutor(this);
getCommand("cast").setExecutor(castCommand);
getCommand("cast").setTabCompleter(castCommand);
getCommand("castp").setExecutor(castCommand);
getCommand("castp").setTabCompleter(castCommand);
TabExecutor wandCommand = new WandCommandExecutor(this);
getCommand("wand").setExecutor(wandCommand);
getCommand("wand").setTabCompleter(wandCommand);
getCommand("wandp").setExecutor(wandCommand);
getCommand("wandp").setTabCompleter(wandCommand);
TabExecutor spellsCommand = new SpellsCommandExecutor(this);
getCommand("spells").setExecutor(spellsCommand);
TabExecutor rpCommand = new RPCommandExecutor(this);
getCommand("getrp").setExecutor(rpCommand);
CitizensController citizens = controller.getCitizens();
if (citizens != null) {
TabExecutor magicTraitCommand = new MagicTraitCommandExecutor(this, citizens);
getCommand("mtrait").setExecutor(magicTraitCommand);
getCommand("mtrait").setTabCompleter(magicTraitCommand);
}
TabExecutor magicConfigCommand = new MagicConfigCommandExecutor(this, controller);
getCommand("mconfig").setExecutor(magicConfigCommand);
getCommand("mconfig").setTabCompleter(magicConfigCommand);
}
use of com.elmakers.mine.bukkit.citizens.CitizensController in project MagicPlugin by elBukkit.
the class MagicController method finalizeIntegration.
protected void finalizeIntegration() {
final PluginManager pluginManager = plugin.getServer().getPluginManager();
// Check for BlockPhysics
if (useBlockPhysics) {
Plugin blockPhysicsPlugin = pluginManager.getPlugin("BlockPhysics");
if (blockPhysicsPlugin != null) {
blockPhysicsManager = new BlockPhysicsManager(plugin, blockPhysicsPlugin);
if (blockPhysicsManager.isEnabled()) {
getLogger().info("BlockPhysics found, some spells will now use physics-based block effects");
} else {
getLogger().warning("Error integrating with BlockPhysics, you may want to set 'enable_block_physics: false' in config.yml");
}
}
}
// Check for Minigames
Plugin minigamesPlugin = pluginManager.getPlugin("Minigames");
if (minigamesPlugin != null) {
pluginManager.registerEvents(new MinigamesListener(this), plugin);
getLogger().info("Minigames found, wands will deactivate before joining a minigame");
}
// Check for LibsDisguise
Plugin libsDisguisePlugin = pluginManager.getPlugin("LibsDisguises");
if (libsDisguisePlugin == null) {
getLogger().info("LibsDisguises not found");
} else if (libsDisguiseEnabled) {
libsDisguiseManager = new LibsDisguiseManager(plugin, libsDisguisePlugin);
if (libsDisguiseManager.initialize()) {
getLogger().info("LibsDisguises found, mob disguises and disguise_restricted features enabled");
} else {
getLogger().warning("LibsDisguises integration failed");
}
} else {
libsDisguiseManager = null;
getLogger().info("LibsDisguises integration disabled");
}
// Check for MobArena
Plugin mobArenaPlugin = pluginManager.getPlugin("MobArena");
if (mobArenaPlugin == null) {
getLogger().info("MobArena not found");
} else if (mobArenaConfiguration.getBoolean("enabled", true)) {
try {
mobArenaManager = new MobArenaManager(this, mobArenaPlugin, mobArenaConfiguration);
// getLogger().info("Integrated with MobArena, use \"magic:<itemkey>\" in arena configs for Magic items, magic mobs can be used in monster configurations");
getLogger().info("MobArena found, magic mobs can be used in monster configurations");
} catch (Throwable ex) {
getLogger().warning("MobArena integration failed, you may need to update the MobArena plugin to use Magic items");
}
} else {
getLogger().info("MobArena integration disabled");
}
// Vault integration is handled internally in MagicLib
Plugin vaultPlugin = pluginManager.getPlugin("Vault");
if (vaultPlugin == null) {
getLogger().info("Vault not found, virtual economy unavailable");
} else {
if (VaultController.initialize(plugin, vaultPlugin)) {
getLogger().info("Vault found, virtual economy and descriptive item names available");
} else {
getLogger().warning("Vault integration failed");
}
}
// Try to link to Essentials:
Plugin essentials = pluginManager.getPlugin("Essentials");
hasEssentials = essentials != null;
if (hasEssentials) {
if (warpController.setEssentials(essentials)) {
getLogger().info("Integrating with Essentials for Recall warps");
}
try {
mailer = new Mailer(essentials);
} catch (Exception ex) {
getLogger().warning("Essentials found, but failed to hook up to Mailer");
mailer = null;
}
}
if (essentialsSignsEnabled) {
final MagicController me = this;
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
try {
Object essentials = me.plugin.getServer().getPluginManager().getPlugin("Essentials");
if (essentials != null) {
Class<?> essentialsClass = essentials.getClass();
Field itemDbField = essentialsClass.getDeclaredField("itemDb");
itemDbField.setAccessible(true);
Object oldEntry = itemDbField.get(essentials);
if (oldEntry == null) {
getLogger().info("Essentials integration failure");
return;
}
if (oldEntry instanceof MagicItemDb) {
getLogger().info("Essentials integration already set up, skipping");
return;
}
if (!oldEntry.getClass().getName().equals("com.earth2me.essentials.ItemDb")) {
getLogger().info("Essentials Item DB class unexepcted: " + oldEntry.getClass().getName() + ", skipping integration");
return;
}
Object newEntry = new MagicItemDb(me, essentials);
itemDbField.set(essentials, newEntry);
Field confListField = essentialsClass.getDeclaredField("confList");
confListField.setAccessible(true);
@SuppressWarnings("unchecked") List<Object> confList = (List<Object>) confListField.get(essentials);
confList.remove(oldEntry);
confList.add(newEntry);
getLogger().info("Essentials found, hooked up custom item handler");
}
} catch (Throwable ex) {
ex.printStackTrace();
}
}
}, 5);
}
// Try to link to CommandBook
hasCommandBook = false;
try {
Plugin commandBookPlugin = plugin.getServer().getPluginManager().getPlugin("CommandBook");
if (commandBookPlugin != null) {
if (warpController.setCommandBook(commandBookPlugin)) {
getLogger().info("CommandBook found, integrating for Recall warps");
hasCommandBook = true;
} else {
getLogger().warning("CommandBook integration failed");
}
}
} catch (Throwable ignored) {
}
// Link to factions
factionsManager.initialize(plugin);
// Try to (dynamically) link to WorldGuard:
worldGuardManager.initialize(plugin);
// Link to PvpManager
pvpManager.initialize(plugin);
// Link to Multiverse
multiverseManager.initialize(plugin);
// Link to PreciousStones
preciousStonesManager.initialize(plugin);
// Link to Towny
townyManager.initialize(plugin);
// Link to Lockette
locketteManager.initialize(plugin);
// Link to GriefPrevention
griefPreventionManager.initialize(plugin);
// Link to NoCheatPlus
ncpManager.initialize(plugin);
// Try to link to Heroes:
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
try {
Plugin heroesPlugin = plugin.getServer().getPluginManager().getPlugin("Heroes");
if (heroesPlugin != null) {
heroesManager = new HeroesManager(plugin, heroesPlugin);
} else {
heroesManager = null;
}
} catch (Throwable ex) {
plugin.getLogger().warning(ex.getMessage());
}
}
}, 2);
// Try to link to dynmap:
try {
Plugin dynmapPlugin = plugin.getServer().getPluginManager().getPlugin("dynmap");
if (dynmapPlugin != null) {
dynmap = new DynmapController(plugin, dynmapPlugin);
} else {
dynmap = null;
}
} catch (Throwable ex) {
plugin.getLogger().warning(ex.getMessage());
}
if (dynmap == null) {
getLogger().info("dynmap not found, not integrating.");
} else {
getLogger().info("dynmap found, integrating.");
}
// Try to link to Elementals:
try {
Plugin elementalsPlugin = plugin.getServer().getPluginManager().getPlugin("Splateds_Elementals");
if (elementalsPlugin != null) {
elementals = new ElementalsController(elementalsPlugin);
} else {
elementals = null;
}
} catch (Throwable ex) {
plugin.getLogger().warning(ex.getMessage());
}
if (elementals != null) {
getLogger().info("Elementals found, integrating.");
}
// Try to link to Citizens
if (citizensEnabled) {
try {
Plugin citizensPlugin = plugin.getServer().getPluginManager().getPlugin("Citizens");
if (citizensPlugin != null) {
citizens = new CitizensController(citizensPlugin);
} else {
citizens = null;
getLogger().info("Citizens not found, Magic trait unavailable.");
}
} catch (Throwable ex) {
citizens = null;
getLogger().warning("Error integrating with Citizens");
plugin.getLogger().warning(ex.getMessage());
}
} else {
citizens = null;
getLogger().info("Citizens integration disabled.");
}
// Placeholder API
if (placeholdersEnabled) {
if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) {
try {
// Can only register this once
if (placeholderAPIManager == null) {
placeholderAPIManager = new PlaceholderAPIManager(this);
}
} catch (Throwable ex) {
getLogger().log(Level.WARNING, "Error integrating with PlaceholderAPI", ex);
}
}
} else {
getLogger().info("PlaceholderAPI integration disabled.");
}
// Light API
if (lightAPIEnabled) {
if (Bukkit.getPluginManager().isPluginEnabled("LightAPI")) {
try {
lightAPIManager = new LightAPIManager(plugin);
} catch (Throwable ex) {
getLogger().log(Level.WARNING, "Error integrating with LightAPI", ex);
}
} else {
getLogger().info("LightAPI not found, Light action will not work");
}
} else {
lightAPIManager = null;
getLogger().info("LightAPI integration disabled.");
}
// Skript
if (skriptEnabled) {
if (Bukkit.getPluginManager().isPluginEnabled("Skript")) {
try {
new SkriptManager(this);
} catch (Throwable ex) {
getLogger().log(Level.WARNING, "Error integrating with Skript", ex);
}
}
} else {
getLogger().info("Skript integration disabled.");
}
// Citadel
if (citadelConfiguration.getBoolean("enabled")) {
if (Bukkit.getPluginManager().isPluginEnabled("Citadel")) {
try {
citadelManager = new CitadelManager(this, citadelConfiguration);
} catch (Throwable ex) {
getLogger().log(Level.WARNING, "Error integrating with Citadel", ex);
}
}
} else {
getLogger().info("Citadel integration disabled.");
}
// Activate Metrics
activateMetrics();
// Set up the PlayerSpells timer
final MageUpdateTask mageTask = new MageUpdateTask(this);
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, mageTask, 0, mageUpdateFrequency);
// Set up the Block update timer
final BatchUpdateTask blockTask = new BatchUpdateTask(this);
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, blockTask, 0, workFrequency);
// Set up the Update check timer
final UndoUpdateTask undoTask = new UndoUpdateTask(this);
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, undoTask, 0, undoFrequency);
registerListeners();
// Activate/load any active player Mages
Collection<? extends Player> allPlayers = plugin.getServer().getOnlinePlayers();
for (Player player : allPlayers) {
getMage(player);
}
// Set up Break/Build/PVP Managers
blockBreakManagers.clear();
blockBuildManagers.clear();
pvpManagers.clear();
// PVP Managers
if (worldGuardManager.isEnabled())
pvpManagers.add(worldGuardManager);
if (pvpManager.isEnabled())
pvpManagers.add(pvpManager);
if (multiverseManager.isEnabled())
pvpManagers.add(multiverseManager);
if (preciousStonesManager.isEnabled())
pvpManagers.add(preciousStonesManager);
if (townyManager.isEnabled())
pvpManagers.add(townyManager);
if (griefPreventionManager.isEnabled())
pvpManagers.add(griefPreventionManager);
if (factionsManager.isEnabled())
pvpManagers.add(factionsManager);
// Build Managers
if (worldGuardManager.isEnabled())
blockBuildManagers.add(worldGuardManager);
if (factionsManager.isEnabled())
blockBuildManagers.add(factionsManager);
if (locketteManager.isEnabled())
blockBuildManagers.add(locketteManager);
if (preciousStonesManager.isEnabled())
blockBuildManagers.add(preciousStonesManager);
if (townyManager.isEnabled())
blockBuildManagers.add(townyManager);
if (griefPreventionManager.isEnabled())
blockBuildManagers.add(griefPreventionManager);
if (mobArenaManager != null && mobArenaManager.isProtected())
blockBuildManagers.add(mobArenaManager);
// Break Managers
if (worldGuardManager.isEnabled())
blockBreakManagers.add(worldGuardManager);
if (factionsManager.isEnabled())
blockBreakManagers.add(factionsManager);
if (locketteManager.isEnabled())
blockBreakManagers.add(locketteManager);
if (preciousStonesManager.isEnabled())
blockBreakManagers.add(preciousStonesManager);
if (townyManager.isEnabled())
blockBreakManagers.add(townyManager);
if (griefPreventionManager.isEnabled())
blockBreakManagers.add(griefPreventionManager);
if (mobArenaManager != null && mobArenaManager.isProtected())
blockBreakManagers.add(mobArenaManager);
if (citadelManager != null)
blockBreakManagers.add(citadelManager);
initialized = true;
}
Aggregations