Skip to content

Commit

Permalink
🏷 4.0.1
Browse files Browse the repository at this point in the history
- Deprecate contextualServers
- Warn if `contextualServers` is present in config.yml
  • Loading branch information
acrylic-style committed Oct 16, 2022
1 parent 60cbce0 commit 51f2926
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public class AziPluginMessagingConfig {
public static final Map<String, String> servers = new ConcurrentHashMap<>();
public static final Map<String, String> saraShowServers = new ConcurrentHashMap<>();
public static final Map<String, String> rankableServers = new ConcurrentHashMap<>();
@SuppressWarnings("DeprecatedIsStillUsed") // not used outside this class
@Deprecated
public static final Map<String, String> contextualServers = new ConcurrentHashMap<>();

/**
Expand Down Expand Up @@ -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",
Expand All @@ -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:",
Expand Down Expand Up @@ -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) {
Expand All @@ -148,8 +147,15 @@ public static void reload() {
}

private static void readMap(@NotNull Map<String, String> to, @NotNull YamlObject obj, @NotNull String configKey) {
readMap(to, obj, configKey, false);
}

private static void readMap(@NotNull Map<String, String> 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)));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class ProxyboundClearPrefixPacket implements ProxyMessageHandler<Proxybou
@Override
public @NotNull ProxyboundClearPrefixMessage read(@NotNull ServerConnection server, @NotNull DataInputStream in) throws IOException {
String serverName = server.getServerInfo().getName();
serverName = AziPluginMessagingConfig.contextualServers.getOrDefault(serverName, serverName);
serverName = AziPluginMessagingConfig.servers.getOrDefault(serverName, serverName);
return ProxyboundClearPrefixMessage.read(serverName, in);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class ProxyboundSetPrefixPacket implements ProxyMessageHandler<Proxybound
@Override
public @NotNull ProxyboundSetPrefixMessage read(@NotNull ServerConnection server, @NotNull DataInputStream in) throws IOException {
String serverName = server.getServerInfo().getName();
serverName = AziPluginMessagingConfig.contextualServers.getOrDefault(serverName, serverName);
serverName = AziPluginMessagingConfig.servers.getOrDefault(serverName, serverName);
return ProxyboundSetPrefixMessage.read(serverName, in);
}

Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
}

group = "net.azisaba.azipluginmessaging"
version = "4.0.0"
version = "4.0.1"

repositories {
mavenCentral()
Expand Down

0 comments on commit 51f2926

Please sign in to comment.