diff --git a/FightSystem/FightSystem_18/build.gradle.kts b/FightSystem/FightSystem_18/build.gradle.kts index b140d148..b5d694ed 100644 --- a/FightSystem/FightSystem_18/build.gradle.kts +++ b/FightSystem/FightSystem_18/build.gradle.kts @@ -31,5 +31,6 @@ dependencies { compileOnly(libs.nms18) compileOnly(libs.fawe18) + compileOnly(libs.authlib) compileOnly(libs.fastutil) } diff --git a/FightSystem/FightSystem_18/src/de/steamwar/fightsystem/utils/BlockIdWrapper18.java b/FightSystem/FightSystem_18/src/de/steamwar/fightsystem/utils/BlockIdWrapper18.java index 66ea9b08..992dd451 100644 --- a/FightSystem/FightSystem_18/src/de/steamwar/fightsystem/utils/BlockIdWrapper18.java +++ b/FightSystem/FightSystem_18/src/de/steamwar/fightsystem/utils/BlockIdWrapper18.java @@ -19,24 +19,29 @@ package de.steamwar.fightsystem.utils; -import de.steamwar.Reflection; +import com.comphenix.tinyprotocol.TinyProtocol; +import com.mojang.authlib.GameProfile; +import de.steamwar.core.ProtocolWrapper; +import de.steamwar.fightsystem.FightSystem; +import org.bukkit.GameMode; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; -import java.util.*; - public class BlockIdWrapper18 extends BlockIdWrapper14 { - private static final Reflection.Field hiddenEntities = Reflection.getField(Reflection.getClass("org.bukkit.craftbukkit.entity.CraftPlayer"), Map.class, 0, UUID.class, Set.class); @Override public void trackEntity(Player player, Entity entity) { - hiddenEntities.get(player).remove(entity.getUniqueId()); - super.trackEntity(player, entity); + if(entity instanceof Player) + TinyProtocol.instance.sendPacket(player, ProtocolWrapper.impl.playerInfoPacketConstructor(ProtocolWrapper.PlayerInfoAction.REMOVE, new GameProfile(entity.getUniqueId(), entity.getName()), GameMode.CREATIVE)); + + player.showEntity(FightSystem.getPlugin(), entity); } @Override public void untrackEntity(Player player, Entity entity) { - hiddenEntities.get(player).put(entity.getUniqueId(), new HashSet<>(1)); - super.untrackEntity(player, entity); + player.hideEntity(FightSystem.getPlugin(), entity); + + if(entity instanceof Player) + TinyProtocol.instance.sendPacket(player, ProtocolWrapper.impl.playerInfoPacketConstructor(ProtocolWrapper.PlayerInfoAction.ADD, new GameProfile(entity.getUniqueId(), entity.getName()), GameMode.CREATIVE)); } }