Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. private static void removeNameplate() {
  2. HologramsSupport hs;
  3. if((hs=MythicMobs.inst().getCompatibility().getHolograms().get())==null) return;
  4. Class<HologramsSupport>c=(Class<HologramsSupport>)hs.getClass();
  5. ConcurrentHashMap<UUID,Object>m;
  6. try {
  7. Field f=c.getDeclaredField("nameplates");
  8. f.setAccessible(true);
  9. m=(ConcurrentHashMap<UUID,Object>)f.get(hs);
  10. } catch (Exception e) {
  11. e.printStackTrace();
  12. return;
  13. }
  14. if (m==null||m.isEmpty()) {
  15. // print out empty if the map is empty
  16. System.out.println("empty");
  17. } else {
  18. // else iterate through the and check for the uuid of the entity which ones nameplate you want to remove.
  19. for(Iterator<Entry<UUID,Object>>it=m.entrySet().iterator();it.hasNext();) {
  20. Entry<UUID,Object>e=it.next();
  21. UUID u=e.getKey();
  22. // if u match the uuid use reflection to make the nameplate's remove method avail.
  23. try {
  24. Object o=e.getValue();
  25. Method f1=o.getClass().getDeclaredMethod("remove");
  26. f1.setAccessible(true);
  27. f1.invoke(o);
  28. } catch (Exception e1) {
  29. e1.printStackTrace();
  30. return;
  31. }
  32. // remove the entry from iterator.
  33. it.remove();
  34. }
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement