Add configuration for declare commands and player list

This commit is contained in:
BoomEaro 2022-01-29 21:34:28 +02:00
parent e089fb5584
commit 188d2de0df
3 changed files with 48 additions and 9 deletions

View File

@ -33,6 +33,7 @@ import java.net.SocketAddress;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.List;
public final class LimboConfig { public final class LimboConfig {
@ -50,10 +51,13 @@ public final class LimboConfig {
private boolean useJoinMessage; private boolean useJoinMessage;
private boolean useBossBar; private boolean useBossBar;
private boolean useTitle; private boolean useTitle;
private boolean useDeclareCommands;
private boolean usePlayerList;
private String brandName; private String brandName;
private String joinMessage; private String joinMessage;
private BossBar bossBar; private BossBar bossBar;
private Title title; private Title title;
private List<String> declareCommands;
private InfoForwarding infoForwarding; private InfoForwarding infoForwarding;
private long readTimeout; private long readTimeout;
@ -86,8 +90,10 @@ public final class LimboConfig {
useJoinMessage = conf.node("joinMessage", "enable").getBoolean(); useJoinMessage = conf.node("joinMessage", "enable").getBoolean();
useBossBar = conf.node("bossBar", "enable").getBoolean(); useBossBar = conf.node("bossBar", "enable").getBoolean();
useTitle = conf.node("title", "enable").getBoolean(); useTitle = conf.node("title", "enable").getBoolean();
useDeclareCommands = conf.node("declareCommands", "enable").getBoolean();
usePlayerList = conf.node("playerList").getBoolean();
if(useBrandName) if (useBrandName)
brandName = conf.node("brandName", "content").getString(); brandName = conf.node("brandName", "content").getString();
if (useJoinMessage) if (useJoinMessage)
@ -99,6 +105,9 @@ public final class LimboConfig {
if (useTitle) if (useTitle)
title = conf.node("title").get(Title.class); title = conf.node("title").get(Title.class);
if (useDeclareCommands)
declareCommands = conf.node("declareCommands", "commands").getList(String.class);
infoForwarding = conf.node("infoForwarding").get(InfoForwarding.class); infoForwarding = conf.node("infoForwarding").get(InfoForwarding.class);
readTimeout = conf.node("readTimeout").getLong(); readTimeout = conf.node("readTimeout").getLong();
debugLevel = conf.node("debugLevel").getInt(); debugLevel = conf.node("debugLevel").getInt();
@ -187,6 +196,14 @@ public final class LimboConfig {
return useTitle; return useTitle;
} }
public boolean isUseDeclareCommands() {
return useDeclareCommands;
}
public boolean isUsePlayerList() {
return usePlayerList;
}
public String getBrandName() { public String getBrandName() {
return brandName; return brandName;
} }
@ -203,6 +220,10 @@ public final class LimboConfig {
return title; return title;
} }
public List<String> getDeclareCommands() {
return declareCommands;
}
public boolean isUseEpoll() { public boolean isUseEpoll() {
return useEpoll; return useEpoll;
} }

View File

@ -50,7 +50,6 @@ import java.net.InetSocketAddress;
import java.net.SocketAddress; import java.net.SocketAddress;
import java.security.InvalidKeyException; import java.security.InvalidKeyException;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.util.Collections;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.ThreadLocalRandom;
@ -239,10 +238,14 @@ public class ClientConnection extends ChannelInboundHandlerAdapter {
writePacket(PACKET_JOIN_GAME); writePacket(PACKET_JOIN_GAME);
writePacket(PACKET_PLAYER_ABILITIES); writePacket(PACKET_PLAYER_ABILITIES);
writePacket(PACKET_PLAYER_POS); writePacket(PACKET_PLAYER_POS);
writePacket(PACKET_PLAYER_INFO); if (PACKET_PLAYER_INFO != null) {
writePacket(PACKET_PLAYER_INFO);
}
if (clientVersion.moreOrEqual(Version.V1_13)){ if (clientVersion.moreOrEqual(Version.V1_13)){
writePacket(PACKET_DECLARE_COMMANDS); if (PACKET_DECLARE_COMMANDS != null)
writePacket(PACKET_DECLARE_COMMANDS);
if (PACKET_PLUGIN_MESSAGE != null) if (PACKET_PLUGIN_MESSAGE != null)
writePacket(PACKET_PLUGIN_MESSAGE); writePacket(PACKET_PLUGIN_MESSAGE);
@ -426,15 +429,21 @@ public class ClientConnection extends ChannelInboundHandlerAdapter {
info.setGameMode(server.getConfig().getGameMode()); info.setGameMode(server.getConfig().getGameMode());
info.setUuid(uuid); info.setUuid(uuid);
PacketDeclareCommands declareCommands = new PacketDeclareCommands();
declareCommands.setCommands(Collections.emptyList());
PACKET_LOGIN_SUCCESS = PacketSnapshot.of(loginSuccess); PACKET_LOGIN_SUCCESS = PacketSnapshot.of(loginSuccess);
PACKET_JOIN_GAME = PacketSnapshot.of(joinGame); PACKET_JOIN_GAME = PacketSnapshot.of(joinGame);
PACKET_PLAYER_ABILITIES = PacketSnapshot.of(playerAbilities); PACKET_PLAYER_ABILITIES = PacketSnapshot.of(playerAbilities);
PACKET_PLAYER_POS = PacketSnapshot.of(positionAndLook); PACKET_PLAYER_POS = PacketSnapshot.of(positionAndLook);
PACKET_PLAYER_INFO = PacketSnapshot.of(info);
PACKET_DECLARE_COMMANDS = PacketSnapshot.of(declareCommands); if (server.getConfig().isUsePlayerList()) {
PACKET_PLAYER_INFO = PacketSnapshot.of(info);
}
if (server.getConfig().isUseDeclareCommands()) {
PacketDeclareCommands declareCommands = new PacketDeclareCommands();
declareCommands.setCommands(server.getConfig().getDeclareCommands());
PACKET_DECLARE_COMMANDS = PacketSnapshot.of(declareCommands);
}
if (server.getConfig().isUseBrandName()){ if (server.getConfig().isUseBrandName()){
PacketPluginMessage pluginMessage = new PacketPluginMessage(); PacketPluginMessage pluginMessage = new PacketPluginMessage();

View File

@ -19,6 +19,15 @@ ping:
# Available dimensions: OVERWORLD, NETHER, THE_END # Available dimensions: OVERWORLD, NETHER, THE_END
dimension: THE_END dimension: THE_END
# Sending prepared tabcomplete commands to the player
declareCommands:
enable: true
commands:
- 'NanoLimbo'
# Whether to display the player in the player list
playerList: true
# Spawn position in the world # Spawn position in the world
spawnPosition: spawnPosition:
x: 0.0 x: 0.0