spigot/CraftBukkit-Patches/0045-Add-Late-Bind-Option.patch
2019-01-05 16:21:07 +11:00

62 lines
2.8 KiB
Diff

From 91b51934463020a4df4986d1309e9396b92b1f02 Mon Sep 17 00:00:00 2001
From: slide23 <me@slide.ws>
Date: Fri, 20 Dec 2013 20:15:33 -0600
Subject: [PATCH] Add Late Bind Option
Add late-bind config option to delay binding until loading is done.
diff --git a/src/main/java/net/minecraft/server/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java
index 0f107c6ea..b750ab0a0 100644
--- a/src/main/java/net/minecraft/server/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/DedicatedServer.java
@@ -188,6 +188,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
this.a(MinecraftEncryption.b());
DedicatedServer.LOGGER.info("Starting Minecraft server on {}:{}", this.getServerIp().isEmpty() ? "*" : this.getServerIp(), this.getPort());
+ if (!org.spigotmc.SpigotConfig.lateBind) {
try {
this.getServerConnection().a(inetaddress, this.getPort());
} catch (IOException ioexception) {
@@ -196,6 +197,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
DedicatedServer.LOGGER.warn("Perhaps a server is already running on that port?");
return false;
}
+ }
// CraftBukkit start
// this.a((PlayerList) (new DedicatedPlayerList(this))); // Spigot - moved up
@@ -307,6 +309,17 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
}
// CraftBukkit end
+ if (org.spigotmc.SpigotConfig.lateBind) {
+ try {
+ this.getServerConnection().a(inetaddress, this.getPort());
+ } catch (IOException ioexception) {
+ DedicatedServer.LOGGER.warn("**** FAILED TO BIND TO PORT!");
+ DedicatedServer.LOGGER.warn("The exception was: {}", ioexception.toString());
+ DedicatedServer.LOGGER.warn("Perhaps a server is already running on that port?");
+ return false;
+ }
+ }
+
if (false && this.getMaxTickTime() > 0L) { // Spigot - disable
Thread thread1 = new Thread(new ThreadWatchdog(this));
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
index a4200e43e..33f0e3b87 100644
--- a/src/main/java/org/spigotmc/SpigotConfig.java
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
@@ -231,4 +231,9 @@ public class SpigotConfig
System.setProperty( "io.netty.eventLoopThreads", Integer.toString( count ) );
Bukkit.getLogger().log( Level.INFO, "Using {0} threads for Netty based IO", count );
}
+
+ public static boolean lateBind;
+ private static void lateBind() {
+ lateBind = getBoolean( "settings.late-bind", false );
+ }
}
--
2.19.1