mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2025-02-11 01:01:53 +01:00
Don't generate disabled island worlds
This commit is contained in:
parent
e620d3eb0e
commit
904511f6c8
@ -20,6 +20,9 @@ public class IslandLocation {
|
||||
this.world = world;
|
||||
this.environment = environment;
|
||||
|
||||
if (location == null)
|
||||
return;
|
||||
|
||||
this.x = location.getX();
|
||||
this.y = location.getY();
|
||||
this.z = location.getZ();
|
||||
|
@ -154,7 +154,7 @@ public class IslandManager {
|
||||
island.setStructure(structure.getName());
|
||||
islandStorage.put(player.getUniqueId(), island);
|
||||
|
||||
for (IslandWorld worldList : IslandWorld.values()) {
|
||||
for (IslandWorld worldList : IslandWorld.getIslandWorlds()) {
|
||||
prepareIsland(island, worldList);
|
||||
}
|
||||
|
||||
@ -513,7 +513,7 @@ public class IslandManager {
|
||||
Island island = new Island(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID));
|
||||
islandStorage.put(islandOwnerUUID, island);
|
||||
|
||||
for (IslandWorld worldList : IslandWorld.values()) {
|
||||
for (IslandWorld worldList : IslandWorld.getIslandWorlds()) {
|
||||
prepareIsland(island, worldList);
|
||||
}
|
||||
|
||||
@ -705,7 +705,7 @@ public class IslandManager {
|
||||
}
|
||||
|
||||
public void resetIsland(Island island) {
|
||||
for (IslandWorld worldList : IslandWorld.values()) {
|
||||
for (IslandWorld worldList : IslandWorld.getIslandWorlds()) {
|
||||
pasteStructure(island, worldList);
|
||||
}
|
||||
}
|
||||
@ -1049,7 +1049,7 @@ public class IslandManager {
|
||||
List<Player> playersAtIsland = new ArrayList<>();
|
||||
|
||||
if (island != null) {
|
||||
for (IslandWorld worldList : IslandWorld.values()) {
|
||||
for (IslandWorld worldList : IslandWorld.getIslandWorlds()) {
|
||||
playersAtIsland.addAll(getPlayersAtIsland(island, worldList));
|
||||
}
|
||||
}
|
||||
@ -1262,7 +1262,7 @@ public class IslandManager {
|
||||
if (island.isBorder()) {
|
||||
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getBoolean("Island.WorldBorder.Enable")) {
|
||||
for (IslandWorld worldList : IslandWorld.values()) {
|
||||
for (IslandWorld worldList : IslandWorld.getIslandWorlds()) {
|
||||
if (worldList == IslandWorld.Nether) {
|
||||
if (NMSUtil.getVersionNumber() < 13) {
|
||||
continue;
|
||||
@ -1276,7 +1276,7 @@ public class IslandManager {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (IslandWorld worldList : IslandWorld.values()) {
|
||||
for (IslandWorld worldList : IslandWorld.getIslandWorlds()) {
|
||||
if (worldList == IslandWorld.Nether) {
|
||||
if (NMSUtil.getVersionNumber() < 13) {
|
||||
continue;
|
||||
@ -1325,7 +1325,7 @@ public class IslandManager {
|
||||
}
|
||||
|
||||
public boolean isLocationAtIsland(Island island, org.bukkit.Location location) {
|
||||
for (IslandWorld worldList : IslandWorld.values()) {
|
||||
for (IslandWorld worldList : IslandWorld.getIslandWorlds()) {
|
||||
if (isLocationAtIsland(island, location, worldList)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -1,21 +1,56 @@
|
||||
package me.goodandevil.skyblock.island;
|
||||
|
||||
import me.goodandevil.skyblock.SkyBlock;
|
||||
import me.goodandevil.skyblock.world.WorldManager;
|
||||
import org.bukkit.World.Environment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public enum IslandWorld {
|
||||
|
||||
Normal, Nether, End;
|
||||
|
||||
public Environment getEnvironment() {
|
||||
public Environment getUncheckedEnvironment() {
|
||||
switch (this) {
|
||||
case End:
|
||||
return Environment.THE_END;
|
||||
case Nether:
|
||||
return Environment.NETHER;
|
||||
case Normal:
|
||||
return Environment.NORMAL;
|
||||
case Normal:
|
||||
return Environment.NORMAL;
|
||||
case Nether:
|
||||
return Environment.NETHER;
|
||||
case End:
|
||||
return Environment.THE_END;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public Environment getEnvironment() {
|
||||
WorldManager worldManager = SkyBlock.getInstance().getWorldManager();
|
||||
if (worldManager.getWorld(Normal) != null)
|
||||
return Environment.NORMAL;
|
||||
|
||||
if (worldManager.getWorld(Nether) != null)
|
||||
return Environment.NETHER;
|
||||
|
||||
if (worldManager.getWorld(End) != null)
|
||||
return Environment.THE_END;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<IslandWorld> getIslandWorlds() {
|
||||
List<IslandWorld> islandWorlds = new ArrayList<>();
|
||||
|
||||
WorldManager worldManager = SkyBlock.getInstance().getWorldManager();
|
||||
if (worldManager.getWorld(Normal) != null)
|
||||
islandWorlds.add(Normal);
|
||||
|
||||
if (worldManager.getWorld(Nether) != null)
|
||||
islandWorlds.add(Nether);
|
||||
|
||||
if (worldManager.getWorld(End) != null)
|
||||
islandWorlds.add(End);
|
||||
|
||||
return islandWorlds;
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public class Chunk {
|
||||
boolean hasNether = config.getBoolean("Island.World.Nether.Enable") && islandData.getBoolean("Unlocked.Nether", false);
|
||||
boolean hasEnd = config.getBoolean("Island.World.End.Enable") && islandData.getBoolean("Unlocked.End", false);
|
||||
|
||||
for (IslandWorld islandWorld : IslandWorld.values()) {
|
||||
for (IslandWorld islandWorld : IslandWorld.getIslandWorlds()) {
|
||||
if (islandWorld == IslandWorld.Normal || (islandWorld == IslandWorld.Nether && hasNether) || (islandWorld == IslandWorld.End && hasEnd)) {
|
||||
this.getChunksToScan(islandWorld);
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ public class LevellingManager {
|
||||
|
||||
int height = 0;
|
||||
|
||||
for (IslandWorld worldList : IslandWorld.values()) {
|
||||
for (IslandWorld worldList : IslandWorld.getIslandWorlds()) {
|
||||
org.bukkit.World world = worldManager.getWorld(worldList);
|
||||
|
||||
if (height == 0 || height > world.getMaxHeight()) {
|
||||
|
@ -43,7 +43,7 @@ public final class LocationUtil {
|
||||
}
|
||||
|
||||
public static boolean isLocationAtLocationRadius(Location location1, Location location2, double radius) {
|
||||
if (location1 == null || location2 == null
|
||||
if (location1 == null || location2 == null || location1.getWorld() == null || location2.getWorld() == null
|
||||
|| !location1.getWorld().getName().equals(location2.getWorld().getName())) {
|
||||
return false;
|
||||
}
|
||||
|
@ -37,6 +37,9 @@ public class WorldManager {
|
||||
String netherWorldName = configLoad.getString("Island.World.Nether.Name");
|
||||
String endWorldName = configLoad.getString("Island.World.End.Name");
|
||||
|
||||
boolean netherWorldEnabled = configLoad.getBoolean("Island.World.Nether.Enable");
|
||||
boolean endWorldEnabled = configLoad.getBoolean("Island.World.End.Enable");
|
||||
|
||||
normalWorld = Bukkit.getServer().getWorld(normalWorldName);
|
||||
netherWorld = Bukkit.getServer().getWorld(netherWorldName);
|
||||
endWorld = Bukkit.getServer().getWorld(endWorldName);
|
||||
@ -50,7 +53,7 @@ public class WorldManager {
|
||||
Bukkit.getServer().getScheduler().runTask(skyblock, () -> registerMultiverse(normalWorldName, World.Environment.NORMAL));
|
||||
}
|
||||
|
||||
if (netherWorld == null) {
|
||||
if (netherWorld == null && netherWorldEnabled) {
|
||||
Bukkit.getServer().getLogger().log(Level.INFO,
|
||||
"SkyBlock | Info: Generating VoidWorld '" + netherWorldName + "'.");
|
||||
netherWorld = WorldCreator.name(netherWorldName).type(WorldType.FLAT).environment(World.Environment.NETHER)
|
||||
@ -59,7 +62,7 @@ public class WorldManager {
|
||||
Bukkit.getServer().getScheduler().runTask(skyblock, () -> registerMultiverse(netherWorldName, World.Environment.NETHER));
|
||||
}
|
||||
|
||||
if (endWorld == null) {
|
||||
if (endWorld == null && endWorldEnabled) {
|
||||
Bukkit.getServer().getLogger().log(Level.INFO,
|
||||
"SkyBlock | Info: Generating VoidWorld '" + endWorldName + "'.");
|
||||
endWorld = WorldCreator.name(endWorldName).type(WorldType.FLAT).environment(World.Environment.THE_END)
|
||||
@ -95,26 +98,30 @@ public class WorldManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (normalWorld.getName().equals(world.getName())) {
|
||||
if (normalWorld != null && normalWorld.getName().equals(world.getName()))
|
||||
return IslandWorld.Normal;
|
||||
} else if (netherWorld.getName().equals(world.getName())) {
|
||||
|
||||
if (netherWorld != null && netherWorld.getName().equals(world.getName()))
|
||||
return IslandWorld.Nether;
|
||||
} else if (endWorld.getName().equals(world.getName())) {
|
||||
|
||||
if (endWorld != null && endWorld.getName().equals(world.getName()))
|
||||
return IslandWorld.End;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isIslandWorld(World world) {
|
||||
if (world == null) {
|
||||
if (world == null)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (normalWorld.getName().equals(world.getName()) || netherWorld.getName().equals(world.getName())
|
||||
|| endWorld.getName().equals(world.getName())) {
|
||||
if (normalWorld != null && normalWorld.getName().equals(world.getName()))
|
||||
return true;
|
||||
|
||||
if (netherWorld != null && netherWorld.getName().equals(world.getName()))
|
||||
return true;
|
||||
|
||||
if (endWorld != null && endWorld.getName().equals(world.getName()))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ public class VoidGenerator extends ChunkGenerator {
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
for (IslandWorld worldList : IslandWorld.values()) {
|
||||
if (world.getEnvironment() == worldList.getEnvironment()) {
|
||||
if (world.getEnvironment() == worldList.getUncheckedEnvironment()) {
|
||||
if (configLoad.getBoolean("Island.World." + worldList.name() + ".Liquid.Enable")) {
|
||||
if (configLoad.getBoolean("Island.World." + worldList.name() + ".Liquid.Lava")) {
|
||||
setBlock(chunkData, Materials.LEGACY_STATIONARY_LAVA.parseMaterial(),
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user