mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2025-02-19 05:01:45 +01:00
Fixed loading islands for offline members
This commit is contained in:
parent
e9cbfdac92
commit
341edb3c3b
@ -459,7 +459,8 @@ public class Island {
|
|||||||
*/
|
*/
|
||||||
public void load() {
|
public void load() {
|
||||||
if (this.handle == null) {
|
if (this.handle == null) {
|
||||||
this.handle = SkyBlockAPI.getImplementation().getIslandManager().loadIsland(player);
|
SkyBlockAPI.getImplementation().getIslandManager().loadIsland(player);
|
||||||
|
this.handle = SkyBlockAPI.getImplementation().getIslandManager().getIsland(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,8 @@ public class DeleteCommand extends SubCommand {
|
|||||||
configLoad.getString("Command.Island.Admin.Delete.Owner.Message"));
|
configLoad.getString("Command.Island.Admin.Delete.Owner.Message"));
|
||||||
soundManager.playSound(sender, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
soundManager.playSound(sender, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||||
} else {
|
} else {
|
||||||
Island island = islandManager.loadIsland(Bukkit.getServer().getOfflinePlayer(targetPlayerUUID));
|
islandManager.loadIsland(Bukkit.getServer().getOfflinePlayer(targetPlayerUUID));
|
||||||
|
Island island = islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(targetPlayerUUID));
|
||||||
Location spawnLocation = LocationUtil.getSpawnLocation();
|
Location spawnLocation = LocationUtil.getSpawnLocation();
|
||||||
|
|
||||||
if (spawnLocation != null && islandManager.isLocationAtIsland(island, spawnLocation)) {
|
if (spawnLocation != null && islandManager.isLocationAtIsland(island, spawnLocation)) {
|
||||||
|
@ -79,7 +79,8 @@ public class SetBiomeCommand extends SubCommand {
|
|||||||
biomeManager.setBiome(island, biome.getBiome());
|
biomeManager.setBiome(island, biome.getBiome());
|
||||||
island.setBiome(biome.getBiome());
|
island.setBiome(biome.getBiome());
|
||||||
} else {
|
} else {
|
||||||
Island island = islandManager.loadIsland(Bukkit.getOfflinePlayer(islandOwnerUUID));
|
islandManager.loadIsland(Bukkit.getOfflinePlayer(islandOwnerUUID));
|
||||||
|
Island island = islandManager.getIsland(Bukkit.getOfflinePlayer(islandOwnerUUID));
|
||||||
if (island == null) {
|
if (island == null) {
|
||||||
messageManager.sendMessage(sender,
|
messageManager.sendMessage(sender,
|
||||||
configLoad.getString("Command.Island.Admin.SetBiome.Island.Data.Message"));
|
configLoad.getString("Command.Island.Admin.SetBiome.Island.Data.Message"));
|
||||||
|
@ -62,8 +62,8 @@ public class AcceptCommand extends SubCommand {
|
|||||||
island = islandManager
|
island = islandManager
|
||||||
.getIsland(Bukkit.getServer().getOfflinePlayer(invite.getOwnerUUID()));
|
.getIsland(Bukkit.getServer().getOfflinePlayer(invite.getOwnerUUID()));
|
||||||
} else {
|
} else {
|
||||||
island = islandManager
|
islandManager.loadIsland(Bukkit.getServer().getOfflinePlayer(invite.getOwnerUUID()));
|
||||||
.loadIsland(Bukkit.getServer().getOfflinePlayer(invite.getOwnerUUID()));
|
island = islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(invite.getOwnerUUID()));
|
||||||
unloadIsland = true;
|
unloadIsland = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -671,7 +671,7 @@ public class IslandManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Island loadIsland(org.bukkit.OfflinePlayer player) {
|
public void loadIsland(org.bukkit.OfflinePlayer player) {
|
||||||
VisitManager visitManager = skyblock.getVisitManager();
|
VisitManager visitManager = skyblock.getVisitManager();
|
||||||
FileManager fileManager = skyblock.getFileManager();
|
FileManager fileManager = skyblock.getFileManager();
|
||||||
BanManager banManager = skyblock.getBanManager();
|
BanManager banManager = skyblock.getBanManager();
|
||||||
@ -686,7 +686,7 @@ public class IslandManager {
|
|||||||
deleteIslandData(player.getUniqueId());
|
deleteIslandData(player.getUniqueId());
|
||||||
configLoad.set("Island.Owner", null);
|
configLoad.set("Island.Owner", null);
|
||||||
|
|
||||||
return null;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
islandOwnerUUID = player.getUniqueId();
|
islandOwnerUUID = player.getUniqueId();
|
||||||
@ -698,7 +698,8 @@ public class IslandManager {
|
|||||||
|
|
||||||
if (islandOwnerUUID != null) {
|
if (islandOwnerUUID != null) {
|
||||||
if (containsIsland(islandOwnerUUID)) {
|
if (containsIsland(islandOwnerUUID)) {
|
||||||
return getIsland(player);
|
//return getIsland(player);
|
||||||
|
return;
|
||||||
} else {
|
} else {
|
||||||
config = fileManager.getConfig(new File(skyblock.getDataFolder().toString() + "/island-data", islandOwnerUUID.toString() + ".yml"));
|
config = fileManager.getConfig(new File(skyblock.getDataFolder().toString() + "/island-data", islandOwnerUUID.toString() + ".yml"));
|
||||||
|
|
||||||
@ -706,7 +707,7 @@ public class IslandManager {
|
|||||||
deleteIslandData(islandOwnerUUID);
|
deleteIslandData(islandOwnerUUID);
|
||||||
configLoad.set("Island.Owner", null);
|
configLoad.set("Island.Owner", null);
|
||||||
|
|
||||||
return null;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Island island = new Island(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID));
|
Island island = new Island(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID));
|
||||||
@ -731,11 +732,9 @@ public class IslandManager {
|
|||||||
Bukkit.getScheduler().runTask(skyblock, () ->
|
Bukkit.getScheduler().runTask(skyblock, () ->
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new IslandLoadEvent(island.getAPIWrapper())));
|
Bukkit.getServer().getPluginManager().callEvent(new IslandLoadEvent(island.getAPIWrapper())));
|
||||||
|
|
||||||
return island;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -786,11 +785,11 @@ public class IslandManager {
|
|||||||
oldSystemIslands.put(IslandWorld.End, endZ);
|
oldSystemIslands.put(IslandWorld.End, endZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Island loadIslandAtLocation(Location location) {
|
public void loadIslandAtLocation(Location location) {
|
||||||
FileManager fileManager = skyblock.getFileManager();
|
FileManager fileManager = skyblock.getFileManager();
|
||||||
File configFile = new File(skyblock.getDataFolder().toString() + "/island-data");
|
File configFile = new File(skyblock.getDataFolder().toString() + "/island-data");
|
||||||
|
|
||||||
if (!configFile.exists()) return null;
|
if (!configFile.exists()) return;
|
||||||
|
|
||||||
for (File fileList : configFile.listFiles()) {
|
for (File fileList : configFile.listFiles()) {
|
||||||
if (fileList != null && fileList.getName().contains(".yml") && fileList.getName().length() > 35) {
|
if (fileList != null && fileList.getName().contains(".yml") && fileList.getName().length() > 35) {
|
||||||
@ -807,7 +806,8 @@ public class IslandManager {
|
|||||||
|
|
||||||
if (LocationUtil.isLocationAtLocationRadius(location, islandLocation, size)) {
|
if (LocationUtil.isLocationAtLocationRadius(location, islandLocation, size)) {
|
||||||
UUID islandOwnerUUID = UUID.fromString(fileList.getName().replace(".yml", ""));
|
UUID islandOwnerUUID = UUID.fromString(fileList.getName().replace(".yml", ""));
|
||||||
return this.loadIsland(Bukkit.getOfflinePlayer(islandOwnerUUID));
|
// return this.loadIsland(Bukkit.getOfflinePlayer(islandOwnerUUID));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -815,7 +815,7 @@ public class IslandManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unloadIsland(Island island, org.bukkit.OfflinePlayer player) {
|
public void unloadIsland(Island island, org.bukkit.OfflinePlayer player) {
|
||||||
@ -1203,12 +1203,11 @@ public class IslandManager {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
OfflinePlayer offlinePlayerData = new OfflinePlayer(offlinePlayer.getUniqueId());
|
OfflinePlayer offlinePlayerData = new OfflinePlayer(offlinePlayer.getUniqueId());
|
||||||
|
loadIsland(offlinePlayer);
|
||||||
|
|
||||||
if (offlinePlayerData.getOwner() != null && islandStorage.containsKey(offlinePlayer.getUniqueId())) {
|
if (offlinePlayerData.getOwner() != null && islandStorage.containsKey(offlinePlayer.getUniqueId())) {
|
||||||
return islandStorage.get(offlinePlayerData.getOwner());
|
return islandStorage.get(offlinePlayerData.getOwner());
|
||||||
}
|
}
|
||||||
|
|
||||||
return loadIsland(offlinePlayer); // TODO That could be done first, needs testing - Fabrimat
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -1391,7 +1390,7 @@ public class IslandManager {
|
|||||||
if (Bukkit.getServer().getPluginManager().getPlugin("Residence") != null) {
|
if (Bukkit.getServer().getPluginManager().getPlugin("Residence") != null) {
|
||||||
ClaimedResidence res = Residence.getInstance().getResidenceManagerAPI().getByLoc(player.getLocation());
|
ClaimedResidence res = Residence.getInstance().getResidenceManagerAPI().getByLoc(player.getLocation());
|
||||||
if(res != null){
|
if(res != null){
|
||||||
if(res.getPermissions().has(Flags.fly, false)){
|
if (res.getPermissions().has(Flags.fly, false) || res.getPermissions().has(Flags.nofly, false)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,8 @@ public class Join implements Listener {
|
|||||||
userCacheManager.saveAsync();
|
userCacheManager.saveAsync();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Island island = islandManager.loadIsland(player);
|
islandManager.loadIsland(player);
|
||||||
|
Island island = islandManager.getIsland(player);
|
||||||
boolean teleportedToIsland = false;
|
boolean teleportedToIsland = false;
|
||||||
|
|
||||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
|
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
|
||||||
|
@ -169,7 +169,8 @@ public class Move implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load the island they are now on if one exists
|
// Load the island they are now on if one exists
|
||||||
Island loadedIsland = islandManager.loadIslandAtLocation(player.getLocation());
|
islandManager.loadIslandAtLocation(player.getLocation());
|
||||||
|
Island loadedIsland = islandManager.getIslandAtLocation(player.getLocation());
|
||||||
if (loadedIsland != null) {
|
if (loadedIsland != null) {
|
||||||
if (player.hasPermission("fabledskyblock.bypass")) {
|
if (player.hasPermission("fabledskyblock.bypass")) {
|
||||||
playerData.setIsland(loadedIsland.getOwnerUUID());
|
playerData.setIsland(loadedIsland.getOwnerUUID());
|
||||||
|
Loading…
Reference in New Issue
Block a user