mirror of
https://github.com/Nan1t/NanoLimbo.git
synced 2025-07-15 13:40:14 +02:00
Added HeaderAndFooter packet. Modified config file. Take username for playerlist not from version string
This commit is contained in:
parent
416878d160
commit
647997aa5e
10
Dockerfile
Normal file
10
Dockerfile
Normal file
@ -0,0 +1,10 @@
|
||||
FROM openjdk:17-alpine3.14
|
||||
|
||||
ENV JAVA_HEAP_SIZE="1G"
|
||||
ENV JAVA_ARGS=""
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY build/libs/NanoLimbo-*-all.jar server.jar
|
||||
|
||||
ENTRYPOINT java $JAVA_ARGS -Xmx$JAVA_HEAP_SIZE -Xms$JAVA_HEAP_SIZE -jar server.jar
|
@ -51,11 +51,17 @@ public final class LimboConfig {
|
||||
private boolean useBossBar;
|
||||
private boolean useTitle;
|
||||
private boolean usePlayerList;
|
||||
private boolean useHeaderAndFooter;
|
||||
|
||||
private String brandName;
|
||||
private String joinMessage;
|
||||
private BossBar bossBar;
|
||||
private Title title;
|
||||
|
||||
private String playerListUsername;
|
||||
private String playerListHeader;
|
||||
private String playerListFooter;
|
||||
|
||||
private InfoForwarding infoForwarding;
|
||||
private long readTimeout;
|
||||
private int debugLevel = 3;
|
||||
@ -87,7 +93,8 @@ public final class LimboConfig {
|
||||
useJoinMessage = conf.node("joinMessage", "enable").getBoolean();
|
||||
useBossBar = conf.node("bossBar", "enable").getBoolean();
|
||||
useTitle = conf.node("title", "enable").getBoolean();
|
||||
usePlayerList = conf.node("playerList").getBoolean();
|
||||
usePlayerList = conf.node("playerList", "enable").getBoolean();
|
||||
useHeaderAndFooter = conf.node("headerAndFooter", "enable").getBoolean();
|
||||
|
||||
if (useBrandName)
|
||||
brandName = conf.node("brandName", "content").getString();
|
||||
@ -101,6 +108,14 @@ public final class LimboConfig {
|
||||
if (useTitle)
|
||||
title = conf.node("title").get(Title.class);
|
||||
|
||||
if (usePlayerList)
|
||||
playerListUsername = conf.node("playerList", "username").getString();
|
||||
|
||||
if (useHeaderAndFooter) {
|
||||
playerListHeader = conf.node("headerAndFooter", "header").getString();
|
||||
playerListFooter = conf.node("headerAndFooter", "footer").getString();
|
||||
}
|
||||
|
||||
infoForwarding = conf.node("infoForwarding").get(InfoForwarding.class);
|
||||
readTimeout = conf.node("readTimeout").getLong();
|
||||
debugLevel = conf.node("debugLevel").getInt();
|
||||
@ -193,6 +208,10 @@ public final class LimboConfig {
|
||||
return usePlayerList;
|
||||
}
|
||||
|
||||
public boolean isUseHeaderAndFooter() {
|
||||
return useHeaderAndFooter;
|
||||
}
|
||||
|
||||
public String getBrandName() {
|
||||
return brandName;
|
||||
}
|
||||
@ -209,6 +228,18 @@ public final class LimboConfig {
|
||||
return title;
|
||||
}
|
||||
|
||||
public String getPlayerListUsername() {
|
||||
return playerListUsername;
|
||||
}
|
||||
|
||||
public String getPlayerListHeader() {
|
||||
return playerListHeader;
|
||||
}
|
||||
|
||||
public String getPlayerListFooter() {
|
||||
return playerListFooter;
|
||||
}
|
||||
|
||||
public boolean isUseEpoll() {
|
||||
return useEpoll;
|
||||
}
|
||||
|
@ -65,6 +65,7 @@ public class ClientConnection extends ChannelInboundHandlerAdapter {
|
||||
private static PacketSnapshot PACKET_PLAYER_POS;
|
||||
private static PacketSnapshot PACKET_JOIN_MESSAGE;
|
||||
private static PacketSnapshot PACKET_BOSS_BAR;
|
||||
private static PacketSnapshot PACKET_HEADER_AND_FOOTER;
|
||||
|
||||
private static PacketSnapshot PACKET_TITLE_TITLE;
|
||||
private static PacketSnapshot PACKET_TITLE_SUBTITLE;
|
||||
@ -240,19 +241,12 @@ public class ClientConnection extends ChannelInboundHandlerAdapter {
|
||||
writePacket(PACKET_PLAYER_ABILITIES);
|
||||
writePacket(PACKET_PLAYER_POS);
|
||||
|
||||
if (clientVersion.moreOrEqual(Version.V1_17)) {
|
||||
if (server.getConfig().isUsePlayerList()) {
|
||||
if (PACKET_PLAYER_INFO != null && !clientVersion.equals(Version.V1_16_4))
|
||||
writePacket(PACKET_PLAYER_INFO);
|
||||
}
|
||||
}
|
||||
else {
|
||||
writePacket(PACKET_PLAYER_INFO);
|
||||
}
|
||||
|
||||
if (clientVersion.moreOrEqual(Version.V1_13)){
|
||||
writePacket(PACKET_DECLARE_COMMANDS);
|
||||
|
||||
|
||||
if (PACKET_PLUGIN_MESSAGE != null)
|
||||
writePacket(PACKET_PLUGIN_MESSAGE);
|
||||
}
|
||||
@ -266,6 +260,9 @@ public class ClientConnection extends ChannelInboundHandlerAdapter {
|
||||
if (PACKET_TITLE_TITLE != null)
|
||||
writeTitle();
|
||||
|
||||
if (PACKET_HEADER_AND_FOOTER != null)
|
||||
writePacket(PACKET_HEADER_AND_FOOTER);
|
||||
|
||||
sendKeepAlive();
|
||||
}
|
||||
|
||||
@ -430,11 +427,6 @@ public class ClientConnection extends ChannelInboundHandlerAdapter {
|
||||
positionAndLook.setPitch(server.getConfig().getSpawnPosition().getPitch());
|
||||
positionAndLook.setTeleportId(ThreadLocalRandom.current().nextInt());
|
||||
|
||||
PacketPlayerInfo info = new PacketPlayerInfo();
|
||||
info.setUsername(username);
|
||||
info.setGameMode(server.getConfig().getGameMode());
|
||||
info.setUuid(uuid);
|
||||
|
||||
PacketDeclareCommands declareCommands = new PacketDeclareCommands();
|
||||
declareCommands.setCommands(Collections.emptyList());
|
||||
|
||||
@ -443,9 +435,22 @@ public class ClientConnection extends ChannelInboundHandlerAdapter {
|
||||
PACKET_PLAYER_ABILITIES = PacketSnapshot.of(playerAbilities);
|
||||
PACKET_PLAYER_POS = PacketSnapshot.of(positionAndLook);
|
||||
|
||||
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);
|
||||
|
||||
PACKET_DECLARE_COMMANDS = PacketSnapshot.of(declareCommands);
|
||||
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()){
|
||||
PacketPluginMessage pluginMessage = new PacketPluginMessage();
|
||||
|
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Nan1t
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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 PacketPlayerListHeader implements PacketOut {
|
||||
|
||||
private String header;
|
||||
private String footer;
|
||||
|
||||
public void setHeader(String header) {
|
||||
this.header = header;
|
||||
}
|
||||
|
||||
public void setFooter(String footer) {
|
||||
this.footer = footer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(ByteMessage msg, Version version) {
|
||||
msg.writeString(header);
|
||||
msg.writeString(footer);
|
||||
}
|
||||
}
|
@ -29,6 +29,7 @@ public class PacketPluginMessage implements PacketOut {
|
||||
public void setChannel(String channel) {
|
||||
this.channel = channel;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
@ -189,6 +189,19 @@ public enum State {
|
||||
map(0x5A, V1_17, V1_17_1),
|
||||
map(0x5B, V1_18, V1_18)
|
||||
);
|
||||
clientBound.register(PacketPlayerListHeader::new,
|
||||
map(0x47, V1_8, V1_8),
|
||||
map(0x48, V1_9, V1_9_2),
|
||||
map(0x47, V1_9_4, V1_11_1),
|
||||
map(0x49, V1_12, V1_12),
|
||||
map(0x4A, V1_12_1, V1_12_2),
|
||||
map(0x4E, V1_13, V1_13_2),
|
||||
map(0x53, V1_14, V1_14_4),
|
||||
map(0x54, V1_15, V1_15_2),
|
||||
map(0x53, V1_16, V1_16_4),
|
||||
map(0x5E, V1_17, V1_17_1),
|
||||
map(0x5F, V1_18, V1_18)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -20,7 +20,16 @@ ping:
|
||||
dimension: THE_END
|
||||
|
||||
# Whether to display the player in the player list
|
||||
playerList: true
|
||||
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!"}'
|
||||
footer: '{"text": "&9NanoLimbo"}'
|
||||
|
||||
# Spawn position in the world
|
||||
spawnPosition:
|
||||
|
Loading…
x
Reference in New Issue
Block a user