Skip to content

Support wildcards in world name lists - #886

Open
HyperGaming99 wants to merge 1 commit into
Winds-Studio:ver/26.2from
HyperGaming99:feat/world-list-wildcards
Open

Support wildcards in world name lists#886
HyperGaming99 wants to merge 1 commit into
Winds-Studio:ver/26.2from
HyperGaming99:feat/world-list-wildcards

Conversation

@HyperGaming99

Copy link
Copy Markdown
Contributor

Closes #807.

World name lists in the config can now use * as a wildcard instead of spelling out every world:

misc:
  disable-world-data-saving:
    worlds:
      - auth_lobby   # exact name, as before
      - hub*         # hub01, hub02, ...
      - '*hub*'      # every world whose name contains "hub"

* matches any (possibly empty) sequence of characters, and a pattern has to match the whole
name, so hub* does not match myhub01. Entries without * keep being matched exactly, so
existing configs behave exactly as before.

Implementation

org.dreeam.leaf.config.WorldList holds the exact names in a HashSet and compiles the
wildcard entries into Patterns once at config load, so matching does no per-call parsing.
DisableWorldDataSaving.shouldSkipSave keeps its isEmpty() short circuit, meaning servers
that do not use the option pay nothing. The only call sites are chunk/entity/POI saving and
ServerLevel#save, next to NBT serialization and disk IO, so a regex match there is noise.

Currently disable-world-data-saving.worlds is the only world list in the config; WorldList
is written so any future one can reuse it.

Notes

The issue proposed a --hub prefix to mean "contains". I went with * instead: it expresses
contains (*hub*), prefix (hub*) and suffix (*hub) with the same syntax, it is the
convention users already know, and * is not a legal character in world folder names on
Windows, so it cannot collide with an existing exact entry. Happy to switch to another syntax
if you prefer.

Matching is case sensitive, like world folder names.

Testing

Verified against the compiled class with assertions covering: regex metacharacters in world
names staying literal (a+b, c(d), e.f*, *g|h), Pattern.quote with an embedded \E,
multiple and adjacent wildcards, anchoring (hub not matching hub01), unicode names,
case sensitivity, and blank/null entries being skipped.

World lists in the config now accept '*' as a wildcard, so 'hub*' or
'*hub*' can be used instead of listing every world by name. Entries
without '*' keep matching exactly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] new world list system

1 participant