Skip to content

Commit 025b2d4

Browse files
committed
Added API to construct an island with a specified protection size.
1 parent b562aaf commit 025b2d4

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/main/java/world/bentobox/bentobox/managers/IslandsManager.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,23 @@ public Island createIsland(@NonNull Location location) {
248248
*/
249249
@Nullable
250250
public Island createIsland(@NonNull Location location, @Nullable UUID owner) {
251-
Island island = new Island(location, owner, plugin.getIWM().getIslandProtectionRange(location.getWorld()));
251+
return createIsland(location, owner, plugin.getIWM().getIslandProtectionRange(location.getWorld()));
252+
}
253+
254+
/**
255+
* Create an island with owner, and a specified protection range. Note this does not paste blocks. It just creates
256+
* the island data object.
257+
*
258+
* @param location the location, not null
259+
* @param owner the island owner UUID, may be null
260+
* @param protectionRange size of protection range
261+
* @return Island or null if the island could not be created for some reason
262+
* @since 3.10.0
263+
*/
264+
public Island createIsland(@NonNull Location location, @Nullable UUID owner, int protectionRange) {
265+
Island island = new Island(location, owner, protectionRange);
252266
// Game the gamemode name and prefix the uniqueId
253-
String gmName = plugin.getIWM().getAddon(location.getWorld()).map(gm -> gm.getDescription().getName())
254-
.orElse("");
267+
String gmName = plugin.getIWM().getAddon(location.getWorld()).map(gm -> gm.getDescription().getName()).orElse("");
255268
island.setGameMode(gmName);
256269
island.setUniqueId(gmName + island.getUniqueId());
257270
if (islandCache.addIsland(island)) {
@@ -265,6 +278,7 @@ public Island createIsland(@NonNull Location location, @Nullable UUID owner) {
265278
}
266279
return null;
267280
}
281+
268282

269283
/**
270284
* Deletes island.

0 commit comments

Comments
 (0)