Dieser Commit ist enthalten in:
Ursprung
2c2d27893d
Commit
75dcb3dbea
@ -19,13 +19,19 @@
|
||||
|
||||
package de.steamwar.bausystem.features.tpslimit;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.features.xray.XrayWrapper;
|
||||
import de.steamwar.bausystem.utils.NMSWrapper;
|
||||
import de.steamwar.bausystem.utils.ProtocolAPI;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
@UtilityClass
|
||||
public class TPSLimitUtils {
|
||||
|
||||
@ -86,4 +92,20 @@ public class TPSLimitUtils {
|
||||
currentTPSLimit = d;
|
||||
tpsLimiter();
|
||||
}
|
||||
|
||||
private static final Class<?> position = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInFlying$PacketPlayInPosition");
|
||||
private static final Class<?> positionLook = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInFlying$PacketPlayInPositionLook");
|
||||
static {
|
||||
BiFunction<Player, Object, Object> positionSetter = (player, o) -> {
|
||||
if (currentTPSLimit < 20) {
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||
XrayWrapper.impl.setPosition(player, o);
|
||||
}, 1L);
|
||||
return null;
|
||||
}
|
||||
return o;
|
||||
};
|
||||
ProtocolAPI.setIncomingHandler(position, positionSetter);
|
||||
ProtocolAPI.setIncomingHandler(positionLook, positionSetter);
|
||||
}
|
||||
}
|
In neuem Issue referenzieren
Einen Benutzer sperren