瀏覽代碼

Added IslandWorld hook

mastercake10 5 年之前
父節點
當前提交
547b61a53b

+ 8 - 1
pom.xml

@@ -4,7 +4,7 @@
 	<modelVersion>4.0.0</modelVersion>
 	<groupId>xyz.spaceio</groupId>
 	<artifactId>CustomOreGen</artifactId>
-	<version>1.3.9-SNAPSHOT</version>
+	<version>1.3.11-SNAPSHOT</version>
 	<repositories>
 		<!-- Spigot repository -->
 		<repository>
@@ -70,6 +70,13 @@
 			<artifactId>uSkyBlock-API</artifactId>
 			<version>2.6.4</version>
 		</dependency>
+		<!-- USkyblock -->
+		<dependency>
+			<groupId>pl.islandworld</groupId>
+			<artifactId>IslandWorld</artifactId>
+			<version>13.0-SNAPSHOT</version>
+			<scope>provided</scope>
+		</dependency>
 		<!-- BentoBox -->
 		<dependency>
 			<groupId>world.bentobox</groupId>

+ 10 - 3
src/xyz/spaceio/customoregen/CustomOreGen.java

@@ -32,6 +32,7 @@ import xyz.spaceio.config.JSONConfig;
 import xyz.spaceio.hooks.HookASkyBlock;
 import xyz.spaceio.hooks.HookAcidIsland;
 import xyz.spaceio.hooks.HookBentoBox;
+import xyz.spaceio.hooks.HookIslandWorld;
 import xyz.spaceio.hooks.HookPlotSquared;
 import xyz.spaceio.hooks.HookSkyblockEarth;
 import xyz.spaceio.hooks.SkyblockAPIHook;
@@ -129,12 +130,18 @@ public class CustomOreGen extends JavaPlugin {
 		} else if (Bukkit.getServer().getPluginManager().isPluginEnabled("BentoBox")) {
 			skyblockAPI = new HookBentoBox();
 			sendConsole("&aUsing BentoBox as SkyBlock-Plugin");
-		} else if (Bukkit.getServer().getPluginManager().isPluginEnabled("SkyBlock")) {
-			skyblockAPI = new HookSkyblockEarth();
-			sendConsole("&aUsing SkyblockEarth as SkyBlock-Plugin");
+		//} else if (Bukkit.getServer().getPluginManager().isPluginEnabled("SkyBlock")) {
+			//skyblockAPI = new HookSkyblockEarth();
+			//sendConsole("&aUsing SkyblockEarth as SkyBlock-Plugin");
 		} else if (Bukkit.getServer().getPluginManager().isPluginEnabled("PlotSquared")) {
 			skyblockAPI = new HookPlotSquared();
 			sendConsole("&aUsing PlotSquared as SkyBlock-Plugin");
+		} else if (Bukkit.getServer().getPluginManager().isPluginEnabled("IslandWorld")) {
+			skyblockAPI = new HookIslandWorld();
+			sendConsole("&aUsing IslandWorld as SkyBlock-Plugin");
+		} else {
+			sendConsole("§cYou are not using any Skyblock plugin! This plugin only works in addition with a Skyblock plugin of your choice!");
+			Bukkit.getPluginManager().disablePlugin(this);
 		}
 	}
 

+ 2 - 1
src/xyz/spaceio/hooks/HookBentoBox.java

@@ -2,6 +2,7 @@ package xyz.spaceio.hooks;
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.util.Arrays;
 import java.util.Optional;
 import java.util.UUID;
 
@@ -52,7 +53,7 @@ public class HookBentoBox implements SkyblockAPIHook{
 
 	@Override
 	public String[] getSkyBlockWorldNames() {
-		return api.getIWM().getOverWorlds().stream().map(w -> w.getName()).toArray(String[]::new);
+		return api.getIWM().getOverWorlds().stream().map(w -> new String[]{w.getName(), w.getName() + "_nether", w.getName() + "_the_end"}).flatMap(s -> Arrays.stream(s)).toArray(String[]::new);
 	}
 	
 }

+ 43 - 0
src/xyz/spaceio/hooks/HookIslandWorld.java

@@ -0,0 +1,43 @@
+package xyz.spaceio.hooks;
+
+import java.util.Optional;
+import java.util.UUID;
+
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
+
+import pl.islandworld.IslandWorld;
+import pl.islandworld.entity.SimpleIsland;
+
+public class HookIslandWorld implements SkyblockAPIHook {
+
+	private IslandWorld api;
+
+	public HookIslandWorld() {
+		api = (IslandWorld) Bukkit.getPluginManager().getPlugin("IslandWorld");
+	}
+
+	@Override
+	public int getIslandLevel(UUID uuid, String world) {
+		SimpleIsland is = api.getUUIDList().getOrDefault(uuid, null);
+		return is != null ? is.getLevel() : 0;
+	}
+
+	@Override
+	public Optional<UUID> getIslandOwner(Location loc) {
+		Optional<UUID> optional = Optional.empty();
+		
+		SimpleIsland is = api.getCoordList().getOrDefault(api.hashMeFromLoc(loc), null);
+		if(is != null) {
+			optional =  Optional.of(is.getOwnerUUID());
+		}
+		
+		return optional;
+	}
+
+	@Override
+	public String[] getSkyBlockWorldNames() {
+		return new String[] { api.getIslandWorld().getName() };
+	}
+
+}