diff --git a/src/main/java/fr/themode/demo/PlayerInit.java b/src/main/java/fr/themode/demo/PlayerInit.java index 5540d9221..2e56c5425 100644 --- a/src/main/java/fr/themode/demo/PlayerInit.java +++ b/src/main/java/fr/themode/demo/PlayerInit.java @@ -250,14 +250,11 @@ public class PlayerInit { public static ResponseDataConsumer getResponseDataConsumer() { return (playerConnection, responseData) -> { - responseData.setName("1.15.2"); - responseData.setProtocol(578); responseData.setMaxPlayer(100); responseData.setOnline(MinecraftServer.getConnectionManager().getOnlinePlayers().size()); responseData.addPlayer("A name", UUID.randomUUID()); responseData.addPlayer("Could be some message", UUID.randomUUID()); responseData.setDescription("IP test: " + playerConnection.getRemoteAddress()); - responseData.setFavicon("data:image/png;base64,"); }; } diff --git a/src/main/java/fr/themode/demo/commands/GamemodeCommand.java b/src/main/java/fr/themode/demo/commands/GamemodeCommand.java index 010c93cfa..d90eb186f 100644 --- a/src/main/java/fr/themode/demo/commands/GamemodeCommand.java +++ b/src/main/java/fr/themode/demo/commands/GamemodeCommand.java @@ -45,8 +45,6 @@ public class GamemodeCommand extends Command { assert mode != null; // mode is not supposed to be null, because gamemodeName will be valid player.setGameMode(mode); player.sendMessage("You are now playing in " + gamemodeName); - - System.out.println("hello"); } private void executeOnOther(Player player, Arguments arguments) { diff --git a/src/main/java/net/minestom/server/MinecraftServer.java b/src/main/java/net/minestom/server/MinecraftServer.java index fd482b0ec..2e7a9a81d 100644 --- a/src/main/java/net/minestom/server/MinecraftServer.java +++ b/src/main/java/net/minestom/server/MinecraftServer.java @@ -29,6 +29,8 @@ import java.io.IOException; public class MinecraftServer { private final static Logger LOGGER = LoggerFactory.getLogger(MinecraftServer.class); + public static final int PROTOCOL_VERSION = 578; + // Threads public static final String THREAD_NAME_BENCHMARK = "Ms-Benchmark"; @@ -207,6 +209,10 @@ public class MinecraftServer { LOGGER.info("Minestom server started successfully."); } + public void start(String address, int port) { + start(address, port, null); + } + /** * Stops this server properly (saves if needed, kicking players, etc.) */ diff --git a/src/main/java/net/minestom/server/network/packet/client/status/StatusRequestPacket.java b/src/main/java/net/minestom/server/network/packet/client/status/StatusRequestPacket.java index 0b88f3f6e..c3a1efa35 100644 --- a/src/main/java/net/minestom/server/network/packet/client/status/StatusRequestPacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/status/StatusRequestPacket.java @@ -15,9 +15,17 @@ public class StatusRequestPacket implements ClientPreplayPacket { public void process(PlayerConnection connection, ConnectionManager connectionManager) { ResponseDataConsumer consumer = MinecraftServer.getResponseDataConsumer(); ResponseData responseData = new ResponseData(); - if (consumer == null) - throw new NullPointerException("You need to register a ResponseDataConsumer"); - consumer.accept(connection, responseData); + + // Fill default params + responseData.setName("1.15.2"); + responseData.setProtocol(MinecraftServer.PROTOCOL_VERSION); + responseData.setMaxPlayer(0); + responseData.setOnline(0); + responseData.setDescription("Minestom Server"); + responseData.setFavicon("data:image/png;base64,"); + + if (consumer != null) + consumer.accept(connection, responseData); ResponsePacket responsePacket = new ResponsePacket(); responsePacket.jsonResponse = responseData.build().toString();