Skip to content

Commit

Permalink
添加了 WHITE_TIMEOUT 查询标签
Browse files Browse the repository at this point in the history
  • Loading branch information
ApliNi committed Aug 9, 2024
1 parent c5e3457 commit 552ec68
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 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>ApliNi</groupId>
<artifactId>IpacWhitelist</artifactId>
<version>4.1.1-rc5</version>
<version>4.1.2</version>
<packaging>jar</packaging>

<name>IpacWhitelist</name>
Expand Down
1 change: 1 addition & 0 deletions src/main/java/aplini/ipacwhitelist/enums/Key.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public enum Key {
GET_VISIT_CONVERT,
GET_ALL,
GET_NAME_CONFLICT,
GET_WHITE_TIMEOUT,
ERR,
TRUE,
FALSE,
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/aplini/ipacwhitelist/listener/cmd/list.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static void cmd(CommandSender sender, String[] args){
}

if(args.length < 2){
sender.sendMessage("/wl list <Type>");
sender.sendMessage("/wl list <NOT | VISIT | WHITE | VISIT_CONVERT | BAN | ALL | NAME_CONFLICT | WHITE_TIMEOUT>");
return;
}

Expand All @@ -41,6 +41,7 @@ public static void cmd(CommandSender sender, String[] args){
case "BAN" -> sendListMsg(sender, sql.findPlayerDataList("", Key.GET_BAN));
case "ALL" -> sendListMsg(sender, sql.findPlayerDataList("", Key.GET_ALL));
case "NAME_CONFLICT" -> sendListMsg(sender, sql.findPlayerDataList("", Key.GET_NAME_CONFLICT));
case "WHITE_TIMEOUT" -> sendListMsg(sender, sql.findPlayerDataList("", Key.GET_WHITE_TIMEOUT));
default -> sender.sendMessage("/wl list <Type>");
}
}
Expand Down Expand Up @@ -78,7 +79,8 @@ public static List<String> tab(CommandSender sender, String[] args){
"VISIT_CONVERT",
"BAN",
"ALL",
"NAME_CONFLICT"
"NAME_CONFLICT",
"WHITE_TIMEOUT"
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ else if(onOtherPlayer != Type.NOT){
// 白名单
case WHITE -> {
// 白名单超时
if(getTime() - pd.time > config.getLong("whitelist.WHITE.timeOut", 18394560)){
if(pd.time < getTime() - config.getLong("whitelist.WHITE.timeOut", 18394560)){
event.disallow(KICK_OTHER, config.getString("whitelist.WHITE.timeOutMsg", ""));
return;
}
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/aplini/ipacwhitelist/utils/sql.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ public static List<PlayerData> findPlayerDataList(String inp, Key mode){
case GET_ALLOW_BAN -> // 获取可以被封禁的账户
" AND (`Type` = '%s' OR `Type` = '%s') AND `Ban` = '%s' ".formatted(Type.WHITE.num, Type.VISIT.num, Type.NOT.num);

case GET_WHITE_TIMEOUT -> {
long timeout = getTime() - config.getLong("whitelist.WHITE.timeOut", 18394560);
yield " AND `Type` = '%s' AND `Time` < '%s' ".formatted(Type.WHITE.num, timeout);
}

case GET_ALL -> {
sql = conn.prepareStatement("SELECT * FROM `player` LIMIT 999999;");
yield "";
Expand Down

0 comments on commit 552ec68

Please sign in to comment.