mirror of
https://github.com/Minestom/Minestom.git
synced 2024-09-29 15:07:36 +02:00
Cache invalid version text and add clarification to the version which should be used
This commit is contained in:
parent
dc8f885aff
commit
9a567811c7
@ -83,6 +83,7 @@ public class ChunkBatch implements InstanceBatch {
|
||||
|
||||
/**
|
||||
* Execute the batch in the dedicated pool and run the callback during the next instance update when blocks are placed
|
||||
* (which means that the callback can be called 50ms after, and in a determinable thread)
|
||||
*
|
||||
* @param callback the callback to execute once the blocks are placed
|
||||
*/
|
||||
@ -93,7 +94,7 @@ public class ChunkBatch implements InstanceBatch {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the batch in the dedicated pool and run the callback once blocks are placed (in the current thread)
|
||||
* Execute the batch in the dedicated pool and run the callback once blocks are placed (in the block batch pool)
|
||||
*
|
||||
* @param callback the callback to execute once the blocks are placed
|
||||
*/
|
||||
|
@ -11,6 +11,11 @@ import net.minestom.server.utils.binary.BinaryReader;
|
||||
|
||||
public class HandshakePacket implements ClientPreplayPacket {
|
||||
|
||||
/**
|
||||
* Text sent if a player tries to connect with an invalid version of the client
|
||||
*/
|
||||
private static final ColoredText INVALID_VERSION_TEXT = ColoredText.of(ChatColor.RED, "Invalid Version, please use " + MinecraftServer.VERSION_NAME);
|
||||
|
||||
private int protocolVersion;
|
||||
private String serverAddress;
|
||||
private int serverPort;
|
||||
@ -33,7 +38,7 @@ public class HandshakePacket implements ClientPreplayPacket {
|
||||
case 2:
|
||||
connection.setConnectionState(ConnectionState.LOGIN);
|
||||
if (protocolVersion != MinecraftServer.PROTOCOL_VERSION) {
|
||||
connection.sendPacket(new LoginDisconnect(ColoredText.of(ChatColor.RED, "Invalid Version").toString()));
|
||||
connection.sendPacket(new LoginDisconnect(INVALID_VERSION_TEXT.toString()));
|
||||
connection.disconnect();
|
||||
}
|
||||
break;
|
||||
|
@ -4,20 +4,21 @@ import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
|
||||
public class LoginDisconnect implements ServerPacket {
|
||||
private String kickMessage;
|
||||
|
||||
public LoginDisconnect(String kickMessage) {
|
||||
this.kickMessage = kickMessage;
|
||||
}
|
||||
private String kickMessage;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
writer.writeSizedString(kickMessage);
|
||||
}
|
||||
public LoginDisconnect(String kickMessage) {
|
||||
this.kickMessage = kickMessage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return 0x00;
|
||||
}
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
writer.writeSizedString(kickMessage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return 0x00;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user