Getting a player's group through Vault

Discussion in 'Plugin Development' started by UnpeeledBanana1, Nov 9, 2015.

Thread Status:
Not open for further replies.
  1. Offline


    So, I'm basically trying to setup chat in my plugin, and making it format depending on the player's group. I'm using Vault to get the player's group.
    The imports for Vault permissions are all fine, they work as they should do.
    I'm just stuck on seeing what group a player is in.
    Here's the code:

    public class Chat extends JavaPlugin implements Listener {
        public static Economy econ = null;
        public static Permission perms = null;
        public void onEnable() {
            if (!setupEconomy() ) {
                Bukkit.getConsoleSender().sendMessage("§cVault needed mate...");
        private boolean setupPermissions() {
            RegisteredServiceProvider<Permission> rsp = getServer().getServicesManager().getRegistration(Permission.class);
            perms = rsp.getProvider();
            return perms != null;
        public void chatFormat(AsyncPlayerChatEvent event) {
          Player player = event.getPlayer();
          if ((perms.getPrimaryGroup(player) == (perms.getPrimaryGroup(player)))) {
              event.setFormat("§8[Member] §7" + player.getDisplayName() + ":§7 " + event.getMessage());
          } else {
              event.setFormat("§7" + player.getDisplayName() + " §8:" + event.getMessage());
    I realize that this finds the player's group:
    But I just get stuck when i'm trying to find if it's equal to another group.
    Any solutions out there?

    Thanks :)
  2. Offline


  3. Offline




    Let's do some math with this "equality"

    You can divide it by (perms.getPrimaryGroup(player)), vecause either side has it, you get

    1 == 1
    This means, that this is always true, so you don't need that if statement.
  4. Offline


    @mcdorli I know that... It's just there temporarily until I can find a solution.
    Plus, they are exactly the same. Isn't that a bit obvious to point out?
  5. Offline


    If it's that obvious, why have it at all?
    Even temporarily?

    For any reason?
    What reason?
  6. Offline


    @Scimiguy Just personal preference.

    I came here for help, not criticism :l

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Nov 10, 2015
  7. Offline



    You asked for help about comparing the group and he pointed out that you have a completely pointless comparison concerning the player's group. That's pretty relevant, I would think.
Thread Status:
Not open for further replies.

Share This Page