Przeglądaj źródła

added another skyblock plugin + fixed priority on plotsquared

MasterCake 5 lat temu
rodzic
commit
f105984ca2

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

@@ -138,6 +138,7 @@ public class CustomOreGen extends JavaPlugin {
 					// TODO Auto-generated catch block
 					e.printStackTrace();
 				}
+				break;
 			}
 		}
 		

+ 62 - 0
src/xyz/spaceio/hooks/HookFabledSkyblock.java

@@ -0,0 +1,62 @@
+package xyz.spaceio.hooks;
+
+import java.util.Optional;
+import java.util.UUID;
+
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
+import org.bukkit.OfflinePlayer;
+
+import me.goodandevil.skyblock.SkyBlock;
+import me.goodandevil.skyblock.island.Island;
+
+
+public class HookFabledSkyblock implements SkyblockAPIHook{
+	
+	private SkyBlock api;
+	
+	public HookFabledSkyblock() {
+		api = (SkyBlock) Bukkit.getPluginManager().getPlugin("FabledSkyBlock");
+	}
+
+	@Override
+	public int getIslandLevel(UUID uuid, String onWorld) {
+		// create an offline player object because this plugin (unlike the others) does not have a method to obtain an island by UUID.
+		OfflinePlayer skyblockPlayer = Bukkit.getOfflinePlayer(uuid);
+		
+		// api does not provide any optional, so doing a few checks here
+		if(api.getIslandManager() != null) {
+			if(api.getIslandManager().getIsland(skyblockPlayer) != null) {
+				Island is =  api.getIslandManager().getIsland(skyblockPlayer);
+				if(is.getLevel() != null) {
+					return is.getLevel().getLevel();
+				}
+			}
+		}
+		return 0;
+	}
+
+	@Override
+	public Optional<UUID> getIslandOwner(Location loc) {
+		Optional<UUID> optional = Optional.empty();
+		// some more classic null checks...
+		if(api.getIslandManager() != null) {
+			if(api.getIslandManager().getIslandAtLocation(loc) != null) {
+				if(api.getIslandManager().getIslandAtLocation(loc).getOwnerUUID() != null) {
+					optional = Optional.of(api.getIslandManager().getIslandAtLocation(loc).getOwnerUUID());
+				}
+			}
+		}
+		return optional;
+	}
+
+	@Override
+	public String[] getSkyBlockWorldNames() {
+		if(api.getWorldManager() != null) {
+			// a method for getting the islands is missing, so using what we have
+			return Bukkit.getWorlds().stream().filter(w -> api.getWorldManager().isIslandWorld(w)).toArray(String[]::new);
+		}
+		return null;
+	}
+	
+}

+ 9 - 7
src/xyz/spaceio/hooks/HookInfo.java

@@ -7,17 +7,19 @@ package xyz.spaceio.hooks;
  *
  */
 public enum HookInfo {
-	
-	AcidIsland(HookAcidIsland.class), ASkyBlock(HookASkyBlock.class), BentoBox(HookBentoBox.class), IslandWorld(HookIslandWorld.class), PlotSquared(HookPlotSquared.class),
-	SpaceSkyblock(HookSpaceSkyblock.class), SuperiorSkyblock2(HookSuperiorSkyblock.class), uSkyBlock(HookuSkyBlock.class);
-	
+
+	AcidIsland(HookAcidIsland.class), ASkyBlock(HookASkyBlock.class), BentoBox(HookBentoBox.class),
+	IslandWorld(HookIslandWorld.class), SpaceSkyblock(HookSpaceSkyblock.class),
+	SuperiorSkyblock2(HookSuperiorSkyblock.class), uSkyBlock(HookuSkyBlock.class),
+	FabledSkyBlock(HookFabledSkyblock.class), PlotSquared(HookPlotSquared.class);
+
 	private Class<?> hookClass;
-	
+
 	HookInfo(Class<?> hookClass) {
 		this.hookClass = hookClass;
 	}
-	
-	public Class<?> getHookClass(){
+
+	public Class<?> getHookClass() {
 		return this.hookClass;
 	}
 }