mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 12:27:59 +01:00
Fix GS4 querying
This commit is contained in:
parent
3bf9315d27
commit
892f1ec052
@ -30,47 +30,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
--- a/src/main/java/net/minecraft/server/rcon/thread/QueryThreadGs4.java
|
||||
+++ b/src/main/java/net/minecraft/server/rcon/thread/QueryThreadGs4.java
|
||||
@@ -0,0 +0,0 @@ public class QueryThreadGs4 extends GenericThread {
|
||||
if (3 <= i && -2 == bs[0] && -3 == bs[1]) {
|
||||
LOGGER.debug("Packet '{}' [{}]", PktUtils.toHexString(bs[2]), socketAddress);
|
||||
switch(bs[2]) {
|
||||
- case 0:
|
||||
- if (!this.validChallenge(packet)) {
|
||||
- LOGGER.debug("Invalid challenge [{}]", (Object)socketAddress);
|
||||
- return false;
|
||||
- } else if (15 == i) {
|
||||
- this.sendTo(this.buildRuleResponse(packet), packet);
|
||||
- LOGGER.debug("Rules [{}]", (Object)socketAddress);
|
||||
- } else {
|
||||
- NetworkDataOutputStream networkDataOutputStream = new NetworkDataOutputStream(1460);
|
||||
- networkDataOutputStream.write(0);
|
||||
- networkDataOutputStream.writeBytes(this.getIdentBytes(packet.getSocketAddress()));
|
||||
NetworkDataOutputStream networkDataOutputStream = new NetworkDataOutputStream(1460);
|
||||
networkDataOutputStream.write(0);
|
||||
networkDataOutputStream.writeBytes(this.getIdentBytes(packet.getSocketAddress()));
|
||||
- networkDataOutputStream.writeString(this.serverName);
|
||||
- networkDataOutputStream.writeString("SMP");
|
||||
- networkDataOutputStream.writeString(this.worldName);
|
||||
- networkDataOutputStream.writeString(Integer.toString(this.serverInterface.getPlayerCount()));
|
||||
- networkDataOutputStream.writeString(Integer.toString(this.maxPlayers));
|
||||
- networkDataOutputStream.writeShort((short)this.serverPort);
|
||||
- networkDataOutputStream.writeString(this.hostIp);
|
||||
- this.sendTo(networkDataOutputStream.toByteArray(), packet);
|
||||
- LOGGER.debug("Status [{}]", (Object)socketAddress);
|
||||
- }
|
||||
- default:
|
||||
- return true;
|
||||
- case 9:
|
||||
- this.sendChallenge(packet);
|
||||
- LOGGER.debug("Challenge [{}]", (Object)socketAddress);
|
||||
- return true;
|
||||
+ case 0:
|
||||
+ if (!this.validChallenge(packet)) {
|
||||
+ LOGGER.debug("Invalid challenge [{}]", (Object)socketAddress);
|
||||
+ return false;
|
||||
+ } else if (15 == i) {
|
||||
+ this.sendTo(this.buildRuleResponse(packet), packet);
|
||||
+ LOGGER.debug("Rules [{}]", (Object)socketAddress);
|
||||
+ } else {
|
||||
+ NetworkDataOutputStream networkDataOutputStream = new NetworkDataOutputStream(1460);
|
||||
+ networkDataOutputStream.write(0);
|
||||
+ networkDataOutputStream.writeBytes(this.getIdentBytes(packet.getSocketAddress()));
|
||||
+
|
||||
+ com.destroystokyo.paper.event.server.GS4QueryEvent.QueryType queryType =
|
||||
+ com.destroystokyo.paper.event.server.GS4QueryEvent.QueryType.BASIC;
|
||||
@ -90,25 +53,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ queryResponse = queryEvent.getResponse();
|
||||
+
|
||||
+ networkDataOutputStream.writeString(queryResponse.getMotd());
|
||||
+ networkDataOutputStream.writeString("SMP");
|
||||
networkDataOutputStream.writeString("SMP");
|
||||
- networkDataOutputStream.writeString(this.worldName);
|
||||
- networkDataOutputStream.writeString(Integer.toString(this.serverInterface.getPlayerCount()));
|
||||
- networkDataOutputStream.writeString(Integer.toString(this.maxPlayers));
|
||||
- networkDataOutputStream.writeShort((short)this.serverPort);
|
||||
- networkDataOutputStream.writeString(this.hostIp);
|
||||
+ networkDataOutputStream.writeString(queryResponse.getMap());
|
||||
+ networkDataOutputStream.writeString(Integer.toString(queryResponse.getCurrentPlayers()));
|
||||
+ networkDataOutputStream.writeString(Integer.toString(queryResponse.getMaxPlayers()));
|
||||
+ networkDataOutputStream.writeShort((short) queryResponse.getPort());
|
||||
+ networkDataOutputStream.writeString(queryResponse.getHostname());
|
||||
+ // Paper end
|
||||
+ this.sendTo(networkDataOutputStream.toByteArray(), packet);
|
||||
+ LOGGER.debug("Status [{}]", (Object)socketAddress);
|
||||
+ }
|
||||
+ default:
|
||||
+ return true;
|
||||
+ case 9:
|
||||
+ this.sendChallenge(packet);
|
||||
+ LOGGER.debug("Challenge [{}]", (Object)socketAddress);
|
||||
+ return true;
|
||||
this.sendTo(networkDataOutputStream.toByteArray(), packet);
|
||||
LOGGER.debug("Status [{}]", (Object)socketAddress);
|
||||
}
|
||||
} else {
|
||||
LOGGER.debug("Invalid packet [{}]", (Object)socketAddress);
|
||||
@@ -0,0 +0,0 @@ public class QueryThreadGs4 extends GenericThread {
|
||||
this.rulesResponse.writeString("splitnum");
|
||||
this.rulesResponse.write(128);
|
||||
@ -184,26 +143,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ this.rulesResponse.writeString(Integer.toString(queryResponse.getPort()));
|
||||
this.rulesResponse.writeString("hostip");
|
||||
- this.rulesResponse.writeString(this.hostIp);
|
||||
- this.rulesResponse.write(0);
|
||||
- this.rulesResponse.write(1);
|
||||
+ this.rulesResponse.writeString(queryResponse.getHostname());
|
||||
+ // The "meaningless data" start, copied from above
|
||||
+ this.rulesResponse.writeInt(0);
|
||||
+ this.rulesResponse.writeInt(1);
|
||||
this.rulesResponse.write(0);
|
||||
this.rulesResponse.write(1);
|
||||
this.rulesResponse.writeString("player_");
|
||||
- this.rulesResponse.write(0);
|
||||
this.rulesResponse.write(0);
|
||||
- String[] strings = this.serverInterface.getPlayerNames();
|
||||
-
|
||||
- for(String string : strings) {
|
||||
- this.rulesResponse.writeString(string);
|
||||
- }
|
||||
-
|
||||
- this.rulesResponse.write(0);
|
||||
+ this.rulesResponse.writeInt(0);
|
||||
+ // "Meaningless data" end
|
||||
+ queryResponse.getPlayers().forEach(this.rulesResponse::writeStringUnchecked);
|
||||
+ this.rulesResponse.writeInt(0);
|
||||
+ // Paper end
|
||||
return this.rulesResponse.toByteArray();
|
||||
}
|
||||
}
|
||||
+ String[] strings = queryResponse.getPlayers().toArray(String[]::new);
|
||||
|
||||
for(String string : strings) {
|
||||
this.rulesResponse.writeString(string);
|
||||
|
Loading…
Reference in New Issue
Block a user