From 053bd06342c274fc28498888242556227dc46676 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Mon, 6 Jan 2025 19:18:47 +0100 Subject: [PATCH] Fix invisible players --- FightSystem/FightSystem_18/build.gradle.kts | 1 + .../fightsystem/utils/BlockIdWrapper18.java | 21 ++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) 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 c229353a..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 com.comphenix.tinyprotocol.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.FieldAccessor hiddenEntities = Reflection.getField(Reflection.getClass("{obc}.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)); } }