mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
prepare for 1.21.4 update
This commit is contained in:
@@ -1,83 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Wed, 22 Jan 2020 20:13:40 -0600
|
||||
Subject: [PATCH] UPnP Port Forwarding
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index f03d6ddaeda45fee69f19d765fbf1e23333b8de3..6111c300ea25e73cc8f840dfff94998d3b87dcf3 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -330,6 +330,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
public final io.papermc.paper.configuration.PaperConfigurations paperConfigurations; // Paper - add paper configuration files
|
||||
public boolean isIteratingOverLevels = false; // Paper - Throw exception on world create while being ticked
|
||||
public boolean lagging = false; // Purpur
|
||||
+ protected boolean upnp = false; // Purpur
|
||||
|
||||
public volatile Thread shutdownThread; // Paper
|
||||
public volatile boolean abnormalExit = false; // Paper
|
||||
@@ -1057,6 +1058,15 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
|
||||
MinecraftServer.LOGGER.info("Stopping server");
|
||||
Commands.COMMAND_SENDING_POOL.shutdownNow(); // Paper - Perf: Async command map building; Shutdown and don't bother finishing
|
||||
+ // Purpur start
|
||||
+ if (upnp) {
|
||||
+ if (dev.omega24.upnp4j.UPnP4J.close(this.getPort(), dev.omega24.upnp4j.util.Protocol.TCP)) {
|
||||
+ LOGGER.info("[UPnP] Port {} closed", this.getPort());
|
||||
+ } else {
|
||||
+ LOGGER.error("[UPnP] Failed to close port {}", this.getPort());
|
||||
+ }
|
||||
+ }
|
||||
+ // Purpur end
|
||||
// CraftBukkit start
|
||||
if (this.server != null) {
|
||||
this.server.spark.disable(); // Paper - spark
|
||||
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
index 3596c659b638eeaeb8e8bd8f0b02e5ccd829accd..c34c95efadd5e88e47322185c8e3b04e8260cdc5 100644
|
||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -294,6 +294,30 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
if (true) throw new IllegalStateException("Failed to bind to port", ioexception); // Paper - Propagate failed to bind to port error
|
||||
return false;
|
||||
}
|
||||
+ // Purpur start
|
||||
+ if (org.purpurmc.purpur.PurpurConfig.useUPnP) {
|
||||
+ LOGGER.info("[UPnP] Attempting to start UPnP port forwarding service...");
|
||||
+ if (dev.omega24.upnp4j.UPnP4J.isUPnPAvailable()) {
|
||||
+ if (dev.omega24.upnp4j.UPnP4J.isOpen(this.getPort(), dev.omega24.upnp4j.util.Protocol.TCP)) {
|
||||
+ this.upnp = false;
|
||||
+ LOGGER.info("[UPnP] Port {} is already open", this.getPort());
|
||||
+ } else if (dev.omega24.upnp4j.UPnP4J.open(this.getPort(), dev.omega24.upnp4j.util.Protocol.TCP)) {
|
||||
+ this.upnp = true;
|
||||
+ LOGGER.info("[UPnP] Successfully opened port {}", this.getPort());
|
||||
+ } else {
|
||||
+ this.upnp = false;
|
||||
+ LOGGER.info("[UPnP] Failed to open port {}", this.getPort());
|
||||
+ }
|
||||
+
|
||||
+ if (upnp) {
|
||||
+ LOGGER.info("[UPnP] {}:{}", dev.omega24.upnp4j.UPnP4J.getExternalIP(), this.getPort());
|
||||
+ }
|
||||
+ } else {
|
||||
+ this.upnp = false;
|
||||
+ LOGGER.error("[UPnP] Service is unavailable");
|
||||
+ }
|
||||
+ }
|
||||
+ // Purpur end
|
||||
|
||||
// CraftBukkit start
|
||||
// this.setPlayerList(new DedicatedPlayerList(this, this.registries(), this.playerDataStorage)); // Spigot - moved up
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/PurpurConfig.java b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
||||
index a1e1aad7a1b845e2efd381da0221559443808cf7..d8930c57a867a63a4a8149136eb8a7a9ab96e11b 100644
|
||||
--- a/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
||||
+++ b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
||||
@@ -422,4 +422,9 @@ public class PurpurConfig {
|
||||
private static void tpsCatchup() {
|
||||
tpsCatchup = getBoolean("settings.tps-catchup", tpsCatchup);
|
||||
}
|
||||
+
|
||||
+ public static boolean useUPnP = false;
|
||||
+ private static void networkSettings() {
|
||||
+ useUPnP = getBoolean("settings.network.upnp-port-forwarding", useUPnP);
|
||||
+ }
|
||||
}
|
||||
Reference in New Issue
Block a user