Skip to content

Commit

Permalink
Make UPnP option no longer inverted
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaming32 committed Jul 2, 2024
1 parent cc911c7 commit b95b2a6
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/main/java/io/github/gaming32/worldhost/WorldHost.java
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ private static void init() {

reconnect(false, true);

if (!CONFIG.isNoUPnP()) {
if (CONFIG.isUPnP()) {
scanUpnp();
}

Expand Down Expand Up @@ -372,11 +372,11 @@ public static void commandRegistrationHandler(CommandDispatcher<CommandSourceSta
)
.then(literal("tempip")
.requires(s ->
!CONFIG.isNoUPnP() &&
s.getServer().isPublished() &&
CONFIG.isUPnP() &&
s.getServer().isPublished() &&
upnpGateway != null &&
protoClient != null &&
!protoClient.getUserIp().isEmpty()
!protoClient.getUserIp().isEmpty()
)
.executes(ctx -> {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public final class ConfigOptions {
public static final Map<String, ? extends ConfigOption<?>> OPTIONS = initConfigOptions();

static {
OPTIONS.get("noUPnP").onSet(WorldHost::scanUpnp);
OPTIONS.get("UPnP").onSet(WorldHost::scanUpnp);
}

private ConfigOptions() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/assets/world-host/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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",
Expand Down

0 comments on commit b95b2a6

Please sign in to comment.