Skip to content

Commit

Permalink
feat: 修改 CatSeedLoginAPI 和其他几个类,更改 getLastLoginTime 方法的返回类型为 Long,并更新…
Browse files Browse the repository at this point in the history
…相关调用此方法的代码。同时,更新了 recordCurrentIP 方法,使其能够正确处理 Player 对象的元数据。
  • Loading branch information
shulng committed Jul 11, 2024
1 parent 0929b98 commit 81818ed
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static boolean isRegister(String name) {
* @return 时间戳- 未注册为null
* @since 1.4.2
*/
public static boolean getLastLoginTime(String name) {
public static Long getLastLoginTime(String name) {
return LoginPlayerHelper.getLastLoginTime(name);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public boolean onCommand(CommandSender sender, Command command, String s, String
if (Config.Settings.BedrockLoginBypass && LoginPlayerHelper.isFloodgatePlayer(player)){
return true;
}
if (Config.Settings.LoginwiththesameIP && LoginPlayerHelper.getLastLoginTime(player)){
if (Config.Settings.LoginwiththesameIP && LoginPlayerHelper.recordCurrentIP(player)){
return true;
}
LoginPlayer lp = Cache.getIgnoreCase(name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public boolean onCommand(CommandSender sender, Command command, String lable, St
if (Config.Settings.BedrockLoginBypass && LoginPlayerHelper.isFloodgatePlayer((Player) sender)){
return true;
}
if (Config.Settings.LoginwiththesameIP && LoginPlayerHelper.getLastLoginTime((Player) sender)){
if (Config.Settings.LoginwiththesameIP && LoginPlayerHelper.recordCurrentIP((Player) sender)){
return true;
}
LoginPlayer lp = Cache.getIgnoreCase(name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public boolean onCommand(CommandSender sender, Command command, String lable, St
if (Config.Settings.BedrockLoginBypass && LoginPlayerHelper.isFloodgatePlayer(player)){
return true;
}
if (Config.Settings.LoginwiththesameIP && LoginPlayerHelper.getLastLoginTime(player)){
if (Config.Settings.LoginwiththesameIP && LoginPlayerHelper.recordCurrentIP(player)){
return true;
}
if (LoginPlayerHelper.isLogin(name)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public boolean onCommand(CommandSender sender, Command command, String lable, St
if (Config.Settings.BedrockLoginBypass && LoginPlayerHelper.isFloodgatePlayer(player)){
return true;
}
if (Config.Settings.LoginwiththesameIP && LoginPlayerHelper.getLastLoginTime(player)){
if (Config.Settings.LoginwiththesameIP && LoginPlayerHelper.recordCurrentIP(player)){
return true;
}
if (LoginPlayerHelper.isLogin(name)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public boolean onCommand(CommandSender sender, Command command, String s, String
if (Config.Settings.BedrockLoginBypass && LoginPlayerHelper.isFloodgatePlayer(player)){
return true;
}
if (Config.Settings.LoginwiththesameIP && LoginPlayerHelper.getLastLoginTime(player)){
if (Config.Settings.LoginwiththesameIP && LoginPlayerHelper.recordCurrentIP(player)){
return true;
}
LoginPlayer lp = Cache.getIgnoreCase(name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static boolean isLogin(String name){
if (Config.Settings.BedrockLoginBypass && isFloodgatePlayer(name)){
return true;
}
if (Config.Settings.LoginwiththesameIP && getLastLoginTime(name)){
if (Config.Settings.LoginwiththesameIP && recordCurrentIP(name)){
return true;
}
for (LoginPlayer lp : set) {
Expand All @@ -77,20 +77,20 @@ public static boolean isRegister(String name){
if (Config.Settings.BedrockLoginBypass && isFloodgatePlayer(name)){
return true;
}
if (Config.Settings.LoginwiththesameIP && getLastLoginTime(name)){
if (Config.Settings.LoginwiththesameIP && recordCurrentIP(name)){
return true;
}
return Cache.getIgnoreCase(name) != null;

}

public static boolean getLastLoginTime(String name) {
public static boolean recordCurrentIP(String name) {
Player player = Bukkit.getPlayerExact(name);
return player != null && getLastLoginTime(player);
return player != null && recordCurrentIP(player);
}

public static boolean getLastLoginTime(Player player) {
return Bukkit.getPluginManager().getPlugin("floodgate") != null && FloodgateApi.getInstance().isFloodgatePlayer(player.getUniqueId());
public static boolean recordCurrentIP(Player player) {
return player.hasMetadata("LastLoginTime") && player.getMetadata("LastLoginTime").size() > 0;
}


Expand All @@ -107,12 +107,12 @@ public static boolean isFloodgatePlayer(Player player) {
return Bukkit.getPluginManager().getPlugin("floodgate") != null && FloodgateApi.getInstance().isFloodgatePlayer(player.getUniqueId());
}

public static boolean isLastLoginTime(String name) {
public static Long getLastLoginTime(String name) {
LoginPlayer loginPlayer = Cache.getIgnoreCase(name);
if (loginPlayer == null) {
return false;
return null;
}
return loginPlayer.getLastAction() != 0;
return loginPlayer.getLastAction();
}

// 记录登录IP
Expand Down

0 comments on commit 81818ed

Please sign in to comment.