mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@f7e3976 Revert "Legacy data should look for legacy materials (Fixes #6618)" (Fixes #6664) PaperMC/Paper@ce1e7e8 Fix jline relocation (#6677) PaperMC/Paper@3e8fb21 Suggest PlayerPostRespawnEvent if changing player state (#6679) PaperMC/Paper@2b404b0 Fix nullability on Block#breakNaturally (#6651) PaperMC/Paper@8ee9bdd Fix stacktrace deobf where thrownProxy got initialized before rewriting (#6684) PaperMC/Paper@fce7905 Option to prevent NBT copy in smithing recipes (#6671) PaperMC/Paper@3b2b835 Fix click event when vanilla scoreboard name coloring is enabled (#6652) PaperMC/Paper@425edfa More CommandBlock API (#5746) PaperMC/Paper@6847f57 Improve ItemStack#editMeta (#6502) PaperMC/Paper@6703c13 Preserve overstacked loot (#5943) PaperMC/Paper@0032236 Make Levels Use Correct Spawn Settings (#6419) PaperMC/Paper@4a27a4a Update head rotation in missing places (#5481) PaperMC/Paper@ebfd70b Use null for null resource pack prompts (#6572) PaperMC/Paper@826acaf Fix plugin provides load order (#6687) PaperMC/Paper@f905057 Prevent unintended light block manipulation (#6601) PaperMC/Paper@45c4f90 Readd root/admin user detection (#6593) PaperMC/Paper@e8830b2 Revert "Readd root/admin user detection (#6593)" (#6699) PaperMC/Paper@cc38c16 Updated Upstream (Bukkit/CraftBukkit) (#6638) PaperMC/Paper@7dd7c0c [ci skip] update issue template to remove checkboxes and add datapacks (#6702) PaperMC/Paper@bde7b98 Make legacyRenderer a ViewerUnaware renderer (#6691) PaperMC/Paper@e391591 Update paperweight to 1.1.12 (#6653) PaperMC/Paper@e14aff9 Don't count named piglins and hoglins towards mob cap (#6452) PaperMC/Paper@a978f41 Start console thread after PaperConfig & MinecraftServer.console are initialized (#6716) PaperMC/Paper@b1f0cbd [ci skip] Remove redundant/broken readme badges (#6715) PaperMC/Paper@e3ef498 [ci skip] remove markdown from issue template (#6705) PaperMC/Paper@7ebf08a Handle missing Spawn Egg item meta for 1.17 mobs (#6700) PaperMC/Paper@90f717f Add missing team sidebar display slots (#6690)
83 lines
4.2 KiB
Diff
83 lines
4.2 KiB
Diff
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 80df7819c2c28a16ca18c3159fc16498307fa924..6907bbe83f4907eddf22280e8674c9bdd2682279 100644
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
@@ -311,6 +311,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
public final SlackActivityAccountant slackActivityAccountant = new SlackActivityAccountant();
|
|
// Spigot end
|
|
public static long currentTickLong = 0L; // Paper
|
|
+ protected boolean upnp = false; // Purpur
|
|
|
|
public volatile Thread shutdownThread; // Paper
|
|
public volatile boolean abnormalExit = false; // Paper
|
|
@@ -1042,6 +1043,14 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
// CraftBukkit end
|
|
MinecraftServer.LOGGER.info("Stopping server");
|
|
MinecraftTimings.stopServer(); // Paper
|
|
+ // 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());
|
|
+ }
|
|
+ }
|
|
// CraftBukkit start
|
|
if (this.server != null) {
|
|
this.server.disablePlugins();
|
|
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
|
index f2e6676cbcf66e3334d5a76a03b1c1e8862504d3..855428f579af69af35605f324029a6ce67b50e5e 100644
|
|
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
|
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
|
@@ -282,6 +282,30 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
|
DedicatedServer.LOGGER.warn("Perhaps a server is already running on that port?");
|
|
return false;
|
|
}
|
|
+ // Purpur start
|
|
+ if (net.pl3x.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.a((PlayerList) (new DedicatedPlayerList(this, this.customRegistry, this.worldNBTStorage))); // Spigot - moved up
|
|
diff --git a/src/main/java/net/pl3x/purpur/PurpurConfig.java b/src/main/java/net/pl3x/purpur/PurpurConfig.java
|
|
index df12c714aaa2817b653a5fe6278e0dc39aada34d..646cab345fc96d3ebaae49bb61925b8094dc68d9 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurConfig.java
|
|
@@ -398,4 +398,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);
|
|
+ }
|
|
}
|