mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-24 11:45:31 +01:00
Added equals to User class
Added null check for FlatFileDB Handler.
This commit is contained in:
parent
5a3a557cf2
commit
b043e641a1
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -196,6 +196,7 @@ public class FlatFileDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
|
||||
}
|
||||
// TODO: this may not work with all keys. Further serialization may be required.
|
||||
Map<Object,Object> value = new HashMap<>();
|
||||
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()));
|
||||
@ -210,6 +211,7 @@ public class FlatFileDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
|
||||
}
|
||||
value.put(mapKey, mapValue);
|
||||
}
|
||||
}
|
||||
method.invoke(instance, value);
|
||||
} else if (Set.class.isAssignableFrom(propertyDescriptor.getPropertyType())) {
|
||||
if (DEBUG) {
|
||||
|
Loading…
Reference in New Issue
Block a user