Warm "hello" for the slowstack.tv
This commit is contained in:
parent
26e0436b91
commit
871ffbdc2c
3 changed files with 12 additions and 6 deletions
2
pom.xml
2
pom.xml
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
<groupId>net.rubeta</groupId>
|
||||
<artifactId>LegacyPing</artifactId>
|
||||
<version>2.0</version>
|
||||
<version>2.1</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>LegacyPing</name>
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ public final class LegacyPing extends JavaPlugin {
|
|||
final String host = config.getString("host", "0.0.0.0");
|
||||
final List<Integer> ports = config.getIntegerList("port");
|
||||
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) {
|
||||
try {
|
||||
this.threads.add(new ServerThread(this, host, port, version, protocol));
|
||||
|
|
|
|||
|
|
@ -17,9 +17,10 @@ public class ServerThread extends Thread {
|
|||
"{\"version\": {\"name\": \"%version%\",\"protocol\": %protocol%}," +
|
||||
"\"players\": {\"max\": %max%,\"online\": %now%}," +
|
||||
"\"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 \"}," +
|
||||
"{\"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 Server minecraftServer;
|
||||
private final String version;
|
||||
|
|
@ -85,10 +86,15 @@ public class ServerThread extends Thread {
|
|||
final int port = inputStream.readShort();
|
||||
final int status = this.readVarInt(inputStream);
|
||||
this.logger.info("Ping from " + socket.getRemoteSocketAddress() + " to " + hostname + ":" + port);
|
||||
// System.out.println(packetLength + "; Protocol version: " + protocolVersion + ", host: " + hostname
|
||||
// + ", port: " + port + ", status: " + status);
|
||||
boolean slowstack = hostname.equalsIgnoreCase(SLOWSTACK_ID);
|
||||
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 {
|
||||
this.responseForModernPing(outputStream, DISCONNECT_REASON);
|
||||
socket.close();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue