2011-03-19 23:39:51 +01:00
|
|
|
package com.earth2me.essentials.chat;
|
|
|
|
|
2022-06-27 20:54:10 +02:00
|
|
|
import com.earth2me.essentials.EssentialsLogger;
|
2020-07-05 20:30:01 +02:00
|
|
|
import com.earth2me.essentials.metrics.MetricsWrapper;
|
2013-07-13 18:40:50 +02:00
|
|
|
import net.ess3.api.IEssentials;
|
2021-02-20 17:37:16 +01:00
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
2015-04-15 06:06:16 +02:00
|
|
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
|
|
|
import org.bukkit.plugin.PluginManager;
|
|
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
|
|
|
2012-08-03 21:45:32 +02:00
|
|
|
import java.util.Collections;
|
2011-07-19 11:26:23 +02:00
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.Map;
|
2011-03-19 23:39:51 +01:00
|
|
|
import java.util.logging.Level;
|
|
|
|
|
2015-04-15 06:06:16 +02:00
|
|
|
import static com.earth2me.essentials.I18n.tl;
|
|
|
|
|
|
|
|
public class EssentialsChat extends JavaPlugin {
|
2021-02-20 17:37:16 +01:00
|
|
|
private transient IEssentials ess;
|
2020-07-05 20:30:01 +02:00
|
|
|
private transient MetricsWrapper metrics = null;
|
2015-04-15 06:06:16 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onEnable() {
|
2022-07-02 20:50:45 +02:00
|
|
|
EssentialsLogger.updatePluginLogger(this);
|
2015-04-15 06:06:16 +02:00
|
|
|
final PluginManager pluginManager = getServer().getPluginManager();
|
2021-02-20 17:37:16 +01:00
|
|
|
ess = (IEssentials) pluginManager.getPlugin("Essentials");
|
2015-04-15 06:06:16 +02:00
|
|
|
if (!this.getDescription().getVersion().equals(ess.getDescription().getVersion())) {
|
2019-01-05 19:42:09 +01:00
|
|
|
getLogger().log(Level.WARNING, tl("versionMismatchAll"));
|
2015-04-15 06:06:16 +02:00
|
|
|
}
|
|
|
|
if (!ess.isEnabled()) {
|
|
|
|
this.setEnabled(false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-01-05 19:42:09 +01:00
|
|
|
final Map<AsyncPlayerChatEvent, ChatStore> chatStore = Collections.synchronizedMap(new HashMap<>());
|
2015-04-15 06:06:16 +02:00
|
|
|
|
2022-06-27 20:54:10 +02:00
|
|
|
final EssentialsChatPlayerListenerLowest playerListenerLowest = new EssentialsChatPlayerListenerLowest(getServer(), ess, this, chatStore);
|
|
|
|
final EssentialsChatPlayerListenerNormal playerListenerNormal = new EssentialsChatPlayerListenerNormal(getServer(), ess, this, chatStore);
|
|
|
|
final EssentialsChatPlayerListenerHighest playerListenerHighest = new EssentialsChatPlayerListenerHighest(getServer(), ess, this, chatStore);
|
2015-04-15 06:06:16 +02:00
|
|
|
pluginManager.registerEvents(playerListenerLowest, this);
|
|
|
|
pluginManager.registerEvents(playerListenerNormal, this);
|
|
|
|
pluginManager.registerEvents(playerListenerHighest, this);
|
2011-03-19 23:39:51 +01:00
|
|
|
|
2019-01-05 18:48:44 +01:00
|
|
|
if (metrics == null) {
|
2020-07-05 20:30:01 +02:00
|
|
|
metrics = new MetricsWrapper(this, 3814, false);
|
2019-01-05 18:48:44 +01:00
|
|
|
}
|
2015-04-15 06:06:16 +02:00
|
|
|
}
|
2019-01-05 19:42:09 +01:00
|
|
|
|
2021-02-20 17:37:16 +01:00
|
|
|
@Override
|
|
|
|
public boolean onCommand(final CommandSender sender, final Command command, final String commandLabel, final String[] args) {
|
|
|
|
metrics.markCommand(command.getName(), true);
|
|
|
|
return ess.onCommandEssentials(sender, command, commandLabel, args, EssentialsChat.class.getClassLoader(), "com.earth2me.essentials.chat.Command", "essentials.", null);
|
|
|
|
}
|
2011-03-19 23:39:51 +01:00
|
|
|
}
|