diff --git a/divinemc-api/src/main/java/dev/imanity/antixray/sdk/AntiXrayAdapter.java b/divinemc-api/src/main/java/dev/imanity/antixray/sdk/AntiXrayAdapter.java new file mode 100644 index 0000000..975fa49 --- /dev/null +++ b/divinemc-api/src/main/java/dev/imanity/antixray/sdk/AntiXrayAdapter.java @@ -0,0 +1,33 @@ +package dev.imanity.antixray.sdk; + +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.entity.Player; + +public interface AntiXrayAdapter { + /** + * Call a block change to the AntiXray system + * It should be at Level.setBlock(BlockPos, BlockState, flags, maxUpdateDepth) + * Or World.setTypeAndData(BlockPosition, IBlockData, i) in legacy spigot versions + * + * @param world the bukkit world + * @param x the x + * @param y the y + * @param z the z + * @param material the bukkit material + */ + void callBlockChange(World world, int x, int y, int z, Material material); + + /** + * Call a player left click block to the AntiXray system + * It should be at ServerPlayerGameMode.handleBlockBreakAction(BlockPos, ServerboundPlayerActionPacket.Action, Direction, worldHeight, sequence) + * Or PlayerInteractManager.a(BlockPosition, EnumDirection) in legacy spigot versions + * + * @param world the bukkit world + * @param player the bukkit player + * @param x the x + * @param y the y + * @param z the z + */ + void callPlayerLeftClickBlock(World world, Player player, int x, int y, int z); +} diff --git a/divinemc-api/src/main/java/dev/imanity/antixray/sdk/AntiXraySDK.java b/divinemc-api/src/main/java/dev/imanity/antixray/sdk/AntiXraySDK.java new file mode 100644 index 0000000..1e164dc --- /dev/null +++ b/divinemc-api/src/main/java/dev/imanity/antixray/sdk/AntiXraySDK.java @@ -0,0 +1,13 @@ +package dev.imanity.antixray.sdk; + +public class AntiXraySDK { + private static AntiXrayAdapter ADAPTER; + + public static AntiXrayAdapter getAdapter() { + return ADAPTER; + } + + public static void setAdapter(AntiXrayAdapter adapter) { + ADAPTER = adapter; + } +} diff --git a/divinemc-api/src/main/java/dev/imanity/antixray/sdk/package-info.java b/divinemc-api/src/main/java/dev/imanity/antixray/sdk/package-info.java new file mode 100644 index 0000000..afb61aa --- /dev/null +++ b/divinemc-api/src/main/java/dev/imanity/antixray/sdk/package-info.java @@ -0,0 +1,6 @@ +/** + * Integration with Imanity Software's Raytrace AntiXray for better use of this plugin + *
+ * Original project: GitHub Repository
+ */
+package dev.imanity.antixray.sdk;
diff --git a/divinemc-server/minecraft-patches/features/0047-Raytrace-AntiXray-SDK-integration.patch b/divinemc-server/minecraft-patches/features/0047-Raytrace-AntiXray-SDK-integration.patch
new file mode 100644
index 0000000..63af13a
--- /dev/null
+++ b/divinemc-server/minecraft-patches/features/0047-Raytrace-AntiXray-SDK-integration.patch
@@ -0,0 +1,43 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
+Date: Sun, 27 Apr 2025 14:24:19 +0300
+Subject: [PATCH] Raytrace AntiXray SDK integration
+
+Integration with Imanity Software's Raytrace AntiXray for better use of this plugin
+
+Original project: https://github.com/Imanity-Software/raytrace-antixray-spigot-sdk
+
+diff --git a/net/minecraft/server/level/ServerPlayerGameMode.java b/net/minecraft/server/level/ServerPlayerGameMode.java
+index d1f74d10e5e3d65895d7e87dd77f298cd9689b33..8fdc5ab8bfba0e40cedfac64d6bc5e24d1cca969 100644
+--- a/net/minecraft/server/level/ServerPlayerGameMode.java
++++ b/net/minecraft/server/level/ServerPlayerGameMode.java
+@@ -296,6 +296,12 @@ public class ServerPlayerGameMode {
+ org.bukkit.craftbukkit.event.CraftEventFactory.callBlockDamageAbortEvent(this.player, pos, this.player.getInventory().getSelectedItem()); // CraftBukkit
+ }
+ }
++ // Imanity start - AntiXraySDK integration
++ dev.imanity.antixray.sdk.AntiXrayAdapter adapter = dev.imanity.antixray.sdk.AntiXraySDK.getAdapter();
++ if (adapter != null) {
++ adapter.callPlayerLeftClickBlock(this.level.getWorld(), this.player.getBukkitEntity(), pos.getX(), pos.getY(), pos.getZ());
++ }
++ // Imanity end - AntiXraySDK integration
+ this.level.chunkPacketBlockController.onPlayerLeftClickBlock(this, pos, action, face, maxBuildHeight, sequence); // Paper - Anti-Xray
+ }
+
+diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
+index c01463194470624ecd84209100fdbdc851028fb7..3577017125e508db86a022e96355bdb6923ce3d4 100644
+--- a/net/minecraft/world/level/Level.java
++++ b/net/minecraft/world/level/Level.java
+@@ -1173,6 +1173,12 @@ public abstract class Level implements LevelAccessor, UUIDLookup