diff --git a/FightSystem_14/build.gradle b/FightSystem_14/build.gradle
index 29ff288..1d2a18c 100644
--- a/FightSystem_14/build.gradle
+++ b/FightSystem_14/build.gradle
@@ -46,6 +46,8 @@ dependencies {
implementation project(":FightSystem_9")
implementation project(":FightSystem_8")
+ compileOnly 'it.unimi.dsi:fastutil:8.5.6'
+
compileOnly swdep("Spigot-1.14")
compileOnly swdep("WorldEdit-1.15")
compileOnly swdep("SpigotCore")
diff --git a/FightSystem_14/src/de/steamwar/fightsystem/utils/BlockIdWrapper14.java b/FightSystem_14/src/de/steamwar/fightsystem/utils/BlockIdWrapper14.java
index 934d9b6..f2330e1 100644
--- a/FightSystem_14/src/de/steamwar/fightsystem/utils/BlockIdWrapper14.java
+++ b/FightSystem_14/src/de/steamwar/fightsystem/utils/BlockIdWrapper14.java
@@ -21,18 +21,31 @@ package de.steamwar.fightsystem.utils;
import com.comphenix.tinyprotocol.Reflection;
import de.steamwar.core.Core;
+import de.steamwar.fightsystem.Config;
+import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
+import org.bukkit.entity.Player;
+
+import java.util.Map;
public class BlockIdWrapper14 implements BlockIdWrapper {
- private static final Class> worldServer = Reflection.getClass("{nms.server.level}.WorldServer");
private static final Class> chunkProviderServer = Reflection.getClass("{nms.server.level}.ChunkProviderServer");
+ private static final Reflection.MethodInvoker getChunkProvider = Reflection.getTypedMethod(worldServer, null, chunkProviderServer);
+ private static final Class> playerChunkMap = Reflection.getClass("{nms.server.level}.PlayerChunkMap");
+ private static final Reflection.FieldAccessor> getPlayerChunkMap = Reflection.getField(chunkProviderServer, playerChunkMap, 0);
+ private static final Reflection.FieldAccessor extends Map> entityTrackers = Core.getVersion() > 15 ? Reflection.getField(playerChunkMap, Int2ObjectMap.class, 0) : Reflection.getField(playerChunkMap, org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil.ints.Int2ObjectMap.class, 0);
private static final Class> block = Reflection.getClass("{nms.world.level.block}.Block");
private static final Class> iBlockData = Reflection.getClass("{nms.world.level.block.state}.IBlockData");
private static final Class> blockPosition = Reflection.getClass("{nms.core}.BlockPosition");
+ private final Map trackers;
+ public BlockIdWrapper14() {
+ trackers = entityTrackers.get(getPlayerChunkMap.get(getChunkProvider.invoke(getWorldHandle.invoke(Config.world))));
+ }
+
private static final Reflection.MethodInvoker getCombinedId = Reflection.getTypedMethod(block, null, int.class, iBlockData);
private static final Reflection.MethodInvoker getNMS = Reflection.getTypedMethod(Reflection.getClass("{obc}.block.CraftBlock"), "getNMS", iBlockData);
@Override
@@ -41,11 +54,9 @@ public class BlockIdWrapper14 implements BlockIdWrapper {
}
private static final Reflection.MethodInvoker getByCombinedId = Reflection.getTypedMethod(block, null, iBlockData, int.class);
- private static final Reflection.MethodInvoker getWorldHandle = Reflection.getTypedMethod(Reflection.getClass("{obc}.CraftWorld"), "getHandle", worldServer);
private static final Reflection.ConstructorInvoker newBlockPosition = Reflection.getConstructor(blockPosition, int.class, int.class, int.class);
private static final Reflection.MethodInvoker getTypeAndData = Reflection.getMethod(worldServer, null, blockPosition, iBlockData, int.class);
private static final Reflection.MethodInvoker removeTileEntity = Reflection.getMethod(worldServer, Core.getVersion() > 15 ? "m" : "removeTileEntity", blockPosition);
- private static final Reflection.MethodInvoker getChunkProvider = Reflection.getTypedMethod(worldServer, null, chunkProviderServer);
private static final Reflection.MethodInvoker flagDirty = Reflection.getMethod(chunkProviderServer, null, blockPosition);
@Override
public void setBlock(World world, int x, int y, int z, int blockState) {
@@ -58,6 +69,23 @@ public class BlockIdWrapper14 implements BlockIdWrapper {
flagDirty.invoke(getChunkProvider.invoke(nworld), pos);
}
+ private static final Class> entityTracker = Reflection.getClass("{nms.server.level}.PlayerChunkMap$EntityTracker");
+ private static final Reflection.MethodInvoker updatePlayer = Reflection.getMethod(entityTracker, Core.getVersion() > 15 ? "b" : "updatePlayer", entityPlayer);
+ @Override
+ public void trackEntity(Player player, int entity) {
+ Object tracker = trackers.get(entity);
+ if(tracker != null)
+ updatePlayer.invoke(tracker, getPlayer.invoke(player));
+ }
+
+ private static final Reflection.MethodInvoker clearPlayer = Reflection.getMethod(entityTracker, Core.getVersion() > 15 ? "a" : "clear", entityPlayer);
+ @Override
+ public void untrackEntity(Player player, int entity) {
+ Object tracker = trackers.get(entity);
+ if(tracker != null)
+ clearPlayer.invoke(tracker, getPlayer.invoke(player));
+ }
+
private static final Reflection.MethodInvoker getMaterialByBlock = Reflection.getTypedMethod(Reflection.getClass("{obc}.util.CraftMagicNumbers"), "getMaterial", Material.class, block);
private static final Reflection.MethodInvoker getBlockByBlockData = Reflection.getTypedMethod(iBlockData, null, block);
@Override
diff --git a/FightSystem_18/build.gradle b/FightSystem_18/build.gradle
index 91b8b08..7b0940e 100644
--- a/FightSystem_18/build.gradle
+++ b/FightSystem_18/build.gradle
@@ -48,6 +48,7 @@ dependencies {
compileOnly 'com.mojang:datafixerupper:4.0.26'
compileOnly 'io.netty:netty-all:4.1.68.Final'
compileOnly 'com.mojang:authlib:1.5.25'
+ compileOnly 'it.unimi.dsi:fastutil:8.5.6'
compileOnly swdep("Spigot-1.18")
compileOnly swdep("WorldEdit-1.15")
diff --git a/FightSystem_18/src/de/steamwar/fightsystem/utils/HullHiderWrapper18.java b/FightSystem_18/src/de/steamwar/fightsystem/utils/HullHiderWrapper18.java
new file mode 100644
index 0000000..8f81cf9
--- /dev/null
+++ b/FightSystem_18/src/de/steamwar/fightsystem/utils/HullHiderWrapper18.java
@@ -0,0 +1,82 @@
+/*
+ * This file is a part of the SteamWar software.
+ *
+ * Copyright (C) 2024 SteamWar.de-Serverteam
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package de.steamwar.fightsystem.utils;
+
+import com.comphenix.tinyprotocol.Reflection;
+import de.steamwar.fightsystem.Config;
+import it.unimi.dsi.fastutil.shorts.Short2ObjectArrayMap;
+import net.minecraft.core.BlockPosition;
+import net.minecraft.core.SectionPosition;
+import net.minecraft.network.protocol.game.PacketPlayOutBlockChange;
+import net.minecraft.network.protocol.game.PacketPlayOutMultiBlockChange;
+import net.minecraft.world.level.block.state.IBlockData;
+import org.bukkit.block.data.BlockData;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+public class HullHiderWrapper18 implements HullHiderWrapper {
+
+ private static final Reflection.MethodInvoker getState = Reflection.getTypedMethod(Reflection.getClass("{obc}.block.data.CraftBlockData"), "getState", IBlockData.class);
+ @Override
+ public Object generateBlockChangePacket(List changes) {
+ List