package com.example.dunechat; import com.google.gson.JsonObject; import java.lang.reflect.Method; import java.util.UUID; import org.bukkit.plugin.Plugin; /** Reuse the installed JARVIS reads without replacing the GUI or the central service. */ final class ChatIdentitySource { private final Plugin jarvis; private final Method house; private final Method organisations; ChatIdentitySource(Plugin jarvis) throws ReflectiveOperationException { this.jarvis = jarvis; if (jarvis == null || !jarvis.isEnabled()) throw new IllegalStateException("JARVIS unavailable"); house = jarvis.getClass().getMethod("requestHouse", UUID.class, String.class, int.class, UUID.class); organisations = jarvis.getClass().getMethod("requestOrganisations", UUID.class); } JsonObject house(UUID player) throws ReflectiveOperationException { return (JsonObject) house.invoke(jarvis, player, null, 0, null); } JsonObject organisations(UUID player) throws ReflectiveOperationException { return (JsonObject) organisations.invoke(jarvis, player); } }