mirror of
https://github.com/funkemunky/KauriV3.git
synced 2026-07-01 02:08:27 +00:00
Merge branch 'main' of https://github.com/funkemunky/EnterpriseAnticheat
This commit is contained in:
@@ -33,7 +33,7 @@ public class BlockInformation {
|
||||
rosebush = XMaterial.ROSE_BUSH.parseMaterial(),
|
||||
scaffolding = XMaterial.SCAFFOLDING.parseMaterial(),
|
||||
honey = XMaterial.HONEY_BLOCK.parseMaterial();
|
||||
public final Map<Material, Integer> collisionMaterialCount = new HashMap<>();
|
||||
public final Map<Material, Integer> collisionMaterialCount = new EnumMap<>(Material.class);
|
||||
|
||||
public BlockInformation(APlayer objectData) {
|
||||
this.player = objectData;
|
||||
@@ -130,6 +130,19 @@ public class BlockInformation {
|
||||
int xstart = Math.min(startX, endX), xend = Math.max(startX, endX);
|
||||
int zstart = Math.min(startZ, endZ), zend = Math.max(startZ, endZ);
|
||||
|
||||
SimpleCollisionBox boundsForCollision = player.getMovement().getFrom().getBox() != null ? player.getMovement().getFrom().getBox().copy().shrink(0.001D, 0.001D, 0.001D) : null;
|
||||
|
||||
IntVector min;
|
||||
IntVector max;
|
||||
|
||||
if(boundsForCollision != null) {
|
||||
min = new IntVector((int) boundsForCollision.xMin, (int) boundsForCollision.yMin, (int) boundsForCollision.zMin);
|
||||
max = new IntVector((int) boundsForCollision.xMax, (int) boundsForCollision.yMax, (int) boundsForCollision.zMax);
|
||||
} else {
|
||||
min = new IntVector(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE);
|
||||
max = new IntVector(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE);
|
||||
}
|
||||
|
||||
loop: {
|
||||
for (int x = xstart; x <= xend; ++x) {
|
||||
for (int z = zstart; z <= zend; ++z) {
|
||||
@@ -137,6 +150,8 @@ public class BlockInformation {
|
||||
if (it-- <= 0) {
|
||||
break loop;
|
||||
}
|
||||
|
||||
|
||||
final Deque<Material> types =
|
||||
player.getBlockUpdateHandler().getPossibleMaterials(new IntVector(x, y, z));
|
||||
|
||||
@@ -148,6 +163,15 @@ public class BlockInformation {
|
||||
CollisionBox blockBox = BlockData.getData(type)
|
||||
.getBox(world, new IntVector(x, y, z), player.getPlayerVersion());
|
||||
|
||||
// Checking of within boundsForCollision
|
||||
if(x >= min.getX() && x <= max.getX() && y >= min.getY() && y <= max.getY() && z >= min.getZ() && z <= max.getZ()) {
|
||||
collisionMaterialCount.compute(type, (key, count) -> {
|
||||
if(count == null) return 1;
|
||||
|
||||
return count + 1;
|
||||
});
|
||||
}
|
||||
|
||||
if(blockBox.isCollided(normalBox)) {
|
||||
if(type.equals(cobweb))
|
||||
inWeb = true;
|
||||
@@ -171,6 +195,10 @@ public class BlockInformation {
|
||||
}
|
||||
}
|
||||
|
||||
if(Materials.checkFlag(type, Materials.FENCE) && player.getMovement().getDeltaY() == 0.5) {
|
||||
System.out.println(blockBox);
|
||||
}
|
||||
|
||||
if(normalBox.copy().expand(0.1, 0, 0.1)
|
||||
.expandMax(0, -0.4, 0).expandMin(0, -0.55, 0)
|
||||
.isCollided(blockBox)) {
|
||||
|
||||
@@ -37,7 +37,7 @@ public abstract class HandlerAbstract{
|
||||
public abstract void sendPacket(APlayer player, Object packet);
|
||||
|
||||
public void shutdown() {
|
||||
Bukkit.getOnlinePlayers().forEach(handler::remove);
|
||||
handler.shutdown();
|
||||
handler = null;
|
||||
}
|
||||
public abstract int getProtocolVersion(Player player);
|
||||
|
||||
@@ -7,6 +7,7 @@ import dev.brighten.ac.data.APlayer;
|
||||
import dev.brighten.ac.packet.wrapper.PacketType;
|
||||
import dev.brighten.ac.packet.wrapper.WPacket;
|
||||
import dev.brighten.ac.packet.wrapper.login.WPacketHandshakingInSetProtocol;
|
||||
import dev.brighten.ac.utils.RunUtils;
|
||||
import dev.brighten.ac.utils.reflections.impl.CraftReflection;
|
||||
import dev.brighten.ac.utils.reflections.impl.MinecraftReflection;
|
||||
import dev.brighten.ac.utils.reflections.types.WrappedClass;
|
||||
@@ -37,7 +38,7 @@ public class ModernHandler extends HandlerAbstract {
|
||||
protected void initChannel(Channel channel) throws Exception {
|
||||
try {
|
||||
// Stop injecting channels
|
||||
if (!Anticheat.INSTANCE.isEnabled()) {
|
||||
if (Anticheat.INSTANCE.isEnabled()) {
|
||||
channel.eventLoop().submit(() -> injectChannel(channel));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@@ -68,47 +69,47 @@ public class ModernHandler extends HandlerAbstract {
|
||||
|
||||
};
|
||||
|
||||
Object mcServer = CraftReflection.getMinecraftServer();
|
||||
Object serverConnection = MinecraftReflection.getServerConnection(mcServer);
|
||||
boolean looking = true;
|
||||
RunUtils.task(() -> {
|
||||
Object mcServer = CraftReflection.getMinecraftServer();
|
||||
Object serverConnection = MinecraftReflection.getServerConnection(mcServer);
|
||||
boolean looking = true;
|
||||
|
||||
// We need to synchronize against this list
|
||||
for (Method m : mcServer.getClass().getMethods()) {
|
||||
if (m.getParameterTypes().length == 0 && m.getReturnType()
|
||||
.isAssignableFrom(MinecraftReflection.serverConnection.getParent())) {
|
||||
try {
|
||||
Object result = m.invoke(mcServer);
|
||||
if (result != null) serverConnection = result;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
// We need to synchronize against this list
|
||||
for (Method m : mcServer.getClass().getMethods()) {
|
||||
if (m.getParameterTypes().length == 0 && m.getReturnType()
|
||||
.isAssignableFrom(MinecraftReflection.serverConnection.getParent())) {
|
||||
try {
|
||||
Object result = m.invoke(mcServer);
|
||||
if (result != null) serverConnection = result;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; looking; i++) {
|
||||
List<Object> list = new WrappedClass(serverConnection.getClass()).getFieldByType(List.class, i)
|
||||
.get(serverConnection);
|
||||
for (int i = 0; looking; i++) {
|
||||
List<Object> list = new WrappedClass(serverConnection.getClass()).getFieldByType(List.class, i)
|
||||
.get(serverConnection);
|
||||
|
||||
for (Object item : list) {
|
||||
//if (!ChannelFuture.class.isInstance(item))
|
||||
// break;
|
||||
for (Object item : list) {
|
||||
//if (!ChannelFuture.class.isInstance(item))
|
||||
// break;
|
||||
|
||||
// Channel future that contains the server connection
|
||||
Channel serverChannel = ((ChannelFuture) item).channel();
|
||||
// Channel future that contains the server connection
|
||||
Channel serverChannel = ((ChannelFuture) item).channel();
|
||||
|
||||
serverChannels.add(serverChannel);
|
||||
serverChannel.pipeline().addFirst(serverChannelHandler);
|
||||
Bukkit.getLogger().info("Server channel handler injected (" + serverChannel + ")");
|
||||
looking = false;
|
||||
serverChannels.add(serverChannel);
|
||||
serverChannel.pipeline().addFirst(serverChannelHandler);
|
||||
Bukkit.getLogger().info("Server channel handler injected (" + serverChannel + ")");
|
||||
looking = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(Player player) {
|
||||
try {
|
||||
System.out.println("Adding " + player.getName() + " to packets");
|
||||
Channel channel = getChannel(player);
|
||||
|
||||
injectChannel(channel).player = player;
|
||||
@@ -157,9 +158,18 @@ public class ModernHandler extends HandlerAbstract {
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
serverChannels.forEach(this::uninjectChannel);
|
||||
Bukkit.getOnlinePlayers().forEach(this::remove);
|
||||
for (Channel serverChannel : serverChannels) {
|
||||
serverChannel.eventLoop().execute(() -> {
|
||||
final ChannelPipeline pipeline = serverChannel.pipeline();
|
||||
try {
|
||||
pipeline.remove(serverChannelHandler);
|
||||
} catch (NoSuchElementException e) {
|
||||
// That's fine
|
||||
}
|
||||
});
|
||||
}
|
||||
serverChannels.clear();
|
||||
super.shutdown();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -182,7 +192,7 @@ public class ModernHandler extends HandlerAbstract {
|
||||
private Player player;
|
||||
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) {
|
||||
String name = msg.getClass().getName();
|
||||
int index = name.lastIndexOf(".");
|
||||
String packetName = name.substring(index + 1);
|
||||
@@ -212,9 +222,19 @@ public class ModernHandler extends HandlerAbstract {
|
||||
}
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
super.channelRead(ctx, msg);
|
||||
try {
|
||||
super.channelRead(ctx, msg);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} else super.channelRead(ctx, msg);
|
||||
} else {
|
||||
try {
|
||||
super.channelRead(ctx, msg);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class SimpleCollisionBox implements CollisionBox {
|
||||
public double xMin, yMin, zMin, xMax, yMax, zMax;
|
||||
@@ -350,4 +351,29 @@ public class SimpleCollisionBox implements CollisionBox {
|
||||
|
||||
return hxz - (xwidth + zwidth + bxwidth + bzwidth) / 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
SimpleCollisionBox that = (SimpleCollisionBox) o;
|
||||
return Double.compare(that.xMin, xMin) == 0 && Double.compare(that.yMin, yMin) == 0 && Double.compare(that.zMin, zMin) == 0 && Double.compare(that.xMax, xMax) == 0 && Double.compare(that.yMax, yMax) == 0 && Double.compare(that.zMax, zMax) == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(xMin, yMin, zMin, xMax, yMax, zMax);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SimpleCollisionBox{" +
|
||||
"xMin=" + xMin +
|
||||
", yMin=" + yMin +
|
||||
", zMin=" + zMin +
|
||||
", xMax=" + xMax +
|
||||
", yMax=" + yMax +
|
||||
", zMax=" + zMax +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user