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

1.21 Compability #176

Open
gurkleffe opened this issue Jun 30, 2024 · 16 comments
Open

1.21 Compability #176

gurkleffe opened this issue Jun 30, 2024 · 16 comments
Assignees
Labels
enhancement New feature or request

Comments

@gurkleffe
Copy link

I've tried running the plugin with Minecraft 1.21 which gives the error Encountered an error parsing currency. Please check your Gringotts configuration. Error was: amount must be greater than 0, followed by these messages:

[15:16:38 INFO]: [Gringotts] Disabling Gringotts v2.12.5
[15:16:38 INFO]: [Gringotts] Disabling dependency Towny
[15:16:38 INFO]: [Gringotts] Disabling dependency Vault
[15:16:38 INFO]: [Gringotts] disabled
[15:16:38 WARN]: [Gringotts] Gringotts disabled due to startup errors.

There is also another error which seems to be related to this and which is triggered earlier than the ones mentioned above:

[15:25:38 ERROR]: [com.avaje.ebean.config.PropertyMapLoader] ebean.properties not found

I'd love to see a new version of it being compatible!

@gurkleffe gurkleffe added the enhancement New feature or request label Jun 30, 2024
@sprydagger
Copy link

sprydagger commented Jul 3, 2024

Exact same problem. I am hosting it on falixnodes and also have Chestshop, Dynmap, floodgate, geyser, gringotts, maptowny, towny, townychat, townycombat, townyprovinces, and vault installed.

[11:32:28 ERROR]: [com.avaje.ebean.config.PropertyMapLoader] ebean.properties not found

[11:20:00 ERROR]: [Gringotts] Encountered an error parsing currency. Please check your Gringotts configuration. Error was: amount must be greater than 0
[11:20:00 INFO]: [Gringotts] Disabling Gringotts v2.12.7-SNAPSHOT
[11:20:00 INFO]: [Gringotts] Disabling dependency Vault
[11:20:00 INFO]: [Gringotts] disabled
[11:20:00 WARN]: [Gringotts] Gringotts disabled due to startup errors.

@beepee123
Copy link

I'm not a git pro or a programmer, BUT I was able to fix/work around this (probably incorrectly) by changing line 106 of Configuration.java:

Change:
return new ItemStack(material, 0);
to
return new ItemStack(material, 1);

and recompile. With this hack, was able to get the mod to successfully load on paper-1.21-63.jar

Haven't done much testing yet, just running a small server for my kids. Hope this helps someone!

@XorrDev
Copy link

XorrDev commented Jul 19, 2024

Hi. I'm going to try to do the same. Where is the configuration.java file located?

@Shadownite7
Copy link

I'm not a git pro or a programmer, BUT I was able to fix/work around this (probably incorrectly) by changing line 106 of Configuration.java:

Change: return new ItemStack(material, 0); to return new ItemStack(material, 1);

and recompile. With this hack, was able to get the mod to successfully load on paper-1.21-63.jar

Haven't done much testing yet, just running a small server for my kids. Hope this helps someone!

This may have got the plugin to compile with 1.21 but I am unable to withdraw/deposit money

@DocSplinters
Copy link

Same situation, including me not being much of a (Java) programmer. To make the plugin load I've changed the same line in itemByName() to
return new ItemStack(material);
and compiled (same consequence behind the scenes, amount is set to 1 instead of 0). I have a much bigger issue though: My currency item is poisonous_potato, and in v1.20.6 the commands /balance and /money showed the correct amounts in inventory and my vault (e.g. 30). However, in v1.21 the overall balance is much higher (~200!) and also, regular potatoes add to my balance, i.e. after harvesting my potato patch (and only gaining one poisonous potato) my balance was up to 500+ instead of 31. It is counting regular potatoes for sure because my balance changes when I remove them from my inventory by tossing them on the ground or putting them into a chest that's not my vault.

@DocSplinters
Copy link

Hi. I'm going to try to do the same. Where is the configuration.java file located?

You have to clone this repository, then edit the file \src\main\java\org\gestern\gringotts\Configuration.java as described and compile the whole thing using Apache Maven.

@DocSplinters
Copy link

[...] It is counting regular potatoes for sure [...]

Correction: It is counting everything in my inventory, including armor and off-hand items. Please see the attached pictures showing the difference between 60 carrots on the ground vs. in my hot bar.
2024-07-22_21 37 44
2024-07-22_21 38 09

@DocSplinters
Copy link

ebean.properties not found

@gurkleffe - This error is fixed by creating an empty file called "ebean.properties" in the server's main directory, the same place your server.jar, server.properties ... live. The ebean Java classes provide database connectivity, that's what Gringotts is using to interact with its SQLite database.

@DrJekyllH
Copy link

DrJekyllH commented Jul 27, 2024

According to my survey to the source code,
It can't get the currency correctly on balance() in AccountInvenrtory.java,
or
It can't get the denomination material correctly on getDenominationOf() in GringottsCurrency.java.

Even though the Material of Denomination is set to Emerald in the configuration file, it is AIR in the code. As a result, withdraw/deposit may be made in AIR.

1.20.6
image

1.21
image

@DocSplinters
Copy link

DocSplinters commented Aug 1, 2024

@DrJekyllH Thanks for your post, it gave me the idea to print to stdout, since the logger can't be used everywhere ...

