diff --git a/src/main/java/world/bentobox/bentobox/database/objects/Island.java b/src/main/java/world/bentobox/bentobox/database/objects/Island.java index 3f64aa160..adc6d76fc 100644 --- a/src/main/java/world/bentobox/bentobox/database/objects/Island.java +++ b/src/main/java/world/bentobox/bentobox/database/objects/Island.java @@ -100,7 +100,7 @@ public class Island implements DataObject { //// Island History //// @Adapter(LogEntryListAdapter.class) - //FIXME: see https://github.com/BentoBoxWorld/BentoBox/issues/482 + @Expose private List history = new LinkedList<>(); @Expose diff --git a/src/main/java/world/bentobox/bentobox/database/objects/adapters/LogEntryListAdapter.java b/src/main/java/world/bentobox/bentobox/database/objects/adapters/LogEntryListAdapter.java index d6af820b6..f37e2d314 100644 --- a/src/main/java/world/bentobox/bentobox/database/objects/adapters/LogEntryListAdapter.java +++ b/src/main/java/world/bentobox/bentobox/database/objects/adapters/LogEntryListAdapter.java @@ -1,11 +1,14 @@ package world.bentobox.bentobox.database.objects.adapters; +import org.eclipse.jdt.annotation.NonNull; import world.bentobox.bentobox.api.logs.LogEntry; +import java.util.HashMap; import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.UUID; /** * @author Poslovitch @@ -63,11 +66,35 @@ public class LogEntryListAdapter implements AdapterInterface, Lis Map value = new LinkedHashMap<>(); value.put(TIMESTAMP, logEntry.getTimestamp()); value.put(TYPE, logEntry.getType()); - value.put(DATA, logEntry.getData()); + + if (logEntry.getData() != null) { + value.put(DATA, tidy(logEntry.getData())); + } result.add(value); }); return result; } + + /** + * Returns a "data" map that contains "tidied up" values, as some types are not safe to store 'as is'. + * See https://github.com/BentoBoxWorld/BentoBox/issues/486 + * @param data the data map to tidy up + * @return the tidied up data map + * @since 1.1.1 + */ + @NonNull + private Map tidy(@NonNull Map data) { + Map result = new HashMap<>(); + for (Map.Entry entry : data.entrySet()) { + if (entry.getValue() instanceof UUID) { + // UUIDs need some special handling + result.put(entry.getKey(), entry.getValue().toString()); + } else { + result.put(entry.getKey(), entry.getValue()); + } + } + return result; + } }