mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-09-26 05:42:37 +02:00
Added IslandsManager and IslandCache#getIslands(World)
This commit is contained in:
parent
4e86441f6f
commit
edb6d11fc2
@ -356,7 +356,7 @@ public class IslandsManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an <strong>unmodifiable collection</strong> of all the islands (even those who may be unowned).
|
||||
* Returns an <strong>unmodifiable collection</strong> of all existing islands (even those who may be unowned).
|
||||
* @return unmodifiable collection containing every island.
|
||||
* @since 1.1
|
||||
*/
|
||||
@ -365,6 +365,17 @@ public class IslandsManager {
|
||||
return islandCache.getIslands();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an <strong>unmodifiable collection</strong> of all the islands (even those who may be unowned) in the specified world.
|
||||
* @param world World of the gamemode.
|
||||
* @return unmodifiable collection containing all the islands in the specified world.
|
||||
* @since 1.7.0
|
||||
*/
|
||||
@NonNull
|
||||
public Collection<Island> getIslands(@NonNull World world) {
|
||||
return islandCache.getIslands(world);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the IslandCache instance.
|
||||
* @return the islandCache
|
||||
|
@ -1,12 +1,15 @@
|
||||
package world.bentobox.bentobox.managers.island;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
@ -158,6 +161,23 @@ public class IslandCache {
|
||||
return Collections.unmodifiableCollection(islandsByLocation.values());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an <strong>unmodifiable collection</strong> of all the islands (even those who may be unowned) in the specified world.
|
||||
* @param world World of the gamemode.
|
||||
* @return unmodifiable collection containing all the islands in the specified world.
|
||||
* @since 1.7.0
|
||||
*/
|
||||
@NonNull
|
||||
public Collection<Island> getIslands(@NonNull World world) {
|
||||
World overworld = Util.getWorld(world);
|
||||
List<Island> islandsInWorld = islandsByLocation.entrySet().stream()
|
||||
.filter(entry -> overworld.equals(Util.getWorld(entry.getKey().getWorld()))) // shouldn't make NPEs
|
||||
.map(Map.Entry::getValue)
|
||||
.collect(Collectors.toCollection(ArrayList::new));
|
||||
|
||||
return Collections.unmodifiableCollection(islandsInWorld);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param world world to check
|
||||
* @param uuid uuid of player to check
|
||||
|
Loading…
Reference in New Issue
Block a user