Update to new integration method for EssentialsChat; needs up-to-date Essentials (2.5.1 or newer)

NOTE: if Essentials is too old, this error will occur at server startup (sadly impossible to catch or otherwise handle due to how Bukkit loads plugins):
java.lang.NoClassDefFoundError: com/earth2me/essentials/chat/IEssentialsChatListener
This commit is contained in:
Brettflan 2011-07-20 08:48:14 -05:00
parent fb3021800d
commit c79692940e
2 changed files with 34 additions and 3 deletions

BIN
lib/EssentialsChat.jar Normal file

Binary file not shown.

View File

@ -8,8 +8,6 @@ import java.util.Map;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -20,15 +18,17 @@ import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import com.massivecraft.factions.commands.*; import com.massivecraft.factions.commands.*;
import com.massivecraft.factions.gson.Gson; import com.massivecraft.factions.gson.Gson;
import com.massivecraft.factions.gson.GsonBuilder; import com.massivecraft.factions.gson.GsonBuilder;
import com.massivecraft.factions.listeners.FactionsBlockListener; import com.massivecraft.factions.listeners.FactionsBlockListener;
import com.massivecraft.factions.listeners.FactionsEntityListener; import com.massivecraft.factions.listeners.FactionsEntityListener;
import com.massivecraft.factions.listeners.FactionsPlayerListener; import com.massivecraft.factions.listeners.FactionsPlayerListener;
import com.nijiko.permissions.PermissionHandler; import com.nijiko.permissions.PermissionHandler;
import com.nijikokun.bukkit.Permissions.Permissions; import com.nijikokun.bukkit.Permissions.Permissions;
import com.earth2me.essentials.chat.EssentialsChat;
import com.earth2me.essentials.chat.IEssentialsChatListener;
/** /**
* The data is saved to disk every 30min and on plugin disable. * The data is saved to disk every 30min and on plugin disable.
@ -51,6 +51,7 @@ public class Factions extends JavaPlugin {
private final FactionsBlockListener blockListener = new FactionsBlockListener(); private final FactionsBlockListener blockListener = new FactionsBlockListener();
public static PermissionHandler Permissions; public static PermissionHandler Permissions;
public static EssentialsChat essChat;
// Commands // Commands
public List<FBaseCommand> commands = new ArrayList<FBaseCommand>(); public List<FBaseCommand> commands = new ArrayList<FBaseCommand>();
@ -118,6 +119,7 @@ public class Factions extends JavaPlugin {
Board.load(); Board.load();
setupPermissions(); setupPermissions();
integrateEssentialsChat();
// preload could apparently cause issues; removed since "softdepend" is now available // preload could apparently cause issues; removed since "softdepend" is now available
@ -157,6 +159,7 @@ public class Factions extends JavaPlugin {
saveTask = null; saveTask = null;
} }
saveAll(); saveAll();
unhookEssentialsChat();
log("Disabled"); log("Disabled");
} }
@ -179,6 +182,34 @@ public class Factions extends JavaPlugin {
} }
} }
private void integrateEssentialsChat() {
if (essChat != null) {
return;
}
Plugin test = this.getServer().getPluginManager().getPlugin("EssentialsChat");
if (test != null) {
essChat = (EssentialsChat)test;
essChat.addEssentialsChatListener("Factions", new IEssentialsChatListener() {
public boolean shouldHandleThisChat(PlayerChatEvent event)
{
return shouldLetFactionsHandleThisChat(event);
}
public String modifyMessage(PlayerChatEvent event, Player target, String message)
{
return message.replace("{FACTION}", getPlayerFactionTagRelation(event.getPlayer(), target)).replace("{FACTION_TITLE}", getPlayerTitle(event.getPlayer()));
}
});
Factions.log("Found and will integrate chat with "+test.getDescription().getFullName());
}
}
private void unhookEssentialsChat() {
if (essChat != null) {
essChat.removeEssentialsChatListener("Factions");
}
}
// -------------------------------------------- // // -------------------------------------------- //
// Functions for other plugins to hook into // Functions for other plugins to hook into
// -------------------------------------------- // // -------------------------------------------- //