mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
Add work penalty type
This commit is contained in:
parent
98172a11c9
commit
519ab1853c
4 changed files with 85 additions and 5 deletions
|
|
@ -0,0 +1,50 @@
|
|||
package xyz.alexcrea.cuanvil.config;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public enum WorkPenaltyType {
|
||||
DEFAULT("default", true, true),
|
||||
INCREASE("increase_only", true, false),
|
||||
ADDITIVE("add_only", false, true),
|
||||
DISABLED("disabled", false, false),
|
||||
;
|
||||
|
||||
private final String name;
|
||||
private final boolean penaltyIncrease;
|
||||
private final boolean penaltyAdditive;
|
||||
|
||||
WorkPenaltyType(String name, boolean penaltyIncrease, boolean penaltyAdditive) {
|
||||
this.name = name;
|
||||
this.penaltyIncrease = penaltyIncrease;
|
||||
this.penaltyAdditive = penaltyAdditive;
|
||||
}
|
||||
|
||||
public boolean isPenaltyIncreasing() {
|
||||
return penaltyIncrease;
|
||||
}
|
||||
|
||||
public boolean isPenaltyAdditive() {
|
||||
return penaltyAdditive;
|
||||
}
|
||||
|
||||
private boolean doRepresentThisType(String toTest){
|
||||
return name.equalsIgnoreCase(toTest);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static WorkPenaltyType fromString(@Nullable String toTest){
|
||||
if(toTest == null) return DEFAULT;
|
||||
|
||||
// Test if it matches any of values
|
||||
for (WorkPenaltyType value : values()) {
|
||||
if(value.doRepresentThisType(toTest)){
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
// Use default if not found
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue