From 51f2926470b2ace33c716428bba80f4dd93c1460 Mon Sep 17 00:00:00 2001 From: acrylic-style Date: Mon, 17 Oct 2022 01:38:21 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=8F=B7=204.0.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Deprecate contextualServers - Warn if `contextualServers` is present in config.yml --- .../api/AziPluginMessagingConfig.java | 18 ++++++++++++------ .../handler/ProxyboundClearPrefixPacket.java | 2 +- .../handler/ProxyboundSetPrefixPacket.java | 2 +- build.gradle.kts | 2 +- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/api/src/main/java/net/azisaba/azipluginmessaging/api/AziPluginMessagingConfig.java b/api/src/main/java/net/azisaba/azipluginmessaging/api/AziPluginMessagingConfig.java index 9f8179a..a2947d4 100644 --- a/api/src/main/java/net/azisaba/azipluginmessaging/api/AziPluginMessagingConfig.java +++ b/api/src/main/java/net/azisaba/azipluginmessaging/api/AziPluginMessagingConfig.java @@ -23,6 +23,8 @@ public class AziPluginMessagingConfig { public static final Map servers = new ConcurrentHashMap<>(); public static final Map saraShowServers = new ConcurrentHashMap<>(); public static final Map rankableServers = new ConcurrentHashMap<>(); + @SuppressWarnings("DeprecatedIsStillUsed") // not used outside this class + @Deprecated public static final Map contextualServers = new ConcurrentHashMap<>(); /** @@ -78,6 +80,7 @@ public static void reload() { "# This is used for situations where saraShowServers/rankableServers does not apply.", "# This map is used in:", "# - ProxyboundSetPrefixPacket", + "# - ProxyboundClearPrefixPacket", "servers: # this is meaningless in spigot", " life: life", " lifepve: life", @@ -94,11 +97,6 @@ public static void reload() { " life: life", " lifepve: life", "", - "# for ProxyboundSetPrefixPacket and ProxyboundClearPrefixPacket", - "contextualServers:", - " life: life", - " lifepve: life", - "", "# Database settings (required)", "# This setting is used for setting the rank temporary.", "database:", @@ -136,10 +134,11 @@ public static void reload() { YamlObject obj = new YamlConfiguration(configPath.toAbsolutePath().toString()).asObject(); debug = obj.getBoolean("debug", false); if (AziPluginMessagingProvider.get().getEnvironmentType() == EnvironmentType.VELOCITY) { + readMap(contextualServers, obj, "contextualServers", true); + servers.putAll(contextualServers); readMap(servers, obj, "servers"); readMap(rankableServers, obj, "rankableServers"); readMap(saraShowServers, obj, "saraShowServers"); - readMap(contextualServers, obj, "contextualServers"); AziPluginMessagingProvider.get().getProxy().loadConfig(obj); } } catch (IOException ex) { @@ -148,8 +147,15 @@ public static void reload() { } private static void readMap(@NotNull Map to, @NotNull YamlObject obj, @NotNull String configKey) { + readMap(to, obj, configKey, false); + } + + private static void readMap(@NotNull Map to, @NotNull YamlObject obj, @NotNull String configKey, boolean deprecated) { YamlObject mapObject = obj.getObject(configKey); if (mapObject != null) { + if (deprecated) { + Logger.getCurrentLogger().warn("The configuration key '" + configKey + "' is deprecated and will be removed in the future."); + } mapObject.getRawData().forEach((key, value) -> to.put(key, String.valueOf(value))); } } diff --git a/api/src/main/java/net/azisaba/azipluginmessaging/api/protocol/handler/ProxyboundClearPrefixPacket.java b/api/src/main/java/net/azisaba/azipluginmessaging/api/protocol/handler/ProxyboundClearPrefixPacket.java index e359595..a28505d 100644 --- a/api/src/main/java/net/azisaba/azipluginmessaging/api/protocol/handler/ProxyboundClearPrefixPacket.java +++ b/api/src/main/java/net/azisaba/azipluginmessaging/api/protocol/handler/ProxyboundClearPrefixPacket.java @@ -21,7 +21,7 @@ public class ProxyboundClearPrefixPacket implements ProxyMessageHandler