From 29469b0d27cae442ac162168f2e10885190d51dd Mon Sep 17 00:00:00 2001 From: Brettflan Date: Wed, 1 Jun 2011 06:39:25 -0500 Subject: [PATCH] Preload some chat plugins before Factions to prevent conflicts --- src/org/mcteam/factions/Conf.java | 5 +++-- src/org/mcteam/factions/Factions.java | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/org/mcteam/factions/Conf.java b/src/org/mcteam/factions/Conf.java index d41cee2b..7f622121 100644 --- a/src/org/mcteam/factions/Conf.java +++ b/src/org/mcteam/factions/Conf.java @@ -43,6 +43,7 @@ public class Conf { // Configuration on the Faction tag in chat messages. + public static boolean preloadChatPlugins = true; public static boolean chatTagEnabled = true; public static boolean chatTagRelationColored = true; public static int chatTagInsertIndex = 1; @@ -66,11 +67,11 @@ public class Conf { public static boolean safeZoneDenyUseage = true; public static boolean safeZoneBlockTNT = true; + public static boolean warZoneDenyBuild = true; + public static boolean warZoneDenyUseage = true; public static boolean warZoneBlockCreepers = false; public static boolean warZoneBlockFireballs = false; public static boolean warZoneBlockTNT = true; - public static boolean warZoneDenyBuild = true; - public static boolean warZoneDenyUseage = true; public static boolean warZonePowerLoss = true; public static Set territoryProtectedMaterials = new HashSet(); diff --git a/src/org/mcteam/factions/Factions.java b/src/org/mcteam/factions/Factions.java index 57de5e2f..eafb73bf 100644 --- a/src/org/mcteam/factions/Factions.java +++ b/src/org/mcteam/factions/Factions.java @@ -118,6 +118,13 @@ public class Factions extends JavaPlugin { setupPermissions(); + // preload some chat plugins if they're on the server to prevent potential conflicts + if (Conf.preloadChatPlugins) { + preloadPlugin("EssentialsChat"); + preloadPlugin("HeroChat"); + preloadPlugin("iChat"); + } + // Register events PluginManager pm = this.getServer().getPluginManager(); pm.registerEvent(Event.Type.PLAYER_CHAT, this.playerListener, Event.Priority.Highest, this); @@ -176,6 +183,16 @@ public class Factions extends JavaPlugin { } } + private void preloadPlugin(String pluginName) { + PluginManager pm = this.getServer().getPluginManager(); + Plugin prePlug = pm.getPlugin(pluginName); + + if (prePlug != null && !pm.isPluginEnabled(prePlug)) { + Factions.log("Preloading \"" + pluginName + "\" plugin to prevent conflicts."); + pm.enablePlugin(prePlug); + } + } + // -------------------------------------------- // // Test rights // -------------------------------------------- //