mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2025-03-02 10:31:23 +01:00
Fix '/is admin setspawn' on island issue
This commit is contained in:
parent
1d80ffbaeb
commit
25fdc33b4c
@ -34,6 +34,7 @@ import me.goodandevil.skyblock.world.WorldManager;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -540,6 +541,37 @@ public class IslandManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void loadIslandAtLocation(Location location) {
|
||||||
|
FileManager fileManager = skyblock.getFileManager();
|
||||||
|
File configFile = new File(skyblock.getDataFolder().toString() + "/island-data");
|
||||||
|
|
||||||
|
if (!configFile.exists()) return;
|
||||||
|
|
||||||
|
for (File fileList : configFile.listFiles()) {
|
||||||
|
if (fileList != null && fileList.getName().contains(".yml") && fileList.getName().length() > 35) {
|
||||||
|
try {
|
||||||
|
Config config = new FileManager.Config(fileManager, fileList);
|
||||||
|
FileConfiguration configLoad = config.getFileConfiguration();
|
||||||
|
|
||||||
|
int size = 100;
|
||||||
|
if (configLoad.getString("Size") != null) {
|
||||||
|
size = configLoad.getInt("Size");
|
||||||
|
}
|
||||||
|
|
||||||
|
Location islandLocation = fileManager.getLocation(config, "Location.Normal.Island", false);
|
||||||
|
|
||||||
|
if (LocationUtil.isLocationAtLocationRadius(location, islandLocation, size)) {
|
||||||
|
UUID islandOwnerUUID = UUID.fromString(fileList.getName().replace(".yml", ""));
|
||||||
|
this.loadIsland(Bukkit.getOfflinePlayer(islandOwnerUUID));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void unloadIsland(Island island, org.bukkit.OfflinePlayer player) {
|
public void unloadIsland(Island island, org.bukkit.OfflinePlayer player) {
|
||||||
ScoreboardManager scoreboardManager = skyblock.getScoreboardManager();
|
ScoreboardManager scoreboardManager = skyblock.getScoreboardManager();
|
||||||
FileManager fileManager = skyblock.getFileManager();
|
FileManager fileManager = skyblock.getFileManager();
|
||||||
@ -739,8 +771,8 @@ public class IslandManager {
|
|||||||
setNextAvailableLocation(world, islandLocation);
|
setNextAvailableLocation(world, islandLocation);
|
||||||
saveNextAvailableLocation(world);
|
saveNextAvailableLocation(world);
|
||||||
|
|
||||||
// Recalculate island level
|
// Recalculate island level after 5 seconds
|
||||||
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> skyblock.getLevellingManager().calculatePoints(null, island), 20L);
|
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> skyblock.getLevellingManager().calculatePoints(null, island), 100L);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<UUID> getVisitorsAtIsland(Island island) {
|
public Set<UUID> getVisitorsAtIsland(Island island) {
|
||||||
|
@ -3,9 +3,12 @@ package me.goodandevil.skyblock.utils.world;
|
|||||||
import me.goodandevil.skyblock.SkyBlock;
|
import me.goodandevil.skyblock.SkyBlock;
|
||||||
import me.goodandevil.skyblock.config.FileManager;
|
import me.goodandevil.skyblock.config.FileManager;
|
||||||
import me.goodandevil.skyblock.config.FileManager.Config;
|
import me.goodandevil.skyblock.config.FileManager.Config;
|
||||||
|
import me.goodandevil.skyblock.island.Island;
|
||||||
|
import me.goodandevil.skyblock.island.IslandManager;
|
||||||
import me.goodandevil.skyblock.utils.math.VectorUtil;
|
import me.goodandevil.skyblock.utils.math.VectorUtil;
|
||||||
import me.goodandevil.skyblock.utils.version.Materials;
|
import me.goodandevil.skyblock.utils.version.Materials;
|
||||||
import me.goodandevil.skyblock.utils.world.block.BlockDegreesType;
|
import me.goodandevil.skyblock.utils.world.block.BlockDegreesType;
|
||||||
|
import me.goodandevil.skyblock.world.WorldManager;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.World.Environment;
|
import org.bukkit.World.Environment;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -187,6 +190,8 @@ public final class LocationUtil {
|
|||||||
public static void teleportPlayerToSpawn(Player player) {
|
public static void teleportPlayerToSpawn(Player player) {
|
||||||
SkyBlock skyblock = SkyBlock.getInstance();
|
SkyBlock skyblock = SkyBlock.getInstance();
|
||||||
|
|
||||||
|
IslandManager islandManager = skyblock.getIslandManager();
|
||||||
|
WorldManager worldManager = skyblock.getWorldManager();
|
||||||
FileManager fileManager = skyblock.getFileManager();
|
FileManager fileManager = skyblock.getFileManager();
|
||||||
|
|
||||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "locations.yml"));
|
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "locations.yml"));
|
||||||
@ -203,12 +208,17 @@ public final class LocationUtil {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bukkit.getServer().getScheduler().runTask(skyblock, new Runnable() {
|
// If the spawn point is at an island, load that island
|
||||||
@Override
|
if (worldManager.isIslandWorld(spawnLocation.getWorld())) {
|
||||||
public void run() {
|
Island island = islandManager.getIslandAtLocation(spawnLocation);
|
||||||
player.teleport(spawnLocation);
|
if (island == null) {
|
||||||
player.setFallDistance(0.0F);
|
islandManager.loadIslandAtLocation(spawnLocation);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Bukkit.getServer().getScheduler().runTask(skyblock, () -> {
|
||||||
|
player.teleport(spawnLocation);
|
||||||
|
player.setFallDistance(0.0F);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user