mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-03 23:17:48 +01:00
Making the ResponseDataConsumer optional
This commit is contained in:
parent
2e548797c3
commit
f5d4cba29d
@ -250,14 +250,11 @@ public class PlayerInit {
|
|||||||
|
|
||||||
public static ResponseDataConsumer getResponseDataConsumer() {
|
public static ResponseDataConsumer getResponseDataConsumer() {
|
||||||
return (playerConnection, responseData) -> {
|
return (playerConnection, responseData) -> {
|
||||||
responseData.setName("1.15.2");
|
|
||||||
responseData.setProtocol(578);
|
|
||||||
responseData.setMaxPlayer(100);
|
responseData.setMaxPlayer(100);
|
||||||
responseData.setOnline(MinecraftServer.getConnectionManager().getOnlinePlayers().size());
|
responseData.setOnline(MinecraftServer.getConnectionManager().getOnlinePlayers().size());
|
||||||
responseData.addPlayer("A name", UUID.randomUUID());
|
responseData.addPlayer("A name", UUID.randomUUID());
|
||||||
responseData.addPlayer("Could be some message", UUID.randomUUID());
|
responseData.addPlayer("Could be some message", UUID.randomUUID());
|
||||||
responseData.setDescription("IP test: " + playerConnection.getRemoteAddress());
|
responseData.setDescription("IP test: " + playerConnection.getRemoteAddress());
|
||||||
responseData.setFavicon("data:image/png;base64,<data>");
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,8 +45,6 @@ public class GamemodeCommand extends Command<Player> {
|
|||||||
assert mode != null; // mode is not supposed to be null, because gamemodeName will be valid
|
assert mode != null; // mode is not supposed to be null, because gamemodeName will be valid
|
||||||
player.setGameMode(mode);
|
player.setGameMode(mode);
|
||||||
player.sendMessage("You are now playing in " + gamemodeName);
|
player.sendMessage("You are now playing in " + gamemodeName);
|
||||||
|
|
||||||
System.out.println("hello");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void executeOnOther(Player player, Arguments arguments) {
|
private void executeOnOther(Player player, Arguments arguments) {
|
||||||
|
@ -29,6 +29,8 @@ import java.io.IOException;
|
|||||||
public class MinecraftServer {
|
public class MinecraftServer {
|
||||||
private final static Logger LOGGER = LoggerFactory.getLogger(MinecraftServer.class);
|
private final static Logger LOGGER = LoggerFactory.getLogger(MinecraftServer.class);
|
||||||
|
|
||||||
|
public static final int PROTOCOL_VERSION = 578;
|
||||||
|
|
||||||
// Threads
|
// Threads
|
||||||
public static final String THREAD_NAME_BENCHMARK = "Ms-Benchmark";
|
public static final String THREAD_NAME_BENCHMARK = "Ms-Benchmark";
|
||||||
|
|
||||||
@ -207,6 +209,10 @@ public class MinecraftServer {
|
|||||||
LOGGER.info("Minestom server started successfully.");
|
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.)
|
* Stops this server properly (saves if needed, kicking players, etc.)
|
||||||
*/
|
*/
|
||||||
|
@ -15,9 +15,17 @@ public class StatusRequestPacket implements ClientPreplayPacket {
|
|||||||
public void process(PlayerConnection connection, ConnectionManager connectionManager) {
|
public void process(PlayerConnection connection, ConnectionManager connectionManager) {
|
||||||
ResponseDataConsumer consumer = MinecraftServer.getResponseDataConsumer();
|
ResponseDataConsumer consumer = MinecraftServer.getResponseDataConsumer();
|
||||||
ResponseData responseData = new ResponseData();
|
ResponseData responseData = new ResponseData();
|
||||||
if (consumer == null)
|
|
||||||
throw new NullPointerException("You need to register a ResponseDataConsumer");
|
// Fill default params
|
||||||
consumer.accept(connection, responseData);
|
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,<data>");
|
||||||
|
|
||||||
|
if (consumer != null)
|
||||||
|
consumer.accept(connection, responseData);
|
||||||
|
|
||||||
ResponsePacket responsePacket = new ResponsePacket();
|
ResponsePacket responsePacket = new ResponsePacket();
|
||||||
responsePacket.jsonResponse = responseData.build().toString();
|
responsePacket.jsonResponse = responseData.build().toString();
|
||||||
|
Loading…
Reference in New Issue
Block a user