ソースを参照

added support for SkyBlockEarth plugin

mastercake10 6 年 前
コミット
30c6171d3f

+ 8 - 1
pom.xml

@@ -4,7 +4,7 @@
 	<modelVersion>4.0.0</modelVersion>
 	<groupId>xyz.spaceio</groupId>
 	<artifactId>CustomOreGen</artifactId>
-	<version>1.2.9-SNAPSHOT</version>
+	<version>1.3.0-SNAPSHOT</version>
 	<repositories>
 		<!-- Spigot repository -->
 		<repository>
@@ -77,6 +77,13 @@
 			<version>0.9.0-SNAPSHOT</version>
 			<scope>provided</scope>
 		</dependency>
+		<!-- BentoBox -->
+		<dependency>
+			<groupId>me.goodandevil</groupId>
+			<artifactId>skyblockearth</artifactId>
+			<version>11-SNAPSHOT</version>
+			<scope>provided</scope>
+		</dependency>
 		<!--SpaceIO Metrics -->
 		<dependency>
 			<groupId>de.spaceio</groupId>

+ 1 - 1
src/main/resources/plugin.yml

@@ -2,7 +2,7 @@ name: CustomOreGen
 version: ${project.version}
 description: Controls the Ore-Generator
 author: Linus122
-softdepend: [ASkyBlock, AcidIsland, uSkyBlock]
+softdepend: [ASkyBlock, AcidIsland, uSkyBlock, SkyBlock]
 main: xyz.spaceio.customoregen.CustomOreGen
 api-version: 1.13
 commands:

+ 5 - 1
src/xyz/spaceio/customoregen/CustomOreGen.java

@@ -31,6 +31,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.HookSkyblockEarth;
 import xyz.spaceio.hooks.SkyblockAPIHook;
 import xyz.spaceio.hooks.HookuSkyBlock;
 
@@ -126,6 +127,9 @@ 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");
 		}
 	}
 
@@ -170,9 +174,9 @@ public class CustomOreGen extends JavaPlugin {
 		} else {
 
 			int islandLevel = getLevel(p.getUniqueId(), world);
-
 			if (p.isOnline()) {
 				Player realP = p.getPlayer();
+
 				if (this.getActiveWorlds().contains(realP.getWorld())) {
 					for (GeneratorConfig gc2 : generatorConfigs) {
 						if (gc2 == null) {

+ 2 - 2
src/xyz/spaceio/customoregen/Events.java

@@ -35,7 +35,7 @@ public class Events implements Listener {
 
 		int id = this.getID(event.getBlock());
 
-		if ((id >= 8) && (id <= 11) && id != 9 && event.getFace() != BlockFace.DOWN) {
+		if ((id >= 8) && (id <= 11) && event.getFace() != BlockFace.DOWN) {
 			Block b = event.getToBlock();
 			int toid = this.getID(b);
 			Location fromLoc = b.getLocation();
@@ -46,7 +46,7 @@ public class Events implements Listener {
 				}
 			}
 
-			if ((toid == 0 || toid == 9 || toid == 8) && (generatesCobble(id, b))) {
+			if ((toid == 0 || toid == 9 || toid == 8 || toid == 10 || toid == 11) && (generatesCobble(id, b))) {
 				OfflinePlayer p = plugin.getOwner(b.getLocation());
 				if (p == null)
 					return;

+ 20 - 0
src/xyz/spaceio/customoregen/Utils.java

@@ -0,0 +1,20 @@
+package xyz.spaceio.customoregen;
+
+public class Utils {
+	public static enum Material113{
+		STATIONARY_LAVA(10),
+		STATIONARY_WATER(9),
+		WATER(8),
+		LAVA(11),
+		AIR(0);
+		
+		int id;
+		
+		Material113(int id) {
+			this.id = id;
+		}
+		int getID() {
+			return this.id;
+		}
+	}
+}

+ 59 - 0
src/xyz/spaceio/hooks/HookSkyblockEarth.java

@@ -0,0 +1,59 @@
+package xyz.spaceio.hooks;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.UUID;
+
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
+import org.bukkit.configuration.file.FileConfiguration;
+
+import me.goodandevil.skyblock.config.FileManager.Config;
+import me.goodandevil.skyblock.island.IslandManager;
+import me.goodandevil.skyblock.island.Location.Environment;
+import me.goodandevil.skyblock.island.Location.World;
+import me.goodandevil.skyblock.utils.world.LocationUtil;
+
+public class HookSkyblockEarth implements SkyblockAPIHook {
+
+	private me.goodandevil.skyblock.Main mainClass;
+	private IslandManager api;
+
+	public HookSkyblockEarth() {
+		mainClass = (me.goodandevil.skyblock.Main) Bukkit.getPluginManager().getPlugin("SkyBlock");
+		api = mainClass.getIslandManager();
+	}
+
+	@Override
+	public int getIslandLevel(UUID uuid, String world) {
+		if (api.getIsland(uuid) == null)
+			return 0;
+		return api.getIsland(uuid).getLevel().getLevel();
+	}
+
+	@Override
+	public UUID getIslandOwner(Location loc) {
+		UUID[] owner = new UUID[1];
+
+		api.getIslands().forEach((k, v) -> {
+			Arrays.asList(World.values()).forEach(world -> {
+				if (LocationUtil.isLocationAtLocationRadius(loc, v.getLocation(world, Environment.Island), 85)) {
+					owner[0] = k;
+				}
+			});
+
+		});
+		return owner[0];
+	}
+
+	@Override
+	public String[] getSkyBlockWorldNames() {
+		// took from source code of SkyBlock.jar
+		Config var1 = mainClass.getFileManager().getConfig(new File(mainClass.getDataFolder(), "config.yml"));
+		FileConfiguration var2 = var1.getFileConfiguration();
+		String var3 = var2.getString("Island.World.Nether.Name");
+		String var4 = var2.getString("Island.World.Normal.Name");
+		return new String[] {var3, var4};
+	}
+
+}