From 10336d72673b2532958e48ef5c98bed0e2e0cf66 Mon Sep 17 00:00:00 2001
From: XiaMoHuaHuo-CN <2549619802@qq.com>
Date: Thu, 2 Jun 2022 22:05:34 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9B=B4=E6=96=B0=E5=99=A8?=
=?UTF-8?q?=20=E6=94=AF=E6=8C=81=E6=89=8B=E5=8A=A8=E6=A3=80=E6=9F=A5?=
=?UTF-8?q?=E6=9B=B4=E6=96=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pom.xml | 2 +-
src/main/java/moe/xmcn/catsero/Main.java | 17 ++++++++++-------
src/main/java/moe/xmcn/catsero/Updater.java | 13 +++++--------
.../xmcn/catsero/events/commands/CatSero.java | 7 +++++++
.../listeners/QBanPlayer/OnQQGroupMessage.java | 1 -
.../java/moe/xmcn/catsero/utils/ServerTPS.java | 2 +-
6 files changed, 24 insertions(+), 18 deletions(-)
diff --git a/pom.xml b/pom.xml
index 70d51420..acdf0404 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
moe.xmcn.catsero
CatSero
- 1.1.2-pre1
+ 1.1.2-pre2
UTF-8
diff --git a/src/main/java/moe/xmcn/catsero/Main.java b/src/main/java/moe/xmcn/catsero/Main.java
index b0286cc9..12d2fd51 100644
--- a/src/main/java/moe/xmcn/catsero/Main.java
+++ b/src/main/java/moe/xmcn/catsero/Main.java
@@ -12,6 +12,8 @@
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
+import java.util.logging.Level;
+
/**
* 主类
* 注册监听器
@@ -26,7 +28,7 @@ public class Main extends JavaPlugin {
public void onLoad() {
Config.INSTANCE.saveDefConfig();
ThisAPI.Companion.savXMCore("xmcore.info");
- System.out.println("[CatSero] 正在加载CatSero插件");
+ getLogger().log(Level.INFO, "[CatSero] 正在加载CatSero插件");
if (Config.INSTANCE.getConfig().getBoolean("allow-start-warn")) {
getLogger().warning("请确保正在使用CatSero官方的构建版本,本人只为官方版本提供支持");
}
@@ -44,19 +46,20 @@ public void onEnable() {
// bStats
if (Config.INSTANCE.getConfig().getBoolean("allow-bstats")) {
int pluginId = 14767;
- new Metrics((JavaPlugin) Config.INSTANCE.getPlugin(), pluginId);
+ new Metrics(this, pluginId);
}
// 启动TPS计算程序
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new ServerTPS(), 100L, 1L);
- System.out.println("CatSero插件加载成功");
+ getLogger().log(Level.INFO, "CatSero插件加载成功");
// 异步加载更新检查器
new BukkitRunnable() {
@Override
public void run() {
- Updater.startUpdateCheck();
+ getLogger().log(Level.INFO, "开始检查更新...");
+ getLogger().log(Level.INFO, Updater.startUpdateCheck());
}
}.runTaskAsynchronously(this);
} else {
@@ -70,7 +73,7 @@ public void run() {
*/
@Override
public void onDisable() {
- System.out.println("正在卸载CatSero插件");
+ getLogger().log(Level.INFO, "正在卸载CatSero插件");
}
/**
@@ -79,13 +82,13 @@ public void onDisable() {
*/
public void regiserEvents() {
- System.out.println("正在注册事件 -> 监听器:CommandExecutor");
+ getLogger().log(Level.INFO, "正在注册事件 -> 监听器:CommandExecutor");
// catsero命令
Bukkit.getPluginCommand("catsero").setExecutor(new moe.xmcn.catsero.events.commands.CatSero());
// csm命令
Bukkit.getPluginCommand("csm").setExecutor(new moe.xmcn.catsero.events.commands.SendMessageQQ());
- System.out.println("正在注册事件 -> 监听器:Listener");
+ getLogger().log(Level.INFO, "正在注册事件 -> 监听器:Listener");
// PingHost功能
getServer().getPluginManager().registerEvents(new OnQQGroupMessage(), this);
diff --git a/src/main/java/moe/xmcn/catsero/Updater.java b/src/main/java/moe/xmcn/catsero/Updater.java
index 04c54696..b366a9a7 100644
--- a/src/main/java/moe/xmcn/catsero/Updater.java
+++ b/src/main/java/moe/xmcn/catsero/Updater.java
@@ -25,7 +25,7 @@ public Updater(String name, String durl, String devname, String devdurl) {
this.devdurl = devdurl;
}
- public static void startUpdateCheck() {
+ public static String startUpdateCheck() {
String nowversion = Config.INSTANCE.getPluginInfo().getString("version");
Plugin plugin = moe.xmcn.catsero.Main.getPlugin(moe.xmcn.catsero.Main.class);
if (plugin.getConfig().getBoolean("check-update.enabled")) {
@@ -34,17 +34,14 @@ public static void startUpdateCheck() {
Updater updater = gson.fromJson(datajson, Updater.class);
String[] upregex = String.valueOf(updater).split("╳");
if (Objects.equals(nowversion, "dev")) {
- System.out.println(ChatColor.GREEN + "最新构建ID:" + upregex[2]);
- System.out.println(ChatColor.GREEN + "下载地址:" + ChatColor.YELLOW + upregex[3]);
+ return ChatColor.GREEN + "最新构建ID:" + upregex[2] + ChatColor.GREEN + "下载地址:" + ChatColor.YELLOW + upregex[3];
} else if (!Objects.equals(upregex[0], nowversion) && !nowversion.contains("pre") && Objects.equals(nowversion, "passed")) {
- System.out.println(nowversion);
- System.out.println(ChatColor.GREEN + "已找到可用的更新:" + upregex[0]);
- System.out.println(ChatColor.GREEN + "下载地址:" + ChatColor.YELLOW + upregex[1]);
+ return ChatColor.GREEN + "已找到可用的更新:" + upregex[0] + ChatColor.GREEN + "下载地址:" + ChatColor.YELLOW + upregex[1];
} else {
- System.out.println("已是最新版本");
+ return "已是最新版本";
}
} else {
- System.out.println("跳过更新检查");
+ return "跳过更新检查";
}
}
diff --git a/src/main/java/moe/xmcn/catsero/events/commands/CatSero.java b/src/main/java/moe/xmcn/catsero/events/commands/CatSero.java
index 68bd8800..e039e5a3 100644
--- a/src/main/java/moe/xmcn/catsero/events/commands/CatSero.java
+++ b/src/main/java/moe/xmcn/catsero/events/commands/CatSero.java
@@ -1,5 +1,6 @@
package moe.xmcn.catsero.events.commands;
+import moe.xmcn.catsero.Updater;
import moe.xmcn.catsero.events.gists.PingHost;
import moe.xmcn.catsero.events.gists.WeatherUtils;
import moe.xmcn.catsero.utils.Config;
@@ -133,6 +134,12 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', Config.INSTANCE.getPrefix_MC() + Config.INSTANCE.getMsgByMsID("minecraft.undefined-usage")));
return false;
}
+ /*
+ 手动检查更新
+ */
+ } else if (args[0].equalsIgnoreCase("update")) {
+ sender.sendMessage(ChatColor.translateAlternateColorCodes('&', Config.INSTANCE.getPrefix_MC() + "&a开始检查更新..."));
+ sender.sendMessage(Updater.startUpdateCheck());
} else {
/*
无效方法
diff --git a/src/main/java/moe/xmcn/catsero/events/listeners/QBanPlayer/OnQQGroupMessage.java b/src/main/java/moe/xmcn/catsero/events/listeners/QBanPlayer/OnQQGroupMessage.java
index f550800e..93c4dc80 100644
--- a/src/main/java/moe/xmcn/catsero/events/listeners/QBanPlayer/OnQQGroupMessage.java
+++ b/src/main/java/moe/xmcn/catsero/events/listeners/QBanPlayer/OnQQGroupMessage.java
@@ -22,7 +22,6 @@ public void onMiraiGroupMessageEvent(MiraiGroupMessageEvent event) {
if (args[0].equalsIgnoreCase("catsero") && args[1].equalsIgnoreCase("ban")) {
if (event.getSenderID() == Config.INSTANCE.getQQ_OP()) {
- System.out.println(event.getSenderID());
if (args.length == 5) {
Bukkit.getBanList(BanList.Type.NAME).addBan(args[2], args[3], null, null);
try {
diff --git a/src/main/java/moe/xmcn/catsero/utils/ServerTPS.java b/src/main/java/moe/xmcn/catsero/utils/ServerTPS.java
index 19f531c7..6172b86f 100644
--- a/src/main/java/moe/xmcn/catsero/utils/ServerTPS.java
+++ b/src/main/java/moe/xmcn/catsero/utils/ServerTPS.java
@@ -1,8 +1,8 @@
package moe.xmcn.catsero.utils;
public class ServerTPS implements Runnable {
+ public static final long[] TICKS = new long[600];
public static int TICK_COUNT = 0;
- public static long[] TICKS = new long[600];
public static double getTPS() {
return getTPS(100);