Towny Classic

Towny Classic

3.2k Downloads

ListDataField meatadata type doesn't work

Lemar98 opened this issue ยท 5 comments

commented

What steps will reproduce the problem?

I'm using following code:
ListDataField listDataField = new ListDataField(Const.MY_META_KEY); listDataField.getValue().add(new StringDataField(Const.MY_META_KEY, "test value")); government.addMetaData(listDataField, true);

but after server restart got error
[23:48:47 WARN]: [Towny] Error loading metadata for towny object com.palmergames.bukkit.towny.object.Towntest! java.io.IOException: com.google.gson.stream.MalformedJsonException: Unterminated array at line 1 column 41 path $[0][3]

What is the expected output?

ListDataField must be loaded from flatfile correctly

Towny version

0.101.2.3

Server version

paper 1.20.4

Please use Pastebin.com to link the following files

https://pastebin.com/cvr1L57F

commented

Provide the data/towns/town.txt file for the town please

commented

Provide the data/towns/town.txt file for the town please

https://pastebin.com/CN0QAfWV

commented

Provided feedback in Towny Discord explaining how their code causes a malformed json object.

commented

Provided feedback in Towny Discord explaining how their code causes a malformed json object.

thank
I am answer to you in Towny Discord too

commented

I am experiencing the same issue with the identical error message on startup. It only occurs when using flatfile. It works as expected on mysql. The mysql and flatfile metadata contents looks identical to each other.
The code I am using is:

List<CustomDataField<?>> nationMeta = new ArrayList<>();
nationMeta.add(new StringDataField("plugin_nationstring", nationString));
ListDataField ldf = new ListDataField("plugin_nationinfo", nationMeta, "Info");
nation.addMetaData(ldf);