This commit is contained in:
Dereku 2023-03-10 06:03:14 +07:00
parent da9a536ace
commit 50f6d37416
2 changed files with 8 additions and 22 deletions

16
pom.xml
View file

@ -27,22 +27,6 @@
<target>${java.version}</target>
</configuration>
</plugin>
<!--plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin-->
</plugins>
<resources>
<resource>

View file

@ -1,6 +1,8 @@
package net.rubeta.legacyping;
import org.bukkit.Bukkit;
import org.bukkit.Server;
import org.bukkit.craftbukkit.CraftServer;
import java.io.*;
import java.net.InetAddress;
@ -67,8 +69,8 @@ public class ServerThread extends Thread {
final ByteArrayOutputStream result = new ByteArrayOutputStream();
final DataOutputStream dos = new DataOutputStream(result);
dos.write(255); // Packet 0xFF (PacketDisconnect)
final String response = this.minecraftServer.getMotd()
+ '\u0000' + this.minecraftServer.getOnlinePlayers().size()
final String response = ((CraftServer) this.minecraftServer).getServer().motd
+ '\u0000' + this.minecraftServer.getOnlinePlayers().length
+ '\u0000' + this.minecraftServer.getMaxPlayers();
dos.writeShort(response.length());
for (char c : response.toCharArray()) {
@ -83,8 +85,8 @@ public class ServerThread extends Thread {
private void responseForLegacyPing(final OutputStream outputStream) throws IOException {
final DataOutputStream clientOutput = new DataOutputStream(outputStream);
clientOutput.write(255); // Packet 0xFF (PacketDisconnect)
final String response = this.minecraftServer.getMotd()
+ '\u0000' + this.minecraftServer.getOnlinePlayers().size()
final String response = ((CraftServer) this.minecraftServer).getServer().motd
+ '\u0000' + this.minecraftServer.getOnlinePlayers().length
+ '\u0000' + this.minecraftServer.getMaxPlayers();
clientOutput.writeShort(response.length());
for (char c : response.toCharArray()) {
@ -98,8 +100,8 @@ public class ServerThread extends Thread {
clientOutput.write(255); // Packet 0xFF (PacketDisconnect)
final String response = '§' + 1
+ '\u0000' + "b1.7.3m" + '\u0000' + 17 // Protocol version
+ '\u0000' + this.minecraftServer.getMotd()
+ '\u0000' + this.minecraftServer.getOnlinePlayers().size()
+ '\u0000' + ((CraftServer) this.minecraftServer).getServer().motd
+ '\u0000' + this.minecraftServer.getOnlinePlayers().length
+ '\u0000' + this.minecraftServer.getMaxPlayers();
clientOutput.writeShort(response.length());
clientOutput.writeUTF(response);