Search in sources :

Example 1 with RequirementsProcessor

use of com.elmakers.mine.bukkit.api.requirements.RequirementsProcessor in project MagicPlugin by elBukkit.

the class MagicController method checkRequirements.

@Override
@Nullable
public String checkRequirements(@Nonnull CastContext context, @Nullable Collection<Requirement> requirements) {
    if (requirements == null)
        return null;
    for (Requirement requirement : requirements) {
        String type = requirement.getType();
        RequirementsProcessor processor = requirementProcessors.get(type);
        if (processor != null) {
            if (!processor.checkRequirement(context, requirement)) {
                String message = processor.getRequirementDescription(context, requirement);
                if (message == null || message.isEmpty()) {
                    message = messages.get("requirements.unknown");
                }
                return message;
            }
        }
    }
    return null;
}
Also used : Requirement(com.elmakers.mine.bukkit.api.requirements.Requirement) RequirementsProcessor(com.elmakers.mine.bukkit.api.requirements.RequirementsProcessor) Nullable(javax.annotation.Nullable)

Aggregations

Requirement (com.elmakers.mine.bukkit.api.requirements.Requirement)1 RequirementsProcessor (com.elmakers.mine.bukkit.api.requirements.RequirementsProcessor)1 Nullable (javax.annotation.Nullable)1