Skip to content

Commit

Permalink
Fixed playerlist for 1.16.5 clients. Changed version string
Browse files Browse the repository at this point in the history
  • Loading branch information
Nan1t committed Feb 7, 2022
1 parent 021d0a1 commit e1445c0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 20 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group 'ru.nanit'
version '1.3.3'
version '1.3.4'

repositories {
mavenCentral()
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/ru/nanit/limbo/configuration/LimboConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public void load() throws Exception {
useBossBar = conf.node("bossBar", "enable").getBoolean();
useTitle = conf.node("title", "enable").getBoolean();
usePlayerList = conf.node("playerList", "enable").getBoolean();
playerListUsername = conf.node("playerList", "username").getString();
useHeaderAndFooter = conf.node("headerAndFooter", "enable").getBoolean();

if (useBrandName)
Expand All @@ -108,9 +109,6 @@ public void load() throws Exception {
if (useTitle)
title = conf.node("title").get(Title.class);

if (usePlayerList)
playerListUsername = conf.node("playerList", "username").getString();

if (useHeaderAndFooter) {
playerListHeader = Colors.of(conf.node("headerAndFooter", "header").getString());
playerListFooter = Colors.of(conf.node("headerAndFooter", "footer").getString());
Expand Down
28 changes: 13 additions & 15 deletions src/main/java/ru/nanit/limbo/connection/ClientConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,10 @@ private void fireLoginSuccess() {
writePacket(PACKET_PLAYER_ABILITIES);
writePacket(PACKET_PLAYER_POS);

if (PACKET_PLAYER_INFO != null && !clientVersion.equals(Version.V1_16_4))
if (server.getConfig().isUsePlayerList() || clientVersion.equals(Version.V1_16_4))
writePacket(PACKET_PLAYER_INFO);

if (clientVersion.moreOrEqual(Version.V1_13)){
if (clientVersion.moreOrEqual(Version.V1_13)) {
writePacket(PACKET_DECLARE_COMMANDS);

if (PACKET_PLUGIN_MESSAGE != null)
Expand Down Expand Up @@ -430,26 +430,24 @@ public static void initPackets(LimboServer server) {
PacketDeclareCommands declareCommands = new PacketDeclareCommands();
declareCommands.setCommands(Collections.emptyList());

PacketPlayerInfo info = new PacketPlayerInfo();
info.setUsername(server.getConfig().getPlayerListUsername());
info.setGameMode(server.getConfig().getGameMode());
info.setUuid(uuid);

PACKET_LOGIN_SUCCESS = PacketSnapshot.of(loginSuccess);
PACKET_JOIN_GAME = PacketSnapshot.of(joinGame);
PACKET_PLAYER_ABILITIES = PacketSnapshot.of(playerAbilities);
PACKET_PLAYER_POS = PacketSnapshot.of(positionAndLook);
PACKET_PLAYER_INFO = PacketSnapshot.of(info);

PACKET_DECLARE_COMMANDS = PacketSnapshot.of(declareCommands);

if (server.getConfig().isUsePlayerList()) {
PacketPlayerInfo info = new PacketPlayerInfo();
info.setUsername(server.getConfig().getPlayerListUsername());
info.setGameMode(server.getConfig().getGameMode());
info.setUuid(uuid);
PACKET_PLAYER_INFO = PacketSnapshot.of(info);

if (server.getConfig().isUseHeaderAndFooter()) {
PacketPlayerListHeader header = new PacketPlayerListHeader();
header.setHeader(server.getConfig().getPlayerListHeader());
header.setFooter(server.getConfig().getPlayerListFooter());
PACKET_HEADER_AND_FOOTER = PacketSnapshot.of(header);
}
if (server.getConfig().isUseHeaderAndFooter()) {
PacketPlayerListHeader header = new PacketPlayerListHeader();
header.setHeader(server.getConfig().getPlayerListHeader());
header.setFooter(server.getConfig().getPlayerListFooter());
PACKET_HEADER_AND_FOOTER = PacketSnapshot.of(header);
}

if (server.getConfig().isUseBrandName()){
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ ping:
dimension: THE_END

# Whether to display the player in the player list
# For 1.16.5 clients player list will be sent even if disabled, to avoid crash
playerList:
enable: false
username: 'NanoLimbo'

# Whether to display header and footer in player list
# Enable it only if you enabled playerList
headerAndFooter:
enable: false
header: '{"text": "&eWelcome!"}'
Expand Down

0 comments on commit e1445c0

Please sign in to comment.