Solved bPermissions & Vault error after permission.addPlayer(player, group)

Discussion in 'Plugin Development' started by voltywolty, Sep 20, 2021.

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

    voltywolty

    Hey all. I'm trying to make it where after a player has used an item, it sets their permission, however, I am getting the following error:

    Cannot invoke "net.milkbowl.vault.permission.Permission.playerAdd(org.bukkit.entity.Player, String)" because "main.volt.dvz.events.DwarfEvents.dwarfPermission" is null

    I have a variable at the top of my script:
    Code:
    private static Permission dwarfPermission;
    After that, I go into my function and right after the player does that action, I do:
    Code:
    dwarfPermission.playerAdd(player, "builder");
    Not too sure what I am doing wrong, I wouldn't understand why its going null. If someone is experienced with this please help me out! I have the groups set for the world in the groups.yml file, but still not working.
     
  2. Offline

    timtower Administrator Administrator Moderator

    @voltywolty You never initialize the variable. You just say it is there.
     
  3. Offline

    Tim_M

    Code:
    
    private static Permission perms = null;
    private static final Logger log = Logger.getLogger("Minecraft");
    
    
    @Override
    public void onEnable() {
    if (!setupPermissions() ) {
    log.severe(String.format("[%s] - Disabled due to no Vault dependency found!", getDescription().getName()));
    getServer().getPluginManager().disablePlugin(this);
    return;
    }
    
    private boolean setupPermissions() {
    RegisteredServiceProvider<Permission> rsp = getServer().getServicesManager().getRegistration(Permission.class);
    perms = rsp.getProvider();
    return perms != null;
    }
    
    This is literally on the official documentation at https://github.com/MilkBowl/VaultAPI. Did you even try to google. Also I'd recommend learning basic Java before coding plugins first.
     
Thread Status:
Not open for further replies.

Share This Page