package com.dunerealms.gui; import java.lang.reflect.*; import java.util.*; import org.bukkit.*; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; /** Uses the installed DecentHolograms renderer; temporary labels never become saved holograms. */ final class HologramBridge { private final Method create,move,lines,remove,hide,unhide; HologramBridge(Plugin dependency)throws ReflectiveOperationException{ var api=dependency.getClass().getClassLoader().loadClass("eu.decentsoftware.holograms.api.DHAPI");create=api.getMethod("createHologram",String.class,Location.class,boolean.class,List.class);Class type=create.getReturnType();move=api.getMethod("moveHologram",type,Location.class);lines=api.getMethod("setHologramLines",type,List.class);remove=api.getMethod("removeHologram",String.class);hide=type.getMethod("setHidePlayer",Player.class);unhide=type.getMethod("removeHidePlayer",Player.class); } Object create(String id,Location at,List text)throws ReflectiveOperationException{return create.invoke(null,id,at,false,text);} void move(Object hologram,Location at)throws ReflectiveOperationException{move.invoke(null,hologram,at);} void lines(Object hologram,List text)throws ReflectiveOperationException{lines.invoke(null,hologram,text);} void remove(String id)throws ReflectiveOperationException{remove.invoke(null,id);} void hidden(Object hologram,Player viewer,boolean value)throws ReflectiveOperationException{(value?hide:unhide).invoke(hologram,viewer);} }