Quellcode durchsuchen

implemented Vanilla Hook

MasterCake vor 5 Jahren
Ursprung
Commit
fc71d25b8b

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

@@ -24,6 +24,7 @@ import de.Linus122.SpaceIOMetrics.Metrics;
 import xyz.spaceio.configutils.ConfigHandler;
 import xyz.spaceio.configutils.JSONConfig;
 import xyz.spaceio.hooks.HookInfo;
+import xyz.spaceio.hooks.HookVanilla;
 import xyz.spaceio.hooks.SkyblockAPIHook;
 import xyz.spaceio.misc.NamePlaceholder;
 
@@ -130,8 +131,8 @@ public class CustomOreGen extends JavaPlugin {
 		}
 		
 		if(skyblockAPI == null) {
-			sendConsole("§cYou are not using any skyblock plugin! This plugin only works with a listed skyblock plugin! (check documentations)");
-			Bukkit.getPluginManager().disablePlugin(this);
+			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);
+	FabledSkyBlock(HookFabledSkyblock.class), PlotSquared(HookPlotSquared.class), Vanilla(HookVanilla.class);
 
 	private Class<?> hookClass;
 

+ 47 - 0
src/xyz/spaceio/hooks/HookVanilla.java

@@ -0,0 +1,47 @@
+package xyz.spaceio.hooks;
+
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.stream.Collectors;
+
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
+import org.bukkit.entity.Entity;
+import org.bukkit.entity.Player;
+
+public class HookVanilla implements SkyblockAPIHook{
+
+	public HookVanilla() {
+
+	}
+
+	@Override
+	public int getIslandLevel(UUID uuid, String world) {
+		return 0;
+	}
+
+	@Override
+	public Optional<UUID> getIslandOwner(Location loc) {
+		Optional<UUID> optional = Optional.empty();
+		
+		List<Entity> list = loc.getWorld().getNearbyEntities(loc, 5, 5, 5).stream()
+			.filter(e -> e instanceof Player)
+			.sorted(Comparator.comparingDouble(e -> e.getLocation().distance(loc)))
+			.collect(Collectors.toList());
+		
+		if(list.size() > 0) {
+			optional = Optional.of(((Player) list.get(0)).getUniqueId());
+		}
+		
+		return optional;
+	}
+
+	@Override
+	public String[] getSkyBlockWorldNames() {
+		return Bukkit.getWorlds().stream().map(w -> w.getName()).toArray(String[]::new);
+		
+	}
+}