mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2024-11-26 20:26:34 +01:00
Initial support for biome update in other dimensions
This commit is contained in:
parent
e67106cb46
commit
338119ac76
@ -2,6 +2,7 @@ package com.songoda.skyblock.api.biome;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.songoda.skyblock.api.island.Island;
|
||||
import com.songoda.skyblock.island.IslandWorld;
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
public class BiomeManager {
|
||||
@ -19,6 +20,6 @@ public class BiomeManager {
|
||||
Preconditions.checkArgument(island != null, "Cannot set biome to null island");
|
||||
Preconditions.checkArgument(biome != null, "Cannot set biome to null biome");
|
||||
|
||||
this.biomeManager.setBiome(island.getIsland(), biome, null);
|
||||
this.biomeManager.setBiome(island.getIsland(), IslandWorld.Normal, biome, null);
|
||||
}
|
||||
}
|
||||
|
@ -49,17 +49,17 @@ public class BiomeManager {
|
||||
updatingIslands.remove(island);
|
||||
}
|
||||
|
||||
public void setBiome(Island island, Biome biome, CompleteTask task) {
|
||||
public void setBiome(Island island, IslandWorld world, Biome biome, CompleteTask task) {
|
||||
addUpdatingIsland(island);
|
||||
|
||||
if (island.getLocation(IslandWorld.Normal, IslandEnvironment.Island) == null) return;
|
||||
if (island.getLocation(world, IslandEnvironment.Island) == null) return;
|
||||
|
||||
if(plugin.isPaperAsync()){
|
||||
// We keep it sequentially in order to use less RAM
|
||||
int chunkAmount = (int) Math.ceil(Math.pow(island.getSize()/16d, 2d));
|
||||
AtomicInteger progress = new AtomicInteger();
|
||||
|
||||
ChunkLoader.startChunkLoadingPerChunk(island, IslandWorld.Normal, plugin.isPaperAsync(), (asyncChunk, syncChunk) -> {
|
||||
ChunkLoader.startChunkLoadingPerChunk(island, world, plugin.isPaperAsync(), (asyncChunk, syncChunk) -> {
|
||||
Chunk chunk = asyncChunk.join();
|
||||
if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)){ // TODO Should be 1.15 but it works fine there
|
||||
setChunkBiome3D(biome, chunk); // 2D for the moment
|
||||
@ -95,7 +95,7 @@ public class BiomeManager {
|
||||
}
|
||||
}));
|
||||
} else {
|
||||
ChunkLoader.startChunkLoading(island, IslandWorld.Normal, plugin.isPaperAsync(), (asyncChunks, syncChunks) -> {
|
||||
ChunkLoader.startChunkLoading(island, world, plugin.isPaperAsync(), (asyncChunks, syncChunks) -> {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||
int progress = 0;
|
||||
for(Chunk chunk : syncChunks){
|
||||
|
@ -8,6 +8,7 @@ import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.island.IslandWorld;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.playerdata.PlayerDataManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
@ -45,9 +46,23 @@ public class SetBiomeCommand extends SubCommand {
|
||||
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length == 2) {
|
||||
if (args.length >= 2) {
|
||||
String biomeName = args[1].toUpperCase().trim();
|
||||
|
||||
|
||||
IslandWorld world = null;
|
||||
if(args[2] != null) {
|
||||
String worldName = args[2].toUpperCase().trim();
|
||||
for(IslandWorld islandWorld : IslandWorld.values()) {
|
||||
if(islandWorld.name().equalsIgnoreCase(worldName)) {
|
||||
world = islandWorld;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(world == null) {
|
||||
world = IslandWorld.Normal;
|
||||
}
|
||||
|
||||
CompatibleBiome biome = null;
|
||||
for (CompatibleBiome cbiome : CompatibleBiome.values()) {
|
||||
if (cbiome.isCompatible() && cbiome.name().equals(biomeName)) {
|
||||
@ -77,8 +92,10 @@ public class SetBiomeCommand extends SubCommand {
|
||||
} else {
|
||||
if (islandManager.containsIsland(islandOwnerUUID)) {
|
||||
Island island = islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID));
|
||||
biomeManager.setBiome(island, biome.getBiome(), null);
|
||||
island.setBiome(biome.getBiome());
|
||||
biomeManager.setBiome(island, world, biome.getBiome(), null);
|
||||
if(world.equals(IslandWorld.Normal)) {
|
||||
island.setBiome(biome.getBiome());
|
||||
}
|
||||
} else {
|
||||
islandManager.loadIsland(Bukkit.getOfflinePlayer(islandOwnerUUID));
|
||||
Island island = islandManager.getIsland(Bukkit.getOfflinePlayer(islandOwnerUUID));
|
||||
@ -88,8 +105,11 @@ public class SetBiomeCommand extends SubCommand {
|
||||
soundManager.playSound(sender, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
CompatibleBiome finalBiome = biome;
|
||||
biomeManager.setBiome(island, biome.getBiome(), () -> {
|
||||
island.setBiome(finalBiome.getBiome());
|
||||
IslandWorld finalWorld = world;
|
||||
biomeManager.setBiome(island, world, biome.getBiome(), () -> {
|
||||
if(finalWorld.equals(IslandWorld.Normal)) {
|
||||
island.setBiome(finalBiome.getBiome());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ public class GuiBiome extends Gui {
|
||||
}
|
||||
cooldownManager.createPlayer(CooldownType.Biome, player);
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
biomeManager.setBiome(island, icon.biome.getBiome(), () -> {
|
||||
biomeManager.setBiome(island, IslandWorld.Normal, icon.biome.getBiome(), () -> {
|
||||
if(languageLoad.getBoolean("Command.Island.Biome.Completed.Should-Display-Message")){
|
||||
messageManager.sendMessage(player, languageLoad.getString("Command.Island.Biome.Completed.Message"));
|
||||
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_YES.getSound(), 1.0F, 1.0F);
|
||||
|
@ -282,7 +282,7 @@ public class IslandManager {
|
||||
Biome biome = cBiome.getBiome();
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> {
|
||||
plugin.getBiomeManager().setBiome(island, biome, () -> {
|
||||
plugin.getBiomeManager().setBiome(island, IslandWorld.Normal, biome, () -> {
|
||||
if (structure.getCommands() != null) {
|
||||
for (String commandList : structure.getCommands()) {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), commandList.replace("%player", player.getName()));
|
||||
|
@ -135,7 +135,7 @@ public class Biome {
|
||||
SBiome selectedBiomeType = SBiome.getFromGuiIcon(is.getType(), is.getData().getData());
|
||||
|
||||
cooldownManager.createPlayer(CooldownType.Biome, player);
|
||||
biomeManager.setBiome(island, selectedBiomeType.getBiome(), null);
|
||||
biomeManager.setBiome(island,IslandWorld.Normal, selectedBiomeType.getBiome(), null);
|
||||
island.setBiome(selectedBiomeType.getBiome());
|
||||
island.save();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user