Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

killed the dragon #753

Merged
merged 2 commits into from
Oct 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.iridium.iridiumskyblock.managers;

import com.iridium.iridiumcore.dependencies.nbtapi.NBTCompound;
import com.iridium.iridiumcore.dependencies.nbtapi.NBTFile;
import com.iridium.iridiumcore.dependencies.nbtapi.NBTItem;
import com.iridium.iridiumcore.dependencies.paperlib.PaperLib;
import com.iridium.iridiumcore.dependencies.xseries.XMaterial;
Expand Down Expand Up @@ -37,6 +38,8 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.io.File;
import java.io.IOException;
import java.time.LocalDateTime;
import java.util.*;
import java.util.concurrent.CompletableFuture;
Expand All @@ -54,7 +57,35 @@ public void createWorld(World.Environment environment, String name) {
WorldCreator worldCreator = new WorldCreator(name)
.generator(IridiumSkyblock.getInstance().getDefaultWorldGenerator(name, null))
.environment(environment);
Bukkit.createWorld(worldCreator);
World world = Bukkit.createWorld(worldCreator);

if (world != null && world.getEnvironment() == World.Environment.THE_END) {
Bukkit.unloadWorld(world.getName(), true);

try {
File file = new File(worldCreator.name() + File.separator + "level.dat");
NBTFile worldFile = new NBTFile(file);

if (worldFile.getCompound("Data").getCompound("DragonFight") == null) {
IridiumSkyblock.getInstance().getLogger().warning("Cannot load \"DragonFight\" compound because \"DragonFight\" is null.");
return;
}

NBTCompound compound = worldFile.getCompound("Data").getCompound("DragonFight");

compound.setBoolean("PreviouslyKilled", true);
compound.setBoolean("DragonKilled", true);
compound.setBoolean("NeedsStateScanning", false);

worldFile.save();
} catch (Exception exception) {
exception.printStackTrace();
IridiumSkyblock.getInstance().getLogger().warning("Failed to delete dragon from world");
}

// Note this world is already created, we are just loading it here
Bukkit.createWorld(worldCreator);
PeachesMLG marked this conversation as resolved.
Show resolved Hide resolved
}
}

public void setIslandBiome(@NotNull Island island, @NotNull XBiome biome) {
Expand Down
Loading