Bläddra i källkod

fixed legacy plot squared hook

MasterCake 5 år sedan
förälder
incheckning
70fef511d3

+ 7 - 4
src/xyz/spaceio/customoregen/CustomOreGen.java

@@ -124,21 +124,24 @@ public class CustomOreGen extends JavaPlugin {
 	 * Acquires the corresponding skyblock hook class
 	 */
 	private void loadHook() {
+		Exception loadException = null;
 		for(HookInfo hookInfo : HookInfo.values()) {
-			String pluginName = hookInfo.name();
+			String pluginName = hookInfo.name().replace("Legacy", "");
 			if(Bukkit.getServer().getPluginManager().isPluginEnabled(pluginName)) {
-				sendConsole(String.format("&aUsing %s as SkyBlock-Plugin", pluginName));
 				try {
 					skyblockAPI = (SkyblockAPIHook) hookInfo.getHookClass().newInstance();
+					sendConsole(String.format("&aUsing %s as SkyBlock-Plugin, hook class: %s", pluginName, hookInfo.getHookClass().getName()));
 					break;
-				} catch (InstantiationException | IllegalAccessException e) {
+				} catch (Exception e) {
 					// TODO Auto-generated catch block
-					e.printStackTrace();
+					loadException = e;
 				}
 			}
 		}
 		
 		if(skyblockAPI == null) {
+			if(loadException != null)
+				loadException.printStackTrace();
 			sendConsole("§cYou are not using any supported skyblock plugin! Will use the vanilla range check hook instead.");
 			skyblockAPI = new HookVanilla();
 		}

+ 1 - 1
src/xyz/spaceio/hooks/HookInfo.java

@@ -11,7 +11,7 @@ public enum HookInfo {
 	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), Vanilla(HookVanilla.class);
+	FabledSkyBlock(HookFabledSkyblock.class), PlotSquared(HookPlotSquared.class), PlotSquaredLegacy(HookPlotSquaredLegacy.class), Vanilla(HookVanilla.class);
 
 	private Class<?> hookClass;
 

+ 36 - 0
src/xyz/spaceio/hooks/HookPlotSquaredLegacy.java

@@ -0,0 +1,36 @@
+package xyz.spaceio.hooks;
+
+import java.util.Optional;
+import java.util.UUID;
+
+import org.bukkit.Location;
+
+import com.intellectualcrafters.plot.api.PlotAPI;
+
+public class HookPlotSquaredLegacy implements SkyblockAPIHook {
+
+	private PlotAPI api;
+
+	public HookPlotSquaredLegacy() {
+		api = new PlotAPI();
+	}
+
+	@Override
+	public int getIslandLevel(UUID uuid, String world) {
+		return 0;
+	}
+
+	@Override
+	public Optional<UUID> getIslandOwner(Location loc) {
+		Optional<UUID> optional = Optional.empty();
+		if(api.getPlot(loc) != null) {
+			optional = Optional.of(api.getPlot(loc).getOwners().iterator().next());
+		}
+		return optional;
+	}
+
+	@Override
+	public String[] getSkyBlockWorldNames() {
+		return api.getPlotWorlds();
+	}
+}