From 500d103b49ed2de515f8ef5d79be150e3871f84c Mon Sep 17 00:00:00 2001 From: jojo Date: Fri, 25 Dec 2020 23:28:11 +0100 Subject: [PATCH] Update versioned dependant code to new SpigotCore version dependant calls --- .../bausystem/commands/TPSLimit_12.java | 2 +- .../bausystem/commands/TPSLimit_15.java | 2 +- .../bausystem/commands/CommandTPSLimiter.java | 18 +++++------------- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/BauSystem_12/src/de/steamwar/bausystem/commands/TPSLimit_12.java b/BauSystem_12/src/de/steamwar/bausystem/commands/TPSLimit_12.java index e3b5d5a..b84be05 100644 --- a/BauSystem_12/src/de/steamwar/bausystem/commands/TPSLimit_12.java +++ b/BauSystem_12/src/de/steamwar/bausystem/commands/TPSLimit_12.java @@ -49,7 +49,7 @@ class TPSLimit_12 { sendPacketsToPlayer(packets); } - static void sendPacketsToPlayer(Set> packets) { + private static void sendPacketsToPlayer(Set> packets) { Bukkit.getOnlinePlayers().forEach(player -> { PlayerConnection connection = ((CraftPlayer)player).getHandle().playerConnection; for (Packet p : packets) { diff --git a/BauSystem_15/src/de/steamwar/bausystem/commands/TPSLimit_15.java b/BauSystem_15/src/de/steamwar/bausystem/commands/TPSLimit_15.java index efaca78..00855e8 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/commands/TPSLimit_15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/commands/TPSLimit_15.java @@ -50,7 +50,7 @@ class TPSLimit_15 { sendPacketsToPlayer(packets); } - static void sendPacketsToPlayer(Set> packets) { + private static void sendPacketsToPlayer(Set> packets) { Bukkit.getOnlinePlayers().forEach(player -> { PlayerConnection connection = ((CraftPlayer)player).getHandle().playerConnection; for (Packet p : packets) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java index c09bdf3..f845e81 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTPSLimiter.java @@ -23,6 +23,7 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.world.Welt; import de.steamwar.core.Core; +import de.steamwar.core.VersionedRunnable; import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.Bukkit; @@ -102,10 +103,12 @@ public class CommandTPSLimiter implements CommandExecutor { } else { if (tpsLimiter != null) return; tpsLimiter = Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), () -> { - versionDependantCall(() -> TPSLimit_12.createTickCache(world), () -> TPSLimit_15.createTickCache(world)); + VersionedRunnable.call(new VersionedRunnable(() -> TPSLimit_12.createTickCache(world), 8), + new VersionedRunnable(() -> TPSLimit_15.createTickCache(world), 14)); for (int i = 0; i < (20 / currentTPSLimit); i++) { sleepUntilNextTick(); - versionDependantCall(TPSLimit_12::sendTickPackets, TPSLimit_15::sendTickPackets); + VersionedRunnable.call(new VersionedRunnable(TPSLimit_12::sendTickPackets, 8), + new VersionedRunnable(TPSLimit_15::sendTickPackets, 14)); } }, 0, 1); } @@ -130,17 +133,6 @@ public class CommandTPSLimiter implements CommandExecutor { } } - private void versionDependantCall(Runnable v12, Runnable v15) { - switch (Core.getVersion()) { - case 12: - v12.run(); - break; - default: - v15.run(); - break; - } - } - public static double getCurrentTPSLimit() { return currentTPSLimit; }