diff --git a/src/main/java/ru/nanit/limbo/configuration/LimboConfig.java b/src/main/java/ru/nanit/limbo/configuration/LimboConfig.java index c55daed..fa256f0 100644 --- a/src/main/java/ru/nanit/limbo/configuration/LimboConfig.java +++ b/src/main/java/ru/nanit/limbo/configuration/LimboConfig.java @@ -33,6 +33,7 @@ import java.net.SocketAddress; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.List; public final class LimboConfig { @@ -50,10 +51,13 @@ public final class LimboConfig { private boolean useJoinMessage; private boolean useBossBar; private boolean useTitle; + private boolean useDeclareCommands; + private boolean usePlayerList; private String brandName; private String joinMessage; private BossBar bossBar; private Title title; + private List declareCommands; private InfoForwarding infoForwarding; private long readTimeout; @@ -86,8 +90,10 @@ public final class LimboConfig { useJoinMessage = conf.node("joinMessage", "enable").getBoolean(); useBossBar = conf.node("bossBar", "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(); if (useJoinMessage) @@ -99,6 +105,9 @@ public final class LimboConfig { if (useTitle) title = conf.node("title").get(Title.class); + if (useDeclareCommands) + declareCommands = conf.node("declareCommands", "commands").getList(String.class); + infoForwarding = conf.node("infoForwarding").get(InfoForwarding.class); readTimeout = conf.node("readTimeout").getLong(); debugLevel = conf.node("debugLevel").getInt(); @@ -187,6 +196,14 @@ public final class LimboConfig { return useTitle; } + public boolean isUseDeclareCommands() { + return useDeclareCommands; + } + + public boolean isUsePlayerList() { + return usePlayerList; + } + public String getBrandName() { return brandName; } @@ -203,6 +220,10 @@ public final class LimboConfig { return title; } + public List getDeclareCommands() { + return declareCommands; + } + public boolean isUseEpoll() { return useEpoll; } diff --git a/src/main/java/ru/nanit/limbo/connection/ClientConnection.java b/src/main/java/ru/nanit/limbo/connection/ClientConnection.java index ea9eb1e..04a742d 100644 --- a/src/main/java/ru/nanit/limbo/connection/ClientConnection.java +++ b/src/main/java/ru/nanit/limbo/connection/ClientConnection.java @@ -50,7 +50,6 @@ import java.net.InetSocketAddress; import java.net.SocketAddress; import java.security.InvalidKeyException; import java.security.MessageDigest; -import java.util.Collections; import java.util.UUID; import java.util.concurrent.ThreadLocalRandom; @@ -239,10 +238,14 @@ public class ClientConnection extends ChannelInboundHandlerAdapter { writePacket(PACKET_JOIN_GAME); writePacket(PACKET_PLAYER_ABILITIES); writePacket(PACKET_PLAYER_POS); - writePacket(PACKET_PLAYER_INFO); + if (PACKET_PLAYER_INFO != null) { + writePacket(PACKET_PLAYER_INFO); + } if (clientVersion.moreOrEqual(Version.V1_13)){ - writePacket(PACKET_DECLARE_COMMANDS); + if (PACKET_DECLARE_COMMANDS != null) + writePacket(PACKET_DECLARE_COMMANDS); + if (PACKET_PLUGIN_MESSAGE != null) writePacket(PACKET_PLUGIN_MESSAGE); @@ -426,15 +429,21 @@ public class ClientConnection extends ChannelInboundHandlerAdapter { info.setGameMode(server.getConfig().getGameMode()); info.setUuid(uuid); - PacketDeclareCommands declareCommands = new PacketDeclareCommands(); - declareCommands.setCommands(Collections.emptyList()); - 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()) { + 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()){ PacketPluginMessage pluginMessage = new PacketPluginMessage(); diff --git a/src/main/resources/settings.yml b/src/main/resources/settings.yml index e47477d..e33899a 100644 --- a/src/main/resources/settings.yml +++ b/src/main/resources/settings.yml @@ -19,6 +19,15 @@ ping: # Available dimensions: OVERWORLD, NETHER, 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 spawnPosition: x: 0.0