diff --git a/src/main/java/io/github/gaming32/worldhost/WorldHost.java b/src/main/java/io/github/gaming32/worldhost/WorldHost.java index f6ab0d5..fef1a6a 100644 --- a/src/main/java/io/github/gaming32/worldhost/WorldHost.java +++ b/src/main/java/io/github/gaming32/worldhost/WorldHost.java @@ -263,7 +263,7 @@ private static void init() { reconnect(false, true); - if (!CONFIG.isNoUPnP()) { + if (CONFIG.isUPnP()) { scanUpnp(); } @@ -372,11 +372,11 @@ public static void commandRegistrationHandler(CommandDispatcher - !CONFIG.isNoUPnP() && - s.getServer().isPublished() && + CONFIG.isUPnP() && + s.getServer().isPublished() && upnpGateway != null && protoClient != null && - !protoClient.getUserIp().isEmpty() + !protoClient.getUserIp().isEmpty() ) .executes(ctx -> { try { diff --git a/src/main/java/io/github/gaming32/worldhost/config/WorldHostConfig.java b/src/main/java/io/github/gaming32/worldhost/config/WorldHostConfig.java index 87a1189..b6b7c87 100644 --- a/src/main/java/io/github/gaming32/worldhost/config/WorldHostConfig.java +++ b/src/main/java/io/github/gaming32/worldhost/config/WorldHostConfig.java @@ -22,7 +22,7 @@ public class WorldHostConfig { private OnlineStatusLocation onlineStatusLocation = OnlineStatusLocation.RIGHT; private boolean enableFriends = true; private boolean enableReconnectionToasts = false; - private boolean noUPnP = false; + private boolean UPnP = false; private boolean useShortIp = false; private boolean showOutdatedWorldHost = true; private boolean shareButton = true; @@ -67,6 +67,10 @@ public void read(JsonReader reader) throws IOException { WorldHost.LOGGER.info("Converting old showOnlineStatus to new onlineStatusLocation."); onlineStatusLocation = reader.nextBoolean() ? OnlineStatusLocation.RIGHT : OnlineStatusLocation.OFF; } + case "noUPnP" -> { + WorldHost.LOGGER.info("Converting old noUPnP to new UPnP"); + UPnP = !reader.nextBoolean(); + } case "friends" -> { WorldHost.LOGGER.info("Found old friends list."); reader.beginArray(); @@ -146,12 +150,12 @@ public void setEnableReconnectionToasts(boolean enableReconnectionToasts) { } @ConfigProperty(order = 4) - public boolean isNoUPnP() { - return noUPnP; + public boolean isUPnP() { + return UPnP; } - public void setNoUPnP(boolean noUPnP) { - this.noUPnP = noUPnP; + public void setUPnP(boolean UPnP) { + this.UPnP = UPnP; } @ConfigProperty(order = 5) diff --git a/src/main/java/io/github/gaming32/worldhost/config/option/ConfigOptions.java b/src/main/java/io/github/gaming32/worldhost/config/option/ConfigOptions.java index 6d44167..fa29fd4 100644 --- a/src/main/java/io/github/gaming32/worldhost/config/option/ConfigOptions.java +++ b/src/main/java/io/github/gaming32/worldhost/config/option/ConfigOptions.java @@ -19,7 +19,7 @@ public final class ConfigOptions { public static final Map> OPTIONS = initConfigOptions(); static { - OPTIONS.get("noUPnP").onSet(WorldHost::scanUpnp); + OPTIONS.get("UPnP").onSet(WorldHost::scanUpnp); } private ConfigOptions() { diff --git a/src/main/java/io/github/gaming32/worldhost/protocol/WorldHostS2CMessage.java b/src/main/java/io/github/gaming32/worldhost/protocol/WorldHostS2CMessage.java index 2220afe..b6edd97 100644 --- a/src/main/java/io/github/gaming32/worldhost/protocol/WorldHostS2CMessage.java +++ b/src/main/java/io/github/gaming32/worldhost/protocol/WorldHostS2CMessage.java @@ -160,7 +160,7 @@ public void handle(ProtocolClient client) { final var server = Minecraft.getInstance().getSingleplayerServer(); if (server == null || !server.isPublished()) return; JoinType joinType = JoinType.Proxy.INSTANCE; - if (WorldHost.isFriend(user) && WorldHost.upnpGateway != null && !WorldHost.CONFIG.isNoUPnP()) { + if (WorldHost.isFriend(user) && WorldHost.upnpGateway != null && WorldHost.CONFIG.isUPnP()) { try { final var error = WorldHost.upnpGateway.openPort( server.getPort(), 60, false diff --git a/src/main/resources/assets/world-host/lang/en_us.json b/src/main/resources/assets/world-host/lang/en_us.json index 5164faa..7969914 100644 --- a/src/main/resources/assets/world-host/lang/en_us.json +++ b/src/main/resources/assets/world-host/lang/en_us.json @@ -1,5 +1,5 @@ { - "world-host.config.title": "World Host Config", + "world-host.config.title": "World Host Options", "world-host.config.serverIp": "Server Address", "world-host.config.onlineStatusLocation": "Online Status Location", "world-host.config.onlineStatusLocation.left": "Left", @@ -8,8 +8,8 @@ "world-host.config.enableFriends": "Enable Friends", "world-host.config.enableFriends.tooltip": "Enable all friends-related GUIs and the entire friends system.\nIf you disable this and re-enable it, all your friends will still be there.", "world-host.config.enableReconnectionToasts": "Reconnection Toasts", - "world-host.config.noUPnP": "Don't Try UPnP", - "world-host.config.noUPnP.tooltip": "UPnP is a mechanism that can be used for direct connection. However, it sometimes has weird issues.\nEnable this setting if people are having trouble connecting to you through the friends list or tempip.", + "world-host.config.UPnP": "Use UPnP", + "world-host.config.UPnP.tooltip": "UPnP is a mechanism that can be used for direct connection. However, it sometimes has weird issues.\nDisable this option if people are having trouble connecting to you through the friends list or tempip.", "world-host.config.useShortIp": "Use Short IP", "world-host.config.useShortIp.tooltip": "These IPs are made up of nine letters and numbers instead of three words. This makes them shorter, but harder to remember.", "world-host.config.showOutdatedWorldHost": "Version Check Popup",