Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-17 13:30:06 +01:00
Implemented configurable ping packet limit.
Dieser Commit ist enthalten in:
Ursprung
096672b3c1
Commit
392e2a4272
@ -47,11 +47,13 @@ public class ServerConfigurationManager {
|
|||||||
|
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
private CraftServer cserver;
|
private CraftServer cserver;
|
||||||
|
private final int MAX_PACKETS_PER_TICK;
|
||||||
|
|
||||||
public ServerConfigurationManager(MinecraftServer minecraftserver) {
|
public ServerConfigurationManager(MinecraftServer minecraftserver) {
|
||||||
minecraftserver.server = new CraftServer(minecraftserver, this);
|
minecraftserver.server = new CraftServer(minecraftserver, this);
|
||||||
minecraftserver.console = new ColouredConsoleSender(minecraftserver.server);
|
minecraftserver.console = new ColouredConsoleSender(minecraftserver.server);
|
||||||
this.cserver = minecraftserver.server;
|
this.cserver = minecraftserver.server;
|
||||||
|
this.MAX_PACKETS_PER_TICK = minecraftserver.server.getPingPacketLimit();
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
|
|
||||||
this.server = minecraftserver;
|
this.server = minecraftserver;
|
||||||
@ -315,25 +317,29 @@ public class ServerConfigurationManager {
|
|||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CraftBukkit start - Limit/throttle latency packets
|
||||||
public void b() {
|
public void b() {
|
||||||
int i;
|
int playerCount = this.players.size();
|
||||||
|
if ((MAX_PACKETS_PER_TICK > 0) && (playerCount > 0)) {
|
||||||
|
int fromIndex, toIndex;
|
||||||
|
|
||||||
if (this.p-- <= 0) {
|
int playerListSize = playerCount > 126 ? 126 : playerCount;
|
||||||
for (i = 0; i < this.players.size(); ++i) {
|
int totalPacketCount = playerCount * playerListSize;
|
||||||
// CraftBukkit start -- Client cannot render anymore than 126 Players so there's no point sending anymore packets.
|
int packetsToSend = totalPacketCount < MAX_PACKETS_PER_TICK ? totalPacketCount : MAX_PACKETS_PER_TICK;
|
||||||
if (i > 126) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// CraftBukkit end
|
|
||||||
EntityPlayer entityplayer = (EntityPlayer) this.players.get(i);
|
|
||||||
|
|
||||||
this.sendAll(new Packet201PlayerInfo(entityplayer.name, true, entityplayer.i));
|
int lastIndex = (this.server.ticks * packetsToSend) % totalPacketCount;
|
||||||
|
|
||||||
|
for (int i = lastIndex; i < lastIndex + packetsToSend; i++) {
|
||||||
|
i %= totalPacketCount;
|
||||||
|
toIndex = i % playerCount;
|
||||||
|
fromIndex = i / playerCount;
|
||||||
|
|
||||||
|
((EntityPlayer) this.players.get(toIndex)).netServerHandler.sendPacket(new Packet201PlayerInfo(((EntityPlayer) this.players.get(fromIndex)).name, true, ((EntityPlayer) this.players.get(fromIndex)).i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CraftBukkit start
|
for (int j = 0; j < this.server.worlds.size(); ++j) {
|
||||||
for (i = 0; i < this.server.worlds.size(); ++i) {
|
this.server.worlds.get(j).manager.flush();
|
||||||
this.server.worlds.get(i).manager.flush();
|
|
||||||
}
|
}
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
}
|
}
|
||||||
|
@ -119,6 +119,8 @@ public final class CraftServer implements Server {
|
|||||||
|
|
||||||
configuration.getString("settings.permissions-file", "permissions.yml");
|
configuration.getString("settings.permissions-file", "permissions.yml");
|
||||||
|
|
||||||
|
configuration.getInt("settings.ping-packet-limit", 100);
|
||||||
|
|
||||||
if (configuration.getNode("aliases") == null) {
|
if (configuration.getNode("aliases") == null) {
|
||||||
List<String> icanhasbukkit = new ArrayList<String>();
|
List<String> icanhasbukkit = new ArrayList<String>();
|
||||||
icanhasbukkit.add("version");
|
icanhasbukkit.add("version");
|
||||||
@ -317,6 +319,10 @@ public final class CraftServer implements Server {
|
|||||||
return this.configuration.getString("settings.update-folder", "update");
|
return this.configuration.getString("settings.update-folder", "update");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getPingPacketLimit() {
|
||||||
|
return this.configuration.getInt("settings.ping-packet-limit", 100);
|
||||||
|
}
|
||||||
|
|
||||||
public PluginManager getPluginManager() {
|
public PluginManager getPluginManager() {
|
||||||
return pluginManager;
|
return pluginManager;
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren