From d4da428bc19515cd3768d0c68d96ce8499bb7fe3 Mon Sep 17 00:00:00 2001 From: Eric Date: Tue, 30 May 2017 20:41:49 +0200 Subject: [PATCH] Removed "useCurrentThread" parameter from "hidePlayer" method --- .../de/epiceric/shopchest/nms/Hologram.java | 51 +++++++------------ 1 file changed, 18 insertions(+), 33 deletions(-) diff --git a/src/main/java/de/epiceric/shopchest/nms/Hologram.java b/src/main/java/de/epiceric/shopchest/nms/Hologram.java index a583373..d7e7b85 100644 --- a/src/main/java/de/epiceric/shopchest/nms/Hologram.java +++ b/src/main/java/de/epiceric/shopchest/nms/Hologram.java @@ -207,44 +207,29 @@ public class Hologram { /** * @param p Player from which the hologram should be hidden */ - public void hidePlayer(final Player p, boolean useCurrentThread) { - if (useCurrentThread) { - sendDestroyPackets(p); - } else { - new BukkitRunnable() { - @Override - public void run() { - sendDestroyPackets(p); + public void hidePlayer(final Player p) { + new BukkitRunnable() { + @Override + public void run() { + for (Object o : nmsArmorStands) { + try { + int id = (int) entityArmorStandClass.getMethod("getId").invoke(o); + + Object packet = packetPlayOutEntityDestroyClass.getConstructor(int[].class).newInstance((Object) new int[] {id}); + + Utils.sendPacket(plugin, packet, p); + } catch (NoSuchMethodException | InstantiationException | InvocationTargetException | IllegalAccessException e) { + plugin.getLogger().severe("Could not hide Hologram from player with reflection"); + plugin.debug("Could not hide Hologram from player with reflection"); + plugin.debug(e); + } } - }.runTaskAsynchronously(plugin); - } + } + }.runTaskAsynchronously(plugin); visible.remove(p); } - private void sendDestroyPackets(Player p) { - for (Object o : nmsArmorStands) { - try { - int id = (int) entityArmorStandClass.getMethod("getId").invoke(o); - - Object packet = packetPlayOutEntityDestroyClass.getConstructor(int[].class).newInstance((Object) new int[] {id}); - - Utils.sendPacket(plugin, packet, p); - } catch (NoSuchMethodException | InstantiationException | InvocationTargetException | IllegalAccessException e) { - plugin.getLogger().severe("Could not hide Hologram from player with reflection"); - plugin.debug("Could not hide Hologram from player with reflection"); - plugin.debug(e); - } - } - } - - /** - * @param p Player from which the hologram should be hidden - */ - public void hidePlayer(final Player p) { - hidePlayer(p, false); - } - /** * @param p Player to check * @return Whether the hologram is visible to the player