Skip to content

Commit

Permalink
Release 1.1-rc2 Bug修复
Browse files Browse the repository at this point in the history
  • Loading branch information
DreamVoid committed Jun 7, 2021
1 parent cf426e3 commit 0220a9e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 16 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.github.dreamvoid</groupId>
<artifactId>MiraiMC</artifactId>
<version>1.1-rc1</version>
<version>1.1-rc2</version>
<repositories>
<!-- This adds the Spigot Maven repository to the build -->
<repository>
Expand Down
22 changes: 9 additions & 13 deletions src/main/java/me/dreamvoid/miraimc/api/MiraiBot.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package me.dreamvoid.miraimc.api;

import me.dreamvoid.miraimc.bukkit.BukkitPlugin;
import me.dreamvoid.miraimc.internal.Config;
import net.mamoe.mirai.Bot;
import net.mamoe.mirai.BotFactory;
import net.mamoe.mirai.message.code.MiraiCode;
import net.mamoe.mirai.message.data.PlainText;
import net.mamoe.mirai.utils.BotConfiguration;
import net.mamoe.mirai.utils.LoggerAdapters;
import org.bukkit.Bukkit;

import java.io.File;
import java.util.ArrayList;
Expand All @@ -17,13 +17,9 @@

public class MiraiBot {

private static Config config;
private final Logger GlobalLogger;

public MiraiBot(Logger GlobalLogger, BukkitPlugin plugin) {
this.GlobalLogger = GlobalLogger;
config = new Config(plugin);
}
public MiraiBot() { this.GlobalLogger = Bukkit.getLogger(); }

/**
* 登录一个机器人账号
Expand Down Expand Up @@ -337,17 +333,17 @@ private void privateBotLogin(int Account, String Password, BotConfiguration.Mira
fileBasedDeviceInfo();

// 是否关闭日志输出(不建议开发者关闭)
if(config.getBoolean("bot.disable-network-logs",false)) { noNetworkLog(); }
if(config.getBoolean("bot.disable-bot-logs",false)) { noBotLog(); }
if(Config.config.getBoolean("bot.disable-network-logs",false)) { noNetworkLog(); }
if(Config.config.getBoolean("bot.disable-bot-logs",false)) { noBotLog(); }

// 是否使用Bukkit的Logger接管Mirai的Logger
if(config.getBoolean("bot.use-bukkit-logger.bot-logs",true)) { setBotLoggerSupplier(bot -> LoggerAdapters.asMiraiLogger(GlobalLogger)); }
if(config.getBoolean("bot.use-bukkit-logger.network-logs",true)) { setNetworkLoggerSupplier(bot -> LoggerAdapters.asMiraiLogger(GlobalLogger)); }
if(Config.config.getBoolean("bot.use-bukkit-logger.bot-logs",true)) { setBotLoggerSupplier(bot -> LoggerAdapters.asMiraiLogger(GlobalLogger)); }
if(Config.config.getBoolean("bot.use-bukkit-logger.network-logs",true)) { setNetworkLoggerSupplier(bot -> LoggerAdapters.asMiraiLogger(GlobalLogger)); }

// 是否使用缓存——对于开发者,请启用;对于用户,请禁用。详见 https://github.com/mamoe/mirai/blob/dev/docs/Bots.md#%E5%90%AF%E7%94%A8%E5%88%97%E8%A1%A8%E7%BC%93%E5%AD%98
getContactListCache().setFriendListCacheEnabled(config.getBoolean("bot.contact-cache.enable-friend-list-cache",false));
getContactListCache().setGroupMemberListCacheEnabled(config.getBoolean("bot.contact-cache.enable-group-member-list-cache",false));
getContactListCache().setSaveIntervalMillis(config.getLong("bot.contact-cache.save-interval-millis",60000));
getContactListCache().setFriendListCacheEnabled(Config.config.getBoolean("bot.contact-cache.enable-friend-list-cache",false));
getContactListCache().setGroupMemberListCacheEnabled(Config.config.getBoolean("bot.contact-cache.enable-group-member-list-cache",false));
getContactListCache().setSaveIntervalMillis(Config.config.getLong("bot.contact-cache.save-interval-millis",60000));

}});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class BukkitPlugin extends JavaPlugin {
public void onLoad() {
Config config = new Config(this);
this.BotEvent = new BotEvent();
this.MiraiBot = new MiraiBot(this.getLogger(), this);
this.MiraiBot = new MiraiBot();
}

@Override // 启用插件
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class CommandHandler implements CommandExecutor {

public CommandHandler(BukkitPlugin plugin) {
this.plugin = plugin;
this.mirai = new MiraiBot(plugin.getLogger(), plugin);
this.mirai = new MiraiBot();
}

@Override
Expand Down

0 comments on commit 0220a9e

Please sign in to comment.