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

Add hologram Converter API #173

Merged
merged 7 commits into from
Dec 26, 2024
Merged

Conversation

Matt-MX
Copy link
Contributor

@Matt-MX Matt-MX commented Dec 21, 2024

Adds the HologramConverter interface for creating multiple converter implementations.

e.g. a builtin DecentHologramsConverter that converts lines and optionally attempts to convert icons to item holograms that align with the text

Adds the FHConversionRegistry to store and procure all HologramConverter.
Adds the /fancyholograms convert <converterId> <target> [args...] command to invoke the converters.
Adds the ConverterTarget class which is essentially a regex to target holograms individually or as groups.

An example of API usage:

ConverterTarget target = ConverterTarget.all();

// The constructor can also take in a CommandSender sender  and String[] args for logging results/errors and processing additional arguments.
HologramConversionSession session = new HologramConversionSession(target);

FHConversionRegistry.getConverterById("DecentHolograms")
  .ifPresent((converter) -> {
    List<HologramData> data = converter.convert(session);

    // Handle the data yourself e.g. add it to manager and save.
  });

@Matt-MX
Copy link
Contributor Author

Matt-MX commented Dec 21, 2024

This additionally allows players to control translation of holograms through the command /holo edit <hologram> translation <x> <y> <z>

Copy link
Member

@OliverSchlueter OliverSchlueter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I type "/fancyholograms convert DecentHolograms " and then press tab, it throws an exception "DecentHolograms holograms folder doesn't exist or is empty"
I probably wound't suggest DecentHolograms at all, when the folder is empty or doesn't exists.
There are a few TODO comments in the DecentHologramsConverter class, idk if you wanted to solve them.
LGTM otherwise

@Matt-MX
Copy link
Contributor Author

Matt-MX commented Dec 25, 2024

I'll have a look at the exception and finish the TODOs, I think it's just for handling errors.

@Matt-MX
Copy link
Contributor Author

Matt-MX commented Dec 26, 2024

@OliverSchlueter Should have fixed the thrown exception, also filters out any converters deemed not usable from tab completion.

@OliverSchlueter OliverSchlueter merged commit 948ebf0 into FancyMcPlugins:main Dec 26, 2024
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.

2 participants