mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-28 13:36:33 +01:00
Add dungeon map API
This commit is contained in:
parent
da149bd51e
commit
c5d95d1788
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (C) 2014-2020 Daniel Saukel
|
||||
*
|
||||
* 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;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
/**
|
||||
* A raw resource world instance to edit the dungeon map. There is never more than one edit world per resource world.
|
||||
* <p>
|
||||
* An edit world is not equal to a {@link de.erethon.dungeonsxl.api.dungeon.Dungeon}.
|
||||
*
|
||||
* @author Daniel Saukel
|
||||
*/
|
||||
public interface EditWorld extends InstanceWorld {
|
||||
|
||||
/**
|
||||
* Registers the block as a {@link de.erethon.dungeonsxl.api.sign.DungeonSign} sothat it can later be saved persistently.
|
||||
*
|
||||
* @param block a DungeonSign block
|
||||
*/
|
||||
void registerSign(Block block);
|
||||
|
||||
/**
|
||||
* Saves the sign data and overrides the resource with the changes.
|
||||
*/
|
||||
void save();
|
||||
|
||||
@Override
|
||||
default void delete() {
|
||||
delete(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes this edit instance.
|
||||
*
|
||||
* @param save whether this world should be {@link #save()}ed
|
||||
*/
|
||||
void delete(boolean save);
|
||||
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (C) 2014-2020 Daniel Saukel
|
||||
*
|
||||
* 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;
|
||||
|
||||
import de.erethon.dungeonsxl.api.Dungeon;
|
||||
import de.erethon.dungeonsxl.api.game.Game;
|
||||
import org.bukkit.Location;
|
||||
|
||||
/**
|
||||
* A playable resource instance. There may be any amount of GameWorlds per {@link ResourceWorld}.
|
||||
* <p>
|
||||
* A game world is not equal to a {@link de.erethon.dungeonsxl.api.Dungeon}.
|
||||
*
|
||||
* @author Daniel Saukel
|
||||
*/
|
||||
// Implementation-specific methods: [gameblock, secure objects, classes signs, mobs, triggers] methods, getMobCount(), setPlaying(), startGame(), listener methods
|
||||
public interface GameWorld extends InstanceWorld {
|
||||
|
||||
enum Type {
|
||||
START_FLOOR,
|
||||
END_FLOOR,
|
||||
DEFAULT
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link Type} of this GameWorld.
|
||||
*
|
||||
* @return the {@link Type} of this GameWorld
|
||||
*/
|
||||
Type getType();
|
||||
|
||||
/**
|
||||
* Sets the {@link Type} of this GameWorld.
|
||||
*
|
||||
* @param type the type
|
||||
*/
|
||||
void setType(Type type);
|
||||
|
||||
/**
|
||||
* Returns the game that is played in the game world.
|
||||
*
|
||||
* @return the game that is played in the game world
|
||||
*/
|
||||
Game getGame();
|
||||
|
||||
/**
|
||||
* Returns the dungeon that the game world is part of.
|
||||
* <p>
|
||||
* Note: While a {@link ResourceWorld} may be part of multiple dungeons, an instance is instantiated per game and thus has just one dungeon.
|
||||
*
|
||||
* @return the dungeon that the game world is part of
|
||||
*/
|
||||
Dungeon getDungeon();
|
||||
|
||||
/**
|
||||
* Returns if the game has begun in the game world.
|
||||
*
|
||||
* @return if the game has begun in the game world
|
||||
*/
|
||||
boolean isPlaying();
|
||||
|
||||
/**
|
||||
* Returns the start location of the world. This may be set by a start {@link de.erethon.dungeonsxl.api.sign.DungeonSign sign} or, if none exists, the
|
||||
* Vanilla spawn location of the {@link #getWorld() world}.
|
||||
*
|
||||
* @return the start location of the world
|
||||
*/
|
||||
Location getStartLocation();
|
||||
|
||||
}
|
@ -0,0 +1,132 @@
|
||||
/*
|
||||
* Copyright (C) 2014-2020 Daniel Saukel
|
||||
*
|
||||
* 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;
|
||||
|
||||
import de.erethon.dungeonsxl.api.player.InstancePlayer;
|
||||
import de.erethon.dungeonsxl.api.sign.DungeonSign;
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
|
||||
/**
|
||||
* Super interface for worlds that are instantiated by DungeonsXL.
|
||||
* <p>
|
||||
* An instance world is not equal to a {@link de.erethon.dungeonsxl.api.dungeon.Dungeon}.
|
||||
*
|
||||
* @author Daniel Saukel
|
||||
*/
|
||||
// Implementation-specific methods: getConfig, exists, setWeather
|
||||
public interface InstanceWorld {
|
||||
|
||||
/**
|
||||
* Returns the name of the resource world of this instance.
|
||||
* <p>
|
||||
* Use {@link #getWorld()#getName()} to get the name of the instantiated world (like e.g. DXL_Game_1).
|
||||
*
|
||||
* @return the name of the resource world of this instance
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Returns the saved map this instance was loaded from.
|
||||
*
|
||||
* @return the saved map this instance was loaded from
|
||||
*/
|
||||
ResourceWorld getResource();
|
||||
|
||||
/**
|
||||
* Returns the world folder.
|
||||
*
|
||||
* @return the world folder
|
||||
*/
|
||||
File getFolder();
|
||||
|
||||
/**
|
||||
* Returns the wrapped Bukkit world.
|
||||
*
|
||||
* @return the wrapped Bukkit world
|
||||
*/
|
||||
World getWorld();
|
||||
|
||||
/**
|
||||
* Returns the ID. This is usually the number in the map name.
|
||||
*
|
||||
* @return the ID
|
||||
*/
|
||||
int getId();
|
||||
|
||||
/**
|
||||
* Returns a collection of the signs in this instance.
|
||||
*
|
||||
* @return a collection of the signs in this instance
|
||||
*/
|
||||
Collection<DungeonSign> getDungeonSigns();
|
||||
|
||||
/**
|
||||
* Adds a dungeon sign to this instance.
|
||||
*
|
||||
* @param sign the sign
|
||||
*/
|
||||
void addDungeonSign(DungeonSign sign);
|
||||
|
||||
/**
|
||||
* Removes a dungeon sign from this instance.
|
||||
*
|
||||
* @param sign the sign
|
||||
*/
|
||||
void removeDungeonSign(DungeonSign sign);
|
||||
|
||||
/**
|
||||
* Returns the location of the lobby where players spawn by default when they are teleported into the dungeon.
|
||||
*
|
||||
* @return the location of the lobby where players spawn by default when they are teleported into the dungeon
|
||||
*/
|
||||
Location getLobbyLocation();
|
||||
|
||||
/**
|
||||
* Sets the default spawn location of the instance.
|
||||
* <p>
|
||||
* This is not persistent and does not create a lobby sign.
|
||||
*
|
||||
* @param location the location
|
||||
*/
|
||||
void setLobbyLocation(Location location);
|
||||
|
||||
/**
|
||||
* Returns the players in the instance.
|
||||
*
|
||||
* @return the players in the instance
|
||||
*/
|
||||
Collection<InstancePlayer> getPlayers();
|
||||
|
||||
/**
|
||||
* Sends a message to all players in the instance.
|
||||
*
|
||||
* @param message the message to send
|
||||
*/
|
||||
void sendMessage(String message);
|
||||
|
||||
/**
|
||||
* Makes all players leave the world. Attempts to let them leave properly if they are correct DInstancePlayers; teleports them to the spawn if they are not.
|
||||
*/
|
||||
void kickAllPlayers();
|
||||
|
||||
/**
|
||||
* Deletes this instance.
|
||||
*/
|
||||
void delete();
|
||||
|
||||
}
|
@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (C) 2014-2020 Daniel Saukel
|
||||
*
|
||||
* 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;
|
||||
|
||||
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: getConfig, getSignData, generate
|
||||
public interface ResourceWorld {
|
||||
|
||||
/**
|
||||
* Returns the name of this resource world.
|
||||
* <p>
|
||||
* Equals {@link #getFolder()#getName()}.
|
||||
*
|
||||
* @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 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);
|
||||
|
||||
/**
|
||||
* 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 generates a new one if none exists.
|
||||
*
|
||||
* @return the loaded edit instance of this world or generates a new one if none exists
|
||||
*/
|
||||
EditWorld getOrInstantiateEditWorld();
|
||||
|
||||
/**
|
||||
* Returns a new game instance of this resource.
|
||||
*
|
||||
* @return a new game instance of this resource
|
||||
*/
|
||||
GameWorld instantiateGameWorld();
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user