Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regex Support for Block/Tool Lists #100

Open
meekachuwu opened this issue Aug 8, 2023 · 4 comments
Open

Regex Support for Block/Tool Lists #100

meekachuwu opened this issue Aug 8, 2023 · 4 comments
Labels
enhancement A feature request or enhancement proposal help wanted Open to discussion on how to tackle an issue. Perhaps another contributor can attempt a fix/change

Comments

@meekachuwu
Copy link

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.

ಥ⌓ಢ

@2008Choco
Copy link
Owner

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:

  1. It's difficult to read or use from a user configuration standpoint
  2. 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
  3. 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.

@2008Choco 2008Choco added enhancement A feature request or enhancement proposal help wanted Open to discussion on how to tackle an issue. Perhaps another contributor can attempt a fix/change labels Aug 8, 2023
@DreamyLynn
Copy link
Contributor

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).

@2008Choco
Copy link
Owner

2008Choco commented Aug 25, 2023

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.

@2008Choco
Copy link
Owner

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.

2008Choco added a commit that referenced this issue Sep 8, 2024
I still think this feature should wait until Bukkit's Tag API is improved and BlockType and ItemType are better integrated into the API. But for now this should at least work as expected.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A feature request or enhancement proposal help wanted Open to discussion on how to tackle an issue. Perhaps another contributor can attempt a fix/change
Projects
None yet
Development

No branches or pull requests

3 participants