Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static void removeNameplate() {
- HologramsSupport hs;
- if((hs=MythicMobs.inst().getCompatibility().getHolograms().get())==null) return;
- Class<HologramsSupport>c=(Class<HologramsSupport>)hs.getClass();
- ConcurrentHashMap<UUID,Object>m;
- try {
- Field f=c.getDeclaredField("nameplates");
- f.setAccessible(true);
- m=(ConcurrentHashMap<UUID,Object>)f.get(hs);
- } catch (Exception e) {
- e.printStackTrace();
- return;
- }
- if (m==null||m.isEmpty()) {
- // print out empty if the map is empty
- System.out.println("empty");
- } else {
- // else iterate through the and check for the uuid of the entity which ones nameplate you want to remove.
- for(Iterator<Entry<UUID,Object>>it=m.entrySet().iterator();it.hasNext();) {
- Entry<UUID,Object>e=it.next();
- UUID u=e.getKey();
- // if u match the uuid use reflection to make the nameplate's remove method avail.
- try {
- Object o=e.getValue();
- Method f1=o.getClass().getDeclaredMethod("remove");
- f1.setAccessible(true);
- f1.invoke(o);
- } catch (Exception e1) {
- e1.printStackTrace();
- return;
- }
- // remove the entry from iterator.
- it.remove();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement