diff --git a/common/src/main/java/net/william278/husksync/HuskSync.java b/common/src/main/java/net/william278/husksync/HuskSync.java index 101cb6a3..e442e202 100644 --- a/common/src/main/java/net/william278/husksync/HuskSync.java +++ b/common/src/main/java/net/william278/husksync/HuskSync.java @@ -50,6 +50,7 @@ import java.io.IOException; import java.io.InputStream; import java.lang.reflect.InvocationTargetException; +import java.text.SimpleDateFormat; import java.util.*; import java.util.logging.Level; @@ -247,10 +248,16 @@ default void initialize(@NotNull String name, @NotNull ThrowingConsumer getUserCheckedOut(@NotNull User user) { final byte[] key = getKey(RedisKeyType.DATA_CHECKOUT, user.getUuid(), clusterId); final byte[] readData = jedis.get(key); if (readData != null) { - plugin.debug(String.format("[%s] [%s] Read %s key from Redis server", user.getUsername(), - SimpleDateFormat.getDateTimeInstance().format(new Date()), RedisKeyType.DATA_CHECKOUT)); + plugin.debug(String.format("[%s] Read %s key from Redis server", user.getUsername(), + RedisKeyType.DATA_CHECKOUT)); return Optional.of(new String(readData, StandardCharsets.UTF_8)); } } catch (Throwable e) { plugin.log(Level.SEVERE, "An exception occurred getting a user's checkout key from Redis", e); } - plugin.debug(String.format("[%s] [%s] Waiting for %s key from Redis server", user.getUsername(), - SimpleDateFormat.getDateTimeInstance().format(new Date()), RedisKeyType.DATA_CHECKOUT)); + plugin.debug(String.format("[%s] Waiting for %s key from Redis server", user.getUsername(), + RedisKeyType.DATA_CHECKOUT)); return Optional.empty(); } @@ -268,8 +266,8 @@ public void setUserServerSwitch(@NotNull User user) { getKey(RedisKeyType.SERVER_SWITCH, user.getUuid(), clusterId), RedisKeyType.SERVER_SWITCH.getTimeToLive(), new byte[0] ); - plugin.debug(String.format("[%s] [%s] Set %s key to Redis server", user.getUsername(), - SimpleDateFormat.getDateTimeInstance().format(new Date()), RedisKeyType.SERVER_SWITCH)); + plugin.debug(String.format("[%s] Set %s key to Redis server", + user.getUsername(), RedisKeyType.SERVER_SWITCH)); } catch (Throwable e) { plugin.log(Level.SEVERE, "An exception occurred setting a user's server switch key from Redis", e); } @@ -287,12 +285,12 @@ public Optional getUserData(@NotNull User user) { final byte[] key = getKey(RedisKeyType.DATA_UPDATE, user.getUuid(), clusterId); final byte[] dataByteArray = jedis.get(key); if (dataByteArray == null) { - plugin.debug(String.format("[%s] [%s] Waiting for %s key from Redis server", user.getUsername(), - SimpleDateFormat.getDateTimeInstance().format(new Date()), RedisKeyType.DATA_UPDATE)); + plugin.debug(String.format("[%s] Waiting for %s key from Redis server", + user.getUsername(), RedisKeyType.DATA_UPDATE)); return Optional.empty(); } - plugin.debug(String.format("[%s] [%s] Read %s key from Redis server", user.getUsername(), - SimpleDateFormat.getDateTimeInstance().format(new Date()), RedisKeyType.DATA_UPDATE)); + plugin.debug(String.format("[%s] Read %s key from Redis server", + user.getUsername(), RedisKeyType.DATA_UPDATE)); // Consume the key (delete from redis) jedis.del(key); @@ -300,7 +298,7 @@ public Optional getUserData(@NotNull User user) { // Use Snappy to decompress the json return Optional.of(DataSnapshot.deserialize(plugin, dataByteArray)); } catch (Throwable e) { - plugin.log(Level.SEVERE, "An exception occurred getting a user's data from redis", e); + plugin.log(Level.SEVERE, "An exception occurred getting a user's data from Redis", e); return Optional.empty(); } } @@ -311,18 +309,18 @@ public boolean getUserServerSwitch(@NotNull User user) { final byte[] key = getKey(RedisKeyType.SERVER_SWITCH, user.getUuid(), clusterId); final byte[] readData = jedis.get(key); if (readData == null) { - plugin.debug(String.format("[%s] [%s] Waiting for %s key from Redis server", user.getUsername(), - SimpleDateFormat.getDateTimeInstance().format(new Date()), RedisKeyType.SERVER_SWITCH)); + plugin.debug(String.format("[%s] Waiting for %s key from Redis server", + user.getUsername(), RedisKeyType.SERVER_SWITCH)); return false; } - plugin.debug(String.format("[%s] [%s] Read %s key from Redis server", user.getUsername(), - SimpleDateFormat.getDateTimeInstance().format(new Date()), RedisKeyType.SERVER_SWITCH)); + plugin.debug(String.format("[%s] Read %s key from Redis server", + user.getUsername(), RedisKeyType.SERVER_SWITCH)); // Consume the key (delete from redis) jedis.del(key); return true; } catch (Throwable e) { - plugin.log(Level.SEVERE, "An exception occurred getting a user's server switch from redis", e); + plugin.log(Level.SEVERE, "An exception occurred getting a user's server switch from Redis", e); return false; } } diff --git a/common/src/main/java/net/william278/husksync/sync/DataSyncer.java b/common/src/main/java/net/william278/husksync/sync/DataSyncer.java index 82fe06e8..900b8b5c 100644 --- a/common/src/main/java/net/william278/husksync/sync/DataSyncer.java +++ b/common/src/main/java/net/william278/husksync/sync/DataSyncer.java @@ -27,8 +27,6 @@ import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; -import java.text.SimpleDateFormat; -import java.util.Date; import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReference; import java.util.function.Function; @@ -116,8 +114,8 @@ protected void listenForRedisData(@NotNull OnlineUser user, @NotNull Supplier maxListenAttempts) { task.get().cancel(); - plugin.debug(String.format("[%s] [%s] Redis timed out after %s attempts; setting from database", - user.getUsername(), SimpleDateFormat.getDateTimeInstance().format(new Date()), timesRun.get())); + plugin.debug(String.format("[%s] Redis timed out after %s attempts; setting from database", + user.getUsername(), timesRun.get())); setUserFromDatabase(user); return; }