My search also led me to the method getDenominationOf(ItemStack stack) in GringottsCurrency.java. I added the line
System.out.println("Map 'denoms' " + (denoms.containsKey(d) ? "contains": "does NOT contain") + " a value for key " + d.typeMaterial.toString());
right before
return denoms.get(d);
and compiled/tested with some poisonous potatoes (my currency) and some sand in my vault. With v1.20.6 the output is:
[18:00:15] [Server thread/INFO]: [Gringotts] [STDOUT] Map 'denoms' contains a value for key POISONOUS_POTATO
[18:00:15] [Server thread/INFO]: [Gringotts] [STDOUT] Map 'denoms' does NOT contain a value for key SAND
while with v1.21 it is:
[18:10:13] [Server thread/INFO]: [Gringotts] [STDOUT] Map 'denoms' contains a value for key POISONOUS_POTATO
[18:10:13] [Server thread/INFO]: [Gringotts] [STDOUT] Map 'denoms' contains a value for key SAND

Somehow I figured out that "denoms" - an instance of "Map<Denominationkey, Denomination>" is using the method equals(Object o) in Denominationkey.java when checking if sand is a valid currency, so I added the line
System.out.println("DenominationKey for " + this.type.toString() + (this.type.equals (that.type) ? " equals" : does NOT equal") + " that for " + that.type.toString());
just before the return statement. With v1.20.6 this leads to:
[19:18:06] [Server thread/INFO]: [Gringotts] [STDOUT] DenominationKey for ItemStack{POISONOUS_POTATO X 0} equals that for ItemStack{ POISONOUS POTATO x 0}
while with 1.21 I got:
[19:25:01] [Server thread/INFO]: [Gringotts] [STDOUT] Denominationkey for ItemStack{AIR x 0} equals that for ItemStack{AIR x 0}
[19:25:01] [Server thread/INFO]: [Gringotts] [STDOUT] Map 'denoms' contains a value for key POISONOUS_POTATO
[19:25:01] [Server thread/INFO]: [Gringotts] [STDOUT] Denominationkey for ItemStack{AIR x 0} equals that for ItemStack{AIR X 0}
[19:25:01] [Server thread/INFO]: [Gringotts] [STDOUT] Map 'denoms' contains a value for key SAND
So as @DrJekyllH already found - instead of looking at emeralds, poisonous potatoes and sand - the plugin is always looking at air, and everything is a match.

What I eventually noticed was the "ItemStack{AIR x 0}". At the beginning of this issue, it was first determined by @beepee123 that
return new ItemStack (material, 0);
will keep the plugin from starting up successfully, so that might be related to why we're getting "{AIR x 0}" instead of "{EMERALD x 0}" or "{ POISONOUS_POTATO x 0}". What I did to fix that was changing
private final Map<Denominationkey, Denomination> denoms = new HashMap<>();
in GringottsCurrency.java to
private final Map<Material, Denomination> denoms = new HashMap<>();
so we don't end up with the ItemStack constructor trouble inside the code of the class java.util.Map which we don't have any control over. This requires two more lines in GringottsCurrency.java to change, namely
denoms.put(k, d);
in the method addDenomination(...) to
denoms.put(k.typeMaterial, d);
and
return denoms.get(d);
in the method getDenominationOf(ItemStack stack) to
return denoms.get(d.typeMaterial);

With those changes made, /balance resp. /money are now coming up with the correct amounts. However, /deposit and /withdraw still don't work ... Maybe the change in the ItemStack constructor is breaking things in more places, or maybe it's a different issue, I don't know. Just wanted to post what I've found so far, hoping this can get someone who's more proficient with Java and Minecraft plugins on the (hopefully) right track!

@DocSplinters
Copy link

Found a better solution, one that's less invasive AND seems to fix /deposit and /withdraw, please see pull request #178.

In a nutshell: Leave the Map instance "denoms" alone, instead add denominations with amount 1 in the DenominationKey constructor.

@DrJekyllH
Copy link

I tested #178 by @DocSplinters under the Paper 1.21
As a result, it seems to work fine for me.
Thank you.

@DrJekyllH
Copy link

DrJekyllH commented Aug 2, 2024

I am not familiar with the etiquette of Github and the open source community, and I am concerned that introducing an alternative plugin here violates that etiquette.
If there is any issue, I will delete this post immediately.

Since it was discovered that gringotts is not compatible with 1.21, I was looking for an alternative plugin in parallel with fixing the source.
I found the following modern plugin.
It is not full-featured yet, but there are very few plugins that have this kind of functionality and work properly.

Until an official 1.21-compatible version of gringotts is released, using this alternative plugin is an option.

banco
https://www.spigotmc.org/resources/banco-1-20-1-21-item-based-economy.118393/
I am on the Discord for this plugin and the author has listened to the users and is actively developing it.

@DocSplinters
Copy link

N00b question: What's the next step, just waiting for the maintainers of this repo to decide whether they want to incorporate #178? Or is there anything I can or have to do to move forward?

@nikosgram
Copy link
Owner

@DocSplinters that's correct :) I'm currently running tests to ensure that is compatible with older versions of Gringotts and is not gonna cause any issues updating to the new version as they are a lot of changes. :)

@GroobleDierne
Copy link

Spoiler: there are breaking changes, so you will need to update your database, I'm currently writing instructions on how to do that. The good news is that you will likely never have to do it again for future versions as it will be automatic from now on.
Instructions should be published by the end of the day.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

9 participants