mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-27 21:27:44 +01:00
Improved javadoc
This commit is contained in:
parent
b7bc63249e
commit
3f5736f555
@ -82,7 +82,7 @@ public class Island implements DataObject {
|
||||
|
||||
//// Team ////
|
||||
@Expose
|
||||
private UUID owner;
|
||||
private @Nullable UUID owner;
|
||||
|
||||
@Expose
|
||||
private Map<UUID, Integer> members = new HashMap<>();
|
||||
@ -527,7 +527,7 @@ public class Island implements DataObject {
|
||||
* Sets the owner of the island.
|
||||
* @param owner the island owner - the owner to set
|
||||
*/
|
||||
public void setOwner(UUID owner){
|
||||
public void setOwner(@Nullable UUID owner){
|
||||
if (this.owner == owner) {
|
||||
return; //No need to update anything
|
||||
}
|
||||
|
@ -33,6 +33,9 @@ import world.bentobox.bentobox.lists.Flags;
|
||||
public class IslandWorldManager {
|
||||
|
||||
private BentoBox plugin;
|
||||
/**
|
||||
* Map associating Worlds (Overworld, Nether and End) with the GameModeAddon that creates them.
|
||||
*/
|
||||
private Map<@NonNull World, @NonNull GameModeAddon> gameModes;
|
||||
|
||||
/**
|
||||
@ -60,7 +63,7 @@ public class IslandWorldManager {
|
||||
*
|
||||
* @param world the World to register
|
||||
*/
|
||||
private void registerToMultiverse(World world) {
|
||||
private void registerToMultiverse(@NonNull World world) {
|
||||
if (!isUseOwnGenerator(world) && plugin.getHooks() != null) {
|
||||
plugin.getHooks().getHook("Multiverse-Core").ifPresent(hook -> {
|
||||
if (Bukkit.isPrimaryThread()) {
|
||||
|
@ -58,20 +58,20 @@ public class IslandCache {
|
||||
|
||||
/**
|
||||
* Adds a player's UUID to the look up for islands. Does no checking
|
||||
* @param uuid - player's uuid
|
||||
* @param island - island to associate with this uuid. Only one island can be associated per world.
|
||||
* @param uuid player's uuid
|
||||
* @param island island to associate with this uuid. Only one island can be associated per world.
|
||||
*/
|
||||
public void addPlayer(UUID uuid, Island island) {
|
||||
public void addPlayer(@NonNull UUID uuid, @NonNull Island island) {
|
||||
islandsByUUID.putIfAbsent(island.getWorld(), new HashMap<>());
|
||||
islandsByUUID.get(island.getWorld()).put(uuid, island);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an island to the grid register
|
||||
* @param newIsland - new island
|
||||
* @param newIsland new island
|
||||
* @return true if successfully added, false if not
|
||||
*/
|
||||
private boolean addToGrid(Island newIsland) {
|
||||
private boolean addToGrid(@NonNull Island newIsland) {
|
||||
grids.putIfAbsent(newIsland.getWorld(), new IslandGrid());
|
||||
return grids.get(newIsland.getWorld()).addToGrid(newIsland);
|
||||
}
|
||||
@ -83,10 +83,10 @@ public class IslandCache {
|
||||
|
||||
/**
|
||||
* Deletes an island from the database. Does not remove blocks
|
||||
* @param island - island to delete
|
||||
* @param island island to delete
|
||||
* @return true if successful, false if not
|
||||
*/
|
||||
public boolean deleteIslandFromCache(Island island) {
|
||||
public boolean deleteIslandFromCache(@NonNull Island island) {
|
||||
if (!islandsByLocation.remove(island.getCenter(), island) || !islandsByUUID.containsKey(island.getWorld())) {
|
||||
return false;
|
||||
}
|
||||
@ -98,20 +98,22 @@ public class IslandCache {
|
||||
|
||||
/**
|
||||
* Get island based on the exact center location of the island
|
||||
* @param location - location to search for
|
||||
* @param location location to search for
|
||||
* @return island or null if it does not exist
|
||||
*/
|
||||
public Island get(Location location) {
|
||||
@Nullable
|
||||
public Island get(@NonNull Location location) {
|
||||
return islandsByLocation.get(location);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns island referenced by UUID
|
||||
* @param world - world to check
|
||||
* @param uuid - player
|
||||
* @param world world to check
|
||||
* @param uuid player
|
||||
* @return island or null if none
|
||||
*/
|
||||
public Island get(World world, UUID uuid) {
|
||||
@Nullable
|
||||
public Island get(@NonNull World world, @NonNull UUID uuid) {
|
||||
return islandsByUUID.containsKey(Util.getWorld(world)) ? islandsByUUID.get(Util.getWorld(world)).get(uuid) : null;
|
||||
}
|
||||
|
||||
@ -119,26 +121,33 @@ public class IslandCache {
|
||||
* Returns the island at the location or null if there is none.
|
||||
* This includes the full island space, not just the protected area
|
||||
*
|
||||
* @param location - the location
|
||||
* @param location the location
|
||||
* @return Island object
|
||||
*/
|
||||
public Island getIslandAt(Location location) {
|
||||
if (location == null || !grids.containsKey(Util.getWorld(location.getWorld()))) {
|
||||
@Nullable
|
||||
public Island getIslandAt(@NonNull Location location) {
|
||||
if (!grids.containsKey(Util.getWorld(location.getWorld()))) {
|
||||
return null;
|
||||
}
|
||||
return grids.get(Util.getWorld(location.getWorld())).getIslandAt(location.getBlockX(), location.getBlockZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an <strong>unmodifiable collection</strong> of all the islands (even those who may be unowned).
|
||||
* @return unmodifiable collection containing every island.
|
||||
*/
|
||||
@NonNull
|
||||
public Collection<Island> getIslands() {
|
||||
return Collections.unmodifiableCollection(islandsByLocation.values());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param world - world to check
|
||||
* @param uuid - uuid of player to check
|
||||
* @param world world to check
|
||||
* @param uuid uuid of player to check
|
||||
* @return set of UUID's of island members. If there is no island, this set will be empty
|
||||
*/
|
||||
public Set<UUID> getMembers(World world, UUID uuid) {
|
||||
@NonNull
|
||||
public Set<UUID> getMembers(@NonNull World world, @NonNull UUID uuid) {
|
||||
islandsByUUID.putIfAbsent(Util.getWorld(world), new HashMap<>());
|
||||
Island island = islandsByUUID.get(Util.getWorld(world)).get(uuid);
|
||||
if (island != null) {
|
||||
@ -153,7 +162,7 @@ public class IslandCache {
|
||||
* @return island owner's UUID, the player UUID if they are not in a team, or null if there is no island
|
||||
*/
|
||||
@Nullable
|
||||
public UUID getOwner(World world, UUID uuid) {
|
||||
public UUID getOwner(@NonNull World world, @NonNull UUID uuid) {
|
||||
islandsByUUID.putIfAbsent(Util.getWorld(world), new HashMap<>());
|
||||
Island island = islandsByUUID.get(Util.getWorld(world)).get(uuid);
|
||||
if (island != null) {
|
||||
@ -163,11 +172,11 @@ public class IslandCache {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param world - the world to check
|
||||
* @param uuid - the player
|
||||
* @param world the world to check
|
||||
* @param uuid the player
|
||||
* @return true if player has island and owns it
|
||||
*/
|
||||
public boolean hasIsland(World world, UUID uuid) {
|
||||
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);
|
||||
@ -176,11 +185,12 @@ public class IslandCache {
|
||||
/**
|
||||
* Removes a player from the cache. If the player has an island, the island owner is removed and membership cleared.
|
||||
* The island is removed from the islandsByUUID map, but kept in the location map.
|
||||
* @param world - world
|
||||
* @param uuid - player's UUID
|
||||
* @param world world
|
||||
* @param uuid player's UUID
|
||||
* @return island player had or null if none
|
||||
*/
|
||||
public Island removePlayer(World world, UUID uuid) {
|
||||
@Nullable
|
||||
public Island removePlayer(@NonNull World world, @NonNull UUID uuid) {
|
||||
world = Util.getWorld(world);
|
||||
islandsByUUID.putIfAbsent(world, new HashMap<>());
|
||||
Island island = islandsByUUID.get(world).get(uuid);
|
||||
@ -218,10 +228,10 @@ public class IslandCache {
|
||||
/**
|
||||
* Sets an island owner.
|
||||
* Clears out any other owner.
|
||||
* @param island - island
|
||||
* @param newOwnerUUID - new owner
|
||||
* @param island island
|
||||
* @param newOwnerUUID new owner
|
||||
*/
|
||||
public void setOwner(Island island, UUID newOwnerUUID) {
|
||||
public void setOwner(@NonNull Island island, @Nullable UUID newOwnerUUID) {
|
||||
island.setOwner(newOwnerUUID);
|
||||
islandsByUUID.putIfAbsent(Util.getWorld(island.getWorld()), new HashMap<>());
|
||||
islandsByUUID.get(Util.getWorld(island.getWorld())).put(newOwnerUUID, island);
|
||||
|
Loading…
Reference in New Issue
Block a user