Slimefun / Slimefun4

Slimefun 4 - A unique Spigot/Paper plugin that looks and feels like a modpack. We've been giving you backpacks, jetpacks, reactors and much more since 2013.
GNU General Public License v3.0
968 stars 543 forks source link

:sparkles: feat(api): Introduce SlimefunItemRegistryFinalizedEvent #4099

Closed ProfElements closed 9 months ago

ProfElements commented 9 months ago

Description

This Event is provided so that plugins that have integrations with each other aren't stuck in a state in which some SlimefunItems may not be available to one plugin or the other.

I will use this event to provide a cleaner integration between Dynatech and other plugins. Currently InfinityXpansion, ExoticGarden, and Gastronomicon.

Proposed changes

Make an event to be able to listen to Slimefun's Registry finalizing all static items.

Checklist

github-actions[bot] commented 9 months ago
Pro Tip! You can help us label your Pull Requests by using the following branch naming convention next time you create a pull request. โค๏ธ Branch naming convention Label
feature/** ๐ŸŽˆ Feature
fix/** โœจ Fix
chore/** ๐Ÿงน Chores
api/** ๐Ÿ”ง API
performance/** ๐Ÿ’ก Performance Optimization
compatibility/** ๐Ÿค Compatibility

If your changes do not fall into any of these categories, don't worry. You can just ignore this message in that case! ๐Ÿ‘€

J3fftw1 commented 9 months ago

Can we get unit tests?

github-actions[bot] commented 9 months ago

Slimefun preview build

A Slimefun preview build is available for testing! Commit: a25a4e43

https://preview-builds.walshy.dev/download/Slimefun/4099/a25a4e43

Note: This is not a supported build and is only here for the purposes of testing. Do not run this on a live server and do not report bugs anywhere but this PR!

ProfElements commented 9 months ago

Fixed up according to suggestions

JustAHuman-xD commented 9 months ago

I'm not sure about the use case of this tbch, for example: if one addon waits for this event to then register its items to integrate with another addon, but then another addon waits for this event to integrate with that addon, then you would still have the same problem.

Currently if you soft depend on any addon you can utilize its items without any problem, in my experience anyways. I guess it depends on the addon but I've never experienced that not working.

The use case you have also provided encourages registering items, after load items is called, which feels wrong.

Idk this could just be me but I don't think this is the right solution.

ProfElements commented 9 months ago

I'm not sure about the use case of this tbch, for example: if one addon waits for this event to then register its items to integrate with another addon, but then another addon waits for this event to integrate with that addon, then you would still have the same problem.

Currently if you soft depend on any addon you can utilize its items without any problem, in my experience anyways. I guess it depends on the addon but I've never experienced that not working.

The use case you have also provided encourages registering items, after load items is called, which feels wrong.

Idk this could just be me but I don't think this is the right solution.

This probably isn't the right solution, but I'm currently in the situation when I want to integrate items into another project. Which I can't load after because its softdepend on DynaTech. I don't thing we should add items to registry after this point, I'm using it to add all my recipes using another projects items IE my SeedPlucker adding Gastro Seeds to its recipes. If you have a circular softdepend ie DynaTech softdepend on Gastronomicon, and Gastronomicon softdepend on DynaTech, they are loaded arbitrarily.

JustAHuman-xD commented 9 months ago

This probably isn't the right solution, but I'm currently in the situation when I want to integrate items into another project. Which I can't load after because its softdepend on DynaTech. I don't thing we should add items to registry after this point, I'm using it to add all my recipes using another projects items IE my SeedPlucker adding Gastro Seeds to its recipes

Ah so you're in a circular dependency problem. Which is similar to the issue I showed with this. One solution I can think of is you PR to gastro and make gastro add it to the seed plucker but yeah I get the problem.

I think what you may be able to do is something kinda like slimefun, slimefun adds a lot of recipes to machines on post register. So if all you want to do is add machine recipes, then this event is actually a good solution. In which case I misunderstood what this was meant for. I thought you meant registering items dependent on addons items ๐Ÿ˜…

ProfElements commented 9 months ago

Yeah Im sorry i know my explanation was kinda confusing