Decimals #2

Open
opened 2024-11-03 19:52:42 +01:00 by GinkAbu · 18 comments

We currently are using you ServerShop and it's perfect, however is it possible to implement decimals for prices e.g 1.00? As I'm adding all the prices from my datapack however they all include decimals, and I'm currently circumventing this issue by using a scale factor of 100 e.g 1.23 => 123.

Thanks for the ServerShop!!!

We currently are using you ServerShop and it's perfect, however is it possible to implement decimals for prices e.g 1.00? As I'm adding all the prices from my datapack however they all include decimals, and I'm currently circumventing this issue by using a scale factor of 100 e.g 1.23 => 123. Thanks for the ServerShop!!!
Owner

I intended to use the scale factor.
Is it really needed?

I intended to use the scale factor. Is it really needed?
Owner

Technically it is possible

Technically it is possible
Owner

Or I can just divide it by 100 when displaying to keep it fixed decimal point

Or I can just divide it by 100 when displaying to keep it fixed decimal point
Author

Yeah even on my datapack I started off using whole number then just dividing it by 100 when displaying which made things way easier. Another method I tried was storing the whole number as price1 and the decimals as price2 but that was way more complex.

Yeah even on my datapack I started off using whole number then just dividing it by 100 when displaying which made things way easier. Another method I tried was storing the whole number as price1 and the decimals as price2 but that was way more complex.
Owner

I could implement it as true floating point if I wanted to

I could implement it as true floating point if I wanted to
Author

Ow you could is it that not complex? I've had many issues trying to store a float value on scoreboard since it only handles integers.

Ow you could is it that not complex? I've had many issues trying to store a float value on scoreboard since it only handles integers.
Owner

This is a java mod. I have access to normal code. It would not be that complex actually

This is a java mod. I have access to normal code. It would not be that complex actually
Author

Ow would you not have to make major changes tho? Also how do you handle the price.dat info I'm currently adding this one by one, I'm trying to write a python code to convert snbt to nbt but having to errors as my datapack uses json.

Ow would you not have to make major changes tho? Also how do you handle the price.dat info I'm currently adding this one by one, I'm trying to write a python code to convert snbt to nbt but having to errors as my datapack uses json.
Author

I've just realised how much quicker /shop edit XD

I've just realised how much quicker /shop edit XD
Owner

This project has a CSV import as well. It can't import item metadata though.
I included the csv price thing.
And for the dat, it is a normal NBT file. Try it with a minecraft NBT editor.
There surely is a python option.

This project has a CSV import as well. It can't import item metadata though. I included the csv price thing. And for the dat, it is a normal NBT file. Try it with a minecraft NBT editor. There surely is a python option.
Owner
Everything about price storage is here: [https://git.brn.systems/BRNSystems/ServerShop/src/branch/main/src/main/java/systems/brn/servershop/lib/storages/PriceStorage.java](https://git.brn.systems/BRNSystems/ServerShop/src/branch/main/src/main/java/systems/brn/servershop/lib/storages/PriceStorage.java) Feel free to explore the code.
Author

I began editing the prices file, should I continue to use the scale factor method of wait until a decimals update?

Thanks.

I began editing the prices file, should I continue to use the scale factor method of wait until a decimals update? Thanks.
Owner

Could you test this build for me?
https://modrinth.com/mod/servershop/version/ZvaH9AeR

Could you test this build for me? https://modrinth.com/mod/servershop/version/ZvaH9AeR
Author

sure

sure
Owner

Is it working?

Is it working?
Author

Works perfectly!!!

Works perfectly!!!
Author

There seems to be an error when trying /balance list, I get incorrect argument as a player and the second error as admin.

image.png image.png
There seems to be an error when trying /balance list, I get incorrect argument as a player and the second error as admin. <img width="718" alt="image.png" src="attachments/eb94dda6-3cf8-49d4-a678-29ee464d53ce"> <img width="722" alt="image.png" src="attachments/971cd8ff-6434-4a0d-9b99-43fc8d9cb1aa">
275 KiB
145 KiB
Owner

Is this an offline mode server?
I have added a check here so it does not crash.
The next release will have it.

Is this an offline mode server? I have added a check here so it does not crash. The next release will have it.
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: BRNSystems/ServerShop#2
No description provided.