LootConditionBuilder
Manages the creation of one or multiple ILootConditions using the builders provided by ILootConditionTypeBuilder.
Each instance of this class may handle the presence of more than one conditions. On the other hand, some builders may require the presence of at most one condition. Refer to their documentation for more information.
This builder does not force any particular interpretation in case of multiple conditions being added: they may be merged together via 'AND', 'OR', or not merged together at all. It is up to the user of the builder to decide how the merges should happen.
Importing the class
It might be required for you to import the package if you encounter any issues (like casting an Array), so better be safe than sorry and add the import at the very top of the file.
Methods
Creates a new empty LootConditionBuilder.
Returns: The newly created instance. Return Type: LootConditionBuilder
Creates a new LootConditionBuilder and automatically adds a single condition of the specified type.
This is merely a helper method to avoid multiple method calls and chains when the user needs to create a builder but only wants to add a single condition to it. It is effectively a call to create
followed by one to add
.
Returns: The newly created builder, already containing the created condition. Return Type: LootConditionBuilder
Creates a new LootConditionBuilder containing an And.
This ensures that, no matter what the underlying implementation may assume, the various conditions will be treated as part of an 'And' condition. Refer to And for more information.
Returns: The newly created instance, containing the 'And' condition. Return Type: LootConditionBuilder
Creates a new LootConditionBuilder containing an Or.
This ensures that, no matter what the underlying implementation may assume, the various conditions will be treated as part of an 'Or' condition. Refer to Or for more information.
Returns: The newly created instance, containing the 'Or' condition. Return Type: LootConditionBuilder
Creates an ILootCondition of the given type
parsing the given json
.
The JSON must respect the constraints specified in the documentation of the Json loot condition.
If no valid condition is found, or the JSON is invalid, an error gets thrown.
Returns: An ILootCondition instance built according to the given data, if possible. Return Type: ILootCondition
Creates an ILootCondition of the given type
parsing the given json
.
The name is treated as a MCResourceLocation, lacking the type safety of the bracket handler. For this reason, it's suggested to prefer the method with a MCResourceLocation as parameter.
The JSON must respect the constraints specified in the documentation of the Json loot condition.
If no valid condition is found, or the JSON is invalid, an error gets thrown.
Returns: An ILootCondition instance built according to the given data, if possible. Return Type: ILootCondition
Creates a new ILootCondition of the given type, according to the parameters specified in the
lender
.
In other words, a new ILootCondition is created based on the chosen ILootConditionTypeBuilder.
This is particularly useful if the creation of a single loot condition is required and the user wants to use one of the already existing builders.
Returns: The condition created by the builder itself. Return Type: ILootCondition
Methods
Adds a new condition of the given type to the ones of this builder.
The condition is built according to the defaults of the ILootConditionTypeBuilder specified. It is thus assumed that the default values lead to a well-formed and correct loot condition. If such isn't the case, then the method may behave erratically or throw an exception: refer to the two parameter version of add
for the method that allows configuration.
Return Type: LootConditionBuilder
Adds a new condition of the given type and configuration to the ones of this builder.
The condition is built according to the specified ILootConditionTypeBuilder and configured according to the details given in lender
. If the default configuration is satisfying, then the single parameter version of add
may also be used.
Return Type: LootConditionBuilder
Builds the current builder, returning all its contents as an array of ILootConditions.
The builder may then be re-used for additional purposes, though this is not suggested.
Return Type: ILootCondition[]