From 9ea38d8cdb2f2ffad8edc8bd76d93ff973e81c3a Mon Sep 17 00:00:00 2001 From: Electroid Date: Tue, 8 Aug 2017 10:51:57 -0700 Subject: [PATCH] Add option to not publish ip --- .../oc/api/minecraft/config/MinecraftApiConfiguration.java | 2 ++ .../api/minecraft/config/MinecraftApiConfigurationImpl.java | 5 +++++ .../tc/oc/api/minecraft/servers/StartupServerDocument.java | 4 +++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/API/minecraft/src/main/java/tc/oc/api/minecraft/config/MinecraftApiConfiguration.java b/API/minecraft/src/main/java/tc/oc/api/minecraft/config/MinecraftApiConfiguration.java index 0015605..8893f40 100644 --- a/API/minecraft/src/main/java/tc/oc/api/minecraft/config/MinecraftApiConfiguration.java +++ b/API/minecraft/src/main/java/tc/oc/api/minecraft/config/MinecraftApiConfiguration.java @@ -12,4 +12,6 @@ public interface MinecraftApiConfiguration extends ApiConfiguration { String box(); ServerDoc.Role role(); + + boolean publishIp(); } diff --git a/API/minecraft/src/main/java/tc/oc/api/minecraft/config/MinecraftApiConfigurationImpl.java b/API/minecraft/src/main/java/tc/oc/api/minecraft/config/MinecraftApiConfigurationImpl.java index aab67a3..4c78f25 100644 --- a/API/minecraft/src/main/java/tc/oc/api/minecraft/config/MinecraftApiConfigurationImpl.java +++ b/API/minecraft/src/main/java/tc/oc/api/minecraft/config/MinecraftApiConfigurationImpl.java @@ -37,6 +37,11 @@ public class MinecraftApiConfigurationImpl implements MinecraftApiConfiguration return ServerDoc.Role.valueOf(config.getString("server.role").toUpperCase()); } + @Override + public boolean publishIp() { + return config.getBoolean("server.publishIp", true); + } + @Override public String primaryQueueName() { return "server." + serverId(); diff --git a/API/minecraft/src/main/java/tc/oc/api/minecraft/servers/StartupServerDocument.java b/API/minecraft/src/main/java/tc/oc/api/minecraft/servers/StartupServerDocument.java index d1b1903..f7ea9f5 100644 --- a/API/minecraft/src/main/java/tc/oc/api/minecraft/servers/StartupServerDocument.java +++ b/API/minecraft/src/main/java/tc/oc/api/minecraft/servers/StartupServerDocument.java @@ -20,6 +20,7 @@ import com.google.common.io.Files; import com.google.gson.Gson; import tc.oc.api.docs.virtual.DeployInfo; import tc.oc.api.docs.virtual.ServerDoc; +import tc.oc.api.minecraft.config.MinecraftApiConfiguration; import tc.oc.commons.core.logging.Loggers; import tc.oc.commons.core.util.Lazy; import tc.oc.minecraft.api.plugin.PluginFinder; @@ -31,6 +32,7 @@ public class StartupServerDocument implements ServerDoc.Startup { @Inject private Gson gson; @Inject private LocalServer minecraftServer; @Inject private PluginFinder pluginFinder; + @Inject private MinecraftApiConfiguration configuration; private Logger logger; @Inject void init(Loggers loggers) { @@ -72,7 +74,7 @@ public class StartupServerDocument implements ServerDoc.Startup { @Override public String ip() { - return ip.get(); + return configuration.publishIp() ? ip.get() : null; } @Override public Integer current_port() {