blob: f487276801d30dbb6549f580e3576555fff1dc22 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
package shcm.shsupercm.fabric.citresewn.cit;
import shcm.shsupercm.fabric.citresewn.CITResewn;
import shcm.shsupercm.fabric.citresewn.api.CITConditionContainer;
import shcm.shsupercm.fabric.citresewn.config.CITResewnConfig;
import shcm.shsupercm.fabric.citresewn.pack.format.PropertyGroup;
import shcm.shsupercm.fabric.citresewn.pack.format.PropertyValue;
import java.util.Collections;
import java.util.Set;
/**
* Instanced parent for CIT Types that are applied to items when conditions pass.<br>
* Common condition types are available under {@link shcm.shsupercm.fabric.citresewn.cit.builtin.conditions}.
* @see CITConditionContainer
* @see CIT
*/
public abstract class CITCondition {
/**
* Parses the given property value into the condition.
* @param value value to read
* @param properties the group containing value
* @throws CITParsingException if errored while parsing the condition
*/
public abstract void load(PropertyValue value, PropertyGroup properties) throws CITParsingException;
/**
* @return a set of classes of conditions that have integration with this condition
*/
public Set<Class<? extends CITCondition>> siblingConditions() {
return Collections.emptySet();
}
/**
* Modifies the given sibling if present in the CIT and declared in {@link #siblingConditions()}.
* @param sibling sibling to modify or be modified by
* @return the sibling or null to remove it from the CIT.
*/
public <T extends CITCondition> T modifySibling(T sibling) {
return sibling;
}
/**
* Tests the given context against this condition.
* @param context context to check
* @return true if the given context passes
*/
public abstract boolean test(CITContext context);
/**
* Logs a warning with the given value's descriptor if enabled in config.
*
* @see CITResewn#logWarnLoading(String)
* @see CITResewnConfig#mute_warns
* @param message warning message
* @param value value associated with the warning
* @param properties property group associated with the warning
*/
protected void warn(String message, PropertyValue value, PropertyGroup properties) {
CITResewn.logWarnLoading("Warning: " + properties.messageWithDescriptorOf(message, value.position()));
}
}
|