mirror of
https://github.com/funkemunky/KauriV3.git
synced 2026-06-04 15:22:17 +00:00
Fixed check loading, implemented Fly (C) detection
This commit is contained in:
@@ -6,8 +6,14 @@ import dev.brighten.ac.check.CheckData;
|
||||
import dev.brighten.ac.check.WAction;
|
||||
import dev.brighten.ac.data.APlayer;
|
||||
import dev.brighten.ac.packet.wrapper.in.WPacketPlayInFlying;
|
||||
import dev.brighten.ac.packet.wrapper.out.WPacketPlayOutEntityVelocity;
|
||||
import dev.brighten.ac.utils.Async;
|
||||
import dev.brighten.ac.utils.MathUtils;
|
||||
import dev.brighten.ac.utils.MovementUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@CheckData(name = "Fly (C)", checkId = "flyc", type = CheckType.MOVEMENT)
|
||||
public class FlyC extends Check {
|
||||
@@ -15,9 +21,48 @@ public class FlyC extends Check {
|
||||
super(player);
|
||||
}
|
||||
|
||||
@Async
|
||||
WAction<WPacketPlayInFlying> flyingAction = packet -> {
|
||||
boolean ground = player.getMovement().getTo().isOnGround(),
|
||||
if(player.getMovement().getLastTeleport().isNotPassed((1))
|
||||
|| player.getInfo().isGeneralCancel())
|
||||
return;
|
||||
final boolean ground = player.getMovement().getTo().isOnGround(),
|
||||
fground = player.getMovement().getFrom().isOnGround();
|
||||
final boolean jumped = fground && !ground && player.getMovement().getDeltaY() > 0;
|
||||
|
||||
final List<Double> possibleHeights = new ArrayList<>();
|
||||
|
||||
// Adding only possible jump height with current circumstances
|
||||
possibleHeights.add(MovementUtils.getJumpHeight(player));
|
||||
|
||||
// Adding all possible velocity deltaY.
|
||||
player.getVelocityHandler().getPossibleVectors().forEach(vec -> possibleHeights.add(vec.getY()));
|
||||
|
||||
jumpCheck: {
|
||||
if(!jumped) break jumpCheck;
|
||||
|
||||
// We want to check all possible heights
|
||||
for (Double possibleHeight : possibleHeights) {
|
||||
double delta = MathUtils.getDelta(player.getMovement().getDeltaY(), possibleHeight);
|
||||
|
||||
if(delta < 1E-5) {
|
||||
debug("Found delta: dy=%.5f, p=%.5f", player.getMovement().getDeltaY(), possibleHeight);
|
||||
break jumpCheck;
|
||||
}
|
||||
}
|
||||
|
||||
// If we reach this point, it means no correct predicted deltaY was found
|
||||
flag("dy=%.5f p[%s]", player.getMovement().getDeltaY(), possibleHeights.stream()
|
||||
.map(s -> String.valueOf(MathUtils.round(s, 5))).collect(Collectors.joining(";")));
|
||||
}
|
||||
|
||||
maximumHeightCheck: {
|
||||
if(player.getInfo().nearGround) break maximumHeightCheck;
|
||||
|
||||
double maxHeight = possibleHeights.stream().max(Comparator.comparing(c -> c)).orElse(1.5) + 0.05f;
|
||||
|
||||
if(player.getMovement().getDeltaY() > maxHeight) {
|
||||
flag("%.4f>-%.4f", player.getMovement().getDeltaY(), maxHeight);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@ public class UseEntity extends Check {
|
||||
flag("delta=%s", timestamp - lastFlying);
|
||||
}
|
||||
} else if(buffer > 0) buffer--;
|
||||
|
||||
debug("delta=%s", timestamp - lastFlying);
|
||||
};
|
||||
|
||||
WTimedAction<WPacketPlayInFlying> flying = (packet, timestamp) -> {
|
||||
|
||||
@@ -14,6 +14,7 @@ import dev.brighten.ac.messages.Messages;
|
||||
import dev.brighten.ac.packet.ProtocolVersion;
|
||||
import dev.brighten.ac.packet.handler.HandlerAbstract;
|
||||
import dev.brighten.ac.utils.KLocation;
|
||||
import dev.brighten.ac.utils.RunUtils;
|
||||
import dev.brighten.ac.utils.Tuple;
|
||||
import dev.brighten.ac.utils.objects.evicting.EvictingList;
|
||||
import dev.brighten.ac.utils.reflections.impl.MinecraftReflection;
|
||||
@@ -115,7 +116,9 @@ public class APlayer {
|
||||
Anticheat.INSTANCE.getScheduler().execute(() -> {
|
||||
playerVersion = ProtocolVersion.getVersion(ProtocolAPI.INSTANCE.getPlayerVersion(getBukkitPlayer()));
|
||||
|
||||
checkHandler.initChecks();
|
||||
RunUtils.task(() -> {
|
||||
checkHandler.initChecks();
|
||||
});
|
||||
});
|
||||
|
||||
// Enabling alerts for players on join if they have the permissions to
|
||||
|
||||
@@ -235,8 +235,8 @@ public class BlockInformation {
|
||||
if (blockBox.isCollided(box))
|
||||
collidesVertically = true;
|
||||
|
||||
if(groundBox.copy().expandMin(0, -0.8, 0).expand(0.4, 0, 0.4)
|
||||
.isCollided(blockBox))
|
||||
if(groundBox.copy().expandMin(0, -0.8, 0)
|
||||
.isIntersected(blockBox))
|
||||
player.getInfo().setNearGround(true);
|
||||
|
||||
if(groundBox.isCollided(blockBox)) {
|
||||
|
||||
@@ -62,7 +62,8 @@ public class CheckHandler {
|
||||
for (Tuple<WrappedField, Class<?>> tuple : checkClass.getActions()) {
|
||||
WAction<?> action = tuple.one.get(check);
|
||||
|
||||
if(!action.getClass().isAnnotationPresent(Async.class)) {
|
||||
if(!tuple.one.getField().isAnnotationPresent(Async.class)) {
|
||||
System.out.println("Adding sync event");
|
||||
events.compute(tuple.two, (packetClass, array) -> {
|
||||
if (array == null) {
|
||||
return new ActionStore[] {new ActionStore(action, checkClass.getCheckClass().getParent())};
|
||||
@@ -79,7 +80,8 @@ public class CheckHandler {
|
||||
for (Tuple<WrappedField, Class<?>> tuple : checkClass.getActions()) {
|
||||
WAction<?> action = tuple.one.get(check);
|
||||
|
||||
if(action.getClass().isAnnotationPresent(Async.class)) {
|
||||
if(tuple.one.getField().isAnnotationPresent(Async.class)) {
|
||||
System.out.println("Adding async event");
|
||||
async_events.compute(tuple.two, (packetClass, array) -> {
|
||||
if (array == null) {
|
||||
return new ActionStore[] {new ActionStore(action, checkClass.getCheckClass().getParent())};
|
||||
@@ -96,7 +98,8 @@ public class CheckHandler {
|
||||
for (Tuple<WrappedField, Class<?>> tuple : checkClass.getTimedActions()) {
|
||||
WTimedAction<?> action = tuple.one.get(check);
|
||||
|
||||
if(!action.getClass().isAnnotationPresent(Async.class)) {
|
||||
if(!tuple.one.getField().isAnnotationPresent(Async.class)) {
|
||||
System.out.println("Adding timed sync event");
|
||||
eventsWithTimestamp.compute(tuple.two, (packetClass, array) -> {
|
||||
if (array == null) {
|
||||
return new TimedActionStore[] {new TimedActionStore(action, checkClass.getCheckClass().getParent())};
|
||||
@@ -113,7 +116,8 @@ public class CheckHandler {
|
||||
for (Tuple<WrappedField, Class<?>> tuple : checkClass.getTimedActions()) {
|
||||
WTimedAction<?> action = tuple.one.get(check);
|
||||
|
||||
if(action.getClass().isAnnotationPresent(Async.class)) {
|
||||
if(tuple.one.getField().isAnnotationPresent(Async.class)) {
|
||||
System.out.println("Adding timed async event");
|
||||
async_eventsWithTimestamp.compute(tuple.two, (packetClass, array) -> {
|
||||
if (array == null) {
|
||||
return new TimedActionStore[] {new TimedActionStore(action, checkClass.getCheckClass().getParent())};
|
||||
@@ -127,10 +131,11 @@ public class CheckHandler {
|
||||
}
|
||||
}
|
||||
synchronized (cancellableEvents) {
|
||||
for (Tuple<WrappedField, Class<?>> tuple : checkClass.getTimedActions()) {
|
||||
for (Tuple<WrappedField, Class<?>> tuple : checkClass.getCancellableActions()) {
|
||||
WCancellable<?> action = tuple.one.get(check);
|
||||
|
||||
if(!action.getClass().isAnnotationPresent(Async.class)) {
|
||||
if(!tuple.one.getField().isAnnotationPresent(Async.class)) {
|
||||
System.out.println("Adding cancel sync event");
|
||||
cancellableEvents.compute(tuple.two, (packetClass, array) -> {
|
||||
if (array == null) {
|
||||
return new CancellableActionStore[] {new CancellableActionStore(action, checkClass.getCheckClass().getParent())};
|
||||
@@ -172,9 +177,10 @@ public class CheckHandler {
|
||||
|
||||
//TODO When using WPacket wrappers only, make this strictly WPacket param based only
|
||||
public void callPacket(Object packet, long timestamp) {
|
||||
//System.out.println("Being called");
|
||||
ThreadHandler.INSTANCE.getThread(player).getThread().execute(() -> {
|
||||
if(async_events.containsKey(packet.getClass())) {
|
||||
synchronized (events) {
|
||||
synchronized (async_events) {
|
||||
ActionStore<Object>[] actions = async_events.get(packet.getClass());
|
||||
for (ActionStore<Object> action : actions) {
|
||||
action.getAction().invoke(packet);
|
||||
@@ -182,7 +188,7 @@ public class CheckHandler {
|
||||
}
|
||||
}
|
||||
if(async_eventsWithTimestamp.containsKey(packet.getClass())) {
|
||||
synchronized (events) {
|
||||
synchronized (async_eventsWithTimestamp) {
|
||||
TimedActionStore<Object>[] actions = async_eventsWithTimestamp.get(packet.getClass());
|
||||
for (TimedActionStore<Object> action : actions) {
|
||||
action.getAction().invoke(packet, timestamp);
|
||||
@@ -202,7 +208,7 @@ public class CheckHandler {
|
||||
}
|
||||
}
|
||||
if(eventsWithTimestamp.containsKey(packet.getClass())) {
|
||||
synchronized (events) {
|
||||
synchronized (eventsWithTimestamp) {
|
||||
TimedActionStore<Object>[] actions = eventsWithTimestamp.get(packet.getClass());
|
||||
for (TimedActionStore<Object> action : actions) {
|
||||
action.getAction().invoke(packet, timestamp);
|
||||
|
||||
@@ -306,8 +306,7 @@ public class PacketHandler {
|
||||
}
|
||||
|
||||
boolean cancelled = player.getCheckHandler().callSyncPacket(packetObject, timestamp);
|
||||
ThreadHandler.INSTANCE.getThread(player).getThread()
|
||||
.execute(() -> player.getCheckHandler().callPacket(packetObject, timestamp));
|
||||
player.getCheckHandler().callPacket(packetObject, timestamp);
|
||||
|
||||
// Post flying settings
|
||||
if(type.equals(PacketType.FLYING)) {
|
||||
|
||||
Reference in New Issue
Block a user