Added validation method for operation entries.
This commit is contained in:
@ -111,7 +111,7 @@ public final class Config {
|
||||
.comment("Examples:")
|
||||
.comment("'minecraft:dirt,set,2,2,0,true' - Sets the xp drop of the dirt block to 2, takes highest priority and stops any additional operations.")
|
||||
.comment("'#forge:ores,multiply,1,2,1,false' - Multiplies xp drop of all blocks tagged forge:ores by 1-2, allows additional operations.")
|
||||
.defineList("blockBreakOperations", List.of(), entry -> true);
|
||||
.defineList("blockBreakOperations", List.of(), Server::isValidOperationEntry);
|
||||
builder.pop();
|
||||
|
||||
builder.comment("Settings for entity killing").push("entity_killing");
|
||||
@ -127,7 +127,7 @@ public final class Config {
|
||||
.comment("Examples:")
|
||||
.comment("'minecraft:creeper,set,2,2,0,true' - Sets the xp drop for killing creepers to 2, takes highest priority and stops any additional operations.")
|
||||
.comment("'#some_mod:some_tag,multiply,1,2,1,false' - Multiplies the xp drop for killing all entities tagged some_mod:some_tag by 1-2, allows additional operations.")
|
||||
.defineList("entityKillOperations", List.of(), entry -> true);
|
||||
.defineList("entityKillOperations", List.of(), Server::isValidOperationEntry);
|
||||
builder.pop();
|
||||
}
|
||||
|
||||
@ -171,5 +171,14 @@ public final class Config {
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private static boolean isValidOperationEntry(Object entry) {
|
||||
return entry instanceof String && ((String) entry).matches(
|
||||
String.format(
|
||||
"(?i)^(\\#?\\w+:\\w+),(%s),(\\d*\\.?\\d+),(\\d*\\.?\\d+),(\\d+),(TRUE|FALSE)$",
|
||||
Arrays.stream(OperationType.values()).map(OperationType::toString).collect(Collectors.joining("|"))
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user