Context error
Closed this issue ยท 1 comments
13:07:12 [GRAVE] Task BungeeTask(sched=net.md_5.bungee.scheduler.BungeeScheduler@5aa0dbf4, id=34269, owner=fr.unicraft.unicoins.UniCoins@24c22fe, task=fr.unicraft.unicoins.task.AsyncRunnableTask$1@4ec459f2, delay=0, period=1000, running=true) encountered an exception
java.lang.NullPointerException: user
at java.util.Objects.requireNonNull(Objects.java:228)
at me.lucko.luckperms.common.api.implementation.ApiContextManager.getContext(ApiContextManager.java:69)
at fr.unicraft.unicoins.UniCoins.hasPermission(UniCoins.java:94)
at fr.unicraft.unicoins.UniCoins.lambda$0(UniCoins.java:78)
at java.util.Iterator.forEachRemaining(Iterator.java:116)
at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:647)
at fr.unicraft.unicoins.UniCoins.getEffectiveRewardedCoins(UniCoins.java:77)
at fr.unicraft.unicoins.task.AsyncRunnableTask$1.lambda$2(AsyncRunnableTask.java:47)
at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:647)
at fr.unicraft.unicoins.task.AsyncRunnableTask$1.run(AsyncRunnableTask.java:47)
at net.md_5.bungee.scheduler.BungeeTask.run(BungeeTask.java:63)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
CODE:
public static boolean hasPermission(User user, String permission) {
ContextManager contextManager = luckperms.getContextManager();
ImmutableContextSet contextSet = contextManager.getContext(user).orElseGet(contextManager::getStaticContext);
CachedPermissionData permissionData = user.getCachedData().getPermissionData(QueryOptions.contextual(contextSet));
return permissionData.checkPermission(permission).asBoolean();
}
The error is on ImmutableContextSet
and i don't know how to fix it.