forked from SteamWar/SteamWar
Fix invisible players
This commit is contained in:
@@ -31,5 +31,6 @@ dependencies {
|
||||
compileOnly(libs.nms18)
|
||||
compileOnly(libs.fawe18)
|
||||
|
||||
compileOnly(libs.authlib)
|
||||
compileOnly(libs.fastutil)
|
||||
}
|
||||
|
||||
@@ -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<Map> 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));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user