Fixed probable NPEs in IslandsManager and IslandCache

This commit is contained in:
Florian CUNY 2019-01-27 09:31:35 +01:00
parent e5170fc4b5
commit 1c3ccba3ae
2 changed files with 5 additions and 4 deletions

View File

@ -489,7 +489,8 @@ public class IslandsManager {
* @param playerUUID the player's UUID
* @return island owner's UUID or null if player has no island
*/
public UUID getOwner(World world, UUID playerUUID) {
@Nullable
public UUID getOwner(@NonNull World world, @NonNull UUID playerUUID) {
return islandCache.getOwner(world, playerUUID);
}
@ -686,8 +687,8 @@ public class IslandsManager {
* @param uniqueId - unique ID
* @return true if the player is the owner of their island.
*/
public boolean isOwner(World world, UUID uniqueId) {
return hasIsland(world, uniqueId) && getIsland(world, uniqueId).getOwner().equals(uniqueId);
public boolean isOwner(@NonNull World world, @NonNull UUID uniqueId) {
return hasIsland(world, uniqueId) && uniqueId.equals(getIsland(world, uniqueId).getOwner());
}
/**

View File

@ -179,7 +179,7 @@ public class IslandCache {
public boolean hasIsland(@NonNull World world, @NonNull UUID uuid) {
islandsByUUID.putIfAbsent(Util.getWorld(world), new HashMap<>());
Island island = islandsByUUID.get(Util.getWorld(world)).get(uuid);
return island != null && island.getOwner().equals(uuid);
return island != null && uuid.equals(island.getOwner());
}
/**