aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches/0079-Timings-v2.patch
blob: 209dd5ae7bce195356c01e7b42479511907fad42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
From d19bcfa1cb87ce084c3ddfe845cc7e3a99b270e4 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Fri, 8 Jan 2016 23:36:39 -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 00000000..b3cafafc
--- /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 00000000..9ebc710f
--- /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/net/minecraft/server/Block.java b/src/main/java/net/minecraft/server/Block.java
index c26975a0..a784e04a 100644
--- a/src/main/java/net/minecraft/server/Block.java
+++ b/src/main/java/net/minecraft/server/Block.java
@@ -65,6 +65,16 @@ public class Block {
     protected boolean y;
     protected boolean z;
     protected boolean isTileEntity;
+    // Spigot 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;
+    }
+    // Spigot end
+
     protected double minX;
     protected double minY;
     protected double minZ;
diff --git a/src/main/java/net/minecraft/server/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java
index 45cea142..088beb22 100644
--- a/src/main/java/net/minecraft/server/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/DedicatedServer.java
@@ -20,7 +20,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; // Spigot
 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 20cc9469..ef59b402 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -16,7 +16,8 @@ import org.bukkit.entity.Hanging;
 import org.bukkit.entity.LivingEntity;
 import org.bukkit.entity.Painting;
 import org.bukkit.entity.Vehicle;
-import org.spigotmc.CustomTimingsHandler; // Spigot
+import co.aikar.timings.SpigotTimings; // Spigot
+import co.aikar.timings.Timing; // Spigot
 import org.bukkit.event.entity.EntityCombustByEntityEvent;
 import org.bukkit.event.hanging.HangingBreakByEntityEvent;
 import org.bukkit.event.painting.PaintingBreakByEntityEvent;
