Skip to content

Commit

Permalink
Improve query
Browse files Browse the repository at this point in the history
  • Loading branch information
PetteriM1 authored and SupremeMortal committed Jun 12, 2019
1 parent df64e2d commit 17c36d2
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/main/java/org/itxtech/nemisys/network/RakNetInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;
import java.util.StringJoiner;
import java.util.concurrent.ConcurrentHashMap;

/**
Expand Down Expand Up @@ -194,15 +195,22 @@ public void notifyACK(String identifier, int identifierACK) {
public void setName(String name) {
QueryRegenerateEvent info = this.server.getQueryInformation();

this.handler.sendOption("name",
"MCPE;" + Utils.rtrim(name.replace(";", "\\;"), '\\') + ";" +
ProtocolInfo.CURRENT_PROTOCOL + ";" +
ProtocolInfo.MINECRAFT_VERSION_NETWORK + ";" +
info.getPlayerCount() + ";" +
info.getMaxPlayerCount() + ";" +
server.getServerUniqueId().toString() +
"" + ";" +
"" + ";");
String[] names = name.split("!@#");
String motd = Utils.rtrim(names[0].replace(";", "\\;"), '\\');
String subMotd = names.length > 1 ? Utils.rtrim(names[1].replace(";", "\\;"), '\\') : "";
StringJoiner joiner = new StringJoiner(";")
.add("MCPE")
.add(motd)
.add(Integer.toString(ProtocolInfo.CURRENT_PROTOCOL))
.add(ProtocolInfo.MINECRAFT_VERSION_NETWORK)
.add(Integer.toString(info.getPlayerCount()))
.add(Integer.toString(info.getMaxPlayerCount()))
.add(server.getServerUniqueId().toString())
.add(subMotd)
.add("Survival")
.add("1");

this.handler.sendOption("name", joiner.toString());
}

public void setPortCheck(boolean value) {
Expand Down

0 comments on commit 17c36d2

Please sign in to comment.