From b26b6dadb07006a96076869fd44e788e43212cce Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Mon, 27 Jan 2014 08:39:26 +1100 Subject: [PATCH] Add Optional Tick Shuffling This prevents players from 'gaming' the server, and strategically relogging to increase their position in the tick order. By: md_5 --- .../network/ServerConnectionListener.java.patch | 14 ++++++++++++++ .../src/main/java/org/spigotmc/SpigotConfig.java | 6 ++++++ 2 files changed, 20 insertions(+) diff --git a/paper-server/patches/sources/net/minecraft/server/network/ServerConnectionListener.java.patch b/paper-server/patches/sources/net/minecraft/server/network/ServerConnectionListener.java.patch index 5d7f68c60e..39649142ff 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/ServerConnectionListener.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/ServerConnectionListener.java.patch @@ -29,3 +29,17 @@ public SocketAddress startMemoryChannel() { List list = this.channels; ChannelFuture channelfuture; +@@ -153,6 +163,13 @@ + List list = this.connections; + + synchronized (this.connections) { ++ // Spigot Start ++ // This prevents players from 'gaming' the server, and strategically relogging to increase their position in the tick order ++ if ( org.spigotmc.SpigotConfig.playerShuffle > 0 && MinecraftServer.currentTick % org.spigotmc.SpigotConfig.playerShuffle == 0 ) ++ { ++ Collections.shuffle( this.connections ); ++ } ++ // Spigot End + Iterator iterator = this.connections.iterator(); + + while (iterator.hasNext()) { diff --git a/paper-server/src/main/java/org/spigotmc/SpigotConfig.java b/paper-server/src/main/java/org/spigotmc/SpigotConfig.java index accee68536..8b1c919347 100644 --- a/paper-server/src/main/java/org/spigotmc/SpigotConfig.java +++ b/paper-server/src/main/java/org/spigotmc/SpigotConfig.java @@ -278,4 +278,10 @@ public class SpigotConfig SpigotConfig.playerSample = SpigotConfig.getInt( "settings.sample-count", 12 ); System.out.println( "Server Ping Player Sample Count: " + SpigotConfig.playerSample ); } + + public static int playerShuffle; + private static void playerShuffle() + { + SpigotConfig.playerShuffle = SpigotConfig.getInt( "settings.player-shuffle", 0 ); + } }