Class GenericRequirement

java.lang.Object
net.storm.api.movement.pathfinder.model.requirement.GenericRequirement
All Implemented Interfaces:
Supplier<Boolean>, Requirement

public class GenericRequirement extends Object implements Requirement
A flexible requirement that compares a supplied value against an expected value.

GenericRequirement allows creating custom requirements by providing a value supplier function, an expected value, and a comparison operator.

Flexibility

Unlike specific requirement types, GenericRequirement can check any integer value from any source:

  • Custom calculations
  • Combined values
  • Dynamic thresholds
  • Non-standard game state

Usage Example


 // Check if player has at least 1000 coins total (bank + inventory)
 GenericRequirement goldReq = new GenericRequirement(
     () -> Static.getBank().getCount(ItemID.COINS)
           + Static.getInventory().getCount(ItemID.COINS),
     1000,
     Comparison.GREATER_THAN_EQUAL
 );

 // Check if combat level is at least 100
 GenericRequirement combatReq = new GenericRequirement(
     () -> Static.getPlayers().getLocal().getCombatLevel(),
     100,
     Comparison.GREATER_THAN_EQUAL
 );

 if (goldReq.get()) {
     // Player has enough gold
 }
 
See Also:
  • Constructor Details

    • GenericRequirement

      public GenericRequirement()
  • Method Details

    • get

      public Boolean get()
      Evaluates the requirement by comparing the supplied value against the expected value.
      Specified by:
      get in interface Supplier<Boolean>
      Returns:
      true if the comparison is satisfied, false otherwise