2019-06-06 13:15:50 +00:00
|
|
|
package ren.taske.nativebot;
|
|
|
|
|
2019-06-06 15:58:08 +00:00
|
|
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
2019-06-06 13:15:50 +00:00
|
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
|
|
|
2019-06-06 15:58:08 +00:00
|
|
|
import cc.moecraft.icq.event.events.message.EventMessage;
|
2019-08-03 12:48:04 +00:00
|
|
|
import cc.moecraft.logger.HyLogger;
|
|
|
|
import cc.moecraft.logger.LoggerInstanceManager;
|
2019-06-26 15:32:23 +00:00
|
|
|
import cn.glycol.t18n.I18n;
|
2019-06-06 15:58:08 +00:00
|
|
|
import ren.taske.nativebot.bot.chatting.Chatting;
|
|
|
|
import ren.taske.nativebot.bot.chatting.MinecraftMessage;
|
|
|
|
import ren.taske.nativebot.bot.chatting.TencentMessage;
|
2019-07-10 15:40:41 +00:00
|
|
|
import ren.taske.nativebot.bot.listener.ServerLoadEventListener;
|
2019-08-03 12:48:04 +00:00
|
|
|
import ren.taske.nativebot.bot.permission.PermissionManager;
|
2019-06-06 13:15:50 +00:00
|
|
|
import ren.taske.nativebot.core.NativeBot;
|
2019-06-26 15:32:23 +00:00
|
|
|
import ren.taske.nativebot.i18n.I18nInit;
|
2019-06-07 06:41:11 +00:00
|
|
|
import ren.taske.nativebot.minecraft.command.CommandQQ;
|
2019-07-10 12:58:47 +00:00
|
|
|
import ren.taske.nativebot.minecraft.command.CommandQQAdmin;
|
2019-06-06 13:15:50 +00:00
|
|
|
|
2019-07-10 14:47:11 +00:00
|
|
|
public class NativeBotPlugin extends JavaPlugin {
|
2019-06-26 15:32:23 +00:00
|
|
|
|
2019-06-06 15:58:08 +00:00
|
|
|
protected final NativeBot nativebot = new NativeBot(this);
|
|
|
|
protected final Chatting chatting = new Chatting(this);
|
|
|
|
|
|
|
|
protected final MinecraftMessage mcevent = new MinecraftMessage(this);
|
|
|
|
protected final TencentMessage tencentevent = new TencentMessage(this);
|
2019-06-06 13:15:50 +00:00
|
|
|
|
2019-07-10 15:40:41 +00:00
|
|
|
protected final ServerLoadEventListener botstartevent = new ServerLoadEventListener();
|
|
|
|
|
2019-06-07 06:41:11 +00:00
|
|
|
protected final CommandQQ cmdqq = new CommandQQ(this);
|
2019-07-10 12:58:47 +00:00
|
|
|
protected final CommandQQAdmin cmdqqadmin = new CommandQQAdmin();
|
2019-06-07 06:41:11 +00:00
|
|
|
|
2019-08-03 12:48:04 +00:00
|
|
|
protected final HyLogger logger = new LoggerInstanceManager().getLoggerInstance("NaB", false);
|
|
|
|
|
2019-06-06 13:15:50 +00:00
|
|
|
@Override
|
|
|
|
public void onEnable() {
|
2019-06-24 16:20:01 +00:00
|
|
|
nativebotJavaPlugin = this;
|
|
|
|
|
2019-06-26 15:32:23 +00:00
|
|
|
I18nInit.init();
|
2019-08-03 12:48:04 +00:00
|
|
|
PermissionManager.init();
|
2019-06-26 15:32:23 +00:00
|
|
|
|
|
|
|
getLogger().info(I18n.format("message.common.welcome"));
|
|
|
|
|
2019-06-06 15:58:08 +00:00
|
|
|
nativebot.onEnable();
|
2019-06-07 06:41:11 +00:00
|
|
|
|
2019-08-03 12:48:04 +00:00
|
|
|
// 绑定QQ号指令
|
2019-06-07 06:41:11 +00:00
|
|
|
getCommand("qq").setExecutor(cmdqq);
|
2019-07-10 12:58:47 +00:00
|
|
|
getCommand("qq-admin").setExecutor(cmdqqadmin);
|
2019-06-07 06:41:11 +00:00
|
|
|
|
2019-08-03 12:48:04 +00:00
|
|
|
// 注册消息事件监听器
|
|
|
|
nativebot.getBot().addEventListenr(tencentevent);
|
2019-06-06 15:58:08 +00:00
|
|
|
getServer().getPluginManager().registerEvents(mcevent, this);
|
2019-07-10 15:40:41 +00:00
|
|
|
|
2019-08-03 12:48:04 +00:00
|
|
|
// 注册服务器载入事件监听器
|
2019-07-10 15:40:41 +00:00
|
|
|
getServer().getPluginManager().registerEvents(botstartevent, this);
|
|
|
|
|
2019-06-06 13:15:50 +00:00
|
|
|
super.onEnable();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onDisable() {
|
2019-06-06 15:58:08 +00:00
|
|
|
nativebot.onDisable();
|
2019-06-06 13:15:50 +00:00
|
|
|
}
|
|
|
|
|
2019-06-06 15:58:08 +00:00
|
|
|
public NativeBot getBot() {
|
|
|
|
return this.nativebot;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void onTencentMessage(EventMessage evt) {
|
|
|
|
chatting.onTencentMessage(evt);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void onMinecraftMessage(AsyncPlayerChatEvent evt) {
|
|
|
|
chatting.onMinecraftMessage(evt);
|
|
|
|
}
|
|
|
|
|
2019-08-03 12:48:04 +00:00
|
|
|
private static NativeBotPlugin nativebotJavaPlugin;
|
|
|
|
|
|
|
|
public static NativeBotPlugin getPlugin() {
|
|
|
|
return nativebotJavaPlugin;
|
|
|
|
}
|
2019-06-24 16:20:01 +00:00
|
|
|
|
2019-08-03 12:48:04 +00:00
|
|
|
public static HyLogger logger() {
|
|
|
|
return nativebotJavaPlugin.logger;
|
2019-06-26 15:32:23 +00:00
|
|
|
}
|
|
|
|
|
2019-06-06 13:15:50 +00:00
|
|
|
}
|