GStefanowich / MC-Server-Protection

A (Minecraft) Fabric server administration mod
MIT License
27 stars 14 forks source link

Basic Grand Economy support - allow Grand Economy to use Sewing Machine currency #50

Open The-Fireplace opened 2 years ago

The-Fireplace commented 2 years ago

Hello, some of my users are requesting support for Sewing Machine Utilities currency in Grand Economy. Since I was unable to find any documentation here about it being available on Maven, I thought I would post something here to see if you can handle creating the adapter, or if you'd be open to a PR which does so. In short, here's what basic support would involve. If this is done, Grand Economy and mods that support it will be able to use Sewing Machine Utilities currency.

One other important note here, Grand Economy is designed to allow accounts which are not players as well as player accounts. This comes in handy for mods such as Clans, where a clan can have an account. I took a glance through MoneyUtils and saw that there is some online/offline player support there. I'm not sure if the offline player stuff will be able to handle UUIDs which are not players, so if not, some adjustments may have to be made to accommodate that before support can be added.

If you have any questions, feel free to ask here or reach out on Discord.

Bonus: If you're up for something a little more advanced, it would be neat if all the economy-using features of Sewing Machine Utilities could use Grand Economy when it's present, and by extension, other economies Grand Economy has integrated with. I have details on what all that would entail and how to make the soft dependency if you're interested, but that is out of scope for this issue. I can make a new one for that if you're open to the idea.

The-Fireplace-Minecraft-Mods/Grand-Economy#37

GStefanowich commented 2 years ago

Seems like something that would be interesting to implement.

Everything thus far in my mod has been it's own self-contained ecosystem. I started it early in Fabrics upbringing and AFAIK there weren't any economy APIs at the time, so I just rolled my own (Same goes for the permissions). I wanted to implement chest shops, so I had to implement currency as well.

I have plans to support other mods implementations of currency or permissions, it just comes down to free time and where I allocate it.

Do you have any examples of a mod that would trigger the isPlayer = false in Grand Economy? Towns in SewingMachine are given their own UUIDs separate from Player UUIDs to prevent collision. Currently towns don't have coffers, only players can hold money. Just to keep money management simplistic.

My best guess would be to give these non-player UUIDs a storage space and just act as the transaction handler. There's not really any other identifying information such as "Charge this town" or "This UUID comes from this mod", just that it's a non-player.

The-Fireplace commented 2 years ago

I don't have any working examples of a non-player account for Fabric at the moment, I'm still in the process of rewriting the mods that use them. One other possibility to consider is the case where isPlayer is null, for if a mod doesn't know whether the UUID is being given for a player or not. I don't have any examples for that either, generally a mod should know whose currency it is interacting with. IIRC the whole "isPlayer" thing originated from integrating with some other economy system that required it to be set up like that; my own economy implementation doesn't care about it and only checks by UUID.