diff --git a/api/src/main/java/com/imaginarycode/minecraft/redisbungee/Constants.java b/api/src/main/java/com/imaginarycode/minecraft/redisbungee/Constants.java index 4471b0f..3188bac 100644 --- a/api/src/main/java/com/imaginarycode/minecraft/redisbungee/Constants.java +++ b/api/src/main/java/com/imaginarycode/minecraft/redisbungee/Constants.java @@ -17,7 +17,7 @@ public class Constants { public final static String GIT_COMMIT = "@git_commit@"; public static String getGithubCommitLink() { - return "https://github.com/ProxioDev/RedisBungee/commit/" + GIT_COMMIT; + return "https://github.com/ProxioDev/ValioBungee/commit/" + GIT_COMMIT; } } diff --git a/api/src/main/java/com/imaginarycode/minecraft/redisbungee/api/util/uuid/CachedUUIDEntry.java b/api/src/main/java/com/imaginarycode/minecraft/redisbungee/api/util/uuid/CachedUUIDEntry.java index 84f5059..f3729f4 100644 --- a/api/src/main/java/com/imaginarycode/minecraft/redisbungee/api/util/uuid/CachedUUIDEntry.java +++ b/api/src/main/java/com/imaginarycode/minecraft/redisbungee/api/util/uuid/CachedUUIDEntry.java @@ -13,28 +13,7 @@ package com.imaginarycode.minecraft.redisbungee.api.util.uuid; import java.util.Calendar; import java.util.UUID; -public class CachedUUIDEntry { - private final String name; - private final UUID uuid; - private final Calendar expiry; - - public CachedUUIDEntry(String name, UUID uuid, Calendar expiry) { - this.name = name; - this.uuid = uuid; - this.expiry = expiry; - } - - public String getName() { - return name; - } - - public UUID getUuid() { - return uuid; - } - - public Calendar getExpiry() { - return expiry; - } +public record CachedUUIDEntry(String name, UUID uuid, Calendar expiry) { public boolean expired() { return Calendar.getInstance().after(expiry); diff --git a/api/src/main/java/com/imaginarycode/minecraft/redisbungee/api/util/uuid/NameFetcher.java b/api/src/main/java/com/imaginarycode/minecraft/redisbungee/api/util/uuid/NameFetcher.java index 3bcd38c..ea27697 100644 --- a/api/src/main/java/com/imaginarycode/minecraft/redisbungee/api/util/uuid/NameFetcher.java +++ b/api/src/main/java/com/imaginarycode/minecraft/redisbungee/api/util/uuid/NameFetcher.java @@ -12,9 +12,9 @@ package com.imaginarycode.minecraft.redisbungee.api.util.uuid; import com.google.gson.Gson; import com.google.gson.JsonObject; -import com.squareup.okhttp.OkHttpClient; -import com.squareup.okhttp.Request; -import com.squareup.okhttp.ResponseBody; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.ResponseBody; import java.io.IOException; import java.util.Collections; @@ -22,13 +22,9 @@ import java.util.List; import java.util.UUID; public class NameFetcher { - private static OkHttpClient httpClient; + private static final OkHttpClient httpClient = new OkHttpClient(); private static final Gson gson = new Gson(); - public static void setHttpClient(OkHttpClient httpClient) { - NameFetcher.httpClient = httpClient; - } - public static List nameHistoryFromUuid(UUID uuid) throws IOException { String name = getName(uuid); if (name == null) return Collections.emptyList(); diff --git a/api/src/main/java/com/imaginarycode/minecraft/redisbungee/api/util/uuid/UUIDFetcher.java b/api/src/main/java/com/imaginarycode/minecraft/redisbungee/api/util/uuid/UUIDFetcher.java index 06433e2..f1f649f 100644 --- a/api/src/main/java/com/imaginarycode/minecraft/redisbungee/api/util/uuid/UUIDFetcher.java +++ b/api/src/main/java/com/imaginarycode/minecraft/redisbungee/api/util/uuid/UUIDFetcher.java @@ -12,7 +12,7 @@ package com.imaginarycode.minecraft.redisbungee.api.util.uuid; import com.google.common.collect.ImmutableList; import com.google.gson.Gson; -import com.squareup.okhttp.*; +import okhttp3.*; import java.util.HashMap; import java.util.List; @@ -28,13 +28,7 @@ public class UUIDFetcher implements Callable> { private final List names; private final boolean rateLimiting; private static final Gson gson = new Gson(); - - - public static void setHttpClient(OkHttpClient httpClient) { - UUIDFetcher.httpClient = httpClient; - } - - private static OkHttpClient httpClient; + private static final OkHttpClient httpClient = new OkHttpClient(); private UUIDFetcher(List names, boolean rateLimiting) { this.names = ImmutableList.copyOf(names); diff --git a/api/src/main/java/com/imaginarycode/minecraft/redisbungee/api/util/uuid/UUIDTranslator.java b/api/src/main/java/com/imaginarycode/minecraft/redisbungee/api/util/uuid/UUIDTranslator.java index acccf40..ffb62b1 100644 --- a/api/src/main/java/com/imaginarycode/minecraft/redisbungee/api/util/uuid/UUIDTranslator.java +++ b/api/src/main/java/com/imaginarycode/minecraft/redisbungee/api/util/uuid/UUIDTranslator.java @@ -61,7 +61,7 @@ public final class UUIDTranslator { CachedUUIDEntry cachedUUIDEntry = nameToUuidMap.get(player.toLowerCase()); if (cachedUUIDEntry != null) { if (!cachedUUIDEntry.expired()) - return cachedUUIDEntry.getUuid(); + return cachedUUIDEntry.uuid(); else nameToUuidMap.remove(player); } @@ -93,11 +93,11 @@ public final class UUIDTranslator { if (entry.expired()) { unifiedJedis.hdel("uuid-cache", player.toLowerCase()); // Doesn't hurt to also remove the UUID entry as well. - unifiedJedis.hdel("uuid-cache", entry.getUuid().toString()); + unifiedJedis.hdel("uuid-cache", entry.uuid().toString()); } else { nameToUuidMap.put(player.toLowerCase(), entry); - uuidToNameMap.put(entry.getUuid(), entry); - return entry.getUuid(); + uuidToNameMap.put(entry.uuid(), entry); + return entry.uuid(); } } @@ -141,7 +141,7 @@ public final class UUIDTranslator { CachedUUIDEntry cachedUUIDEntry = uuidToNameMap.get(player); if (cachedUUIDEntry != null) { if (!cachedUUIDEntry.expired()) - return cachedUUIDEntry.getName(); + return cachedUUIDEntry.name(); else uuidToNameMap.remove(player); } @@ -159,11 +159,11 @@ public final class UUIDTranslator { unifiedJedis.hdel("uuid-cache", player.toString()); // Doesn't hurt to also remove the named entry as well. // TODO: Since UUIDs are fixed, we could look up the name and see if the UUID matches. - unifiedJedis.hdel("uuid-cache", entry.getName()); + unifiedJedis.hdel("uuid-cache", entry.name()); } else { - nameToUuidMap.put(entry.getName().toLowerCase(), entry); + nameToUuidMap.put(entry.name().toLowerCase(), entry); uuidToNameMap.put(player, entry); - return entry.getName(); + return entry.name(); } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 1c37ba5..08b742e 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,7 +1,7 @@ [versions] guava = "31.1-jre" jedis = "5.2.0" -okhttp = "2.7.5" +okhttp = "4.12.0" configurateV3 = "3.7.3" caffeine = "3.1.8" adventure = "4.18.0" @@ -12,13 +12,13 @@ velocity = "3.4.0-SNAPSHOT" [plugins] blossom = { id = "net.kyori.blossom", version = "1.2.0" } -shadow = { id = "com.github.johnrengelman.shadow", version = "8.1.1" } -run-velocity = { id = "xyz.jpenilla.run-velocity", version = "2.0.0" } +shadow = { id = "com.gradleup.shadow", version = "8.3.5" } +run-velocity = { id = "xyz.jpenilla.run-velocity", version = "2.3.1" } [libraries] guava = { module = "com.google.guava:guava", version.ref = "guava" } jedis = { module = "redis.clients:jedis", version.ref = "jedis" } -okhttp = { module = "com.squareup.okhttp:okhttp", version.ref = "okhttp" } +okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" } configurateV3 = { module = "org.spongepowered:configurate-yaml", version.ref = "configurateV3" } caffeine = { module = "com.github.ben-manes.caffeine:caffeine", version.ref = "caffeine" } diff --git a/proxies/bungeecord/build.gradle.kts b/proxies/bungeecord/build.gradle.kts index 6216aa8..d315444 100644 --- a/proxies/bungeecord/build.gradle.kts +++ b/proxies/bungeecord/build.gradle.kts @@ -46,7 +46,7 @@ tasks { relocate("redis.clients.jedis", "com.imaginarycode.minecraft.redisbungee.internal.jedis") relocate("redis.clients.util", "com.imaginarycode.minecraft.redisbungee.internal.jedisutil") relocate("org.apache.commons.pool", "com.imaginarycode.minecraft.redisbungee.internal.commonspool") - relocate("com.squareup.okhttp", "com.imaginarycode.minecraft.redisbungee.internal.okhttp") + relocate("com.squareup.okhttp3", "com.imaginarycode.minecraft.redisbungee.internal.okhttp3") relocate("okio", "com.imaginarycode.minecraft.redisbungee.internal.okio") relocate("org.json", "com.imaginarycode.minecraft.redisbungee.internal.json") // configurate shade diff --git a/proxies/bungeecord/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungee.java b/proxies/bungeecord/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungee.java index d5ae22b..4fd9094 100644 --- a/proxies/bungeecord/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungee.java +++ b/proxies/bungeecord/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungee.java @@ -25,8 +25,6 @@ import com.imaginarycode.minecraft.redisbungee.api.events.IPlayerLeftNetworkEven import com.imaginarycode.minecraft.redisbungee.api.events.IPubSubMessageEvent; import com.imaginarycode.minecraft.redisbungee.api.summoners.Summoner; import com.imaginarycode.minecraft.redisbungee.api.util.InitialUtils; -import com.imaginarycode.minecraft.redisbungee.api.util.uuid.NameFetcher; -import com.imaginarycode.minecraft.redisbungee.api.util.uuid.UUIDFetcher; import com.imaginarycode.minecraft.redisbungee.api.util.uuid.UUIDTranslator; import com.imaginarycode.minecraft.redisbungee.commands.CommandLoader; import com.imaginarycode.minecraft.redisbungee.commands.utils.CommandPlatformHelper; @@ -34,8 +32,6 @@ import com.imaginarycode.minecraft.redisbungee.events.PlayerChangedServerNetwork import com.imaginarycode.minecraft.redisbungee.events.PlayerJoinedNetworkEvent; import com.imaginarycode.minecraft.redisbungee.events.PlayerLeftNetworkEvent; import com.imaginarycode.minecraft.redisbungee.events.PubSubMessageEvent; -import com.squareup.okhttp.Dispatcher; -import com.squareup.okhttp.OkHttpClient; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.serializer.bungeecord.BungeeComponentSerializer; import net.md_5.bungee.api.ProxyServer; @@ -72,7 +68,6 @@ public class RedisBungee extends Plugin implements RedisBungeePlugin this.proxyDataManager.correctionTask(), 0, 60, TimeUnit.SECONDS); // init the http lib - httpClient = new OkHttpClient(); - Dispatcher dispatcher = new Dispatcher(getExecutorService()); - httpClient.setDispatcher(dispatcher); - NameFetcher.setHttpClient(httpClient); - UUIDFetcher.setHttpClient(httpClient); InitialUtils.checkRedisVersion(this); uuidTranslator = new UUIDTranslator(this); diff --git a/proxies/velocity/build.gradle.kts b/proxies/velocity/build.gradle.kts index e68d146..950fcd1 100644 --- a/proxies/velocity/build.gradle.kts +++ b/proxies/velocity/build.gradle.kts @@ -21,7 +21,7 @@ java { tasks { runVelocity { - velocityVersion("3.4.0-SNAPSHOT") + velocityVersion(libs.versions.velocity.get()) environment["REDISBUNGEE_PROXY_ID"] = "velocity-1" environment["REDISBUNGEE_NETWORK_ID"] = "dev" } @@ -36,7 +36,7 @@ tasks { relocate("redis.clients.jedis", "com.imaginarycode.minecraft.redisbungee.internal.jedis") relocate("redis.clients.util", "com.imaginarycode.minecraft.redisbungee.internal.jedisutil") relocate("org.apache.commons.pool", "com.imaginarycode.minecraft.redisbungee.internal.commonspool") - relocate("com.squareup.okhttp", "com.imaginarycode.minecraft.redisbungee.internal.okhttp") + relocate("com.squareup.okhttp3", "com.imaginarycode.minecraft.redisbungee.internal.okhttp3") relocate("okio", "com.imaginarycode.minecraft.redisbungee.internal.okio") relocate("org.json", "com.imaginarycode.minecraft.redisbungee.internal.json") // acf shade diff --git a/proxies/velocity/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeVelocityPlugin.java b/proxies/velocity/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeVelocityPlugin.java index 0a1ffe0..103dcef 100644 --- a/proxies/velocity/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeVelocityPlugin.java +++ b/proxies/velocity/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeVelocityPlugin.java @@ -35,8 +35,6 @@ import com.imaginarycode.minecraft.redisbungee.events.PlayerChangedServerNetwork import com.imaginarycode.minecraft.redisbungee.events.PlayerJoinedNetworkEvent; import com.imaginarycode.minecraft.redisbungee.events.PlayerLeftNetworkEvent; import com.imaginarycode.minecraft.redisbungee.events.PubSubMessageEvent; -import com.squareup.okhttp.Dispatcher; -import com.squareup.okhttp.OkHttpClient; import com.velocitypowered.api.event.PostOrder; import com.velocitypowered.api.event.Subscribe; import com.velocitypowered.api.event.proxy.ProxyInitializeEvent; @@ -78,7 +76,6 @@ public class RedisBungeeVelocityPlugin implements RedisBungeePlugin, Con private final UUIDTranslator uuidTranslator; private RedisBungeeConfiguration configuration; private LangConfiguration langConfiguration; - private final OkHttpClient httpClient; private final ProxyDataManager proxyDataManager; @@ -127,11 +124,6 @@ public class RedisBungeeVelocityPlugin implements RedisBungeePlugin, Con }; this.playerDataManager = new VelocityPlayerDataManager(this); uuidTranslator = new UUIDTranslator(this); - this.httpClient = new OkHttpClient(); - Dispatcher dispatcher = new Dispatcher(Executors.newFixedThreadPool(6)); - this.httpClient.setDispatcher(dispatcher); - NameFetcher.setHttpClient(httpClient); - UUIDFetcher.setHttpClient(httpClient); } @@ -300,8 +292,6 @@ public class RedisBungeeVelocityPlugin implements RedisBungeePlugin, Con if (heartbeatTask != null) { heartbeatTask.cancel(); } - - try { this.proxyDataManager.close(); this.jedisSummoner.close(); @@ -309,13 +299,6 @@ public class RedisBungeeVelocityPlugin implements RedisBungeePlugin, Con throw new RuntimeException(e); } - this.httpClient.getDispatcher().getExecutorService().shutdown(); - try { - logInfo("waiting for httpclient thread-pool termination....."); - this.httpClient.getDispatcher().getExecutorService().awaitTermination(20, TimeUnit.SECONDS); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } if (commandManager != null) commandManager.unregisterCommands(); logInfo("RedisBungee shutdown complete"); }