package org.bukkit; import java.io.File; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import java.util.UUID; import java.util.logging.Logger; import org.bukkit.command.CommandException; import org.bukkit.command.CommandSender; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.command.PluginCommand; import org.bukkit.entity.Player; import org.bukkit.event.inventory.InventoryType; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.Recipe; import org.bukkit.map.MapView; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.ServicesManager; import org.bukkit.plugin.messaging.Messenger; import org.bukkit.plugin.messaging.PluginMessageRecipient; import org.bukkit.scheduler.BukkitScheduler; import com.avaje.ebean.config.ServerConfig; /** * Represents a server implementation */ public interface Server extends PluginMessageRecipient { /** * Used for all administrative messages, such as an operator using a command. *
* For use in {@link #broadcast(java.lang.String, java.lang.String)} */ public static final String BROADCAST_CHANNEL_ADMINISTRATIVE = "bukkit.broadcast.admin"; /** * Used for all announcement messages, such as informing users that a player has joined. * * For use in {@link #broadcast(java.lang.String, java.lang.String)} */ public static final String BROADCAST_CHANNEL_USERS = "bukkit.broadcast.user"; /** * Gets the name of this server implementation * * @return name of this server implementation */ public String getName(); /** * Gets the version string of this server implementation. * * @return version of this server implementation */ public String getVersion(); /** * Gets the Bukkit version that this server is running. * * @return Version of Bukkit */ public String getBukkitVersion(); /** * Gets a list of all currently logged in players * * @return An array of Players that are currently online */ public Player[] getOnlinePlayers(); /** * Get the maximum amount of players which can login to this server * * @return The amount of players this server allows */ public int getMaxPlayers(); /** * Get the game port that the server runs on * * @return The port number of this server */ public int getPort(); /** * Get the view distance from this server. * * @return The view distance from this server. */ public int getViewDistance(); /** * Get the IP that this server is bound to or empty string if not specified * * @return The IP string that this server is bound to, otherwise empty string */ public String getIp(); /** * Get the name of this server * * @return The name of this server */ public String getServerName(); /** * Get an ID of this server. The ID is a simple generally alphanumeric * ID that can be used for uniquely identifying this server. * * @return The ID of this server */ public String getServerId(); /** * Gets whether this server allows the End or not. * * @return Whether this server allows the End or not. */ public boolean getAllowEnd(); /** * Gets whether this server allows the Nether or not. * * @return Whether this server allows the Nether or not. */ public boolean getAllowNether(); /** * Gets whether this server has a whitelist or not. * * @return Whether this server has a whitelist or not. */ public boolean hasWhitelist(); /** * Sets the whitelist on or off * * @param value true if whitelist is on, otherwise false */ public void setWhitelist(boolean value); /** * Gets a list of whitelisted players * * @return Set containing all whitelisted players */ public Set
* If the world is already loaded, it will just return the equivalent of
* getWorld(creator.name()).
*
* @param creator The options to use when creating the world.
* @return Newly created or loaded world
*/
public World createWorld(WorldCreator creator);
/**
* Unloads a world with the given name.
*
* @param name Name of the world to unload
* @param save Whether to save the chunks before unloading.
* @return Whether the action was Successful
*/
public boolean unloadWorld(String name, boolean save);
/**
* Unloads the given world.
*
* @param world The world to unload
* @param save Whether to save the chunks before unloading.
* @return Whether the action was Successful
*/
public boolean unloadWorld(World world, boolean save);
/**
* Gets the world with the given name
*
* @param name Name of the world to retrieve
* @return World with the given name, or null if none exists
*/
public World getWorld(String name);
/**
* Gets the world from the given Unique ID
*
* @param uid Unique ID of the world to retrieve.
* @return World with the given Unique ID, or null if none exists.
*/
public World getWorld(UUID uid);
/**
* Gets the map from the given item ID.
*
* @param id ID of the map to get.
* @return The MapView if it exists, or null otherwise.
*/
public MapView getMap(short id);
/**
* Create a new map with an automatically assigned ID.
*
* @param world The world the map will belong to.
* @return The MapView just created.
*/
public MapView createMap(World world);
/**
* Reloads the server, refreshing settings and plugin information
*/
public void reload();
/**
* Returns the primary logger associated with this server instance
*
* @return Logger associated with this server
*/
public Logger getLogger();
/**
* Gets a {@link PluginCommand} with the given name or alias
*
* @param name Name of the command to retrieve
* @return PluginCommand if found, otherwise null
*/
public PluginCommand getPluginCommand(String name);
/**
* Writes loaded players to disk
*/
public void savePlayers();
/**
* Dispatches a command on the server, and executes it if found.
*
* @param sender The apparent sender of the command
* @param commandLine command + arguments. Example: "test abc 123"
* @return returns false if no target is found.
* @throws CommandException Thrown when the executor for the given command fails with an unhandled exception
*/
public boolean dispatchCommand(CommandSender sender, String commandLine) throws CommandException;
/**
* Populates a given {@link ServerConfig} with values attributes to this server
*
* @param config ServerConfig to populate
*/
public void configureDbConfig(ServerConfig config);
/**
* Adds a recipe to the crafting manager.
*
* @param recipe The recipe to add.
* @return True if the recipe was added, false if it wasn't for some reason.
*/
public boolean addRecipe(Recipe recipe);
/**
* Get a list of all recipes for a given item. The stack size is ignored in comparisons.
* If the durability is -1, it will match any data value.
*
* @param result The item whose recipes you want
* @return The list of recipes
*/
public List