Merge pull request 'bug/17-config_list_definitions' (#18) from bug/17-config_list_definitions into 1.20.1
Reviewed-on: #18
This commit is contained in:
@ -4,7 +4,7 @@ org.gradle.daemon=false
|
|||||||
mod_id=xp_tools
|
mod_id=xp_tools
|
||||||
mod_name=XP Tools
|
mod_name=XP Tools
|
||||||
mod_license=All Rights Reserved
|
mod_license=All Rights Reserved
|
||||||
mod_version=1.0.1
|
mod_version=1.0.2
|
||||||
mod_group_id=dev.micle
|
mod_group_id=dev.micle
|
||||||
mod_authors=Micle
|
mod_authors=Micle
|
||||||
mod_description=Minecraft Forge mod for tweaking various things about XP in Minecraft. Primarily targeted at modpack developers.
|
mod_description=Minecraft Forge mod for tweaking various things about XP in Minecraft. Primarily targeted at modpack developers.
|
||||||
|
@ -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,13 +105,13 @@ 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.")
|
||||||
.define("blockBreakGlobalOperations", new ArrayList<>());
|
.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:")
|
||||||
.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("'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.")
|
.comment("'#forge:ores,multiply,1,2,1,false' - Multiplies xp drop of all blocks tagged forge:ores by 1-2, allows additional operations.")
|
||||||
.define("blockBreakOperations", new ArrayList<>());
|
.defineList("blockBreakOperations", List.of(), Server::isValidOperationEntry);
|
||||||
builder.pop();
|
builder.pop();
|
||||||
|
|
||||||
builder.comment("Settings for entity killing").push("entity_killing");
|
builder.comment("Settings for entity killing").push("entity_killing");
|
||||||
@ -120,13 +121,13 @@ 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.")
|
||||||
.define("entityKillGlobalOperations", new ArrayList<>());
|
.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:")
|
||||||
.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("'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.")
|
.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.")
|
||||||
.define("entityKillOperations", new ArrayList<>());
|
.defineList("entityKillOperations", List.of(), Server::isValidOperationEntry);
|
||||||
builder.pop();
|
builder.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,5 +162,23 @@ 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("|"))
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
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