Paper/Spigot-Server-Patches/0379-Server-Tick-Events.patch

35 lines
1.6 KiB
Diff
Raw Normal View History

2019-05-06 21:30:27 +02:00
From 43ae5db982747cd6244b117f0fe8014f73d355ee Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Wed, 27 Mar 2019 22:48:45 -0400
Subject: [PATCH] Server Tick Events
Fires event at start and end of a server tick
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
2019-05-06 21:30:27 +02:00
index e612879495..3fc232431a 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
2019-05-06 04:58:04 +02:00
@@ -1051,6 +1051,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
co.aikar.timings.TimingsManager.FULL_SERVER_TICK.startTiming(); // Paper
this.slackActivityAccountant.tickStarted(); // Spigot
2019-05-05 19:19:34 +02:00
long i = SystemUtils.getMonotonicNanos();
+ new com.destroystokyo.paper.event.server.ServerTickStartEvent(this.ticks+1).callEvent(); // Paper
++this.ticks;
2019-05-05 19:19:34 +02:00
this.b(booleansupplier);
2019-05-06 04:58:04 +02:00
@@ -1097,6 +1098,11 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
2019-05-05 19:19:34 +02:00
this.methodProfiler.exit();
org.spigotmc.WatchdogThread.tick(); // Spigot
this.slackActivityAccountant.tickEnded(l); // Spigot
+ // Paper start
+ long endTime = System.nanoTime();
+ long remaining = (TICK_TIME - (endTime - lastTick)) - catchupTime;
+ new com.destroystokyo.paper.event.server.ServerTickEndEvent(this.ticks, ((double)(endTime - lastTick) / 1000000D), remaining).callEvent();
+ // Paper end
co.aikar.timings.TimingsManager.FULL_SERVER_TICK.stopTiming(); // Paper
}
--
2.21.0