Read chat authority through retained JARVIS without replacing GUI
This commit is contained in:
parent
186022581a
commit
a5813cc270
1 changed files with 75 additions and 25 deletions
|
|
@ -0,0 +1,28 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue

Staff