Skip to content

Commit

Permalink
Merge pull request #26 from Blue-Millennium/25-fix-bugs-in-data-query
Browse files Browse the repository at this point in the history
25 fix bugs in data query
  • Loading branch information
Suisuroru authored Jan 19, 2025
2 parents 3d7446e + 418b5c9 commit df5797c
Show file tree
Hide file tree
Showing 21 changed files with 90 additions and 189 deletions.
10 changes: 4 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
plugins {
id 'java'
id 'com.gradleup.shadow' version '8.3.3'
id 'com.gradleup.shadow' version '8.3.5'
id 'idea'
}

group = 'Blue-Millennium'
version = '2.7.2'
version = '2.7.3'

idea {
module {
Expand All @@ -14,12 +14,10 @@ idea {
}

repositories {
maven { url 'https://jitpack.io' }
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/public' }
maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots' }
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
maven { url 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' }
maven { url 'https://hub.spigotmc.org/nexus/content/repositories/snapshots' }
mavenCentral()
}

Expand All @@ -28,7 +26,7 @@ dependencies {
implementation 'top.mrxiaom.mirai:overflow-core-api:1.0.2'
implementation 'top.mrxiaom.mirai:overflow-core:1.0.2'
implementation 'net.mamoe:mirai-core-api:2.16.0'
implementation 'com.github.Glavo:rcon-java:2.0.2'
implementation 'org.glavo:rcon-java:3.0'
implementation 'com.fasterxml.jackson.core:jackson-core:2.18.2'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.18.2'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.18.2'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

import java.util.List;

import static fun.xd.suka.Main.LOGGER;

/**
* @author Suisuroru
* Date: 2024/9/29 22:08
Expand Down Expand Up @@ -46,8 +48,8 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
return true;
} catch (Exception e) {
sender.sendMessage("查询数据失败!");
e.printStackTrace();
return false;
LOGGER.warning(e.getMessage());
return true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import java.lang.reflect.Field;
import java.util.Map;

import static fun.xd.suka.Main.LOGGER;

/**
* @author Suisuroru
* Date: 2024/10/15 00:43
Expand Down Expand Up @@ -48,7 +50,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
sender.sendMessage("§a配置项 " + configName + " 当前的值为: " + value);
} catch (NoSuchFieldException | IllegalAccessException e) {
sender.sendMessage("§c无法获取配置项 " + configName + " 的值,请检查配置文件或联系开发人员。");
e.printStackTrace();
LOGGER.warning(e.getMessage());
}
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;

import static fun.xd.suka.Main.LOGGER;

/**
* @author Suisuroru
* Date: 2024/9/28 13:24
Expand All @@ -29,8 +31,8 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
return true;
} catch (Exception e) {
sender.sendMessage("重新加载配置文件失败!");
e.printStackTrace();
return false;
LOGGER.warning(e.getMessage());
return true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

import java.util.Map;

import static fun.xd.suka.Main.LOGGER;

/**
* @author Suisuroru
* Date: 2024/10/15 02:06
Expand Down Expand Up @@ -53,8 +55,8 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
sender.sendMessage("§a配置项 " + configName + " 已成功设置为 " + value);
} catch (Exception e) {
sender.sendMessage("§c修改配置项 " + configName + " 的值时出错,请检查配置文件或联系开发人员。");
e.printStackTrace();
return false;
LOGGER.warning(e.getMessage());
return true;
}

return true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,30 @@
package fun.suya.suisuroru.commands.execute.othercommands.data.QueryFunctions;

import fun.suya.suisuroru.data.AuthData.DataGet;
import fun.suya.suisuroru.data.AuthData.DataProcess;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;

import static fun.suya.suisuroru.commands.execute.othercommands.data.QueryFunctions.DataQueryByUUID.ProcessFinalData;
import static fun.xd.suka.Main.LOGGER;

public class DataQueryByName implements CommandExecutor {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if (!sender.isOp()) {
sender.sendMessage("您没有权限这么做");
return false;
return true;
}
DataGet dataGet = new DataGet();
String Name;
try {
Name = args[0];
} catch (Exception e) {
LOGGER.info(String.valueOf(e));
return false;
}
String playerJson = dataGet.getPlayersByNameAsJson(Name);
if (!playerJson.isEmpty() && !playerJson.equals("[]")) {
sender.sendMessage(DataProcess.processData(playerJson));
return true;
} else {
sender.sendMessage("查询的数据不存在");
return false;
}
String playerJson = dataGet.getPlayersByNameAsJson(Name);
return ProcessFinalData(sender, playerJson);
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package fun.suya.suisuroru.commands.execute.othercommands.data.QueryFunctions;

import fun.suya.suisuroru.data.AuthData.DataGet;
import fun.suya.suisuroru.data.AuthData.DataProcess;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;

import static fun.suya.suisuroru.commands.execute.othercommands.data.QueryFunctions.DataQueryByUUID.ProcessFinalData;
import static fun.xd.suka.Main.LOGGER;

public class DataQueryByQQ implements CommandExecutor {
Expand All @@ -15,7 +15,7 @@ public class DataQueryByQQ implements CommandExecutor {
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if (!sender.isOp()) {
sender.sendMessage("您没有权限这么做");
return false;
return true;
}
DataGet dataGet = new DataGet();
long QQNum = 0;
Expand All @@ -26,15 +26,9 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
return true;
} catch (Exception e) {
LOGGER.info(String.valueOf(e));
return false;
}
String playerJson = dataGet.getPlayersByQQAsJson(QQNum);
if (!playerJson.isEmpty() && !playerJson.equals("[]")) {
sender.sendMessage(DataProcess.processData(playerJson));
return true;
} else {
sender.sendMessage("查询的数据不存在");
return false;
}
String playerJson = dataGet.getPlayersByQQAsJson(QQNum);
return ProcessFinalData(sender, playerJson);
}
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
package fun.suya.suisuroru.commands.execute.othercommands.data.QueryFunctions;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import fun.suya.suisuroru.data.AuthData.DataGet;
import fun.suya.suisuroru.data.AuthData.DataProcess;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;

import java.lang.reflect.Type;
import java.util.List;
import java.util.UUID;

import static fun.xd.suka.Main.LOGGER;

public class DataQueryByUUID implements CommandExecutor {

@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if (!sender.isOp()) {
sender.sendMessage("您没有权限这么做");
return false;
return true;
}
DataGet dataGet = new DataGet();
UUID Uuid;
Expand All @@ -28,19 +33,29 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
Uuid = UUID.fromString(uuidString);
} catch (IllegalArgumentException e) {
LOGGER.info("§c输入的数据不是UUID");
return false;
return true;
} catch (Exception e) {
LOGGER.info(String.valueOf(e));
return false;
return true;
}
String playerJson = dataGet.getPlayersByUUIDAsJson(Uuid);
return ProcessFinalData(sender, playerJson);
}

static boolean ProcessFinalData(@NotNull CommandSender sender, String playerJson) {
if (!playerJson.isEmpty() && !playerJson.equals("[]")) {
sender.sendMessage(DataProcess.processData(playerJson));
return true;
Gson gson = new Gson();
Type listType = new TypeToken<List<Object>>() {
}.getType();
List<Object> playerList = gson.fromJson(playerJson, listType);
for (Object player : playerList) {
String processedData = DataProcess.processData(gson.toJson(player));
sender.sendMessage(processedData);
}
} else {
sender.sendMessage("查询的数据不存在");
return false;
}
return true;
}

private String insertHyphens(String uuid) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
if (Config.UnionBanEnabled) {
if (!sender.isOp()) {
sender.sendMessage("您没有权限这么做");
return false;
return true;
}

if (args.length == 0) {
sender.sendMessage("Usage: /ban <player> [reason]");
return false;
return true;
}

String playerName = args[0];
Expand All @@ -53,7 +53,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command

if (targetPlayer == null) {
sender.sendMessage("未找到玩家: " + playerName);
return false;
return true;
}

// 调用原版的 ban 命令
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class Kill implements CommandExecutor {
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if (!sender.isOp()) {
sender.sendMessage("您没有权限这么做");
return false;
return true;
}
switch (args[0]) {
case "@e" -> {
Expand All @@ -38,6 +38,6 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
return Bukkit.dispatchCommand(sender, "minecraft:kill " + String.join(" ", args));
}
}
return false;
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,19 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
if (Config.UnionBanEnabled) {
if (!sender.isOp()) {
sender.sendMessage("您没有权限这么做");
return false;
return true;
}

if (args.length == 0) {
sender.sendMessage("Usage: /pardon <player>");
return false;
return true;
}

String playerName = args[0];

if (!Bukkit.getBanList(BanList.Type.PROFILE).isBanned(playerName)) {
sender.sendMessage("玩家 " + playerName + " 未被封禁");
return false;
return true;
}

// 调用原版的 pardon 命令
Expand Down
50 changes: 2 additions & 48 deletions src/main/java/fun/suya/suisuroru/data/AuthData/AuthData.java
Original file line number Diff line number Diff line change
@@ -1,51 +1,5 @@
package fun.suya.suisuroru.data.AuthData;

public class AuthData {
private final PlayerData playerData;
private final long firstJoin;
private final long lastJoin;
private final long qqNumber;
private final long linkedTime;
private final String firstJoinIp;
private final String lastJoinIp;

// 构造函数
public AuthData(PlayerData playerData, long firstJoin, long lastJoin, long qqNumber, long linkedTime, String firstJoinIp, String lastJoinIp) {
this.playerData = playerData;
this.firstJoin = firstJoin;
this.lastJoin = lastJoin;
this.qqNumber = qqNumber;
this.linkedTime = linkedTime;
this.firstJoinIp = firstJoinIp;
this.lastJoinIp = lastJoinIp;
}

// Getters
public PlayerData getPlayerData() {
return playerData;
}

public long getFirstJoin() {
return firstJoin;
}

public long getLastJoin() {
return lastJoin;
}

public long getQqNumber() {
return qqNumber;
}

public long getLinkedTime() {
return linkedTime;
}

public String getFirstJoinIp() {
return firstJoinIp;
}

public String getLastJoinIp() {
return lastJoinIp;
}
public record AuthData(PlayerData playerData, long firstJoin, long lastJoin, long qqNumber, long linkedTime,
String firstJoinIp, String lastJoinIp) {
}
Loading

0 comments on commit df5797c

Please sign in to comment.