From 8c7ff941cfe539c31041d5e7dbd7d78953fc82ea Mon Sep 17 00:00:00 2001 From: Prototik Date: Fri, 29 May 2015 19:54:43 +0700 Subject: [PATCH] Add ability to configure max tab player list (#10) --- .../ServerConfigurationManager.java.patch | 14 +++++++++++--- .../cauldron/configuration/CauldronConfig.java | 1 + 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/patches/net/minecraft/server/management/ServerConfigurationManager.java.patch b/patches/net/minecraft/server/management/ServerConfigurationManager.java.patch index 82b047b..b59ee78 100644 --- a/patches/net/minecraft/server/management/ServerConfigurationManager.java.patch +++ b/patches/net/minecraft/server/management/ServerConfigurationManager.java.patch @@ -87,6 +87,7 @@ ChunkCoordinates chunkcoordinates = worldserver.getSpawnPoint(); this.func_72381_a(p_72355_2_, (EntityPlayerMP)null, worldserver); p_72355_2_.playerNetServerHandler = nethandlerplayserver; +- nethandlerplayserver.sendPacket(new S01PacketJoinGame(p_72355_2_.getEntityId(), p_72355_2_.theItemInWorldManager.getGameType(), worldserver.getWorldInfo().isHardcoreModeEnabled(), worldserver.provider.dimensionId, worldserver.difficultySetting, this.getMaxPlayers(), worldserver.getWorldInfo().getTerrainType())); + // CraftBukkit start -- Don't send a higher than 60 MaxPlayer size, otherwise the PlayerInfo window won't render correctly. + int maxPlayers = this.getMaxPlayers(); + @@ -105,7 +106,7 @@ + serverChannel.writeOutbound(new ForgeMessage.DimensionRegisterMessage(p_72355_2_.dimension, worldserver.getWorld().getEnvironment().getId())); + } + // Cauldron end - nethandlerplayserver.sendPacket(new S01PacketJoinGame(p_72355_2_.getEntityId(), p_72355_2_.theItemInWorldManager.getGameType(), worldserver.getWorldInfo().isHardcoreModeEnabled(), worldserver.provider.dimensionId, worldserver.difficultySetting, this.getMaxPlayers(), worldserver.getWorldInfo().getTerrainType())); ++ nethandlerplayserver.sendPacket(new S01PacketJoinGame(p_72355_2_.getEntityId(), p_72355_2_.theItemInWorldManager.getGameType(), worldserver.getWorldInfo().isHardcoreModeEnabled(), worldserver.provider.dimensionId, worldserver.difficultySetting, this.getMaxVisiblePlayers(), worldserver.getWorldInfo().getTerrainType())); + p_72355_2_.getBukkitEntity().sendSupportedChannels(); // CraftBukkit nethandlerplayserver.sendPacket(new S3FPacketCustomPayload("MC|Brand", this.getServerInstance().getServerModName().getBytes(Charsets.UTF_8))); nethandlerplayserver.sendPacket(new S05PacketSpawnPosition(chunkcoordinates.posX, chunkcoordinates.posY, chunkcoordinates.posZ)); @@ -905,8 +906,15 @@ p_72385_1_.playerNetServerHandler.sendPacket(new S09PacketHeldItemChange(p_72385_1_.inventory.currentItem)); } -@@ -963,7 +1487,10 @@ +@@ -961,9 +1485,17 @@ + return this.maxPlayers; + } ++ public int getMaxVisiblePlayers() { ++ int max = mcServer.cauldronConfig.maxPlayersVisible.getValue(); ++ return max > 0 ? max : maxPlayers; ++ } ++ public String[] getAvailablePlayerDat() { - return this.mcServer.worldServers[0].getSaveHandler().getSaveHandler().getAvailablePlayerDat(); @@ -917,7 +925,7 @@ } public void setWhiteListEnabled(boolean p_72371_1_) -@@ -1032,12 +1559,30 @@ +@@ -1032,12 +1564,30 @@ public void removeAllPlayers() { diff --git a/src/main/java/net/minecraftforge/cauldron/configuration/CauldronConfig.java b/src/main/java/net/minecraftforge/cauldron/configuration/CauldronConfig.java index 96c53a5..926e67e 100644 --- a/src/main/java/net/minecraftforge/cauldron/configuration/CauldronConfig.java +++ b/src/main/java/net/minecraftforge/cauldron/configuration/CauldronConfig.java @@ -53,6 +53,7 @@ public class CauldronConfig extends ConfigBase public final BoolSetting flowingLavaDecay = new BoolSetting(this, "world-settings.default.flowing-lava-decay", false, "Lava behaves like vanilla water when source block is removed"); public final BoolSetting allowTntPunishment = new BoolSetting(this, "world-settings.default.allow-tnt-punishment", true, "TNT ability to push other entities (including other TNTs)"); public final BoolSetting fakePlayerLogin = new BoolSetting(this, "fake-players.do-login", false, "Raise login events for fake players"); + public final IntSetting maxPlayersVisible = new IntSetting(this, "world-settings.max-players-visible", -1, "How many players will visible in the tab list"); // Plug-in options public final BoolSetting remapPluginFile = new BoolSetting(this, "plugin-settings.default.remap-plugin-file", false, "Remap the plugin file (dev)");