mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-01 12:41:50 +01:00
30f02fe6e5
I think its pretty clear that no one uses this given that it didn't work at all before
1124 lines
50 KiB
Diff
1124 lines
50 KiB
Diff
From 77ceef80ad43c8d082da0a1328659e0d9cbc3bcb Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Thu, 3 Mar 2016 04:00:11 -0600
|
|
Subject: [PATCH] Timings v2
|
|
|
|
|
|
diff --git a/src/main/java/co/aikar/timings/SpigotTimings.java b/src/main/java/co/aikar/timings/SpigotTimings.java
|
|
new file mode 100644
|
|
index 0000000..b3cafaf
|
|
--- /dev/null
|
|
+++ b/src/main/java/co/aikar/timings/SpigotTimings.java
|
|
@@ -0,0 +1,111 @@
|
|
+package co.aikar.timings;
|
|
+
|
|
+import net.minecraft.server.*;
|
|
+import org.bukkit.plugin.Plugin;
|
|
+import org.bukkit.scheduler.BukkitTask;
|
|
+
|
|
+import org.bukkit.craftbukkit.scheduler.CraftTask;
|
|
+
|
|
+public final class SpigotTimings {
|
|
+
|
|
+ public static final Timing playerListTimer = Timings.ofSafe("Player List");
|
|
+ public static final Timing connectionTimer = Timings.ofSafe("Connection Handler");
|
|
+ public static final Timing tickablesTimer = Timings.ofSafe("Tickables");
|
|
+ public static final Timing minecraftSchedulerTimer = Timings.ofSafe("Minecraft Scheduler");
|
|
+ public static final Timing bukkitSchedulerTimer = Timings.ofSafe("Bukkit Scheduler");
|
|
+ public static final Timing chunkIOTickTimer = Timings.ofSafe("ChunkIOTick");
|
|
+ public static final Timing timeUpdateTimer = Timings.ofSafe("Time Update");
|
|
+ public static final Timing serverCommandTimer = Timings.ofSafe("Server Command");
|
|
+ public static final Timing worldSaveTimer = Timings.ofSafe("World Save");
|
|
+
|
|
+ public static final Timing tickEntityTimer = Timings.ofSafe("## tickEntity");
|
|
+ public static final Timing tickTileEntityTimer = Timings.ofSafe("## tickTileEntity");
|
|
+
|
|
+ public static final Timing processQueueTimer = Timings.ofSafe("processQueue");
|
|
+
|
|
+ public static final Timing playerCommandTimer = Timings.ofSafe("playerCommand");
|
|
+
|
|
+ public static final Timing entityActivationCheckTimer = Timings.ofSafe("entityActivationCheck");
|
|
+ public static final Timing checkIfActiveTimer = Timings.ofSafe("checkIfActive");
|
|
+
|
|
+ public static final Timing antiXrayUpdateTimer = Timings.ofSafe("anti-xray - update");
|
|
+ public static final Timing antiXrayObfuscateTimer = Timings.ofSafe("anti-xray - obfuscate");
|
|
+
|
|
+ private SpigotTimings() {}
|
|
+
|
|
+ /**
|
|
+ * Gets a timer associated with a plugins tasks.
|
|
+ * @param bukkitTask
|
|
+ * @param period
|
|
+ * @return
|
|
+ */
|
|
+ public static Timing getPluginTaskTimings(BukkitTask bukkitTask, long period) {
|
|
+ if (!bukkitTask.isSync()) {
|
|
+ return null;
|
|
+ }
|
|
+ Plugin plugin;
|
|
+
|
|
+ Runnable task = ((CraftTask) bukkitTask).task;
|
|
+
|
|
+ final Class<? extends Runnable> taskClass = task.getClass();
|
|
+ if (bukkitTask.getOwner() != null) {
|
|
+ plugin = bukkitTask.getOwner();
|
|
+ } else {
|
|
+ plugin = TimingsManager.getPluginByClassloader(taskClass);
|
|
+ }
|
|
+
|
|
+ final String taskname;
|
|
+ if (taskClass.isAnonymousClass()) {
|
|
+ taskname = taskClass.getName();
|
|
+ } else {
|
|
+ taskname = taskClass.getCanonicalName();
|
|
+ }
|
|
+
|
|
+ String name = "Task: " +taskname;
|
|
+ if (period > 0) {
|
|
+ name += " (interval:" + period +")";
|
|
+ } else {
|
|
+ name += " (Single)";
|
|
+ }
|
|
+
|
|
+ if (plugin == null) {
|
|
+ return Timings.ofSafe(null, name, TimingsManager.PLUGIN_GROUP_HANDLER);
|
|
+ }
|
|
+
|
|
+ return Timings.ofSafe(plugin, name);
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Get a named timer for the specified entity type to track type specific timings.
|
|
+ * @param entity
|
|
+ * @return
|
|
+ */
|
|
+ public static Timing getEntityTimings(Entity entity) {
|
|
+ String entityType = entity.getClass().getName();
|
|
+ return Timings.ofSafe("Minecraft", "## tickEntity - " + entityType, tickEntityTimer);
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Get a named timer for the specified tile entity type to track type specific timings.
|
|
+ * @param entity
|
|
+ * @return
|
|
+ */
|
|
+ public static Timing getTileEntityTimings(TileEntity entity) {
|
|
+ String entityType = entity.getClass().getName();
|
|
+ return Timings.ofSafe("Minecraft", "## tickTileEntity - " + entityType, tickTileEntityTimer);
|
|
+ }
|
|
+ public static Timing getCancelTasksTimer() {
|
|
+ return Timings.ofSafe("Cancel Tasks");
|
|
+ }
|
|
+ public static Timing getCancelTasksTimer(Plugin plugin) {
|
|
+ return Timings.ofSafe(plugin, "Cancel Tasks");
|
|
+ }
|
|
+
|
|
+ public static void stopServer() {
|
|
+ TimingsManager.stopServer();
|
|
+ }
|
|
+
|
|
+ public static Timing getBlockTiming(Block block) {
|
|
+ return Timings.ofSafe("## Scheduled Block: " + block.getName());
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/co/aikar/timings/WorldTimingsHandler.java b/src/main/java/co/aikar/timings/WorldTimingsHandler.java
|
|
new file mode 100644
|
|
index 0000000..9ebc710
|
|
--- /dev/null
|
|
+++ b/src/main/java/co/aikar/timings/WorldTimingsHandler.java
|
|
@@ -0,0 +1,69 @@
|
|
+package co.aikar.timings;
|
|
+
|
|
+import net.minecraft.server.World;
|
|
+
|
|
+/**
|
|
+ * Set of timers per world, to track world specific timings.
|
|
+ */
|
|
+public class WorldTimingsHandler {
|
|
+ public final Timing mobSpawn;
|
|
+ public final Timing doChunkUnload;
|
|
+ public final Timing doPortalForcer;
|
|
+ public final Timing scheduledBlocks;
|
|
+ public final Timing scheduledBlocksCleanup;
|
|
+ public final Timing scheduledBlocksTicking;
|
|
+ public final Timing chunkTicks;
|
|
+ public final Timing chunkTicksBlocks;
|
|
+ public final Timing doVillages;
|
|
+ public final Timing doChunkMap;
|
|
+ public final Timing doChunkGC;
|
|
+ public final Timing doSounds;
|
|
+ public final Timing entityRemoval;
|
|
+ public final Timing entityTick;
|
|
+ public final Timing tileEntityTick;
|
|
+ public final Timing tileEntityPending;
|
|
+ public final Timing tracker;
|
|
+ public final Timing doTick;
|
|
+ public final Timing tickEntities;
|
|
+
|
|
+ public final Timing syncChunkLoadTimer;
|
|
+ public final Timing syncChunkLoadDataTimer;
|
|
+ public final Timing syncChunkLoadStructuresTimer;
|
|
+ public final Timing syncChunkLoadEntitiesTimer;
|
|
+ public final Timing syncChunkLoadTileEntitiesTimer;
|
|
+ public final Timing syncChunkLoadTileTicksTimer;
|
|
+ public final Timing syncChunkLoadPostTimer;
|
|
+
|
|
+ public WorldTimingsHandler(World server) {
|
|
+ String name = server.worldData.getName() +" - ";
|
|
+
|
|
+ mobSpawn = Timings.ofSafe(name + "mobSpawn");
|
|
+ doChunkUnload = Timings.ofSafe(name + "doChunkUnload");
|
|
+ scheduledBlocks = Timings.ofSafe(name + "Scheduled Blocks");
|
|
+ scheduledBlocksCleanup = Timings.ofSafe(name + "Scheduled Blocks - Cleanup");
|
|
+ scheduledBlocksTicking = Timings.ofSafe(name + "Scheduled Blocks - Ticking");
|
|
+ chunkTicks = Timings.ofSafe(name + "Chunk Ticks");
|
|
+ chunkTicksBlocks = Timings.ofSafe(name + "Chunk Ticks - Blocks");
|
|
+ doVillages = Timings.ofSafe(name + "doVillages");
|
|
+ doChunkMap = Timings.ofSafe(name + "doChunkMap");
|
|
+ doSounds = Timings.ofSafe(name + "doSounds");
|
|
+ doChunkGC = Timings.ofSafe(name + "doChunkGC");
|
|
+ doPortalForcer = Timings.ofSafe(name + "doPortalForcer");
|
|
+ entityTick = Timings.ofSafe(name + "entityTick");
|
|
+ entityRemoval = Timings.ofSafe(name + "entityRemoval");
|
|
+ tileEntityTick = Timings.ofSafe(name + "tileEntityTick");
|
|
+ tileEntityPending = Timings.ofSafe(name + "tileEntityPending");
|
|
+
|
|
+ syncChunkLoadTimer = Timings.ofSafe(name + "syncChunkLoad");
|
|
+ syncChunkLoadDataTimer = Timings.ofSafe(name + "syncChunkLoad - Data");
|
|
+ syncChunkLoadStructuresTimer = Timings.ofSafe(name + "chunkLoad - Structures");
|
|
+ syncChunkLoadEntitiesTimer = Timings.ofSafe(name + "chunkLoad - Entities");
|
|
+ syncChunkLoadTileEntitiesTimer = Timings.ofSafe(name + "chunkLoad - TileEntities");
|
|
+ syncChunkLoadTileTicksTimer = Timings.ofSafe(name + "chunkLoad - TileTicks");
|
|
+ syncChunkLoadPostTimer = Timings.ofSafe(name + "chunkLoad - Post");
|
|
+
|
|
+ tracker = Timings.ofSafe(name + "tracker");
|
|
+ doTick = Timings.ofSafe(name + "doTick");
|
|
+ tickEntities = Timings.ofSafe(name + "tickEntities");
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
|
index 0ffa733..62f4631 100644
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
|
@@ -10,13 +10,17 @@ import java.lang.reflect.Modifier;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
+import java.util.concurrent.TimeUnit;
|
|
import java.util.logging.Level;
|
|
|
|
+import com.google.common.collect.Lists;
|
|
import net.minecraft.server.MinecraftServer;
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.command.Command;
|
|
import org.bukkit.configuration.InvalidConfigurationException;
|
|
import org.bukkit.configuration.file.YamlConfiguration;
|
|
+import co.aikar.timings.Timings;
|
|
+import co.aikar.timings.TimingsManager;
|
|
|
|
public class PaperConfig {
|
|
|
|
@@ -127,4 +131,37 @@ public class PaperConfig {
|
|
Bukkit.getLogger().log(Level.INFO, "Disabling player interaction limiter, your server may be more vulnerable to malicious users");
|
|
}
|
|
}
|
|
+
|
|
+ private static void timings() {
|
|
+ boolean timings = getBoolean("timings.enabled", true);
|
|
+ boolean verboseTimings = getBoolean("timings.verbose", true);
|
|
+ TimingsManager.privacy = getBoolean("timings.server-name-privacy", false);
|
|
+ TimingsManager.hiddenConfigs = getList("timings.hidden-config-entries", Lists.newArrayList("database", "settings.bungeecord-addresses"));
|
|
+ int timingHistoryInterval = getInt("timings.history-interval", 300);
|
|
+ int timingHistoryLength = getInt("timings.history-length", 3600);
|
|
+
|
|
+
|
|
+ Timings.setVerboseTimingsEnabled(verboseTimings);
|
|
+ Timings.setTimingsEnabled(timings);
|
|
+ Timings.setHistoryInterval(timingHistoryInterval * 20);
|
|
+ Timings.setHistoryLength(timingHistoryLength * 20);
|
|
+
|
|
+ Bukkit.getLogger().log(Level.INFO, "Spigot Timings: " + timings +
|
|
+ " - Verbose: " + verboseTimings +
|
|
+ " - Interval: " + timeSummary(Timings.getHistoryInterval() / 20) +
|
|
+ " - Length: " + timeSummary(Timings.getHistoryLength() / 20));
|
|
+ }
|
|
+
|
|
+ protected static String timeSummary(int seconds) {
|
|
+ String time = "";
|
|
+ if (seconds > 60 * 60) {
|
|
+ time += TimeUnit.SECONDS.toHours(seconds) + "h";
|
|
+ seconds /= 60;
|
|
+ }
|
|
+
|
|
+ if (seconds > 0) {
|
|
+ time += TimeUnit.SECONDS.toMinutes(seconds) + "m";
|
|
+ }
|
|
+ return time;
|
|
+ }
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/Block.java b/src/main/java/net/minecraft/server/Block.java
|
|
index bed5577..0f71013 100644
|
|
--- a/src/main/java/net/minecraft/server/Block.java
|
|
+++ b/src/main/java/net/minecraft/server/Block.java
|
|
@@ -32,6 +32,15 @@ public class Block {
|
|
protected final BlockStateList blockStateList;
|
|
private IBlockData blockData;
|
|
private String name;
|
|
+ // Paper start
|
|
+ public co.aikar.timings.Timing timing;
|
|
+ public co.aikar.timings.Timing getTiming() {
|
|
+ if (timing == null) {
|
|
+ timing = co.aikar.timings.SpigotTimings.getBlockTiming(this);
|
|
+ }
|
|
+ return timing;
|
|
+ }
|
|
+ // Paper end
|
|
|
|
public static int getId(Block block) {
|
|
return Block.REGISTRY.a(block); // CraftBukkit - decompile error
|
|
diff --git a/src/main/java/net/minecraft/server/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java
|
|
index dd3abb8..a0186ef 100644
|
|
--- a/src/main/java/net/minecraft/server/DedicatedServer.java
|
|
+++ b/src/main/java/net/minecraft/server/DedicatedServer.java
|
|
@@ -22,7 +22,7 @@ import java.io.PrintStream;
|
|
import org.apache.logging.log4j.Level;
|
|
|
|
import org.bukkit.craftbukkit.LoggerOutputStream;
|
|
-import org.bukkit.craftbukkit.SpigotTimings; // Spigot
|
|
+import co.aikar.timings.SpigotTimings; // Paper
|
|
import org.bukkit.event.server.ServerCommandEvent;
|
|
import org.bukkit.craftbukkit.util.Waitable;
|
|
import org.bukkit.event.server.RemoteServerCommandEvent;
|
|
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
|
index cf58f74..38bc9c0 100644
|
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
|
@@ -24,7 +24,8 @@ import org.bukkit.block.BlockFace;
|
|
import org.bukkit.entity.Hanging;
|
|
import org.bukkit.entity.LivingEntity;
|
|
import org.bukkit.entity.Vehicle;
|
|
-import org.spigotmc.CustomTimingsHandler; // Spigot
|
|
+import co.aikar.timings.SpigotTimings; // Paper
|
|
+import co.aikar.timings.Timing; // Paper
|
|
import org.bukkit.event.entity.EntityCombustByEntityEvent;
|
|
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
|
import org.bukkit.event.vehicle.VehicleBlockCollisionEvent;
|
|
@@ -148,7 +149,7 @@ public abstract class Entity implements ICommandListener {
|
|
public boolean valid; // CraftBukkit
|
|
public org.bukkit.projectiles.ProjectileSource projectileSource; // CraftBukkit - For projectiles only
|
|
public boolean forceExplosionKnockback; // CraftBukkit - SPIGOT-949
|
|
- public CustomTimingsHandler tickTimer = org.bukkit.craftbukkit.SpigotTimings.getEntityTimings(this); // Spigot
|
|
+ public Timing tickTimer = SpigotTimings.getEntityTimings(this); // Paper
|
|
// Spigot start
|
|
public final byte activationType = org.spigotmc.ActivationRange.initializeEntityActivationType(this);
|
|
public final boolean defaultActivationState;
|
|
@@ -477,7 +478,6 @@ public abstract class Entity implements ICommandListener {
|
|
}
|
|
|
|
public void move(double d0, double d1, double d2) {
|
|
- org.bukkit.craftbukkit.SpigotTimings.entityMoveTimer.startTiming(); // Spigot
|
|
if (this.noclip) {
|
|
this.a(this.getBoundingBox().c(d0, d1, d2));
|
|
this.recalcPosition();
|
|
@@ -818,7 +818,6 @@ public abstract class Entity implements ICommandListener {
|
|
|
|
this.world.methodProfiler.b();
|
|
}
|
|
- org.bukkit.craftbukkit.SpigotTimings.entityMoveTimer.stopTiming(); // Spigot
|
|
}
|
|
|
|
public void recalcPosition() {
|
|
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
|
|
index f3fdd4c..d2f7cc2 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
|
@@ -24,7 +24,7 @@ import org.bukkit.event.entity.EntityRegainHealthEvent;
|
|
import org.bukkit.event.player.PlayerItemConsumeEvent;
|
|
// CraftBukkit end
|
|
|
|
-import org.bukkit.craftbukkit.SpigotTimings; // Spigot
|
|
+import co.aikar.timings.SpigotTimings; // Paper
|
|
|
|
public abstract class EntityLiving extends Entity {
|
|
|
|
@@ -1688,7 +1688,6 @@ public abstract class EntityLiving extends Entity {
|
|
}
|
|
|
|
public void m() {
|
|
- SpigotTimings.timerEntityBaseTick.startTiming(); // Spigot
|
|
super.m();
|
|
this.cu();
|
|
if (!this.world.isClientSide) {
|
|
@@ -1761,9 +1760,7 @@ public abstract class EntityLiving extends Entity {
|
|
}
|
|
}
|
|
|
|
- SpigotTimings.timerEntityBaseTick.stopTiming(); // Spigot
|
|
this.n();
|
|
- SpigotTimings.timerEntityTickRest.startTiming(); // Spigot
|
|
double d0 = this.locX - this.lastX;
|
|
double d1 = this.locZ - this.lastZ;
|
|
float f = (float) (d0 * d0 + d1 * d1);
|
|
@@ -1832,8 +1829,6 @@ public abstract class EntityLiving extends Entity {
|
|
} else {
|
|
this.bo = 0;
|
|
}
|
|
-
|
|
- SpigotTimings.timerEntityTickRest.stopTiming(); // Spigot
|
|
}
|
|
|
|
protected float h(float f, float f1) {
|
|
@@ -1898,7 +1893,6 @@ public abstract class EntityLiving extends Entity {
|
|
}
|
|
|
|
this.world.methodProfiler.a("ai");
|
|
- SpigotTimings.timerEntityAI.startTiming(); // Spigot
|
|
if (this.cf()) {
|
|
this.bc = false;
|
|
this.bd = 0.0F;
|
|
@@ -1909,7 +1903,6 @@ public abstract class EntityLiving extends Entity {
|
|
this.doTick();
|
|
this.world.methodProfiler.b();
|
|
}
|
|
- SpigotTimings.timerEntityAI.stopTiming(); // Spigot
|
|
|
|
this.world.methodProfiler.b();
|
|
this.world.methodProfiler.a("jump");
|
|
@@ -1932,14 +1925,10 @@ public abstract class EntityLiving extends Entity {
|
|
this.be *= 0.98F;
|
|
this.bf *= 0.9F;
|
|
this.r();
|
|
- SpigotTimings.timerEntityAIMove.startTiming(); // Spigot
|
|
this.g(this.bd, this.be);
|
|
- SpigotTimings.timerEntityAIMove.stopTiming(); // Spigot
|
|
this.world.methodProfiler.b();
|
|
this.world.methodProfiler.a("push");
|
|
- SpigotTimings.timerEntityAICollision.startTiming(); // Spigot
|
|
this.cn();
|
|
- SpigotTimings.timerEntityAICollision.stopTiming(); // Spigot
|
|
this.world.methodProfiler.b();
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
index 733f8e7..92b98a0 100644
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
@@ -45,7 +45,7 @@ import org.bukkit.craftbukkit.CraftServer;
|
|
|
|
// CraftBukkit start
|
|
// CraftBukkit end
|
|
-import org.bukkit.craftbukkit.SpigotTimings; // Spigot
|
|
+import co.aikar.timings.SpigotTimings; // Paper
|
|
|
|
public abstract class MinecraftServer implements Runnable, ICommandListener, IAsyncTaskHandler, IMojangStatistics {
|
|
|
|
@@ -443,6 +443,7 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
|
|
}
|
|
// CraftBukkit end
|
|
MinecraftServer.LOGGER.info("Stopping server");
|
|
+ SpigotTimings.stopServer(); // Paper
|
|
// CraftBukkit start
|
|
if (this.server != null) {
|
|
this.server.disablePlugins();
|
|
@@ -699,7 +700,7 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
|
|
protected void B() {}
|
|
|
|
protected void C() throws ExceptionWorldConflict { // CraftBukkit - added throws
|
|
- SpigotTimings.serverTickTimer.startTiming(); // Spigot
|
|
+ co.aikar.timings.TimingsManager.FULL_SERVER_TICK.startTiming(); // Paper
|
|
long i = System.nanoTime();
|
|
|
|
++this.ticks;
|
|
@@ -759,11 +760,11 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
|
|
this.methodProfiler.b();
|
|
this.methodProfiler.b();
|
|
org.spigotmc.WatchdogThread.tick(); // Spigot
|
|
- SpigotTimings.serverTickTimer.stopTiming(); // Spigot
|
|
- org.spigotmc.CustomTimingsHandler.tick(); // Spigot
|
|
+ co.aikar.timings.TimingsManager.FULL_SERVER_TICK.stopTiming(); // Paper
|
|
}
|
|
|
|
public void D() {
|
|
+ SpigotTimings.minecraftSchedulerTimer.startTiming(); // Paper
|
|
this.methodProfiler.a("jobs");
|
|
Queue queue = this.j;
|
|
|
|
@@ -774,13 +775,14 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
|
|
SystemUtils.a(entry, MinecraftServer.LOGGER);
|
|
}
|
|
// Spigot end
|
|
+ SpigotTimings.minecraftSchedulerTimer.stopTiming(); // Paper
|
|
|
|
this.methodProfiler.c("levels");
|
|
|
|
- SpigotTimings.schedulerTimer.startTiming(); // Spigot
|
|
+ SpigotTimings.bukkitSchedulerTimer.startTiming(); // Paper
|
|
// CraftBukkit start
|
|
this.server.getScheduler().mainThreadHeartbeat(this.ticks);
|
|
- SpigotTimings.schedulerTimer.stopTiming(); // Spigot
|
|
+ SpigotTimings.bukkitSchedulerTimer.stopTiming(); // Paper
|
|
|
|
// Run tasks that are waiting on processing
|
|
SpigotTimings.processQueueTimer.startTiming(); // Spigot
|
|
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
index cbffd19..80ed7f8 100644
|
|
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
@@ -58,6 +58,7 @@ import org.bukkit.inventory.CraftingInventory;
|
|
import org.bukkit.inventory.EquipmentSlot;
|
|
import org.bukkit.inventory.InventoryView;
|
|
import org.bukkit.util.NumberConversions;
|
|
+import co.aikar.timings.SpigotTimings; // Paper
|
|
// CraftBukkit end
|
|
|
|
public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
|
@@ -1332,7 +1333,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
|
// CraftBukkit end
|
|
|
|
private void handleCommand(String s) {
|
|
- org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.startTiming(); // Spigot
|
|
+ SpigotTimings.playerCommandTimer.startTiming(); // Paper
|
|
// CraftBukkit start - whole method
|
|
if ( org.spigotmc.SpigotConfig.logCommands ) // Spigot
|
|
this.LOGGER.info(this.player.getName() + " issued server command: " + s);
|
|
@@ -1343,22 +1344,22 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
|
this.server.getPluginManager().callEvent(event);
|
|
|
|
if (event.isCancelled()) {
|
|
- org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
|
|
+ SpigotTimings.playerCommandTimer.stopTiming(); // Paper
|
|
return;
|
|
}
|
|
|
|
try {
|
|
if (this.server.dispatchCommand(event.getPlayer(), event.getMessage().substring(1))) {
|
|
- org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
|
|
+ SpigotTimings.playerCommandTimer.stopTiming(); // Paper
|
|
return;
|
|
}
|
|
} catch (org.bukkit.command.CommandException ex) {
|
|
player.sendMessage(org.bukkit.ChatColor.RED + "An internal error occurred while attempting to perform this command");
|
|
java.util.logging.Logger.getLogger(PlayerConnection.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
|
- org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
|
|
+ SpigotTimings.playerCommandTimer.stopTiming(); // Paper
|
|
return;
|
|
}
|
|
- org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
|
|
+ SpigotTimings.playerCommandTimer.stopTiming(); // Paper
|
|
// this.minecraftServer.getCommandHandler().a(this.player, s);
|
|
// CraftBukkit end
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/TileEntity.java b/src/main/java/net/minecraft/server/TileEntity.java
|
|
index d898428..f579d28 100644
|
|
--- a/src/main/java/net/minecraft/server/TileEntity.java
|
|
+++ b/src/main/java/net/minecraft/server/TileEntity.java
|
|
@@ -6,12 +6,13 @@ import java.util.concurrent.Callable;
|
|
import org.apache.logging.log4j.LogManager;
|
|
import org.apache.logging.log4j.Logger;
|
|
|
|
-import org.spigotmc.CustomTimingsHandler; // Spigot
|
|
+import co.aikar.timings.SpigotTimings; // Paper
|
|
+import co.aikar.timings.Timing; // Paper
|
|
import org.bukkit.inventory.InventoryHolder; // CraftBukkit
|
|
|
|
public abstract class TileEntity {
|
|
|
|
- public CustomTimingsHandler tickTimer = org.bukkit.craftbukkit.SpigotTimings.getTileEntityTimings(this); // Spigot
|
|
+ public Timing tickTimer = SpigotTimings.getTileEntityTimings(this); // Paper
|
|
private static final Logger a = LogManager.getLogger();
|
|
private static Map<String, Class<? extends TileEntity>> f = Maps.newHashMap();
|
|
private static Map<Class<? extends TileEntity>, String> g = Maps.newHashMap();
|
|
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
|
index 1815f79..21b0986 100644
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
|
@@ -18,11 +18,11 @@ import com.google.common.collect.Maps;
|
|
import java.util.Map;
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.block.BlockState;
|
|
-import org.bukkit.craftbukkit.SpigotTimings; // Spigot
|
|
import org.bukkit.craftbukkit.CraftServer;
|
|
import org.bukkit.craftbukkit.CraftWorld;
|
|
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
|
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
|
+import org.bukkit.craftbukkit.util.LongHashSet; // Paper
|
|
import org.bukkit.event.block.BlockCanBuildEvent;
|
|
import org.bukkit.event.block.BlockPhysicsEvent;
|
|
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
|
@@ -134,7 +134,7 @@ public abstract class World implements IBlockAccess {
|
|
|
|
public final com.destroystokyo.paper.PaperWorldConfig paperConfig; // Paper
|
|
|
|
- public final SpigotTimings.WorldTimingsHandler timings; // Spigot
|
|
+ public final co.aikar.timings.WorldTimingsHandler timings; // Paper
|
|
private boolean guardEntityList; // Spigot
|
|
public static boolean haveWeSilencedAPhysicsCrash;
|
|
public static String blockLocation;
|
|
@@ -207,7 +207,7 @@ public abstract class World implements IBlockAccess {
|
|
this.getServer().addWorld(this.world);
|
|
// CraftBukkit end
|
|
this.keepSpawnInMemory = this.paperConfig.keepSpawnInMemory; // Paper
|
|
- timings = new SpigotTimings.WorldTimingsHandler(this); // Spigot - code below can generate new world and access timings
|
|
+ timings = new co.aikar.timings.WorldTimingsHandler(this); // Paper - code below can generate new world and access timings
|
|
this.entityLimiter = new org.spigotmc.TickLimiter(spigotConfig.entityMaxTickTime);
|
|
this.tileLimiter = new org.spigotmc.TickLimiter(spigotConfig.tileMaxTickTime);
|
|
}
|
|
@@ -1379,6 +1379,7 @@ public abstract class World implements IBlockAccess {
|
|
}
|
|
|
|
this.methodProfiler.c("remove");
|
|
+ timings.entityRemoval.startTiming(); // Paper
|
|
this.entityList.removeAll(this.f);
|
|
|
|
int j;
|
|
@@ -1399,6 +1400,7 @@ public abstract class World implements IBlockAccess {
|
|
|
|
this.f.clear();
|
|
this.l();
|
|
+ timings.entityRemoval.stopTiming(); // Paper
|
|
this.methodProfiler.c("regular");
|
|
|
|
CrashReportSystemDetails crashreportsystemdetails1;
|
|
@@ -1408,6 +1410,7 @@ public abstract class World implements IBlockAccess {
|
|
timings.entityTick.startTiming(); // Spigot
|
|
guardEntityList = true; // Spigot
|
|
// CraftBukkit start - Use field for loop variable
|
|
+ co.aikar.timings.TimingHistory.entityTicks += this.entityList.size(); // Paper
|
|
int entitiesThisCycle = 0;
|
|
// Paper start - Disable tick limiters
|
|
//if (tickPosition < 0) tickPosition = 0;
|
|
@@ -1429,12 +1432,12 @@ public abstract class World implements IBlockAccess {
|
|
this.methodProfiler.a("tick");
|
|
if (!entity.dead && !(entity instanceof EntityPlayer)) {
|
|
try {
|
|
- SpigotTimings.tickEntityTimer.startTiming(); // Spigot
|
|
+ entity.tickTimer.startTiming(); // Paper
|
|
this.g(entity);
|
|
- SpigotTimings.tickEntityTimer.stopTiming(); // Spigot
|
|
+ entity.tickTimer.stopTiming(); // Paper
|
|
} catch (Throwable throwable1) {
|
|
// Paper start - Prevent tile entity and entity crashes
|
|
- SpigotTimings.tickEntityTimer.stopTiming();
|
|
+ entity.tickTimer.stopTiming();
|
|
System.err.println("Entity threw exception at " + entity.world.getWorld().getName() + ":" + entity.locX + "," + entity.locY + "," + entity.locZ);
|
|
throwable1.printStackTrace();
|
|
entity.dead = true;
|
|
@@ -1563,6 +1566,7 @@ public abstract class World implements IBlockAccess {
|
|
}
|
|
|
|
timings.tileEntityPending.stopTiming(); // Spigot
|
|
+ co.aikar.timings.TimingHistory.tileEntityTicks += this.tileEntityListTick.size(); // Paper
|
|
this.methodProfiler.b();
|
|
this.methodProfiler.b();
|
|
}
|
|
@@ -1608,7 +1612,6 @@ public abstract class World implements IBlockAccess {
|
|
entity.ticksLived++;
|
|
entity.inactiveTick();
|
|
} else {
|
|
- entity.tickTimer.startTiming(); // Spigot
|
|
// CraftBukkit end
|
|
entity.M = entity.locX;
|
|
entity.N = entity.locY;
|
|
@@ -1617,6 +1620,7 @@ public abstract class World implements IBlockAccess {
|
|
entity.lastPitch = entity.pitch;
|
|
if (flag && entity.aa) {
|
|
++entity.ticksLived;
|
|
+ ++co.aikar.timings.TimingHistory.activatedEntityTicks; // Paper
|
|
if (entity.isPassenger()) {
|
|
entity.aw();
|
|
} else {
|
|
@@ -1675,8 +1679,6 @@ public abstract class World implements IBlockAccess {
|
|
}
|
|
}
|
|
}
|
|
-
|
|
- entity.tickTimer.stopTiming(); // Spigot
|
|
}
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
|
|
index c411f01..0e1cbfe 100644
|
|
--- a/src/main/java/net/minecraft/server/WorldServer.java
|
|
+++ b/src/main/java/net/minecraft/server/WorldServer.java
|
|
@@ -241,13 +241,13 @@ public class WorldServer extends World implements IAsyncTaskHandler {
|
|
|
|
timings.doChunkUnload.stopTiming(); // Spigot
|
|
this.methodProfiler.c("tickPending");
|
|
- timings.doTickPending.startTiming(); // Spigot
|
|
+ timings.scheduledBlocks.startTiming(); // Paper
|
|
this.a(false);
|
|
- timings.doTickPending.stopTiming(); // Spigot
|
|
+ timings.scheduledBlocks.stopTiming(); // Paper
|
|
this.methodProfiler.c("tickBlocks");
|
|
- timings.doTickTiles.startTiming(); // Spigot
|
|
+ timings.chunkTicks.startTiming(); // Paper
|
|
this.j();
|
|
- timings.doTickTiles.stopTiming(); // Spigot
|
|
+ timings.chunkTicks.stopTiming(); // Paper
|
|
this.methodProfiler.c("chunkMap");
|
|
timings.doChunkMap.startTiming(); // Spigot
|
|
this.manager.flush();
|
|
@@ -478,7 +478,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
|
|
}
|
|
}
|
|
|
|
- this.methodProfiler.c("tickBlocks");
|
|
+ timings.chunkTicksBlocks.startTiming(); // Paper
|
|
if (i > 0) {
|
|
ChunkSection[] achunksection = chunk.getSections();
|
|
int i1 = achunksection.length;
|
|
@@ -506,6 +506,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
|
|
}
|
|
}
|
|
}
|
|
+ timings.chunkTicksBlocks.stopTiming(); // Paper
|
|
}
|
|
|
|
this.methodProfiler.b();
|
|
@@ -710,6 +711,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
|
|
|
|
this.methodProfiler.a("cleaning");
|
|
|
|
+ timings.scheduledBlocksCleanup.startTiming(); // Paper
|
|
NextTickListEntry nextticklistentry;
|
|
|
|
for (int j = 0; j < i; ++j) {
|
|
@@ -723,6 +725,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
|
|
// this.nextTickListHash.remove(nextticklistentry);
|
|
this.U.add(nextticklistentry);
|
|
}
|
|
+ timings.scheduledBlocksCleanup.stopTiming(); // Paper
|
|
|
|
// Paper start - Allow redstone ticks to bypass the tickNextTickListCap
|
|
if (paperConfig.tickNextTickListCapIgnoresRedstone) {
|
|
@@ -744,6 +747,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
|
|
|
|
this.methodProfiler.b();
|
|
this.methodProfiler.a("ticking");
|
|
+ timings.scheduledBlocksTicking.startTiming(); // Paper
|
|
Iterator iterator = this.U.iterator();
|
|
|
|
while (iterator.hasNext()) {
|
|
@@ -753,6 +757,8 @@ public class WorldServer extends World implements IAsyncTaskHandler {
|
|
|
|
if (this.areChunksLoadedBetween(nextticklistentry.a.a(-b0, -b0, -b0), nextticklistentry.a.a(b0, b0, b0))) {
|
|
IBlockData iblockdata = this.getType(nextticklistentry.a);
|
|
+ co.aikar.timings.Timing timing = iblockdata.getBlock().getTiming(); // Paper
|
|
+ timing.startTiming(); // Paper
|
|
|
|
if (iblockdata.getMaterial() != Material.AIR && Block.a(iblockdata.getBlock(), nextticklistentry.a())) {
|
|
try {
|
|
@@ -765,10 +771,12 @@ public class WorldServer extends World implements IAsyncTaskHandler {
|
|
throw new ReportedException(crashreport);
|
|
}
|
|
}
|
|
+ timing.stopTiming(); // Paper
|
|
} else {
|
|
this.a(nextticklistentry.a, nextticklistentry.a(), 0);
|
|
}
|
|
}
|
|
+ timings.scheduledBlocksTicking.stopTiming(); // Paper
|
|
|
|
this.methodProfiler.b();
|
|
this.U.clear();
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
index 4654a4b..b27d95a 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
@@ -1726,6 +1726,7 @@ public final class CraftServer implements Server {
|
|
private final Spigot spigot = new Spigot()
|
|
{
|
|
|
|
+ @Deprecated
|
|
@Override
|
|
public YamlConfiguration getConfig()
|
|
{
|
|
@@ -1733,6 +1734,24 @@ public final class CraftServer implements Server {
|
|
}
|
|
|
|
@Override
|
|
+ public YamlConfiguration getBukkitConfig()
|
|
+ {
|
|
+ return configuration;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public YamlConfiguration getSpigotConfig()
|
|
+ {
|
|
+ return org.spigotmc.SpigotConfig.config;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public YamlConfiguration getPaperConfig()
|
|
+ {
|
|
+ return com.destroystokyo.paper.PaperConfig.config;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
public void restart() {
|
|
org.spigotmc.RestartCommand.restart();
|
|
}
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java b/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java
|
|
deleted file mode 100644
|
|
index 41d2d87..0000000
|
|
--- a/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java
|
|
+++ /dev/null
|
|
@@ -1,173 +0,0 @@
|
|
-package org.bukkit.craftbukkit;
|
|
-
|
|
-import com.google.common.collect.Maps;
|
|
-import net.minecraft.server.*;
|
|
-import org.bukkit.plugin.java.JavaPluginLoader;
|
|
-import org.spigotmc.CustomTimingsHandler;
|
|
-import org.bukkit.scheduler.BukkitTask;
|
|
-
|
|
-import java.util.HashMap;
|
|
-import java.util.Map;
|
|
-
|
|
-import org.bukkit.craftbukkit.scheduler.CraftTask;
|
|
-
|
|
-public class SpigotTimings {
|
|
-
|
|
- public static final CustomTimingsHandler serverTickTimer = new CustomTimingsHandler("** Full Server Tick");
|
|
- public static final CustomTimingsHandler playerListTimer = new CustomTimingsHandler("Player List");
|
|
- public static final CustomTimingsHandler connectionTimer = new CustomTimingsHandler("Connection Handler");
|
|
- public static final CustomTimingsHandler tickablesTimer = new CustomTimingsHandler("Tickables");
|
|
- public static final CustomTimingsHandler schedulerTimer = new CustomTimingsHandler("Scheduler");
|
|
- public static final CustomTimingsHandler chunkIOTickTimer = new CustomTimingsHandler("ChunkIOTick");
|
|
- public static final CustomTimingsHandler timeUpdateTimer = new CustomTimingsHandler("Time Update");
|
|
- public static final CustomTimingsHandler serverCommandTimer = new CustomTimingsHandler("Server Command");
|
|
- public static final CustomTimingsHandler worldSaveTimer = new CustomTimingsHandler("World Save");
|
|
-
|
|
- public static final CustomTimingsHandler entityMoveTimer = new CustomTimingsHandler("** entityMove");
|
|
- public static final CustomTimingsHandler tickEntityTimer = new CustomTimingsHandler("** tickEntity");
|
|
- public static final CustomTimingsHandler activatedEntityTimer = new CustomTimingsHandler("** activatedTickEntity");
|
|
- public static final CustomTimingsHandler tickTileEntityTimer = new CustomTimingsHandler("** tickTileEntity");
|
|
-
|
|
- public static final CustomTimingsHandler timerEntityBaseTick = new CustomTimingsHandler("** livingEntityBaseTick");
|
|
- public static final CustomTimingsHandler timerEntityAI = new CustomTimingsHandler("** livingEntityAI");
|
|
- public static final CustomTimingsHandler timerEntityAICollision = new CustomTimingsHandler("** livingEntityAICollision");
|
|
- public static final CustomTimingsHandler timerEntityAIMove = new CustomTimingsHandler("** livingEntityAIMove");
|
|
- public static final CustomTimingsHandler timerEntityTickRest = new CustomTimingsHandler("** livingEntityTickRest");
|
|
-
|
|
- public static final CustomTimingsHandler processQueueTimer = new CustomTimingsHandler("processQueue");
|
|
- public static final CustomTimingsHandler schedulerSyncTimer = new CustomTimingsHandler("** Scheduler - Sync Tasks", JavaPluginLoader.pluginParentTimer);
|
|
-
|
|
- public static final CustomTimingsHandler playerCommandTimer = new CustomTimingsHandler("** playerCommand");
|
|
-
|
|
- public static final CustomTimingsHandler entityActivationCheckTimer = new CustomTimingsHandler("entityActivationCheck");
|
|
- public static final CustomTimingsHandler checkIfActiveTimer = new CustomTimingsHandler("** checkIfActive");
|
|
-
|
|
- public static final HashMap<String, CustomTimingsHandler> entityTypeTimingMap = new HashMap<String, CustomTimingsHandler>();
|
|
- public static final HashMap<String, CustomTimingsHandler> tileEntityTypeTimingMap = new HashMap<String, CustomTimingsHandler>();
|
|
- public static final HashMap<String, CustomTimingsHandler> pluginTaskTimingMap = new HashMap<String, CustomTimingsHandler>();
|
|
-
|
|
- /**
|
|
- * Gets a timer associated with a plugins tasks.
|
|
- * @param task
|
|
- * @param period
|
|
- * @return
|
|
- */
|
|
- public static CustomTimingsHandler getPluginTaskTimings(BukkitTask task, long period) {
|
|
- if (!task.isSync()) {
|
|
- return null;
|
|
- }
|
|
- String plugin;
|
|
- final CraftTask ctask = (CraftTask) task;
|
|
-
|
|
- if (task.getOwner() != null) {
|
|
- plugin = task.getOwner().getDescription().getFullName();
|
|
- } else if (ctask.timingName != null) {
|
|
- plugin = "CraftScheduler";
|
|
- } else {
|
|
- plugin = "Unknown";
|
|
- }
|
|
- String taskname = ctask.getTaskName();
|
|
-
|
|
- String name = "Task: " + plugin + " Runnable: " + taskname;
|
|
- if (period > 0) {
|
|
- name += "(interval:" + period +")";
|
|
- } else {
|
|
- name += "(Single)";
|
|
- }
|
|
- CustomTimingsHandler result = pluginTaskTimingMap.get(name);
|
|
- if (result == null) {
|
|
- result = new CustomTimingsHandler(name, SpigotTimings.schedulerSyncTimer);
|
|
- pluginTaskTimingMap.put(name, result);
|
|
- }
|
|
- return result;
|
|
- }
|
|
-
|
|
- /**
|
|
- * Get a named timer for the specified entity type to track type specific timings.
|
|
- * @param entity
|
|
- * @return
|
|
- */
|
|
- public static CustomTimingsHandler getEntityTimings(Entity entity) {
|
|
- String entityType = entity.getClass().getSimpleName();
|
|
- CustomTimingsHandler result = entityTypeTimingMap.get(entityType);
|
|
- if (result == null) {
|
|
- result = new CustomTimingsHandler("** tickEntity - " + entityType, activatedEntityTimer);
|
|
- entityTypeTimingMap.put(entityType, result);
|
|
- }
|
|
- return result;
|
|
- }
|
|
-
|
|
- /**
|
|
- * Get a named timer for the specified tile entity type to track type specific timings.
|
|
- * @param entity
|
|
- * @return
|
|
- */
|
|
- public static CustomTimingsHandler getTileEntityTimings(TileEntity entity) {
|
|
- String entityType = entity.getClass().getSimpleName();
|
|
- CustomTimingsHandler result = tileEntityTypeTimingMap.get(entityType);
|
|
- if (result == null) {
|
|
- result = new CustomTimingsHandler("** tickTileEntity - " + entityType, tickTileEntityTimer);
|
|
- tileEntityTypeTimingMap.put(entityType, result);
|
|
- }
|
|
- return result;
|
|
- }
|
|
-
|
|
- /**
|
|
- * Set of timers per world, to track world specific timings.
|
|
- */
|
|
- public static class WorldTimingsHandler {
|
|
- public final CustomTimingsHandler mobSpawn;
|
|
- public final CustomTimingsHandler doChunkUnload;
|
|
- public final CustomTimingsHandler doPortalForcer;
|
|
- public final CustomTimingsHandler doTickPending;
|
|
- public final CustomTimingsHandler doTickTiles;
|
|
- public final CustomTimingsHandler doVillages;
|
|
- public final CustomTimingsHandler doChunkMap;
|
|
- public final CustomTimingsHandler doChunkGC;
|
|
- public final CustomTimingsHandler doSounds;
|
|
- public final CustomTimingsHandler entityTick;
|
|
- public final CustomTimingsHandler tileEntityTick;
|
|
- public final CustomTimingsHandler tileEntityPending;
|
|
- public final CustomTimingsHandler tracker;
|
|
- public final CustomTimingsHandler doTick;
|
|
- public final CustomTimingsHandler tickEntities;
|
|
-
|
|
- public final CustomTimingsHandler syncChunkLoadTimer;
|
|
- public final CustomTimingsHandler syncChunkLoadDataTimer;
|
|
- public final CustomTimingsHandler syncChunkLoadStructuresTimer;
|
|
- public final CustomTimingsHandler syncChunkLoadEntitiesTimer;
|
|
- public final CustomTimingsHandler syncChunkLoadTileEntitiesTimer;
|
|
- public final CustomTimingsHandler syncChunkLoadTileTicksTimer;
|
|
- public final CustomTimingsHandler syncChunkLoadPostTimer;
|
|
-
|
|
- public WorldTimingsHandler(World server) {
|
|
- String name = server.worldData.getName() +" - ";
|
|
-
|
|
- mobSpawn = new CustomTimingsHandler("** " + name + "mobSpawn");
|
|
- doChunkUnload = new CustomTimingsHandler("** " + name + "doChunkUnload");
|
|
- doTickPending = new CustomTimingsHandler("** " + name + "doTickPending");
|
|
- doTickTiles = new CustomTimingsHandler("** " + name + "doTickTiles");
|
|
- doVillages = new CustomTimingsHandler("** " + name + "doVillages");
|
|
- doChunkMap = new CustomTimingsHandler("** " + name + "doChunkMap");
|
|
- doSounds = new CustomTimingsHandler("** " + name + "doSounds");
|
|
- doChunkGC = new CustomTimingsHandler("** " + name + "doChunkGC");
|
|
- doPortalForcer = new CustomTimingsHandler("** " + name + "doPortalForcer");
|
|
- entityTick = new CustomTimingsHandler("** " + name + "entityTick");
|
|
- tileEntityTick = new CustomTimingsHandler("** " + name + "tileEntityTick");
|
|
- tileEntityPending = new CustomTimingsHandler("** " + name + "tileEntityPending");
|
|
-
|
|
- syncChunkLoadTimer = new CustomTimingsHandler("** " + name + "syncChunkLoad");
|
|
- syncChunkLoadDataTimer = new CustomTimingsHandler("** " + name + "syncChunkLoad - Data");
|
|
- syncChunkLoadStructuresTimer = new CustomTimingsHandler("** " + name + "chunkLoad - Structures");
|
|
- syncChunkLoadEntitiesTimer = new CustomTimingsHandler("** " + name + "chunkLoad - Entities");
|
|
- syncChunkLoadTileEntitiesTimer = new CustomTimingsHandler("** " + name + "chunkLoad - TileEntities");
|
|
- syncChunkLoadTileTicksTimer = new CustomTimingsHandler("** " + name + "chunkLoad - TileTicks");
|
|
- syncChunkLoadPostTimer = new CustomTimingsHandler("** " + name + "chunkLoad - Post");
|
|
-
|
|
-
|
|
- tracker = new CustomTimingsHandler(name + "tracker");
|
|
- doTick = new CustomTimingsHandler(name + "doTick");
|
|
- tickEntities = new CustomTimingsHandler(name + "tickEntities");
|
|
- }
|
|
- }
|
|
-}
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
index 4a5de6b..582ab4c 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
@@ -37,15 +37,9 @@ import org.bukkit.configuration.serialization.DelegateDeserialization;
|
|
import org.bukkit.conversations.Conversation;
|
|
import org.bukkit.conversations.ConversationAbandonedEvent;
|
|
import org.bukkit.conversations.ManuallyAbandonedConversationCanceller;
|
|
-import org.bukkit.craftbukkit.CraftParticle;
|
|
+import org.bukkit.craftbukkit.*;
|
|
import org.bukkit.craftbukkit.block.CraftSign;
|
|
import org.bukkit.craftbukkit.conversations.ConversationTracker;
|
|
-import org.bukkit.craftbukkit.CraftEffect;
|
|
-import org.bukkit.craftbukkit.CraftOfflinePlayer;
|
|
-import org.bukkit.craftbukkit.CraftServer;
|
|
-import org.bukkit.craftbukkit.CraftSound;
|
|
-import org.bukkit.craftbukkit.CraftStatistic;
|
|
-import org.bukkit.craftbukkit.CraftWorld;
|
|
import org.bukkit.craftbukkit.map.CraftMapView;
|
|
import org.bukkit.craftbukkit.map.RenderData;
|
|
import org.bukkit.craftbukkit.scoreboard.CraftScoreboard;
|
|
@@ -1555,6 +1549,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|
packet.components = components;
|
|
getHandle().playerConnection.sendPacket(packet);
|
|
}
|
|
+
|
|
+ @Override
|
|
+ public int getPing()
|
|
+ {
|
|
+ return getHandle().ping;
|
|
+ }
|
|
};
|
|
|
|
public Player.Spigot spigot()
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
|
|
index 93d8d42..44e057c 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
|
|
@@ -186,7 +186,7 @@ public class CraftScheduler implements BukkitScheduler {
|
|
}
|
|
}
|
|
return false;
|
|
- }});
|
|
+ }}){{this.timings=co.aikar.timings.SpigotTimings.getCancelTasksTimer();}}; // Paper
|
|
handle(task, 0l);
|
|
for (CraftTask taskPending = head.getNext(); taskPending != null; taskPending = taskPending.getNext()) {
|
|
if (taskPending == task) {
|
|
@@ -219,7 +219,7 @@ public class CraftScheduler implements BukkitScheduler {
|
|
}
|
|
}
|
|
}
|
|
- });
|
|
+ }){{this.timings=co.aikar.timings.SpigotTimings.getCancelTasksTimer(plugin);}}; // Paper
|
|
handle(task, 0l);
|
|
for (CraftTask taskPending = head.getNext(); taskPending != null; taskPending = taskPending.getNext()) {
|
|
if (taskPending == task) {
|
|
@@ -251,7 +251,7 @@ public class CraftScheduler implements BukkitScheduler {
|
|
CraftScheduler.this.pending.clear();
|
|
CraftScheduler.this.temp.clear();
|
|
}
|
|
- });
|
|
+ }){{this.timings=co.aikar.timings.SpigotTimings.getCancelTasksTimer();}}; // Paper
|
|
handle(task, 0l);
|
|
for (CraftTask taskPending = head.getNext(); taskPending != null; taskPending = taskPending.getNext()) {
|
|
if (taskPending == task) {
|
|
@@ -346,9 +346,7 @@ public class CraftScheduler implements BukkitScheduler {
|
|
}
|
|
if (task.isSync()) {
|
|
try {
|
|
- task.timings.startTiming(); // Spigot
|
|
task.run();
|
|
- task.timings.stopTiming(); // Spigot
|
|
} catch (final Throwable throwable) {
|
|
task.getOwner().getLogger().log(
|
|
Level.WARNING,
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java
|
|
index 220e39a..ecbb0e5 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java
|
|
@@ -1,8 +1,8 @@
|
|
package org.bukkit.craftbukkit.scheduler;
|
|
|
|
import org.bukkit.Bukkit;
|
|
-import org.bukkit.craftbukkit.SpigotTimings; // Spigot
|
|
-import org.spigotmc.CustomTimingsHandler; // Spigot
|
|
+import co.aikar.timings.SpigotTimings; // Paper
|
|
+import co.aikar.timings.Timing; // Paper
|
|
import org.bukkit.plugin.Plugin;
|
|
import org.bukkit.scheduler.BukkitTask;
|
|
|
|
@@ -20,11 +20,11 @@ public class CraftTask implements BukkitTask, Runnable { // Spigot
|
|
*/
|
|
private volatile long period;
|
|
private long nextRun;
|
|
- private final Runnable task;
|
|
+ public final Runnable task; // Paper
|
|
+ public Timing timings; // Paper
|
|
private final Plugin plugin;
|
|
private final int id;
|
|
|
|
- final CustomTimingsHandler timings; // Spigot
|
|
CraftTask() {
|
|
this(null, null, -1, -1);
|
|
}
|
|
@@ -33,26 +33,12 @@ public class CraftTask implements BukkitTask, Runnable { // Spigot
|
|
this(null, task, -1, -1);
|
|
}
|
|
|
|
- // Spigot start
|
|
- public String timingName = null;
|
|
- CraftTask(String timingName) {
|
|
- this(timingName, null, null, -1, -1);
|
|
- }
|
|
- CraftTask(String timingName, final Runnable task) {
|
|
- this(timingName, null, task, -1, -1);
|
|
- }
|
|
- CraftTask(String timingName, final Plugin plugin, final Runnable task, final int id, final long period) {
|
|
+ CraftTask(final Plugin plugin, final Runnable task, final int id, final long period) { // Paper
|
|
this.plugin = plugin;
|
|
this.task = task;
|
|
this.id = id;
|
|
this.period = period;
|
|
- this.timingName = timingName == null && task == null ? "Unknown" : timingName;
|
|
- timings = this.isSync() ? SpigotTimings.getPluginTaskTimings(this, period) : null;
|
|
- }
|
|
-
|
|
- CraftTask(final Plugin plugin, final Runnable task, final int id, final long period) {
|
|
- this(null, plugin, task, id, period);
|
|
- // Spigot end
|
|
+ timings = task != null ? SpigotTimings.getPluginTaskTimings(this, period) : null; // Paper
|
|
}
|
|
|
|
public final int getTaskId() {
|
|
@@ -68,7 +54,9 @@ public class CraftTask implements BukkitTask, Runnable { // Spigot
|
|
}
|
|
|
|
public void run() {
|
|
+ if (timings != null && isSync()) timings.startTiming(); // Paper
|
|
task.run();
|
|
+ if (timings != null && isSync()) timings.stopTiming(); // Paper
|
|
}
|
|
|
|
long getPeriod() {
|
|
@@ -112,13 +100,4 @@ public class CraftTask implements BukkitTask, Runnable { // Spigot
|
|
setPeriod(-2l);
|
|
return true;
|
|
}
|
|
-
|
|
- // Spigot start
|
|
- public String getTaskName() {
|
|
- if (timingName != null) {
|
|
- return timingName;
|
|
- }
|
|
- return task.getClass().getName();
|
|
- }
|
|
- // Spigot end
|
|
}
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftIconCache.java b/src/main/java/org/bukkit/craftbukkit/util/CraftIconCache.java
|
|
index e52ef47..3d90b34 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftIconCache.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftIconCache.java
|
|
@@ -5,6 +5,7 @@ import org.bukkit.util.CachedServerIcon;
|
|
public class CraftIconCache implements CachedServerIcon {
|
|
public final String value;
|
|
|
|
+ public String getData() { return value; } // Paper
|
|
public CraftIconCache(final String value) {
|
|
this.value = value;
|
|
}
|
|
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
|
|
index 75941ec..4d6362d 100644
|
|
--- a/src/main/java/org/spigotmc/ActivationRange.java
|
|
+++ b/src/main/java/org/spigotmc/ActivationRange.java
|
|
@@ -4,7 +4,7 @@ import java.util.List;
|
|
import java.util.Set;
|
|
|
|
import net.minecraft.server.*;
|
|
-import org.bukkit.craftbukkit.SpigotTimings;
|
|
+import co.aikar.timings.SpigotTimings;
|
|
|
|
public class ActivationRange
|
|
{
|
|
--
|
|
2.7.2
|
|
|