Skip to content

Commit

Permalink
Added the ability to prepare end worlds using the API
Browse files Browse the repository at this point in the history
  • Loading branch information
OmerBenGera committed Jul 9, 2022
1 parent 937f593 commit 4d74d56
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
@@ -1,12 +1,20 @@
package com.bgsoftware.superiorskyblock.api.service.dragon;

import com.bgsoftware.superiorskyblock.api.island.Island;
import org.bukkit.World;
import org.bukkit.entity.EnderDragon;

import javax.annotation.Nullable;

public interface DragonBattleService {

/**
* Prepare an end world for dragon fights.
*
* @param world The world to prepare.
*/
void prepareEndWorld(World world);

/**
* Get the current active ender dragon of an island.
* If there is no active fight, null is returned.
Expand Down
Expand Up @@ -39,7 +39,7 @@ public void prepareWorlds() {
if (plugin.getSettings().getWorlds().getEnd().isEnabled()) {
World endWorld = loadWorld(plugin.getSettings().getWorlds().getEnd().getName(), difficulty, World.Environment.THE_END);
if (plugin.getSettings().getWorlds().getEnd().isDragonFight())
plugin.getNMSDragonFight().prepareEndWorld(endWorld);
plugin.getServices().getDragonBattleService().prepareEndWorld(endWorld);
}
}

Expand Down
Expand Up @@ -4,6 +4,7 @@
import com.bgsoftware.superiorskyblock.api.island.Island;
import com.bgsoftware.superiorskyblock.api.service.dragon.DragonBattleResetResult;
import com.bgsoftware.superiorskyblock.api.service.dragon.DragonBattleService;
import com.google.common.base.Preconditions;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.EnderDragon;
Expand All @@ -18,6 +19,12 @@ public DragonBattleServiceImpl(SuperiorSkyblockPlugin plugin) {
this.plugin = plugin;
}

@Override
public void prepareEndWorld(World bukkitWorld) {
Preconditions.checkState(bukkitWorld.getEnvironment() == World.Environment.THE_END, "world must be the_end environment.");
plugin.getNMSDragonFight().prepareEndWorld(bukkitWorld);
}

@Nullable
@Override
public EnderDragon getEnderDragon(Island island) {
Expand Down

0 comments on commit 4d74d56

Please sign in to comment.