Get prefix in groupmanagerX

Discussion in 'Spigot Plugin Development' started by JohnyTheCarrot, May 28, 2017.

  1. I'm making a chat plugin and I need to get the prefix of the current rank the player has.
    But GMX doesn't have a getPrefix() method.
    Does anyone have any idea how to do this?
  2. Vault
    • Winner Winner x 1
    • Like Like x 1
  3. Code (Text):
    private static Chat chat;

    class plugin extends onEnable{

        public String getPrefix(Player player)[
            if(chat == null) return null;
            return chat.getPlayerPrefix(player);

        public void onEnable()[
             RegisteredServiceProvider<Chat> rsp = getServer().getServicesManager().getRegistration(Chat.class);
             chat = rsp.getProvider();

    Should do the trick
  4. Also you need to soft depend vault, and check for nulls.
  5. I'm getting:
    Code (Text):

    [14:53:03 WARN]: java.lang.NullPointerException
    [14:53:03 WARN]:        at
    [14:53:03 WARN]:        at
    [14:53:03 WARN]:        at
    [14:53:03 WARN]:        at me.JohnyTheCarrot.BloodChat.GroupManagerX.GMHook.getGroupPrefix(
    [14:53:03 WARN]:        at me.JohnyTheCarrot.BloodChat.Main.onChat(
    [14:53:03 WARN]:        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [14:53:03 WARN]:        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    [14:53:03 WARN]:        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    [14:53:03 WARN]:        at java.lang.reflect.Method.invoke(Unknown Source)
    [14:53:03 WARN]:        at$1.execute(
    [14:53:03 WARN]:        at org.bukkit.plugin.RegisteredListener.callEvent(
    [14:53:03 WARN]:        at org.bukkit.plugin.SimplePluginManager.fireEvent(
    [14:53:03 WARN]:        at org.bukkit.plugin.SimplePluginManager.callEvent(
    [14:53:03 WARN]:        at net.minecraft.server.v1_10_R1.PlayerConnection$7.evaluate(
    [14:53:03 WARN]:        at
    [14:53:03 WARN]:        at net.minecraft.server.v1_10_R1.MinecraftServer.D(
    [14:53:03 WARN]:        at net.minecraft.server.v1_10_R1.DedicatedServer.D(
    [14:53:03 WARN]:        at net.minecraft.server.v1_10_R1.MinecraftServer.C(
    [14:53:03 WARN]:        at
    [14:53:03 WARN]:        at Source)
    this for every Vault method
  6. Do you have vault in the server?
  7. What is on these 2 lines;

    Code (Text):
    Line 87 in GMHook
    Line 138 in Main class
    • Agree Agree x 1
  8. Sorry for the very late response all, I have checked if the Chat file was enabled and it wasn't.
    Any way I can fix this?
  9. __