addGroup bug
JonathanVil opened this issue ยท 3 comments
Hi, I am making a plugin that is charging money and items from the player in change for a group/rank. The part with adding the group to the player is seeming to fail. I am using groupmanager as permissions plugin. This is my code:
public class rankupmain extends JavaPlugin {
public static Economy econ = null;
public static Permission permission = null;
public static Economy economy = null;
public static Chat chat = null;
@Override
public void onEnable(){
this.getLogger().info("made by JonathanVil");
this.getLogger().info("has been enabled");
if (!setupEconomy() ) {
getLogger().severe(String.format("[%s] - Disabled due to no Vault dependency found!", getDescription().getName()));
getServer().getPluginManager().disablePlugin(this);
return;
}
}
private boolean setupEconomy() {
if (getServer().getPluginManager().getPlugin("Vault") == null) {
return false;
}
RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
if (rsp == null) {
return false;
}
econ = rsp.getProvider();
return econ != null;
}
@Override
public void onDisable() {
this.getLogger().info("made by JonathanVil");
this.getLogger().info("has been disabled");}
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
Player p = (Player) sender;
Inventory inv = p.getInventory();
double balance = econ.getBalance(p);
if (cmd.getName().equalsIgnoreCase("jrankup"))
if (sender instanceof Player) {
if (p.hasPermission("jvil.rankup"))
if(inv.contains(Material.APPLE, 5)){
if(balance >= 500)
econ.withdrawPlayer(p, 500);
ItemStack appleToRemove = new ItemStack(Material.APPLE, 5);
inv.removeItem(appleToRemove);
p.sendMessage(ChatColor.GREEN + "5 Apple og $500 er blevet taget!");
permission.playerAddGroup(p, "Tester");
}
}
return false;
}
}
I have attached the stacktrace:
I you have any questions or so please ask. Thanks for your time, Jonathan.
public static Permission permission = null; is never changed to anything in your plugin. Without line numbers it's hard to tell much else, but you never setup the permission system.
I have now setup the permissions. I don't really know what to change the Permission permission = null; to. Here is my full class now: http://pastebin.com/RQ80qAhQ
That should work better as long as it's detecting the permission plugin. I can't help much more if you're still having problems without more information. My previous comment was just to indicate that permission was only going to ever be null. so when you attempt to use it, it's going to throw a NullPointerException.