Regex Support for Block/Tool Lists
meekachuwu opened this issue · 4 comments
Manually adding each block/tool ID to the config is a cruel form of torture and I demand you implement some sort of regular expression support (e.g. "_log" selects every block in the game that has the word "log" at the end of it).
I beg of you. My life depends on this feature.
ಥ⌓ಢ
Coming back to further clarify that while I do not plan on adding RegEx support (due to its complex nature and overall user-unfriendliness), I do plan on adding support for Minecraft tags in a future update, which should address your primary concern of adding all logs just with #minecraft:logs
instead of listing each log individually.
I will keep this issue open as a pseudo tracker for this task, but you may also refer to #109 instead for the future update plans.
lol, I appreciate the emoji.
I have a few issues with regular expression or wildcard syntax (exception to just *
, but even that I was against for a while and sort of had to hack in) that has kept me from adding it to VeinMiner's config:
- It's difficult to read or use from a user configuration standpoint
- It can lead to unexpected additions to the block list in future versions of the game, or even just in general if you messed up your RegEx and included blocks you didn't want to include
- Maintaining the list of blocks both in-game and in the config.yml is sort of difficult. I wish I had a better way to go about doing this, but the way these blocks are designed now it requires one
VeinMinerBlock
instance for each entry in a block list. Adding/removing a block from a list is then predictable and easy to convert from string <---> object instance so that serialization is just as easy as deserialization.
I think to some extent I would like to at the very least support tags. It's something that's been brewing in my mind for years now, just being able to add all logs with - '#minecraft:logs
would be fantastic. Though again, this boils down to how the block list is implemented and deserialized, and the unspoken axiom that 1 string entry in a block list equals 1 instance on the server. This functionality is something that's needed rethought and redesigned for years and I just have not come up with a good solution.
TL;DR: I want to support tags, I'm iffy on RegEx due to unpredictability and unreadability for most users, and VeinMiner's block list loading needs to be ripped out and redesigned if I want to do anything other than 1:1 mappings of block list entries.
Something like this would work, right?
Yes it would work and that was my original approach, but my largest issue with it is that values need to get saved to the config from memory as well and if individual block instances are created for all values in a Tag, we then lose the ability to re-save it as a tag if the list is changed via command.
I may revisit the block list handling myself after 2.1.1 is released and focus efforts on cleaning things up for a 2.2.0 release.
EDIT: Worth noting also that I am improving Bukkit's Tag
APIs sometime in the very near future so I suspect it should be easier to interact with tags after the fact. I would be willing to drop support for older versions if I rely on modern Tag changes. Those will likely come with the BlockType
changes as well anyways.
Tag<Material> logsTag = plugin.getServer().getTag(Tag.REGISTRY_BLOCKS, NamespacedKey.fromString("minecraft:logs"), Material.class);
Something like this would work, right? Could even integrate that into the current system as far as I can tell (Get Materials by .getValues()
-> loop over them and create BlockData
-> do the rest that the config parsing is doing already).