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

        @Override
        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 net.milkbowl.vault.chat.plugins.Chat_GroupManager.getPlayerPrefix(Chat_GroupManager.java:271)
    [14:53:03 WARN]:        at net.milkbowl.vault.chat.Chat.getPlayerPrefix(Chat.java:67)
    [14:53:03 WARN]:        at net.milkbowl.vault.chat.Chat.getPlayerPrefix(Chat.java:91)
    [14:53:03 WARN]:        at me.JohnyTheCarrot.BloodChat.GroupManagerX.GMHook.getGroupPrefix(GMHook.java:87)
    [14:53:03 WARN]:        at me.JohnyTheCarrot.BloodChat.Main.onChat(Main.java:138)
    [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 org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302)
    [14:53:03 WARN]:        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62)
    [14:53:03 WARN]:        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502)
    [14:53:03 WARN]:        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487)
    [14:53:03 WARN]:        at net.minecraft.server.v1_10_R1.PlayerConnection$7.evaluate(PlayerConnection.java:1289)
    [14:53:03 WARN]:        at org.bukkit.craftbukkit.v1_10_R1.util.Waitable.run(Waitable.java:24)
    [14:53:03 WARN]:        at net.minecraft.server.v1_10_R1.MinecraftServer.D(MinecraftServer.java:742)
    [14:53:03 WARN]:        at net.minecraft.server.v1_10_R1.DedicatedServer.D(DedicatedServer.java:400)
    [14:53:03 WARN]:        at net.minecraft.server.v1_10_R1.MinecraftServer.C(MinecraftServer.java:668)
    [14:53:03 WARN]:        at net.minecraft.server.v1_10_R1.MinecraftServer.run(MinecraftServer.java:567)
    [14:53:03 WARN]:        at java.lang.Thread.run(Unknown 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. __