SteamWar/BauSystem
Archiviert
13
0

Update versioned dependant code to new SpigotCore version dependant calls

Dieser Commit ist enthalten in:
jojo 2020-12-25 23:28:11 +01:00
Ursprung 65456ea19c
Commit 500d103b49
3 geänderte Dateien mit 7 neuen und 15 gelöschten Zeilen

Datei anzeigen

@ -49,7 +49,7 @@ class TPSLimit_12 {
sendPacketsToPlayer(packets);
}
static void sendPacketsToPlayer(Set<? extends Packet<?>> packets) {
private static void sendPacketsToPlayer(Set<? extends Packet<?>> packets) {
Bukkit.getOnlinePlayers().forEach(player -> {
PlayerConnection connection = ((CraftPlayer)player).getHandle().playerConnection;
for (Packet<?> p : packets) {

Datei anzeigen

@ -50,7 +50,7 @@ class TPSLimit_15 {
sendPacketsToPlayer(packets);
}
static void sendPacketsToPlayer(Set<? extends Packet<?>> packets) {
private static void sendPacketsToPlayer(Set<? extends Packet<?>> packets) {
Bukkit.getOnlinePlayers().forEach(player -> {
PlayerConnection connection = ((CraftPlayer)player).getHandle().playerConnection;
for (Packet<?> p : packets) {

Datei anzeigen

@ -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;
}