From 73b67b6fc4ab1a46cb7c1113a4648915bf072f56 Mon Sep 17 00:00:00 2001 From: File Date: Sun, 20 Apr 1997 05:37:42 -0800 Subject: [PATCH] purpur File Patches diff --git a/net/minecraft/server/dedicated/DedicatedServer.java b/net/minecraft/server/dedicated/DedicatedServer.java index 354b48c88b113c4048e258f2402aad2647d3c364..e728611fc4148f88d5c4f964af6f17a7b7ee9581 100644 --- a/net/minecraft/server/dedicated/DedicatedServer.java +++ b/net/minecraft/server/dedicated/DedicatedServer.java @@ -198,6 +198,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface public void run() { if (!org.bukkit.craftbukkit.Main.useConsole) return; // CraftBukkit // Paper start - Use TerminalConsoleAppender + if (DedicatedServer.this.gui == null || System.console() != null) // Purpur - GUI Improvements - has no GUI or has console (did not double-click) new com.destroystokyo.paper.console.PaperConsole(DedicatedServer.this).start(); /* BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8)); @@ -276,6 +277,15 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface io.papermc.paper.command.PaperCommands.registerCommands(this); // Paper - setup /paper command this.server.spark.registerCommandBeforePlugins(this.server); // Paper - spark com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); // Paper - start metrics + // Purpur start - Purpur config files + try { + org.purpurmc.purpur.PurpurConfig.init((java.io.File) options.valueOf("purpur-settings")); + } catch (Exception e) { + DedicatedServer.LOGGER.error("Unable to load server configuration", e); + return false; + } + org.purpurmc.purpur.PurpurConfig.registerCommands(); + // Purpur end - Purpur config files com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // Paper - load version history now // this.worldData.setGameType(properties.gameMode.get()); // CraftBukkit - moved to world loading @@ -318,6 +328,30 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface if (true) throw new IllegalStateException("Failed to bind to port", var11); // Paper - Propagate failed to bind to port error return false; } + // Purpur start - UPnP Port Forwarding + 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 - UPnP Port Forwarding // CraftBukkit start this.server.loadPlugins(); @@ -393,6 +427,9 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface LOGGER.info("JMX monitoring enabled"); } + org.purpurmc.purpur.task.BossBarTask.startAll(); // Purpur - Implement TPSBar + if (org.purpurmc.purpur.PurpurConfig.beeCountPayload) org.purpurmc.purpur.task.BeehiveTask.instance().register(); // Purpur - Give bee counts in beehives to Purpur clients + this.notificationManager().serverStarted(); return true; }