mirror of
https://github.com/BX-Team/DivineMC.git
synced 2025-12-20 23:39:16 +00:00
75 lines
3.6 KiB
Diff
75 lines
3.6 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
|
Date: Sat, 1 Apr 2023 00:13:31 +0300
|
|
Subject: [PATCH] Paper PR - Fire ServerListPingEvent for secondary motd send
|
|
|
|
|
|
diff --git a/src/main/java/com/destroystokyo/paper/network/StandardPaperServerListPingEventImpl.java b/src/main/java/com/destroystokyo/paper/network/StandardPaperServerListPingEventImpl.java
|
|
index 6b0bdc266109cdfb874f08bf74323603921d2260..a355470f6b0e8286a178ad279ad93bcaf931cb51 100644
|
|
--- a/src/main/java/com/destroystokyo/paper/network/StandardPaperServerListPingEventImpl.java
|
|
+++ b/src/main/java/com/destroystokyo/paper/network/StandardPaperServerListPingEventImpl.java
|
|
@@ -75,13 +75,24 @@ public final class StandardPaperServerListPingEventImpl extends PaperServerListP
|
|
}
|
|
|
|
public static void processRequest(MinecraftServer server, Connection networkManager) {
|
|
+ ServerStatus ping = getEventResponse(server, networkManager);
|
|
+
|
|
+ if (ping == null) {
|
|
+ networkManager.disconnect(null);
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ // Send response
|
|
+ networkManager.send(new ClientboundStatusResponsePacket(ping));
|
|
+ }
|
|
+
|
|
+ public static ServerStatus getEventResponse(MinecraftServer server, Connection networkManager) {
|
|
StandardPaperServerListPingEventImpl event = new StandardPaperServerListPingEventImpl(server, networkManager, server.getStatus());
|
|
server.server.getPluginManager().callEvent(event);
|
|
|
|
// Close connection immediately if event is cancelled
|
|
if (event.isCancelled()) {
|
|
- networkManager.disconnect(null);
|
|
- return;
|
|
+ return null;
|
|
}
|
|
|
|
// Setup response
|
|
@@ -107,10 +118,6 @@ public final class StandardPaperServerListPingEventImpl extends PaperServerListP
|
|
} else {
|
|
favicon = Optional.empty();
|
|
}
|
|
- final ServerStatus ping = new ServerStatus(description, players, Optional.of(version), favicon, server.enforceSecureProfile());
|
|
-
|
|
- // Send response
|
|
- networkManager.send(new ClientboundStatusResponsePacket(ping));
|
|
+ return new ServerStatus(description, players, Optional.of(version), favicon, server.enforceSecureProfile());
|
|
}
|
|
-
|
|
-}
|
|
+}
|
|
\ No newline at end of file
|
|
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
index 33d4c1af86382cc3343d5db42283b27f69f52374..9679cce1a836add4aee343087370a2fc4d2d132e 100644
|
|
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
@@ -302,11 +302,13 @@ public abstract class PlayerList {
|
|
Component joinMessage = ichatmutablecomponent; // Paper - Adventure
|
|
|
|
playerconnection.teleport(player.getX(), player.getY(), player.getZ(), player.getYRot(), player.getXRot());
|
|
- ServerStatus serverping = this.server.getStatus();
|
|
-
|
|
- if (serverping != null) {
|
|
- player.sendServerStatus(serverping);
|
|
- }
|
|
+ // Paper start - fire ServerListPingEvent
|
|
+ io.papermc.paper.util.MCUtil.scheduleAsyncTask(() -> {
|
|
+ if (player.hasDisconnected()) return;
|
|
+ net.minecraft.network.protocol.status.ServerStatus status = com.destroystokyo.paper.network.StandardPaperServerListPingEventImpl.getEventResponse(this.server, player.connection.connection);
|
|
+ if (status != null) player.sendServerStatus(status);
|
|
+ });
|
|
+ // Paper end
|
|
|
|
// player.connection.send(ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(this.players)); // Paper
|
|
this.players.add(player);
|