mirror of
https://github.com/funkemunky/KauriV3.git
synced 2026-06-25 16:00:39 +00:00
Merge branch 'bugfix/transaction'
This commit is contained in:
@@ -276,3 +276,7 @@ $RECYCLE.BIN/
|
||||
# End of https://www.toptal.com/developers/gitignore/api/java,maven,intellij+all,eclipse,linux,macos,windows
|
||||
*.iml
|
||||
API/API.iml
|
||||
|
||||
# custom
|
||||
.mcsources/
|
||||
.gradle/
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package dev.brighten.ac.check;
|
||||
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import dev.brighten.ac.data.APlayer;
|
||||
import dev.brighten.ac.utils.Tuple;
|
||||
import dev.brighten.ac.utils.annotation.Bind;
|
||||
@@ -9,7 +8,6 @@ import dev.brighten.ac.utils.reflections.types.WrappedConstructor;
|
||||
import dev.brighten.ac.utils.reflections.types.WrappedField;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
@@ -52,13 +50,6 @@ public class CheckStatic {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!PacketWrapper.class.isAssignableFrom((Class<?>) type)
|
||||
&& !Event.class.isAssignableFrom((Class<?>) type)) {
|
||||
Bukkit.getLogger().warning("Type " + ((Class<?>) type).getSimpleName() + " is not a valid type for field "
|
||||
+ field.getField().getName() + " in class " + checkClass.getClass().getSimpleName());
|
||||
continue;
|
||||
}
|
||||
|
||||
if(field.getType().equals(WAction.class)) {
|
||||
actions.add(new Tuple<>(field, (Class<?>)type));
|
||||
} else if(field.getType().equals(WTimedAction.class)) { //This will always be TimedAction
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package dev.brighten.ac.check.impl.misc;
|
||||
|
||||
import dev.brighten.ac.api.check.CheckType;
|
||||
import dev.brighten.ac.check.Check;
|
||||
import dev.brighten.ac.check.CheckData;
|
||||
import dev.brighten.ac.check.WAction;
|
||||
import dev.brighten.ac.data.APlayer;
|
||||
import dev.brighten.ac.packet.TransactionClientWrapper;
|
||||
import dev.brighten.ac.packet.TransactionServerWrapper;
|
||||
import dev.brighten.ac.utils.annotation.Bind;
|
||||
|
||||
@CheckData(name = "TransactionDebug", checkId = "transactiondebug", type = CheckType.EXPLOIT)
|
||||
public class TransactionDebug extends Check {
|
||||
|
||||
public TransactionDebug(APlayer player) {
|
||||
super(player);
|
||||
}
|
||||
|
||||
@Bind
|
||||
WAction<TransactionClientWrapper> clientTrans = packet -> {
|
||||
debug("[%s, %s] Client", packet.getId(), packet.getAction());
|
||||
};
|
||||
|
||||
@Bind
|
||||
WAction<TransactionServerWrapper> serverTrans = packet -> {
|
||||
debug("[%s, %s] Server", packet.getId(), packet.getAction());
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package dev.brighten.ac.check.impl.misc;
|
||||
|
||||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientKeepAlive;
|
||||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying;
|
||||
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerKeepAlive;
|
||||
import dev.brighten.ac.Anticheat;
|
||||
import dev.brighten.ac.api.check.CheckType;
|
||||
import dev.brighten.ac.check.Check;
|
||||
import dev.brighten.ac.check.CheckData;
|
||||
import dev.brighten.ac.check.WAction;
|
||||
import dev.brighten.ac.data.APlayer;
|
||||
import dev.brighten.ac.packet.TransactionClientWrapper;
|
||||
import dev.brighten.ac.utils.annotation.Bind;
|
||||
import dev.brighten.ac.utils.timer.Timer;
|
||||
import dev.brighten.ac.utils.timer.impl.TickTimer;
|
||||
|
||||
@CheckData(name = "TransactionSpoof", checkId = "transactionspoof", type = CheckType.EXPLOIT)
|
||||
public class TransactionSpoof extends Check {
|
||||
|
||||
public TransactionSpoof(APlayer player) {
|
||||
super(player);
|
||||
}
|
||||
|
||||
private int positionsSinceLastTrans = 0, keepAlivesSinceLastTrans = 0;
|
||||
private Timer lastPosition = new TickTimer();
|
||||
|
||||
@Bind
|
||||
WAction<TransactionClientWrapper> clientTransaction = packet -> {
|
||||
positionsSinceLastTrans = 0;
|
||||
keepAlivesSinceLastTrans = 0;
|
||||
};
|
||||
|
||||
@Bind
|
||||
WAction<WrapperPlayClientKeepAlive> clientKeepalive = packet -> {
|
||||
if(keepAlivesSinceLastTrans > 5 && positionsSinceLastTrans > 5) {
|
||||
vl++;
|
||||
flag("Too many keep alives since last transaction %s", keepAlivesSinceLastTrans);
|
||||
}
|
||||
keepAlivesSinceLastTrans++;
|
||||
|
||||
debug("keepAlive=%s packetId=%s", keepAlivesSinceLastTrans, packet.getId());
|
||||
};
|
||||
|
||||
@Bind
|
||||
WAction<WrapperPlayServerKeepAlive> serverKeepalive = packet -> {
|
||||
debug("[Server] keepAlive=%s packetId=%s", keepAlivesSinceLastTrans, packet.getId());
|
||||
};
|
||||
|
||||
@Bind
|
||||
WAction<WrapperPlayClientPlayerFlying> flying = packet -> {
|
||||
positionsSinceLastTrans++;
|
||||
|
||||
if(positionsSinceLastTrans > 10) {
|
||||
player.sendPacket(new WrapperPlayServerKeepAlive(player.getPlayerTick()));
|
||||
}
|
||||
|
||||
if(positionsSinceLastTrans > 40) {
|
||||
vl++;
|
||||
flag("Too many positions since last transaction %s", positionsSinceLastTrans);
|
||||
if(vl > 10) {
|
||||
Anticheat.INSTANCE.getRunUtils().task(() -> player.getBukkitPlayer().kickPlayer("Connection Timed Out"));
|
||||
}
|
||||
}
|
||||
|
||||
lastPosition.reset();
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package dev.brighten.ac.check.impl.movement.noslow;
|
||||
|
||||
import dev.brighten.ac.api.check.CheckType;
|
||||
import dev.brighten.ac.check.Check;
|
||||
import dev.brighten.ac.check.CheckData;
|
||||
import dev.brighten.ac.data.APlayer;
|
||||
|
||||
@CheckData(name = "NoSlow (Hand)", checkId = "noslowhand", type = CheckType.MOVEMENT, punishVl = 5, punishable = false, experimental = true)
|
||||
public class NoSlowdown extends Check {
|
||||
public NoSlowdown(APlayer player) {
|
||||
super(player);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package dev.brighten.ac.check.impl.movement.speed;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
|
||||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying;
|
||||
import dev.brighten.ac.api.check.CheckType;
|
||||
import dev.brighten.ac.check.Check;
|
||||
|
||||
@@ -85,7 +85,6 @@ public class MovementHandler {
|
||||
private final Timer lastCinematic = new TickTimer(2);
|
||||
private final Timer lastReset = new TickTimer(2);
|
||||
private final EvictingList<Integer> sensitivitySamples = new EvictingList<>(50);
|
||||
private final boolean modernMovement;
|
||||
|
||||
public MovementHandler(APlayer player) {
|
||||
this.player = player;
|
||||
@@ -96,8 +95,6 @@ public class MovementHandler {
|
||||
|
||||
// Setting from as same location as to
|
||||
from.setLoc(to);
|
||||
|
||||
modernMovement = PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_21_5);
|
||||
}
|
||||
|
||||
private final boolean[] IS_OR_NOT = new boolean[]{true, false};
|
||||
@@ -177,7 +174,7 @@ public class MovementHandler {
|
||||
.strafing(strafe)
|
||||
.sprinting(sprinting)
|
||||
.usingItem(usingItem)
|
||||
.modernMovement(modernMovement)
|
||||
.modernMovement(player.getPlayerVersion().isNewerThanOrEquals(ClientVersion.V_1_21_5))
|
||||
.hitSlowdown(hitSlow)
|
||||
.aiMoveSpeed(player.getBukkitPlayer().getWalkSpeed() / 2)
|
||||
.fastMathType(fastMath)
|
||||
|
||||
@@ -24,6 +24,7 @@ import dev.brighten.ac.handler.entity.FakeMob;
|
||||
import dev.brighten.ac.handler.entity.TrackedEntity;
|
||||
import dev.brighten.ac.packet.PlayerCapabilities;
|
||||
import dev.brighten.ac.packet.TransactionClientWrapper;
|
||||
import dev.brighten.ac.packet.TransactionServerWrapper;
|
||||
import dev.brighten.ac.packet.WPacketPlayOutEntity;
|
||||
import dev.brighten.ac.utils.BlockUtils;
|
||||
import dev.brighten.ac.utils.KLocation;
|
||||
@@ -118,8 +119,6 @@ public class PacketHandler {
|
||||
player.getInfo().setSprinting(packet.isSprint());
|
||||
player.getInfo().setSneaking(packet.isShift());
|
||||
player.getInfo().setPlayerInput(PlayerInput.getFromPacket(packet));
|
||||
|
||||
player.getBukkitPlayer().sendMessage("packet: " + packet.isForward());
|
||||
} else if (event.getPacketType().equals(PacketType.Play.Client.PLAYER_POSITION_AND_ROTATION) || event.getPacketType().equals(PacketType.Play.Client.PLAYER_POSITION) || event.getPacketType().equals(PacketType.Play.Client.PLAYER_ROTATION) || event.getPacketType().equals(PacketType.Play.Client.PLAYER_FLYING)) {
|
||||
WrapperPlayClientPlayerFlying packet = new WrapperPlayClientPlayerFlying(event);
|
||||
wrapped = packet;
|
||||
@@ -289,6 +288,8 @@ public class PacketHandler {
|
||||
|
||||
player.getBukkitPlayer().sendMessage(String.format("total: %sms client-server: %sms server-client: %sms", totalFeedback, clientToServer, serverPing));
|
||||
}
|
||||
} else if(event.getPacketType().equals(PacketType.Play.Client.KEEP_ALIVE)) {
|
||||
wrapped = new WrapperPlayClientKeepAlive(event);
|
||||
} else {
|
||||
wrapped = new PacketWrapper<>(event);
|
||||
}
|
||||
@@ -589,6 +590,11 @@ public class PacketHandler {
|
||||
}
|
||||
}
|
||||
|
||||
} else if(event.getPacketType() == PacketType.Play.Server.PING || event.getPacketType() == PacketType.Play.Server.WINDOW_CONFIRMATION) {
|
||||
wrapped = new TransactionServerWrapper(event);
|
||||
|
||||
} else if(event.getPacketType() == PacketType.Play.Server.KEEP_ALIVE) {
|
||||
wrapped = new WrapperPlayServerKeepAlive(event);
|
||||
} else {
|
||||
wrapped = new PacketWrapper<>(event);
|
||||
}
|
||||
|
||||
@@ -31,5 +31,11 @@ public class TransactionClientWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TransactionClientWrapper{" +
|
||||
"action=" + action +
|
||||
", id=" + id +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,9 @@ import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerPing;
|
||||
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerWindowConfirmation;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public class TransactionServerWrapper {
|
||||
private final short action;
|
||||
private final int id;
|
||||
@@ -38,4 +40,13 @@ public class TransactionServerWrapper {
|
||||
return new WrapperPlayServerPing(action);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TransactionServerWrapper{" +
|
||||
"action=" + action +
|
||||
", id=" + id +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user