diff --git a/src/main/java/us/tastybento/bskyblock/api/commands/User.java b/src/main/java/us/tastybento/bskyblock/api/commands/User.java index db0e50deb..8ecf4b497 100644 --- a/src/main/java/us/tastybento/bskyblock/api/commands/User.java +++ b/src/main/java/us/tastybento/bskyblock/api/commands/User.java @@ -291,4 +291,39 @@ public class User { return player.performCommand(cmd); } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((playerUUID == null) ? 0 : playerUUID.hashCode()); + return result; + } + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (!(obj instanceof User)) { + return false; + } + User other = (User) obj; + if (playerUUID == null) { + if (other.playerUUID != null) { + return false; + } + } else if (!playerUUID.equals(other.playerUUID)) { + return false; + } + return true; + } } diff --git a/src/main/java/us/tastybento/bskyblock/database/flatfile/FlatFileDatabaseHandler.java b/src/main/java/us/tastybento/bskyblock/database/flatfile/FlatFileDatabaseHandler.java index 2f5e7c58c..d7053d798 100644 --- a/src/main/java/us/tastybento/bskyblock/database/flatfile/FlatFileDatabaseHandler.java +++ b/src/main/java/us/tastybento/bskyblock/database/flatfile/FlatFileDatabaseHandler.java @@ -196,19 +196,21 @@ public class FlatFileDatabaseHandler extends AbstractDatabaseHandler { } // TODO: this may not work with all keys. Further serialization may be required. Map value = new HashMap<>(); - for (String key : config.getConfigurationSection(storageLocation).getKeys(false)) { - // Keys cannot be null - skip if they exist - Object mapKey = deserialize(key,Class.forName(keyType.getTypeName())); - if (mapKey == null) { - continue; + if (config.getConfigurationSection(storageLocation) != null) { + for (String key : config.getConfigurationSection(storageLocation).getKeys(false)) { + // Keys cannot be null - skip if they exist + Object mapKey = deserialize(key,Class.forName(keyType.getTypeName())); + if (mapKey == null) { + continue; + } + // Map values can be null - it is allowed here + Object mapValue = deserialize(config.get(storageLocation + "." + key), Class.forName(valueType.getTypeName())); + if (DEBUG) { + plugin.getLogger().info(() -> "DEBUG: mapKey = " + mapKey + " (" + mapKey.getClass().getCanonicalName() + ")"); + plugin.getLogger().info(() -> "DEBUG: mapValue = " + mapValue); + } + value.put(mapKey, mapValue); } - // Map values can be null - it is allowed here - Object mapValue = deserialize(config.get(storageLocation + "." + key), Class.forName(valueType.getTypeName())); - if (DEBUG) { - plugin.getLogger().info(() -> "DEBUG: mapKey = " + mapKey + " (" + mapKey.getClass().getCanonicalName() + ")"); - plugin.getLogger().info(() -> "DEBUG: mapValue = " + mapValue); - } - value.put(mapKey, mapValue); } method.invoke(instance, value); } else if (Set.class.isAssignableFrom(propertyDescriptor.getPropertyType())) {