mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-31 04:13:51 -07:00
Update PaperSpigot to Minecraft 1.8
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Sun, 19 Oct 2014 15:56:39 -0500
|
||||
From: Zach Brown <1254957+zachbr@users.noreply.github.com>
|
||||
Date: Fri, 28 Nov 2014 12:48:26 -0600
|
||||
Subject: [PATCH] Further improve server tick loop
|
||||
|
||||
Improves how the catchup buffer is handled, allowing it to roll both ways
|
||||
@@ -15,7 +15,7 @@ diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -0,0 +0,0 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
@@ -0,0 +0,0 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IAs
|
||||
public org.bukkit.command.ConsoleCommandSender console;
|
||||
public org.bukkit.command.RemoteConsoleCommandSender remoteConsole;
|
||||
public ConsoleReader reader;
|
||||
@@ -32,9 +32,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
- public final double[] recentTps = new double[ 3 ];
|
||||
- // Spigot end
|
||||
|
||||
public MinecraftServer(OptionSet options, Proxy proxy) { // CraftBukkit - signature file -> OptionSet
|
||||
net.minecraft.util.io.netty.util.ResourceLeakDetector.setEnabled( false ); // Spigot - disable
|
||||
@@ -0,0 +0,0 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
public MinecraftServer(OptionSet options, Proxy proxy, File file1) {
|
||||
io.netty.util.ResourceLeakDetector.setEnabled( false ); // Spigot - disable
|
||||
@@ -0,0 +0,0 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IAs
|
||||
this.isRunning = false;
|
||||
}
|
||||
|
||||
@@ -49,8 +49,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ private static final long MAX_CATCHUP_BUFFER = TICK_TIME * TPS * 60L;
|
||||
+ private static final int SAMPLE_INTERVAL = 20;
|
||||
+ public final RollingAverage tps1 = new RollingAverage(60);
|
||||
+ public final RollingAverage tps5 = new RollingAverage(60*5);
|
||||
+ public final RollingAverage tps15 = new RollingAverage(60*15);
|
||||
+ public final RollingAverage tps5 = new RollingAverage(60 * 5);
|
||||
+ public final RollingAverage tps15 = new RollingAverage(60 * 15);
|
||||
+
|
||||
+ public static class RollingAverage {
|
||||
+ private final int size;
|
||||
@@ -74,11 +74,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+
|
||||
+ public void add(double x, long t) {
|
||||
+ time -= times[index];
|
||||
+ total -= samples[index]*times[index];
|
||||
+ total -= samples[index] * times[index];
|
||||
+ samples[index] = x;
|
||||
+ times[index] = t;
|
||||
+ time += t;
|
||||
+ total += x*t;
|
||||
+ total += x * t;
|
||||
+ if (++index == size) {
|
||||
+ index = 0;
|
||||
+ }
|
||||
@@ -93,8 +93,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
@@ -0,0 +0,0 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IMo
|
||||
this.a(this.q);
|
||||
@@ -0,0 +0,0 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IAs
|
||||
this.a(this.r);
|
||||
|
||||
// Spigot start
|
||||
- Arrays.fill( recentTps, 20 );
|
||||
@@ -132,15 +132,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
|
||||
- if ( MinecraftServer.currentTick++ % SAMPLE_INTERVAL == 0 )
|
||||
+ catchupTime = Math.min(MAX_CATCHUP_BUFFER, catchupTime - wait);
|
||||
+ // Paperspigot end
|
||||
+
|
||||
+ if ( ++MinecraftServer.currentTick % SAMPLE_INTERVAL == 0 ) // PaperSpigot - Further improve tick loop
|
||||
+ if ( ++MinecraftServer.currentTick % SAMPLE_INTERVAL == 0 )
|
||||
{
|
||||
- double currentTps = 1E9 / ( curTime - tickSection ) * SAMPLE_INTERVAL;
|
||||
- recentTps[0] = calcTps( recentTps[0], 0.92, currentTps ); // 1/exp(5sec/1min)
|
||||
- recentTps[1] = calcTps( recentTps[1], 0.9835, currentTps ); // 1/exp(5sec/5min)
|
||||
- recentTps[2] = calcTps( recentTps[2], 0.9945, currentTps ); // 1/exp(5sec/15min)
|
||||
+ // PaperSpigot start - Further improve tick loop
|
||||
+ final long diff = curTime - tickSection;
|
||||
+ double currentTps = 1E9 / diff * SAMPLE_INTERVAL;
|
||||
+ tps1.add(currentTps, diff);
|
||||
@@ -156,8 +154,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -0,0 +0,0 @@ public final class CraftServer implements Server {
|
||||
return org.spigotmc.SpigotConfig.config;
|
||||
}
|
||||
private final Spigot spigot = new Spigot()
|
||||
{
|
||||
|
||||
+ // PaperSpigot start - Add getTPS (Further improve tick loop)
|
||||
+ @Override
|
||||
@@ -171,7 +169,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ // PaperSpigot end
|
||||
+
|
||||
@Override
|
||||
public void broadcast( BaseComponent component )
|
||||
public YamlConfiguration getConfig()
|
||||
{
|
||||
diff --git a/src/main/java/org/spigotmc/TicksPerSecondCommand.java b/src/main/java/org/spigotmc/TicksPerSecondCommand.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
@@ -182,9 +180,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
|
||||
-import com.google.common.base.Joiner;
|
||||
-import net.minecraft.server.MinecraftServer;
|
||||
-import net.minecraft.util.com.google.common.collect.Iterables;
|
||||
+import org.apache.commons.lang.StringUtils;
|
||||
+import org.bukkit.Bukkit;
|
||||
-import com.google.common.collect.Iterables;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -198,16 +194,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
- sb.append( format( tps ) );
|
||||
- sb.append( ", " );
|
||||
+ // PaperSpigot start - Further improve tick handling
|
||||
+ double[] tps = Bukkit.spigot().getTPS();
|
||||
+ double[] tps = org.bukkit.Bukkit.spigot().getTPS();
|
||||
+ String[] tpsAvg = new String[tps.length];
|
||||
+
|
||||
+ for ( int i = 0; i < tps.length; i++) {
|
||||
+ tpsAvg[i] = format( tps[i] );
|
||||
+ for ( int i = 0; i < tps.length; i++) {
|
||||
+ tpsAvg[i] = format( tps[i] );
|
||||
}
|
||||
- sender.sendMessage( sb.substring( 0, sb.length() - 2 ) );
|
||||
+
|
||||
+ sender.sendMessage( ChatColor.GOLD + "TPS from last 1m, 5m, 15m: " + StringUtils.join(tpsAvg, ", "));
|
||||
+ // PaperSpigot end
|
||||
+ sender.sendMessage( ChatColor.GOLD + "TPS from last 1m, 5m, 15m: " + org.apache.commons.lang.StringUtils.join(tpsAvg, ", "));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user