Warm "hello" for the slowstack.tv

This commit is contained in:
Dereku 2026-01-06 19:25:53 +07:00
parent 26e0436b91
commit 871ffbdc2c
3 changed files with 12 additions and 6 deletions

View file

@ -6,7 +6,7 @@
<groupId>net.rubeta</groupId> <groupId>net.rubeta</groupId>
<artifactId>LegacyPing</artifactId> <artifactId>LegacyPing</artifactId>
<version>2.0</version> <version>2.1</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>LegacyPing</name> <name>LegacyPing</name>

View file

@ -26,7 +26,7 @@ public final class LegacyPing extends JavaPlugin {
final String host = config.getString("host", "0.0.0.0"); final String host = config.getString("host", "0.0.0.0");
final List<Integer> ports = config.getIntegerList("port"); final List<Integer> ports = config.getIntegerList("port");
final String version = config.getString("displayedVersion", "b1.7.3"); final String version = config.getString("displayedVersion", "b1.7.3");
final int protocol = config.getInt("displayedProtocol", 17); final int protocol = config.getInt("displayedProtocol", 14);
for (int port : ports) { for (int port : ports) {
try { try {
this.threads.add(new ServerThread(this, host, port, version, protocol)); this.threads.add(new ServerThread(this, host, port, version, protocol));

View file

@ -17,9 +17,10 @@ public class ServerThread extends Thread {
"{\"version\": {\"name\": \"%version%\",\"protocol\": %protocol%}," + "{\"version\": {\"name\": \"%version%\",\"protocol\": %protocol%}," +
"\"players\": {\"max\": %max%,\"online\": %now%}," + "\"players\": {\"max\": %max%,\"online\": %now%}," +
"\"description\": {\"text\": \"%motd%\"}," + "\"description\": {\"text\": \"%motd%\"}," +
"\"enforcesSecureChat\": false,\"previewsChat\": true}"; "\"enforcesSecureChat\": false,\"previewsChat\": false}";
private static final String DISCONNECT_REASON = "[\"\",{\"text\":\"This is b1.7.3 server. Visit \"}," + private static final String DISCONNECT_REASON = "[\"\",{\"text\":\"This is b1.7.3 server. Visit \"}," +
"{\"text\":\"https://rubeta.net\",\"underlined\":true},{\"text\":\" for more information.\"}]"; "{\"text\":\"https://rubeta.net\",\"underlined\":true},{\"text\":\" for more information.\"}]";
private static final String SLOWSTACK_ID = "slowstack.tv";
private final AtomicBoolean working = new AtomicBoolean(false); private final AtomicBoolean working = new AtomicBoolean(false);
private final Server minecraftServer; private final Server minecraftServer;
private final String version; private final String version;
@ -85,10 +86,15 @@ public class ServerThread extends Thread {
final int port = inputStream.readShort(); final int port = inputStream.readShort();
final int status = this.readVarInt(inputStream); final int status = this.readVarInt(inputStream);
this.logger.info("Ping from " + socket.getRemoteSocketAddress() + " to " + hostname + ":" + port); this.logger.info("Ping from " + socket.getRemoteSocketAddress() + " to " + hostname + ":" + port);
// System.out.println(packetLength + "; Protocol version: " + protocolVersion + ", host: " + hostname boolean slowstack = hostname.equalsIgnoreCase(SLOWSTACK_ID);
// + ", port: " + port + ", status: " + status);
if (status != 2) { if (status != 2) {
this.responseForModernPing(outputStream, MODERN_RESPONSE); if (slowstack) {
this.responseForModernPing(outputStream, MODERN_RESPONSE.replace(
"%motd%", "%motd% \nHello, slowstack.tv!"
));
} else {
this.responseForModernPing(outputStream, MODERN_RESPONSE);
}
} else { } else {
this.responseForModernPing(outputStream, DISCONNECT_REASON); this.responseForModernPing(outputStream, DISCONNECT_REASON);
socket.close(); socket.close();