From 4e273dab18e6562829f0718a6836a6645082b50d Mon Sep 17 00:00:00 2001 From: YellowZaki Date: Wed, 5 Jun 2019 14:48:53 +0200 Subject: [PATCH] Added Island#hasNetherIsland() & Island#hasEndIsland() (#714) * Added methods to know if the island has nether/end islands * Fixed possible NullPointer * Update src/main/java/world/bentobox/bentobox/database/objects/Island.java Co-Authored-By: Florian CUNY * Update src/main/java/world/bentobox/bentobox/database/objects/Island.java Co-Authored-By: Florian CUNY * Implemented tastybento's required changes --- .../bentobox/database/objects/Island.java | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/main/java/world/bentobox/bentobox/database/objects/Island.java b/src/main/java/world/bentobox/bentobox/database/objects/Island.java index ca4eb1b18..5ac0fb9ff 100644 --- a/src/main/java/world/bentobox/bentobox/database/objects/Island.java +++ b/src/main/java/world/bentobox/bentobox/database/objects/Island.java @@ -940,4 +940,28 @@ public class Island implements DataObject { public void setGameMode(String gameMode) { this.gameMode = gameMode; } -} \ No newline at end of file + + /** + * Returns if this island has its end island generated. + * @return {@code true} if this island has its end island generated, {@code false} otherwise. + * @since 1.5.0 + */ + public boolean hasEndIsland(){ + IslandWorldManager iwm = BentoBox.getInstance().getIWM(); + return iwm.isEndGenerate(getWorld()) && iwm.isEndIslands(getWorld()) && + iwm.getEndWorld(getWorld()) != null && + getCenter().toVector().toLocation(iwm.getEndWorld(getWorld)).getBlock().getType().equals(Material.BEDROCK); + } + + /** + * Returns if this island has its nether island generated. + * @return {@code true} if this island has its nether island generated, {@code false} otherwise. + * @since 1.5.0 + */ + public boolean hasNetherIsland(){ + IslandWorldManager iwm = BentoBox.getInstance().getIWM(); + return iwm.isNetherGenerate(getWorld()) && iwm.isNetherIslands(getWorld()) && + iwm.getNetherWorld(getWorld()) != null && + getCenter().toVector().toLocation(iwm.getNetherWorld(getWorld)).getBlock().getType().equals(Material.BEDROCK); + } +}