DungeonsXL/api/src/main/java/de/erethon/dungeonsxl/api/world/ResourceWorld.java

138 lines
4.7 KiB
Java
Raw Normal View History

2020-01-27 01:42:36 +01:00
/*
2023-09-28 19:16:23 +02:00
* Copyright (C) 2014-2023 Daniel Saukel
2020-01-27 01:42:36 +01:00
*
* This library is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNULesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.erethon.dungeonsxl.api.world;
2020-01-27 19:54:30 +01:00
import de.erethon.dungeonsxl.api.dungeon.Dungeon;
2021-04-25 15:15:59 +02:00
import de.erethon.dungeonsxl.api.dungeon.Game;
import de.erethon.dungeonsxl.api.dungeon.GameRuleContainer;
2020-01-27 01:42:36 +01:00
import java.io.File;
import org.bukkit.OfflinePlayer;
import org.bukkit.World.Environment;
/**
* A stored world that can be instantiated as an {@link EditWorld} or as a {@link GameWorld}.
* <p>
* In the default implementation, these are saved under "plugins/DungeonsXL/maps/".
* <p>
* A resource world is not equal to a {@link de.erethon.dungeonsxl.api.dungeon.Dungeon}.
*
* @author Daniel Saukel
*/
// Implementation-specific methods: getSignData, generate
2020-01-27 01:42:36 +01:00
public interface ResourceWorld {
/**
* Returns the name of this resource world.
* <p>
2020-01-29 02:06:48 +01:00
* Equals {@link #getFolder()}{@link File#getName() #getName()}.
2020-01-27 01:42:36 +01:00
*
* @return name of this resource world
*/
String getName();
/**
* Renames the resource world and its folder.
*
* @param name the new name
*/
void setName(String name);
/**
* Returns the folder where this resource is stored.
*
* @return the folder where this resource is stored
*/
File getFolder();
/**
* Returns the {@link de.erethon.dungeonsxl.api.dungeon.GameRule}s of this world.
* <p>
* Note that these are only the rules that are specific to the map itself. They are not the rules that are actually used in a game instance instantiated
* from this resource world as these ones may be supplemented or overriden by other rules taken from the main config, dungeon config or the
2021-10-23 01:43:23 +02:00
* {@link de.erethon.dungeonsxl.api.dungeon.GameRule#DEFAULT_VALUES}.
*
* @return the {@link de.erethon.dungeonsxl.api.dungeon.GameRule}s of this world
*/
GameRuleContainer getRules();
2020-01-27 01:42:36 +01:00
/**
* Returns the environment of the world as defined in the config or {@link org.bukkit.World.Environment#NORMAL} if nothing is set.
*
* @return the environment of the world as defined in the config or {@link org.bukkit.World.Environment#NORMAL} if nothing is set
*/
Environment getWorldEnvironment();
/**
* Adds the player to the list of players that are invited to edit the resource.
*
* @param player the player
*/
void addInvitedPlayer(OfflinePlayer player);
/**
* Removes a player from the list of players that are invited to edit the resource.
*
* @param player the player
* @return if the action was successful
*/
boolean removeInvitedPlayer(OfflinePlayer player);
2020-01-27 01:42:36 +01:00
/**
* Returns if the player is invited to edit the resource.
*
* @param player the player
* @return if the player is invited to edit the resource
*/
boolean isInvitedPlayer(OfflinePlayer player);
/**
* Creates a backup of the resource.
*/
void backup();
/**
* Returns the loaded edit instance of this world or null if none exists.
*
* @return the loaded edit instance of this world or null if none exists
*/
EditWorld getEditWorld();
2020-01-27 01:42:36 +01:00
/**
* Returns the loaded edit instance of this world or generates a new one if none exists.
*
* @param ignoreLimit if the instance limit set in the main config shall be ignored
2020-01-27 01:42:36 +01:00
* @return the loaded edit instance of this world or generates a new one if none exists
*/
EditWorld getOrInstantiateEditWorld(boolean ignoreLimit);
2020-01-27 01:42:36 +01:00
/**
* Returns a new game instance of this resource.
*
* @see de.erethon.dungeonsxl.api.dungeon.Game#ensureWorldIsLoaded(boolean)
2021-04-25 15:15:59 +02:00
* @param game the game the instance belongs to
* @param ignoreLimit if the instance limit set in the main config shall be ignored
2020-01-27 01:42:36 +01:00
* @return a new game instance of this resource
*/
2021-04-25 15:15:59 +02:00
GameWorld instantiateGameWorld(Game game, boolean ignoreLimit);
2020-01-27 01:42:36 +01:00
2020-01-27 19:54:30 +01:00
/**
* Returns the single floor dungeon of this resource.
*
* @return the single floor dungeon of this resource
*/
Dungeon getSingleFloorDungeon();
2020-01-27 01:42:36 +01:00
}