mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-19 03:49:14 +00:00
Add option to advertise dedicated servers to LAN. (#9502)
This commit is contained in:
1 parent
2b5852072c
commit
301e7252b0
5 files changed
+55
-6
No files matched your search
+6
-2
@@ -27,8 +27,8 @@ plugins {
|
||||
id 'net.minecraftforge.gradleutils' version '2.+'
|
||||
id 'eclipse'
|
||||
id 'de.undercouch.download' version '5.1.3'
|
||||
id 'net.minecraftforge.gradle.patcher' version '[5.1.50,5.2.0)' apply false
|
||||
id 'net.minecraftforge.gradle.mcp' version '[5.1.50,5.2.0)' apply false
|
||||
id 'net.minecraftforge.gradle.patcher' version '[5.1.77,5.2.0)' apply false
|
||||
id 'net.minecraftforge.gradle.mcp' version '[5.1.77,5.2.0)' apply false
|
||||
}
|
||||
|
||||
Util.init() //Init all our extension methods!
|
||||
@@ -884,6 +884,10 @@ project(':forge') {
|
||||
apply plugin: 'net.minecraftforge.gradle.patcher'
|
||||
apply plugin: 'org.cadixdev.licenser'
|
||||
|
||||
applyPatches {
|
||||
level 'WARNING'
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
java {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/client/server/LanServerPinger.java
|
||||
+++ b/net/minecraft/client/server/LanServerPinger.java
|
||||
@@ -16,7 +_,7 @@
|
||||
@@ -13,7 +_,7 @@
|
||||
public class LanServerPinger extends Thread {
|
||||
private static final AtomicInteger f_120101_ = new AtomicInteger(0);
|
||||
private static final Logger f_120102_ = LogUtils.getLogger();
|
||||
@@ -9,7 +9,7 @@
|
||||
public static final int f_174975_ = 4445;
|
||||
private static final long f_174976_ = 1500L;
|
||||
private final String f_120103_;
|
||||
@@ -39,7 +_,7 @@
|
||||
@@ -36,7 +_,7 @@
|
||||
|
||||
while(!this.isInterrupted() && this.f_120105_) {
|
||||
try {
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
--- a/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -68,6 +_,8 @@
|
||||
private MinecraftServerGui f_139605_;
|
||||
@Nullable
|
||||
private final TextFilterClient f_139606_;
|
||||
+ @Nullable
|
||||
+ private net.minecraft.client.server.LanServerPinger dediLanPinger;
|
||||
|
||||
public DedicatedServer(Thread p_214789_, LevelStorageSource.LevelStorageAccess p_214790_, PackRepository p_214791_, WorldStem p_214792_, DedicatedServerSettings p_214793_, DataFixer p_214794_, Services p_214795_, ChunkProgressListenerFactory p_214796_) {
|
||||
super(p_214789_, p_214790_, p_214791_, p_214792_, Proxy.NO_PROXY, p_214794_, p_214795_, p_214796_);
|
||||
@@ -79,6 +_,7 @@
|
||||
public boolean m_7038_() throws IOException {
|
||||
Thread thread = new Thread("Server console handler") {
|
||||
@@ -22,7 +31,7 @@
|
||||
if (dedicatedserverproperties.f_139744_ != null) {
|
||||
this.m_129900_().m_46170_(GameRules.f_46153_).m_46246_(dedicatedserverproperties.f_139744_, this);
|
||||
}
|
||||
@@ -183,12 +_,13 @@
|
||||
@@ -183,12 +_,18 @@
|
||||
thread1.start();
|
||||
}
|
||||
|
||||
@@ -33,7 +42,34 @@
|
||||
}
|
||||
|
||||
- return true;
|
||||
+ if (net.minecraftforge.common.ForgeConfig.SERVER.advertiseDedicatedServerToLan.get()) {
|
||||
+ this.dediLanPinger = new net.minecraft.client.server.LanServerPinger(this.m_129916_(), String.valueOf(this.m_7448_()));
|
||||
+ this.dediLanPinger.start();
|
||||
+ }
|
||||
+
|
||||
+ return net.minecraftforge.server.ServerLifecycleHooks.handleServerStarting(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,6 +_,10 @@
|
||||
this.f_139601_.m_7530_();
|
||||
}
|
||||
|
||||
+ if (this.dediLanPinger != null) {
|
||||
+ this.dediLanPinger.interrupt();
|
||||
+ this.dediLanPinger = null;
|
||||
+ }
|
||||
}
|
||||
|
||||
public void m_5703_(BooleanSupplier p_139661_) {
|
||||
@@ -492,6 +_,10 @@
|
||||
|
||||
public void m_7041_() {
|
||||
super.m_7041_();
|
||||
+ if (this.dediLanPinger != null) {
|
||||
+ this.dediLanPinger.interrupt();
|
||||
+ this.dediLanPinger = null;
|
||||
+ }
|
||||
Util.m_137580_();
|
||||
SkullBlockEntity.m_196704_();
|
||||
}
|
||||
@@ -30,6 +30,8 @@ public class ForgeConfig {
|
||||
|
||||
public final ConfigValue<String> permissionHandler;
|
||||
|
||||
public final BooleanValue advertiseDedicatedServerToLan;
|
||||
|
||||
Server(ForgeConfigSpec.Builder builder) {
|
||||
builder.comment("Server configuration settings")
|
||||
.push("server");
|
||||
@@ -69,6 +71,11 @@ public class ForgeConfig {
|
||||
.translation("forge.configgui.permissionHandler")
|
||||
.define("permissionHandler", "forge:default_handler");
|
||||
|
||||
advertiseDedicatedServerToLan = builder
|
||||
.comment("Set this to true to enable advertising the dedicated server to local LAN clients so that it shows up in the Multiplayer screen automatically.")
|
||||
.translation("forge.configgui.advertiseDedicatedServerToLan")
|
||||
.define("advertiseDedicatedServerToLan", true);
|
||||
|
||||
builder.pop();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,4 +4,6 @@
|
||||
# checkAndFixSAS will populate all overrides as nessasary. Prefixing added lines with \t
|
||||
# checkAndFixSAS also supports names using . so simplest way to find the correct line to add is to get the AT line from the bot
|
||||
# and remove the access modifier.
|
||||
#==================================================================================================================================
|
||||
# You need to run the setup task again after running checkAndFixSAS for genPatches to pick up the changes.
|
||||
#==================================================================================================================================
|
||||
net/minecraft/client/server/LanServerPinger
|
||||
Reference in new issue
Block a user