All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ru.cwcode.commands.preconditions.processor.PreconditionProcessor Maven / Gradle / Ivy

package ru.cwcode.commands.preconditions.processor;

import ru.cwcode.commands.api.Sender;
import ru.cwcode.commands.preconditions.Precondition;

import java.util.Collection;

public class PreconditionProcessor {
  public static PreconditionResult process(Sender sender, Collection preconditions) {
    var feedback = new PreconditionResult();
    
    for (Precondition precondition : preconditions) {
      if (feedback.canPerform() && !precondition.canExecute(sender)) {
        feedback.setCanPerform(false);
        feedback.setCannotPerformMessage(precondition.cannotExecuteFeedback(sender));
      }
      
      if (feedback.canSee() && !precondition.canSee(sender)) {
        feedback.setCanSee(false);
      }
    }
    
    return feedback;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy