mirror of
https://github.com/BentoBoxWorld/Challenges.git
synced 2024-11-26 04:25:13 +01:00
Add check on permission.
This commit is contained in:
parent
0943a48c3c
commit
e0f38206aa
@ -278,7 +278,12 @@ public class TryToComplete
|
||||
else if (!this.challenge.getEnvironment().isEmpty() &&
|
||||
!this.challenge.getEnvironment().contains(this.user.getWorld().getEnvironment()))
|
||||
{
|
||||
this.user.sendMessage("general.errors.wrong-environment");
|
||||
this.user.sendMessage("challenges.errors.wrong-environment");
|
||||
}
|
||||
// Check permission
|
||||
else if (!this.checkPermissions())
|
||||
{
|
||||
this.user.sendMessage("general.errors.no-permission");
|
||||
}
|
||||
else if (type.equals(ChallengeType.INVENTORY))
|
||||
{
|
||||
@ -298,6 +303,16 @@ public class TryToComplete
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method checks if user has all required permissions.
|
||||
* @return true if user has all required permissions, otherwise false.
|
||||
*/
|
||||
private boolean checkPermissions()
|
||||
{
|
||||
return this.challenge.getRequiredPermissions().isEmpty() ||
|
||||
this.challenge.getRequiredPermissions().stream().allMatch(s -> this.user.hasPermission(s));
|
||||
}
|
||||
|
||||
/**
|
||||
* This method runs all commands from command list.
|
||||
* @param commands List of commands that must be performed.
|
||||
|
Loading…
Reference in New Issue
Block a user