@@ -128,7 +129,7 @@ public abstract class Entity implements ICommandListener {
     public boolean loadChunks = false; // PaperSpigot - Entities can load chunks they move through and keep them loaded
 
     // Spigot start
-    public CustomTimingsHandler tickTimer = org.bukkit.craftbukkit.SpigotTimings.getEntityTimings(this); // Spigot
+    public Timing tickTimer = SpigotTimings.getEntityTimings(this); // Spigot
     public final byte activationType = org.spigotmc.ActivationRange.initializeEntityActivationType(this);
     public final boolean defaultActivationState;
     public long activatedTick = Integer.MIN_VALUE;
@@ -426,7 +427,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.loadChunks) loadChunks(); // PaperSpigot - Load chunks
         if (this.noclip) {
             this.a(this.getBoundingBox().c(d0, d1, d2));
@@ -764,7 +764,6 @@ public abstract class Entity implements ICommandListener {
 
             this.world.methodProfiler.b();
         }
-        org.bukkit.craftbukkit.SpigotTimings.entityMoveTimer.stopTiming(); // Spigot
     }
 
     private void recalcPosition() {
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index 0de13bb0..19a743c2 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -23,7 +23,7 @@ import org.bukkit.event.entity.EntityRegainHealthEvent;
 import org.bukkit.event.vehicle.VehicleExitEvent;
 // CraftBukkit end
 
-import org.bukkit.craftbukkit.SpigotTimings; // Spigot
+import co.aikar.timings.SpigotTimings; // Spigot
 
 public abstract class EntityLiving extends Entity {
 
@@ -1449,7 +1449,6 @@ public abstract class EntityLiving extends Entity {
     }
 
     public void t_() {
-        SpigotTimings.timerEntityBaseTick.startTiming(); // Spigot
         super.t_();
         if (!this.world.isClientSide) {
             int i = this.bv();
@@ -1488,9 +1487,7 @@ public abstract class EntityLiving extends Entity {
             }
         }
 
-        SpigotTimings.timerEntityBaseTick.stopTiming(); // Spigot
         this.m();
-        SpigotTimings.timerEntityTickRest.startTiming(); // Spigot
         double d0 = this.locX - this.lastX;
         double d1 = this.locZ - this.lastZ;
         float f = (float) (d0 * d0 + d1 * d1);
@@ -1555,7 +1552,6 @@ public abstract class EntityLiving extends Entity {
 
         this.world.methodProfiler.b();
         this.aT += f2;
-        SpigotTimings.timerEntityTickRest.stopTiming(); // Spigot
     }
 
     protected float h(float f, float f1) {
@@ -1620,7 +1616,6 @@ public abstract class EntityLiving extends Entity {
         }
 
         this.world.methodProfiler.a("ai");
-        SpigotTimings.timerEntityAI.startTiming(); // Spigot
         if (this.bD()) {
             this.aY = false;
             this.aZ = 0.0F;
@@ -1631,7 +1626,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");
@@ -1653,15 +1647,11 @@ public abstract class EntityLiving extends Entity {
         this.aZ *= 0.98F;
         this.ba *= 0.98F;
         this.bb *= 0.9F;
-        SpigotTimings.timerEntityAIMove.startTiming(); // Spigot
         this.g(this.aZ, this.ba);
-        SpigotTimings.timerEntityAIMove.stopTiming(); // Spigot
         this.world.methodProfiler.b();
         this.world.methodProfiler.a("push");
         if (!this.world.isClientSide) {
-            SpigotTimings.timerEntityAICollision.startTiming(); // Spigot
             this.bL();
-            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 eac71e82..ee099222 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -45,7 +45,7 @@ import jline.console.ConsoleReader;
 import joptsimple.OptionSet;
 
 import org.bukkit.craftbukkit.Main;
-import org.bukkit.craftbukkit.SpigotTimings; // Spigot
+import co.aikar.timings.SpigotTimings; // Spigot
 // CraftBukkit end
 
 public abstract class MinecraftServer implements Runnable, ICommandListener, IAsyncTaskHandler, IMojangStatistics {
@@ -449,6 +449,8 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
         // CraftBukkit end
         if (!this.N) {
             MinecraftServer.LOGGER.info("Stopping server");
+            SpigotTimings.stopServer(); // Spigot
+
             // CraftBukkit start
             if (this.server != null) {
                 this.server.disablePlugins();
@@ -697,7 +699,7 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
     protected void z() {}
 
     protected void A() throws ExceptionWorldConflict { // CraftBukkit - added throws
-        SpigotTimings.serverTickTimer.startTiming(); // Spigot
+        co.aikar.timings.TimingsManager.FULL_SERVER_TICK.startTiming(); // Spigot
         long i = System.nanoTime();
 
         ++this.ticks;
@@ -757,11 +759,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(); // Spigot
     }
 
     public void B() {
+        SpigotTimings.minecraftSchedulerTimer.startTiming(); // Spigot
         this.methodProfiler.a("jobs");
         Queue queue = this.j;
 
@@ -772,13 +774,14 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
             SystemUtils.a(entry, MinecraftServer.LOGGER);
          }
         // Spigot end
+        SpigotTimings.minecraftSchedulerTimer.stopTiming(); // Spigot
 
         this.methodProfiler.c("levels");
 
-        SpigotTimings.schedulerTimer.startTiming(); // Spigot
+        SpigotTimings.bukkitSchedulerTimer.startTiming(); // Spigot
         // CraftBukkit start
         this.server.getScheduler().mainThreadHeartbeat(this.ticks);
-        SpigotTimings.schedulerTimer.stopTiming(); // Spigot
+        SpigotTimings.bukkitSchedulerTimer.stopTiming(); // Spigot
 
         // 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 2ab01a1f..11380423 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -60,6 +60,7 @@ import org.bukkit.event.player.PlayerToggleSprintEvent;
 import org.bukkit.inventory.CraftingInventory;
 import org.bukkit.inventory.InventoryView;
 import org.bukkit.util.NumberConversions;
+import co.aikar.timings.SpigotTimings; // Spigot
 // CraftBukkit end
 
 import org.github.paperspigot.PaperSpigotConfig; // PaperSpigot
@@ -1146,7 +1147,7 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
     // CraftBukkit end
 
    private void handleCommand(String s) {
-        org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.startTiming(); // Spigot
+        SpigotTimings.playerCommandTimer.startTiming(); // Spigot
        // CraftBukkit start - whole method
         if ( org.spigotmc.SpigotConfig.logCommands ) // Spigot
         this.c.info(this.player.getName() + " issued server command: " + s);
@@ -1157,22 +1158,22 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
         this.server.getPluginManager().callEvent(event);
 
         if (event.isCancelled()) {
-            org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
+            SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
             return;
         }
 
         try {
             if (this.server.dispatchCommand(event.getPlayer(), event.getMessage().substring(1))) {
-                org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
+                SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
                 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(); // Spigot
             return;
         }
-        org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
+        SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
         // 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 3fc6450a..fdcbf443 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; // Spigot
+import co.aikar.timings.Timing; // Spigot
 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); // Spigot
     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 b957bd27..a76d83c7 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -7,13 +7,14 @@ import org.bukkit.Bukkit;
 import org.bukkit.block.BlockState;
 import org.bukkit.craftbukkit.CraftServer;
 import org.bukkit.craftbukkit.CraftWorld;
-import org.bukkit.craftbukkit.SpigotTimings;
 import org.bukkit.craftbukkit.event.CraftEventFactory;
 import org.bukkit.craftbukkit.util.CraftMagicNumbers;
+import org.bukkit.craftbukkit.util.LongHashSet;
 import org.bukkit.event.block.BlockCanBuildEvent;
 import org.bukkit.event.block.BlockPhysicsEvent;
 import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
 import org.bukkit.generator.ChunkGenerator;
+import co.aikar.timings.SpigotTimings;
 
 import java.util.*;
 import java.util.concurrent.Callable;
@@ -159,7 +160,7 @@ public abstract class World implements IBlockAccess {
 
     public final org.github.paperspigot.PaperSpigotWorldConfig paperSpigotConfig; // PaperSpigot
 
-    public final SpigotTimings.WorldTimingsHandler timings; // Spigot
+    public final co.aikar.timings.WorldTimingsHandler timings; // Spigot
 
     public CraftWorld getWorld() {
         return this.world;
@@ -227,7 +228,7 @@ public abstract class World implements IBlockAccess {
         this.getServer().addWorld(this.world); 
         // CraftBukkit end
         this.keepSpawnInMemory = this.paperSpigotConfig.keepSpawnInMemory; // PaperSpigot
-        timings = new SpigotTimings.WorldTimingsHandler(this); // Spigot - code below can generate new world and access timings 
+        timings = new co.aikar.timings.WorldTimingsHandler(this); // Spigot - 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);
     }
@@ -1393,6 +1394,7 @@ public abstract class World implements IBlockAccess {
         }
 
         this.methodProfiler.c("remove");
+        timings.entityRemoval.startTiming(); // Spigot
         this.entityList.removeAll(this.g);
 
         int j;
@@ -1412,12 +1414,14 @@ public abstract class World implements IBlockAccess {
         }
 
         this.g.clear();
+        timings.entityRemoval.stopTiming(); // Spigot
         this.methodProfiler.c("regular");
 
         org.spigotmc.ActivationRange.activateEntities(this); // Spigot
         timings.entityTick.startTiming(); // Spigot
         guardEntityList = true; // Spigot
         // CraftBukkit start - Use field for loop variable
+        co.aikar.timings.TimingHistory.entityTicks += this.entityList.size(); // Spigot
         int entitiesThisCycle = 0;
         // PaperSpigot start - Disable tick limiters
         //if (tickPosition < 0) tickPosition = 0;
@@ -1438,12 +1442,12 @@ public abstract class World implements IBlockAccess {
             this.methodProfiler.a("tick");
             if (!entity.dead) {
                 try {
-                    SpigotTimings.tickEntityTimer.startTiming(); // Spigot
+                    entity.tickTimer.startTiming(); // Spigot
                     this.g(entity);
-                    SpigotTimings.tickEntityTimer.stopTiming(); // Spigot
+                    entity.tickTimer.stopTiming(); // Spigot
                 } catch (Throwable throwable1) {
                     // PaperSpigot 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;
@@ -1567,6 +1571,8 @@ public abstract class World implements IBlockAccess {
         }
 
         timings.tileEntityPending.stopTiming(); // Spigot
+        co.aikar.timings.TimingHistory.tileEntityTicks += this.tileEntityList.size(); // Spigot
+
         this.methodProfiler.b();
         this.methodProfiler.b();
     }
@@ -1621,7 +1627,6 @@ public abstract class World implements IBlockAccess {
             }
             // PaperSpigot end
         } else {
-            entity.tickTimer.startTiming(); // Spigot
             // CraftBukkit end
             entity.P = entity.locX;
             entity.Q = entity.locY;
@@ -1630,6 +1635,7 @@ public abstract class World implements IBlockAccess {
             entity.lastPitch = entity.pitch;
             if (flag && entity.ad) {
                 ++entity.ticksLived;
+                ++co.aikar.timings.TimingHistory.activatedEntityTicks; // Spigot
                 if (entity.vehicle != null) {
                     entity.ak();
                 } else {
@@ -1686,7 +1692,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 fb16a8ad..3a2ca89c 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -245,13 +245,13 @@ public class WorldServer extends World implements IAsyncTaskHandler {
 
         timings.doChunkUnload.stopTiming(); // Spigot
         this.methodProfiler.c("tickPending");
-        timings.doTickPending.startTiming(); // Spigot
+        timings.scheduledBlocks.startTiming(); // Spigot
         this.a(false);
-        timings.doTickPending.stopTiming(); // Spigot
+        timings.scheduledBlocks.stopTiming(); // Spigot
         this.methodProfiler.c("tickBlocks");
-        timings.doTickTiles.startTiming(); // Spigot
+        timings.chunkTicks.startTiming(); // Spigot
         this.h();
-        timings.doTickTiles.stopTiming(); // Spigot
+        timings.chunkTicks.stopTiming(); // Spigot
         spigotConfig.antiXrayInstance.flushUpdates(this); // PaperSpigot
         this.methodProfiler.c("chunkMap");
         timings.doChunkMap.startTiming(); // Spigot
@@ -471,6 +471,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
                 }
 
                 this.methodProfiler.c("tickBlocks");
+                timings.chunkTicksBlocks.startTiming(); // Spigot
                 i1 = this.getGameRules().c("randomTickSpeed");
                 if (i1 > 0) {
                     ChunkSection[] achunksection = chunk.getSections();
@@ -499,6 +500,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
                         }
                     }
                 }
+                timings.chunkTicksBlocks.stopTiming(); // Spigot
             }
 
         }
@@ -630,6 +632,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
 
                 this.methodProfiler.a("cleaning");
 
+                timings.scheduledBlocksCleanup.startTiming(); // Spigot
                 NextTickListEntry nextticklistentry;
 
                 for (int j = 0; j < i; ++j) {
@@ -642,6 +645,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
                     this.M.remove(nextticklistentry);
                     this.V.add(nextticklistentry);
                 }
+                timings.scheduledBlocksCleanup.stopTiming(); // Spigot
 
                 // PaperSpigot start - Allow redstone ticks to bypass the tickNextTickListCap
                 if (paperSpigotConfig.tickNextTickListCapIgnoresRedstone) {
@@ -662,6 +666,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
 
                 this.methodProfiler.b();
                 this.methodProfiler.a("ticking");
+                timings.scheduledBlocksTicking.startTiming(); // Spigot
                 Iterator iterator = this.V.iterator();
 
                 while (iterator.hasNext()) {
@@ -671,6 +676,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(); // Spigot
+                        timing.startTiming(); // Spigot
 
                         if (iblockdata.getBlock().getMaterial() != Material.AIR && Block.a(iblockdata.getBlock(), nextticklistentry.a())) {
                             try {
@@ -683,10 +690,12 @@ public class WorldServer extends World implements IAsyncTaskHandler {
                                 throw new ReportedException(crashreport);
                             }
                         }
+                        timing.stopTiming(); // Spigot
                     } else {
                         this.a(nextticklistentry.a, nextticklistentry.a(), 0);
                     }
                 }
+                timings.scheduledBlocksTicking.stopTiming(); // Spigot
 
                 this.methodProfiler.b();
                 this.V.clear();
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 7da8d67d..97f9f96e 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -329,6 +329,7 @@ public final class CraftServer implements Server {
             DefaultPermissions.registerCorePermissions();
             CraftDefaultPermissions.registerCorePermissions();
             helpMap.initializeCommands();
+            co.aikar.timings.Timings.reset(); // Spigot
         }
     }
 
@@ -1715,12 +1716,31 @@ public final class CraftServer implements Server {
         }
         // PaperSpigot end
 
+        @Deprecated
         @Override
         public YamlConfiguration getConfig()
+        {
+            return getBukkitConfig();
+        }
+
+        @Override
+        public YamlConfiguration getBukkitConfig()
+        {
+            return configuration;
+        }
+
+        @Override
+        public YamlConfiguration getSpigotConfig()
         {
             return org.spigotmc.SpigotConfig.config;
         }
 
+        @Override
+        public YamlConfiguration getPaperSpigotConfig()
+        {
+            return org.github.paperspigot.PaperSpigotConfig.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 41d2d87e..00000000
--- 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 1135f83c..e8c6d5ee 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -1496,6 +1496,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
             ((WorldServer) getHandle().world).getPlayerChunkMap().updateViewDistance(getHandle(), viewDistance);
         }
         // PaperSpigot end
+
+        @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 93d8d424..d76ec40a 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();}}; // Spigot
         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);}}; // Spigot
         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();}}; // Spigot
         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 220e39ab..4b1e3523 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; // Spigot
+import co.aikar.timings.Timing; // Spigot
 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; //Spigot
+    public Timing timings; // Spigot
     private final Plugin plugin;
     private final int id;
 
-    final CustomTimingsHandler timings; // Spigot
     CraftTask() {
         this(null, null, -1, -1);
     }
@@ -34,25 +34,12 @@ public class CraftTask implements BukkitTask, Runnable { // Spigot
     }
 
     // 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) {
         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; // Spigot
     }
 
     public final int getTaskId() {
@@ -68,7 +55,9 @@ public class CraftTask implements BukkitTask, Runnable { // Spigot
     }
 
     public void run() {
+        if (timings != null && isSync()) timings.startTiming(); // Spigot
         task.run();
+        if (timings != null && isSync()) timings.stopTiming(); // Spigot
     }
 
     long getPeriod() {
@@ -113,12 +102,4 @@ public class CraftTask implements BukkitTask, Runnable { // Spigot
         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 e52ef47b..bd0b8873 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; } // Spigot
     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 5b0c64d2..d3767d2a 100644
--- a/src/main/java/org/spigotmc/ActivationRange.java
+++ b/src/main/java/org/spigotmc/ActivationRange.java
@@ -31,8 +31,8 @@ import net.minecraft.server.EntityWither;
 import net.minecraft.server.MathHelper;
 import net.minecraft.server.MinecraftServer;
 import net.minecraft.server.World;
-import org.bukkit.craftbukkit.SpigotTimings;
-import org.bukkit.entity.Creeper;
+import co.aikar.timings.SpigotTimings;
+
 
 public class ActivationRange
 {
diff --git a/src/main/java/org/spigotmc/AntiXray.java b/src/main/java/org/spigotmc/AntiXray.java
index 5466a61c..c2ad90c8 100644
--- a/src/main/java/org/spigotmc/AntiXray.java
+++ b/src/main/java/org/spigotmc/AntiXray.java
@@ -7,6 +7,7 @@ import net.minecraft.server.BlockPosition;
 import net.minecraft.server.Blocks;
 import net.minecraft.server.World;
 import org.bukkit.craftbukkit.util.CraftMagicNumbers;
+import co.aikar.timings.SpigotTimings;
 
 // PaperSpigot start
 import java.util.HashSet;
@@ -16,9 +17,6 @@ import java.util.Set;
 public class AntiXray
 {
 
-    private static final CustomTimingsHandler update = new CustomTimingsHandler( "xray - update" );
-    private static final CustomTimingsHandler obfuscate = new CustomTimingsHandler( "xray - obfuscate" );
-    /*========================================================================*/
     // Used to keep track of which blocks to obfuscate
     private final boolean[] obfuscateBlocks = new boolean[ Short.MAX_VALUE ];
     // Used to select a random replacement ore
@@ -86,9 +84,9 @@ public class AntiXray
                 return;
             }
             // PaperSpigot end
-            update.startTiming();
+            SpigotTimings.antiXrayUpdateTimer.startTiming();
             updateNearbyBlocks( world, position, 2, false ); // 2 is the radius, we shouldn't change it as that would make it exponentially slower
-            update.stopTiming();
+            SpigotTimings.antiXrayUpdateTimer.stopTiming();
         }
     }
 
@@ -100,9 +98,9 @@ public class AntiXray
     {
         if ( world.spigotConfig.antiXray )
         {
-            obfuscate.startTiming();
+            SpigotTimings.antiXrayObfuscateTimer.startTiming();
             obfuscate( chunkX, chunkY, bitmask, buffer, world );
-            obfuscate.stopTiming();
+            SpigotTimings.antiXrayObfuscateTimer.stopTiming();
         }
     }
 
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
index f6a67d68..b9d185d9 100644
--- a/src/main/java/org/spigotmc/SpigotConfig.java
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
@@ -12,8 +12,10 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.TimeUnit;
 import java.util.logging.Level;
 import gnu.trove.map.hash.TObjectIntHashMap;
+import com.google.common.collect.Lists;
 import net.minecraft.server.AttributeRanged;
 import net.minecraft.server.GenericAttributes;
 import net.minecraft.server.MinecraftServer;
@@ -26,6 +28,8 @@ import org.bukkit.command.Command;
 import org.bukkit.configuration.ConfigurationSection;
 import org.bukkit.configuration.InvalidConfigurationException;
 import org.bukkit.configuration.file.YamlConfiguration;
+import co.aikar.timings.Timings;
+import co.aikar.timings.TimingsManager;
 
 public class SpigotConfig
 {
@@ -232,6 +236,39 @@ public class SpigotConfig
         bungee = getBoolean( "settings.bungeecord", false );
     }
 
+    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;
+    }
+
     private static void nettyThreads()
     {
         int count = getInt( "settings.netty-threads", 4 );
-- 
2.34.0