From c7baa27fd08451a44f10ec55cdcc0ca5bcd820fc Mon Sep 17 00:00:00 2001 From: EnZaXD <60033407+FlorianMichael@users.noreply.github.com> Date: Wed, 14 Feb 2024 22:53:50 +0100 Subject: [PATCH] Some code cleanup (#3698) --- .../viaversion/viaversion/bukkit/util/ProtocolSupportUtil.java | 1 + .../viaversion/viaversion/bungee/platform/BungeeViaConfig.java | 2 +- .../viaversion/viaversion/configuration/AbstractViaConfig.java | 2 +- common/src/main/java/com/viaversion/viaversion/util/Config.java | 2 +- .../viaversion/velocity/platform/VelocityViaConfig.java | 2 +- 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/bukkit-legacy/src/main/java/com/viaversion/viaversion/bukkit/util/ProtocolSupportUtil.java b/bukkit-legacy/src/main/java/com/viaversion/viaversion/bukkit/util/ProtocolSupportUtil.java index 986e026ef..aec90eaf9 100644 --- a/bukkit-legacy/src/main/java/com/viaversion/viaversion/bukkit/util/ProtocolSupportUtil.java +++ b/bukkit-legacy/src/main/java/com/viaversion/viaversion/bukkit/util/ProtocolSupportUtil.java @@ -47,6 +47,7 @@ public final class ProtocolSupportUtil { try { final Object version = PROTOCOL_VERSION_METHOD.invoke(null, player); final int id = (int) GET_ID_METHOD.invoke(version); + // List of pre netty (<= 1.6.4) versions supported by ProtocolSupport, needs to be updated if ProtocolSupport adds support for new versions. final boolean preNetty = id == 78 || id == 74 || id == 73 || id == 61 || id == 60 || id == 51; return ProtocolVersion.getProtocol(preNetty ? VersionType.RELEASE_INITIAL : VersionType.RELEASE, id); diff --git a/bungee/src/main/java/com/viaversion/viaversion/bungee/platform/BungeeViaConfig.java b/bungee/src/main/java/com/viaversion/viaversion/bungee/platform/BungeeViaConfig.java index d784537c0..bd4673419 100644 --- a/bungee/src/main/java/com/viaversion/viaversion/bungee/platform/BungeeViaConfig.java +++ b/bungee/src/main/java/com/viaversion/viaversion/bungee/platform/BungeeViaConfig.java @@ -42,7 +42,7 @@ public class BungeeViaConfig extends AbstractViaConfig { super.loadFields(); bungeePingInterval = getInt("bungee-ping-interval", 60); bungeePingSave = getBoolean("bungee-ping-save", true); - bungeeServerProtocols = get("bungee-servers", Map.class, new HashMap<>()); + bungeeServerProtocols = get("bungee-servers", new HashMap<>()); } @Override diff --git a/common/src/main/java/com/viaversion/viaversion/configuration/AbstractViaConfig.java b/common/src/main/java/com/viaversion/viaversion/configuration/AbstractViaConfig.java index f721c1b22..12252042b 100644 --- a/common/src/main/java/com/viaversion/viaversion/configuration/AbstractViaConfig.java +++ b/common/src/main/java/com/viaversion/viaversion/configuration/AbstractViaConfig.java @@ -152,7 +152,7 @@ public abstract class AbstractViaConfig extends Config implements ViaVersionConf ignoreLongChannelNames = getBoolean("ignore-long-1_16-channel-names", true); forcedUse1_17ResourcePack = getBoolean("forced-use-1_17-resource-pack", false); resourcePack1_17PromptMessage = getSerializedComponent("resource-pack-1_17-prompt"); - Map worlds = get("map-1_16-world-names", Map.class, new HashMap()); + Map worlds = get("map-1_16-world-names", new HashMap<>()); map1_16WorldNames = new WorldIdentifiers(worlds.getOrDefault("overworld", WorldIdentifiers.OVERWORLD_DEFAULT), worlds.getOrDefault("nether", WorldIdentifiers.NETHER_DEFAULT), worlds.getOrDefault("end", WorldIdentifiers.END_DEFAULT)); diff --git a/common/src/main/java/com/viaversion/viaversion/util/Config.java b/common/src/main/java/com/viaversion/viaversion/util/Config.java index a7612eafe..05345aa3d 100644 --- a/common/src/main/java/com/viaversion/viaversion/util/Config.java +++ b/common/src/main/java/com/viaversion/viaversion/util/Config.java @@ -165,7 +165,7 @@ public abstract class Config { return this.config; } - public @Nullable T get(String key, Class clazz, T def) { + public @Nullable T get(String key, T def) { Object o = this.config.get(key); if (o != null) { return (T) o; diff --git a/velocity/src/main/java/com/viaversion/viaversion/velocity/platform/VelocityViaConfig.java b/velocity/src/main/java/com/viaversion/viaversion/velocity/platform/VelocityViaConfig.java index ad2dd29da..2a4ce1ed0 100644 --- a/velocity/src/main/java/com/viaversion/viaversion/velocity/platform/VelocityViaConfig.java +++ b/velocity/src/main/java/com/viaversion/viaversion/velocity/platform/VelocityViaConfig.java @@ -41,7 +41,7 @@ public class VelocityViaConfig extends AbstractViaConfig { super.loadFields(); velocityPingInterval = getInt("velocity-ping-interval", 60); velocityPingSave = getBoolean("velocity-ping-save", true); - velocityServerProtocols = get("velocity-servers", Map.class, new HashMap<>()); + velocityServerProtocols = get("velocity-servers", new HashMap<>()); } @Override