From b1f02b8e07f54b938a7f84f293eea4a0280b8aed Mon Sep 17 00:00:00 2001 From: glowingstone124 Date: Fri, 6 Sep 2024 16:00:00 +0800 Subject: [PATCH] reuse api --- .../vip/qoriginal/quantumplugin/ChatCommandListener.java | 9 +++++---- .../vip/qoriginal/quantumplugin/JoinLeaveListener.java | 1 + .../vip/qoriginal/quantumplugin/PlayerEventListener.java | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/vip/qoriginal/quantumplugin/ChatCommandListener.java b/src/main/java/vip/qoriginal/quantumplugin/ChatCommandListener.java index 169e5a6..50f5160 100644 --- a/src/main/java/vip/qoriginal/quantumplugin/ChatCommandListener.java +++ b/src/main/java/vip/qoriginal/quantumplugin/ChatCommandListener.java @@ -1,5 +1,6 @@ package vip.qoriginal.quantumplugin; +import io.papermc.paper.event.player.AsyncChatEvent; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.event.ClickEvent; import net.kyori.adventure.text.format.TextColor; @@ -11,8 +12,8 @@ public class ChatCommandListener implements Listener { @EventHandler - public void onChat(AsyncPlayerChatEvent event) throws Exception { - if ((event.getMessage().contains("怎么") || event.getMessage().contains("如何")) && event.getMessage().length() > 4) { + public void onChat(AsyncChatEvent event) throws Exception { + if ((event.message().toString().contains("怎么") || event.message().toString().contains("如何")) && event.message().toString().length() > 4) { event.getPlayer().sendMessage(Component.text("【友情提醒】本服务器已和 ") .append(Component.text("G").color(TextColor.color(66, 133, 244))) .append(Component.text("o").color(TextColor.color(233, 66, 53))) @@ -23,8 +24,8 @@ public void onChat(AsyncPlayerChatEvent event) throws Exception { .append(Component.text(" 达成合作,有不懂的可以直接查!"))); } - if (event.getMessage().startsWith("./")) { - String command = "/" + event.getMessage().substring(2).trim(); + if (event.message().toString().startsWith("./")) { + String command = "/" + event.message().toString().substring(2).trim(); Component chatShareCommandComponent = Component.text("玩家 <") .append(Component.text(event.getPlayer().getName())) .append(Component.text("> 分享了了命令: [").clickEvent(ClickEvent.copyToClipboard(command))) diff --git a/src/main/java/vip/qoriginal/quantumplugin/JoinLeaveListener.java b/src/main/java/vip/qoriginal/quantumplugin/JoinLeaveListener.java index 4ff9fba..ed28da1 100644 --- a/src/main/java/vip/qoriginal/quantumplugin/JoinLeaveListener.java +++ b/src/main/java/vip/qoriginal/quantumplugin/JoinLeaveListener.java @@ -99,6 +99,7 @@ public void onPlayerQuit(PlayerQuitEvent event) throws Exception { player.sendMessage("你的本次游玩时长为: " + minutesPlayed + " 分钟"); cs.sendChatMsg("玩家" + event.getPlayer().getName() + "退出了服务器,本次游玩时间 " + minutesPlayed + "分钟"); Request.sendPostRequest("http://qoriginal.vip:8080/qo/upload/gametimerecord?name=" + player.getName() + "&time=" + minutesPlayed, ""); + Request.sendPostRequest("http://qoriginal.vip:8080/qo/offline?name=" + player.getName(), ""); sessionStartTimes.remove(player); } } diff --git a/src/main/java/vip/qoriginal/quantumplugin/PlayerEventListener.java b/src/main/java/vip/qoriginal/quantumplugin/PlayerEventListener.java index 9bde136..dc6ac7c 100644 --- a/src/main/java/vip/qoriginal/quantumplugin/PlayerEventListener.java +++ b/src/main/java/vip/qoriginal/quantumplugin/PlayerEventListener.java @@ -27,6 +27,7 @@ public void onPlayerExpChange(PlayerExpChangeEvent event) { if (newLevel > oldLevel && newLevel >= 100) { cs.sendChatMsg("玩家 " + player.getName() + " 的等级已经超过了100级,现在等级为:" + newLevel); } + } private int getExpToLevel(int level) {