Added validation method for global operation entries.
This commit is contained in:
@ -13,6 +13,7 @@ import net.minecraftforge.fml.event.config.ModConfigEvent;
|
|||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Mod.EventBusSubscriber(modid = XpTools.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
@Mod.EventBusSubscriber(modid = XpTools.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||||
public final class Config {
|
public final class Config {
|
||||||
@ -104,7 +105,7 @@ public final class Config {
|
|||||||
.comment("Global operations are run before any unique operations.")
|
.comment("Global operations are run before any unique operations.")
|
||||||
.comment("Examples:")
|
.comment("Examples:")
|
||||||
.comment("'set,0,0,0' - Sets the xp of all blocks to 0.")
|
.comment("'set,0,0,0' - Sets the xp of all blocks to 0.")
|
||||||
.defineList("blockBreakGlobalOperations", List.of(), entry -> true);
|
.defineList("blockBreakGlobalOperations", List.of(), Server::isValidGlobalOperationEntry);
|
||||||
blockBreakOperationsRaw = builder
|
blockBreakOperationsRaw = builder
|
||||||
.comment("List of unique operations. Format: '[block_id/tag_id],[operation],[min],[max],[priority],[is_last]'")
|
.comment("List of unique operations. Format: '[block_id/tag_id],[operation],[min],[max],[priority],[is_last]'")
|
||||||
.comment("Examples:")
|
.comment("Examples:")
|
||||||
@ -120,7 +121,7 @@ public final class Config {
|
|||||||
.comment("Global operations are run before any unique operations.")
|
.comment("Global operations are run before any unique operations.")
|
||||||
.comment("Examples:")
|
.comment("Examples:")
|
||||||
.comment("'set,0,0,0' - Sets the xp of all entities to 0.")
|
.comment("'set,0,0,0' - Sets the xp of all entities to 0.")
|
||||||
.defineList("entityKillGlobalOperations", List.of(), entry -> true);
|
.defineList("entityKillGlobalOperations", List.of(), Server::isValidGlobalOperationEntry);
|
||||||
entityKillOperationsRaw = builder
|
entityKillOperationsRaw = builder
|
||||||
.comment("List of unique operations. Format: '[entity_id/tag_id],[operation],[min],[max],[priority],[is_last]'")
|
.comment("List of unique operations. Format: '[entity_id/tag_id],[operation],[min],[max],[priority],[is_last]'")
|
||||||
.comment("Examples:")
|
.comment("Examples:")
|
||||||
@ -161,5 +162,14 @@ public final class Config {
|
|||||||
entityKillOperationItems.add(OperationItem.fromConfig(s));
|
entityKillOperationItems.add(OperationItem.fromConfig(s));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean isValidGlobalOperationEntry(Object entry) {
|
||||||
|
return entry instanceof String && ((String) entry).matches(
|
||||||
|
String.format(
|
||||||
|
"(?i)^(%s),(\\d*\\.?\\d+),(\\d*\\.?\\d+),(\\d+)$",
|
||||||
|
Arrays.stream(OperationType.values()).map(OperationType::toString).collect(Collectors.joining("|"))
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user