mirror of
https://github.com/Melledy/Nebula.git
synced 2025-12-24 18:24:47 +01:00
Implement ban functionality
- Added ban module - Added Ban and Unban commands, supporting banning and unbanning players through various command parameters. - Added timestamp formatting method in Utils utility class for displaying ban expiration times - Introduced PlayerErrorCode enum defining various error codes including ErrBan - Added dual ban checking for both IP and user during player login - Optimized login failure responses to provide specific error reasons and parameters
This commit is contained in:
@@ -4,13 +4,17 @@ import java.io.File;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.ServerSocket;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.YearMonth;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
import emu.nebula.GameConstants;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
|
||||
public class Utils {
|
||||
@@ -321,4 +325,16 @@ public class Utils {
|
||||
var month = YearMonth.of(date.getYear(), date.getMonthValue());
|
||||
return month.lengthOfMonth();
|
||||
}
|
||||
|
||||
public static String formatTimestamp(long timestamp) {
|
||||
return Instant.ofEpochMilli(timestamp)
|
||||
.atZone(GameConstants.UTC_ZONE)
|
||||
.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
}
|
||||
|
||||
public static String formatTimestamp(long timestamp, String pattern) {
|
||||
return Instant.ofEpochMilli(timestamp)
|
||||
.atZone(GameConstants.UTC_ZONE)
|
||||
.format(DateTimeFormatter.ofPattern(pattern));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user