Pārlūkot izejas kodu

add null check for SuperiorSkyblock2

mastercake10 1 gadu atpakaļ
vecāks
revīzija
e90ead9e9c
2 mainītis faili ar 13 papildinājumiem un 6 dzēšanām
  1. 1 1
      pom.xml
  2. 12 5
      src/main/java/xyz/spaceio/hooks/HookSuperiorSkyblock.java

+ 1 - 1
pom.xml

@@ -4,7 +4,7 @@
 	<modelVersion>4.0.0</modelVersion>
 	<groupId>xyz.spaceio</groupId>
 	<artifactId>CustomOreGen</artifactId>
-	<version>1.3.34-SNAPSHOT</version>
+	<version>1.3.35-SNAPSHOT</version>
 	<repositories>
 		<!-- Spigot repository -->
 		<repository>

+ 12 - 5
src/main/java/xyz/spaceio/hooks/HookSuperiorSkyblock.java

@@ -1,5 +1,6 @@
 package xyz.spaceio.hooks;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Optional;
 import java.util.UUID;
@@ -51,17 +52,23 @@ public class HookSuperiorSkyblock implements SkyblockAPIHook {
 
 	@Override
 	public String[] getSkyBlockWorldNames() {
-		
-		List<World> worlds = SuperiorSkyblockAPI.getGrid().getRegisteredWorlds();
-		worlds.add(SuperiorSkyblockAPI.getSpawnIsland().getVisitorsLocation().getWorld());
-		
+		List<World> worlds = new ArrayList<>();
+
+		if(SuperiorSkyblockAPI.getGrid() != null && SuperiorSkyblockAPI.getGrid().getRegisteredWorlds() != null) {
+			worlds.addAll(SuperiorSkyblockAPI.getGrid().getRegisteredWorlds());
+		}
+
+		if(SuperiorSkyblockAPI.getSpawnIsland() != null && SuperiorSkyblockAPI.getSpawnIsland().getVisitorsLocation() != null) {
+			worlds.add(SuperiorSkyblockAPI.getSpawnIsland().getVisitorsLocation().getWorld());
+		}
+
 		return worlds.stream().map(w -> w.getName()).toArray(String[]::new);
 	}
 	
 	@Override
 	public void sendBlockAcknowledge(Block block) {
 		if(SuperiorSkyblockAPI.getIslandAt(block.getLocation()) != null) {
-			SuperiorSkyblockAPI.getIslandAt(block.getLocation()).handleBlockPlace(block);	
+			SuperiorSkyblockAPI.getIslandAt(block.getLocation()).handleBlockPlace(block);
 		}
 	}