Skip to content
Merged
Show file tree
Hide file tree
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
20 changes: 16 additions & 4 deletions src/main/java/net/theevilreaper/aves/map/provider/MapProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import net.minestom.server.coordinate.Pos;
import net.minestom.server.entity.Player;
import net.minestom.server.instance.Instance;
import net.minestom.server.instance.anvil.AnvilLoader;
import net.theevilreaper.aves.map.BaseMap;
import net.theevilreaper.aves.map.MapEntry;
import org.jetbrains.annotations.NotNull;
Expand All @@ -16,7 +17,7 @@
/**
* The {@link MapProvider} interface is responsible for managing the available maps.
* It will load all maps data from the given path and store them.
* It would not load the map itself over a {@link net.minestom.server.instance.anvil.AnvilLoader} instance.
* It would not load the map itself over a {@link AnvilLoader} instance.
* This behavior is handled by another class.
*
* @author theEvilReaper
Expand All @@ -26,22 +27,33 @@
public interface MapProvider {

/**
* A static fallback position which can be used if no spawn position is set.
* A static fallback position that can be used if no spawn position is set.
*/
Pos FALLBACK_POS = new Pos(0, 100, 0);

/**
* Saves the given data from a {@link BaseMap} to the given path.
*
* @param path the path where the map data should be saved
* @param baseMap the map data which should be saved
* @param baseMap the map data that should be saved
*/
void saveMap(@NotNull Path path, @NotNull BaseMap baseMap);

/**
* Teleports a {@link Player} to the current active spawn position of the {@link Instance}.
* This method does not change the player's instance.
* To also set the instance, use {@link #teleportToSpawn(Player, boolean)}.
*
* @param player the player which should be teleported
* @param player to teleport
*/
default void teleportToSpawn(@NotNull Player player) {
teleportToSpawn(player, false);
}

/**
* Teleports a {@link Player} to the current active spawn position of the {@link Instance}.
*
* @param player the player that should be teleported
* @param instanceSet if the instance should be set to the current active instance
*/
void teleportToSpawn(@NotNull Player player, boolean instanceSet);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void testMapHandlingLogic(@NotNull Env env) {

assertEquals(Pos.ZERO, player.getPosition());

mapProvider.teleportToSpawn(player, false);
mapProvider.teleportToSpawn(player);

assertNotEquals(Pos.ZERO, player.getPosition());

Expand Down