Class LifestealerUserRulesController
java.lang.Object
dev.chicoferreira.lifestealer.user.rules.LifestealerUserRulesController
-
Constructor Summary
ConstructorsConstructorDescriptionLifestealerUserRulesController
(LifestealerUserRules defaultRules, List<LifestealerUserRulesGroup> groupRules) -
Method Summary
Modifier and TypeMethodDescriptioncomputeRulesByPermission
(Function<String, Boolean> permissionTester) Calculates theLifestealerUserRules
that the permissions tested indicates.void
setDefaultRule
(LifestealerUserRules defaultRule) Sets the default rule that will be used when no group matches the permissions.void
setGroupRules
(List<LifestealerUserRulesGroup> groups) Sets the groups that will be used to calculate the rules based on the permissions.
-
Constructor Details
-
LifestealerUserRulesController
public LifestealerUserRulesController(LifestealerUserRules defaultRules, List<LifestealerUserRulesGroup> groupRules)
-
-
Method Details
-
setDefaultRule
Sets the default rule that will be used when no group matches the permissions. Used when the configuration is reloaded.- Parameters:
defaultRule
- the default rule to set
-
setGroupRules
Sets the groups that will be used to calculate the rules based on the permissions. Used when the configuration is reloaded.- Parameters:
groups
- the groups to set
-
computeRulesByPermission
Calculates theLifestealerUserRules
that the permissions tested indicates.If no group matches the permissions, the default cap is returned. If multiple groups match the permissions, the last one is returned, falling back to previous ones when it does not have a min or max hearts.
This will only compute the rules based on the permissions. If you want to compute the rules based on the user and the permissions, use
LifestealerUserController.computeUserRules(Player, LifestealerUser)
as it will also take into account the user's rules modifiers.- Parameters:
permissionTester
- a function that tests if something has a permission (e.g.player::hasPermission
)- Returns:
- the
LifestealerUserRules
that the permissions tested indicates
-