From d7134b691690c3e8a34f6c5f9e4cb4d8a7fff8a9 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Tue, 10 Oct 2023 18:10:43 +0200 Subject: [PATCH] Add TPSWarpUtils --- SpigotCore_Main/src/de/steamwar/core/ProtocolWrapper.java | 3 +++ SpigotCore_Main/src/de/steamwar/core/TPSWarpUtils.java | 8 +------- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/SpigotCore_Main/src/de/steamwar/core/ProtocolWrapper.java b/SpigotCore_Main/src/de/steamwar/core/ProtocolWrapper.java index 0de99c3..89cb1ea 100644 --- a/SpigotCore_Main/src/de/steamwar/core/ProtocolWrapper.java +++ b/SpigotCore_Main/src/de/steamwar/core/ProtocolWrapper.java @@ -45,6 +45,9 @@ public interface ProtocolWrapper { Object playerInfoPacketConstructor(PlayerInfoAction action, GameProfile profile, GameMode mode); default void initTPSWarp(LongSupplier longSupplier) { + if (Core.getVersion() > 19) return; + Class systemUtils = Reflection.getClass("{nms}.SystemUtils"); + Reflection.getField(systemUtils, LongSupplier.class, 0).set(systemUtils, longSupplier); } enum PlayerInfoAction { diff --git a/SpigotCore_Main/src/de/steamwar/core/TPSWarpUtils.java b/SpigotCore_Main/src/de/steamwar/core/TPSWarpUtils.java index aca02ca..91d7296 100644 --- a/SpigotCore_Main/src/de/steamwar/core/TPSWarpUtils.java +++ b/SpigotCore_Main/src/de/steamwar/core/TPSWarpUtils.java @@ -35,13 +35,7 @@ public class TPSWarpUtils { private static BukkitTask bukkitTask = null; static { - if (Core.getVersion() <= 18) { - Class clazz = Reflection.getClass("{nms}.SystemUtils"); - Reflection.FieldAccessor fieldAccessor = Reflection.getField(clazz, LongSupplier.class, 0); - fieldAccessor.set(clazz, (LongSupplier) () -> System.nanoTime() + nanoDOffset); - } else { - ProtocolWrapper.impl.initTPSWarp(() -> nanoDOffset); - } + ProtocolWrapper.impl.initTPSWarp(() -> nanoDOffset); } public static void warp(double tps) {