48 lines
1.8 KiB
Java
48 lines
1.8 KiB
Java
package com.earth2me.essentials.chat;
|
|
|
|
import com.earth2me.essentials.metrics.Metrics;
|
|
import net.ess3.api.IEssentials;
|
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
|
import org.bukkit.plugin.PluginManager;
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
|
|
import java.util.Collections;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
import java.util.logging.Level;
|
|
|
|
import static com.earth2me.essentials.I18n.tl;
|
|
|
|
|
|
public class EssentialsChat extends JavaPlugin {
|
|
|
|
private transient Metrics metrics = null;
|
|
|
|
@Override
|
|
public void onEnable() {
|
|
final PluginManager pluginManager = getServer().getPluginManager();
|
|
final IEssentials ess = (IEssentials) pluginManager.getPlugin("Essentials");
|
|
if (!this.getDescription().getVersion().equals(ess.getDescription().getVersion())) {
|
|
getLogger().log(Level.WARNING, tl("versionMismatchAll"));
|
|
}
|
|
if (!ess.isEnabled()) {
|
|
this.setEnabled(false);
|
|
return;
|
|
}
|
|
|
|
final Map<AsyncPlayerChatEvent, ChatStore> chatStore = Collections.synchronizedMap(new HashMap<>());
|
|
|
|
final EssentialsChatPlayerListenerLowest playerListenerLowest = new EssentialsChatPlayerListenerLowest(getServer(), ess, chatStore);
|
|
final EssentialsChatPlayerListenerNormal playerListenerNormal = new EssentialsChatPlayerListenerNormal(getServer(), ess, chatStore);
|
|
final EssentialsChatPlayerListenerHighest playerListenerHighest = new EssentialsChatPlayerListenerHighest(getServer(), ess, chatStore);
|
|
pluginManager.registerEvents(playerListenerLowest, this);
|
|
pluginManager.registerEvents(playerListenerNormal, this);
|
|
pluginManager.registerEvents(playerListenerHighest, this);
|
|
|
|
if (metrics == null) {
|
|
metrics = new Metrics(this);
|
|
}
|
|
}
|
|
|
|
}
|