plugins/DuneChat/src/main/java/com/example/dunechat/ChatIdentitySource.java
unimatrixgit a5813cc270
Some checks failed
DuneChat Build / dunechat (push) Has been cancelled
DuneRealms Plugin CI / plugins (push) Has been cancelled
Read chat authority through retained JARVIS without replacing GUI
2026-12-02 13:33:22 +01:00

28 lines
1.1 KiB
Java

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);
}
}