Added display of brand name under f3

This commit is contained in:
MiGoYAm 2021-12-10 17:00:08 +01:00
parent 2dfb952d71
commit 1d200dcfd9
5 changed files with 43 additions and 0 deletions

View File

@ -19,6 +19,7 @@ public final class LimboConfig {
private SocketAddress address; private SocketAddress address;
private int maxPlayers; private int maxPlayers;
private String brandName;
private PingData pingData; private PingData pingData;
private String dimensionType; private String dimensionType;
@ -55,6 +56,7 @@ public final class LimboConfig {
address = conf.node("bind").get(SocketAddress.class); address = conf.node("bind").get(SocketAddress.class);
maxPlayers = conf.node("maxPlayers").getInt(); maxPlayers = conf.node("maxPlayers").getInt();
brandName = conf.node("brandName").getString();
pingData = conf.node("ping").get(PingData.class); pingData = conf.node("ping").get(PingData.class);
dimensionType = conf.node("dimension").getString(); dimensionType = conf.node("dimension").getString();
spawnPosition = conf.node("spawnPosition").get(Position.class); spawnPosition = conf.node("spawnPosition").get(Position.class);
@ -116,6 +118,10 @@ public final class LimboConfig {
return maxPlayers; return maxPlayers;
} }
public String getBrandName() {
return brandName;
}
public PingData getPingData() { public PingData getPingData() {
return pingData; return pingData;
} }

View File

@ -41,6 +41,7 @@ public class ClientConnection extends ChannelInboundHandlerAdapter {
private static PreEncodedPacket PACKET_LOGIN_SUCCESS; private static PreEncodedPacket PACKET_LOGIN_SUCCESS;
private static PreEncodedPacket PACKET_JOIN_GAME; private static PreEncodedPacket PACKET_JOIN_GAME;
private static PreEncodedPacket PACKET_PLUGIN_MESSAGE;
private static PreEncodedPacket PACKET_PLAYER_ABILITIES; private static PreEncodedPacket PACKET_PLAYER_ABILITIES;
private static PreEncodedPacket PACKET_PLAYER_INFO; private static PreEncodedPacket PACKET_PLAYER_INFO;
private static PreEncodedPacket PACKET_DECLARE_COMMANDS; private static PreEncodedPacket PACKET_DECLARE_COMMANDS;
@ -215,6 +216,7 @@ public class ClientConnection extends ChannelInboundHandlerAdapter {
server.getConnections().addConnection(this); server.getConnections().addConnection(this);
writePacket(PACKET_JOIN_GAME); writePacket(PACKET_JOIN_GAME);
writePacket(PACKET_PLUGIN_MESSAGE);
writePacket(PACKET_PLAYER_ABILITIES); writePacket(PACKET_PLAYER_ABILITIES);
writePacket(PACKET_PLAYER_POS); writePacket(PACKET_PLAYER_POS);
writePacket(PACKET_PLAYER_INFO); writePacket(PACKET_PLAYER_INFO);
@ -383,6 +385,10 @@ public class ClientConnection extends ChannelInboundHandlerAdapter {
joinGame.setHashedSeed(0); joinGame.setHashedSeed(0);
joinGame.setDimensionRegistry(server.getDimensionRegistry()); joinGame.setDimensionRegistry(server.getDimensionRegistry());
PacketPluginMessage pluginMessage = new PacketPluginMessage();
pluginMessage.setChannel("minecraft:brand");
pluginMessage.setMessage(server.getConfig().getBrandName());
PacketPlayerAbilities playerAbilities = new PacketPlayerAbilities(); PacketPlayerAbilities playerAbilities = new PacketPlayerAbilities();
playerAbilities.setFlyingSpeed(0.0F); playerAbilities.setFlyingSpeed(0.0F);
playerAbilities.setFlags(0x02); playerAbilities.setFlags(0x02);
@ -406,6 +412,7 @@ public class ClientConnection extends ChannelInboundHandlerAdapter {
PACKET_LOGIN_SUCCESS = PreEncodedPacket.of(loginSuccess); PACKET_LOGIN_SUCCESS = PreEncodedPacket.of(loginSuccess);
PACKET_JOIN_GAME = PreEncodedPacket.of(joinGame); PACKET_JOIN_GAME = PreEncodedPacket.of(joinGame);
PACKET_PLUGIN_MESSAGE = PreEncodedPacket.of(pluginMessage);
PACKET_PLAYER_ABILITIES = PreEncodedPacket.of(playerAbilities); PACKET_PLAYER_ABILITIES = PreEncodedPacket.of(playerAbilities);
PACKET_PLAYER_POS = PreEncodedPacket.of(positionAndLook); PACKET_PLAYER_POS = PreEncodedPacket.of(positionAndLook);
PACKET_PLAYER_INFO = PreEncodedPacket.of(info); PACKET_PLAYER_INFO = PreEncodedPacket.of(info);

View File

@ -0,0 +1,23 @@
package ru.nanit.limbo.protocol.packets.play;
import ru.nanit.limbo.protocol.ByteMessage;
import ru.nanit.limbo.protocol.PacketOut;
import ru.nanit.limbo.protocol.registry.Version;
public class PacketPluginMessage implements PacketOut {
private String channel;
private String message;
public void setChannel(String channel){
this.channel = channel;
}
public void setMessage(String message){
this.message = message;
}
@Override
public void encode(ByteMessage msg, Version version) {
msg.writeString(channel);
msg.writeString(message);
}
}

View File

@ -87,6 +87,10 @@ public enum State {
map(0x24, V1_16_2, V1_16_4), map(0x24, V1_16_2, V1_16_4),
map(0x26, V1_17, V1_18) map(0x26, V1_17, V1_18)
); );
// to do
clientBound.register(PacketPluginMessage::new,
map(0x18, V1_18, V1_18)
);
clientBound.register(PacketPlayerAbilities::new, clientBound.register(PacketPlayerAbilities::new,
map(0x39, V1_8, V1_8), map(0x39, V1_8, V1_8),
map(0x2B, V1_9, V1_12), map(0x2B, V1_9, V1_12),

View File

@ -11,6 +11,9 @@ bind:
# Set -1 to make it infinite # Set -1 to make it infinite
maxPlayers: 100 maxPlayers: 100
# Server name which is shown under F3
brandName: 'NanoLimbo'
# Server's data in servers list # Server's data in servers list
ping: ping:
description: '{"text": "&9NanoLimbo"}' description: '{"text": "&9NanoLimbo"}'