org.bukkit
Interface Server

All Superinterfaces:
PluginMessageRecipient

public interface Server
extends PluginMessageRecipient

Represents a server implementation


Field Summary
static String BROADCAST_CHANNEL_ADMINISTRATIVE
          Used for all administrative messages, such as an operator using a command.
static String BROADCAST_CHANNEL_USERS
          Used for all announcement messages, such as informing users that a player has joined.
 
Method Summary
 boolean addRecipe(Recipe recipe)
          Adds a recipe to the crafting manager.
 void banIP(String address)
          Bans the specified address from the server
 int broadcast(String message, String permission)
          Broadcasts the specified message to every user with the given permission
 int broadcastMessage(String message)
          Broadcast a message to all players.
 void clearRecipes()
          Clears the list of crafting recipes.
 void configureDbConfig(com.avaje.ebean.config.ServerConfig config)
          Populates a given ServerConfig with values attributes to this server
 Inventory createInventory(InventoryHolder owner, int size)
          Creates an empty inventory of type InventoryType.CHEST with the specified size.
 Inventory createInventory(InventoryHolder owner, int size, String title)
          Creates an empty inventory of type InventoryType.CHEST with the specified size and title.
 Inventory createInventory(InventoryHolder owner, InventoryType type)
          Creates an empty inventory of the specified type.
 MapView createMap(World world)
          Create a new map with an automatically assigned ID.
 World createWorld(WorldCreator creator)
          Creates or loads a world with the given name using the specified options.
 boolean dispatchCommand(CommandSender sender, String commandLine)
          Dispatches a command on the server, and executes it if found.
 boolean getAllowEnd()
          Gets whether this server allows the End or not.
 boolean getAllowFlight()
          Gets whether this server allows flying or not.
 boolean getAllowNether()
          Gets whether this server allows the Nether or not.
 int getAmbientSpawnLimit()
          Gets user-specified limit for number of ambient mobs that can spawn in a chunk
 int getAnimalSpawnLimit()
          Gets user-specified limit for number of animals that can spawn in a chunk
 Set<OfflinePlayer> getBannedPlayers()
          Gets a set containing all banned players
 String getBukkitVersion()
          Gets the Bukkit version that this server is running.
 Map<String,String[]> getCommandAliases()
          Gets a list of command aliases defined in the server properties.
 long getConnectionThrottle()
          Gets the value of the connection throttle setting
 ConsoleCommandSender getConsoleSender()
          Gets the ConsoleCommandSender that may be used as an input source for this server.
 GameMode getDefaultGameMode()
          Gets the default GameMode for new players
 boolean getGenerateStructures()
          Get generate-structures setting
 HelpMap getHelpMap()
          Gets the HelpMap providing help topics for this server.
 String getIp()
          Get the IP that this server is bound to or empty string if not specified
 Set<String> getIPBans()
          Gets a set containing all current IPs that are banned
 ItemFactory getItemFactory()
          Gets the instance of the item factory (for ItemMeta).
 Logger getLogger()
          Returns the primary logger associated with this server instance
 MapView getMap(short id)
          Gets the map from the given item ID.
 int getMaxPlayers()
          Get the maximum amount of players which can login to this server
 Messenger getMessenger()
          Gets the Messenger responsible for this server.
 int getMonsterSpawnLimit()
          Gets user-specified limit for number of monsters that can spawn in a chunk
 String getMotd()
          Gets the message that is displayed on the server list
 String getName()
          Gets the name of this server implementation
 OfflinePlayer getOfflinePlayer(String name)
          Gets the player by the given name, regardless if they are offline or online.
 OfflinePlayer[] getOfflinePlayers()
          Gets every player that has ever played on this server.
 boolean getOnlineMode()
          Gets whether the Server is in online mode or not.
 Player[] getOnlinePlayers()
          Gets a list of all currently logged in players
 Set<OfflinePlayer> getOperators()
          Gets a set containing all player operators
 Player getPlayer(String name)
          Gets a player object by the given username

This method may not return objects for offline players

 Player getPlayerExact(String name)
          Gets the player with the exact given name, case insensitive
 PluginCommand getPluginCommand(String name)
          Gets a PluginCommand with the given name or alias
 PluginManager getPluginManager()
          Gets the PluginManager for interfacing with plugins
 int getPort()
          Get the game port that the server runs on
 List<Recipe> getRecipesFor(ItemStack result)
          Get a list of all recipes for a given item.
 BukkitScheduler getScheduler()
          Gets the Scheduler for managing scheduled events
 String getServerId()
          Get an ID of this server.
 String getServerName()
          Get the name of this server
 ServicesManager getServicesManager()
          Gets a services manager
 String getShutdownMessage()
          Gets the default message that is displayed when the server is stopped
 int getSpawnRadius()
          Gets the radius, in blocks, around each worlds spawn point to protect
 int getTicksPerAnimalSpawns()
          Gets default ticks per animal spawns value

Example Usage: A value of 1 will mean the server will attempt to spawn monsters every tick.

 int getTicksPerMonsterSpawns()
          Gets the default ticks per monster spawns value

Example Usage: A value of 1 will mean the server will attempt to spawn monsters every tick.

 String getUpdateFolder()
          Gets the name of the update folder.
 File getUpdateFolderFile()
          Gets the update folder.
 String getVersion()
          Gets the version string of this server implementation.
 int getViewDistance()
          Get the view distance from this server.
 Warning.WarningState getWarningState()
          Gets the current warning state for the server
 int getWaterAnimalSpawnLimit()
          Gets user-specified limit for number of water animals that can spawn in a chunk
 Set<OfflinePlayer> getWhitelistedPlayers()
          Gets a list of whitelisted players
 World getWorld(String name)
          Gets the world with the given name
 World getWorld(UUID uid)
          Gets the world from the given Unique ID
 File getWorldContainer()
          Gets the folder that contains all of the various Worlds.
 List<World> getWorlds()
          Gets a list of all worlds on this server
 String getWorldType()
          Get world type (level-type setting) for default world
 boolean hasWhitelist()
          Gets whether this server has a whitelist or not.
 boolean isHardcore()
          Gets whether the server is in hardcore mode or not.
 boolean isPrimaryThread()
          Returns true if the current Thread is the server's primary thread
 List<Player> matchPlayer(String name)
          Attempts to match any players with the given name, and returns a list of all possibly matches

This list is not sorted in any particular order.

 Iterator<Recipe> recipeIterator()
          Get an iterator through the list of crafting recipes.
 void reload()
          Reloads the server, refreshing settings and plugin information
 void reloadWhitelist()
          Reloads the whitelist from disk
 void resetRecipes()
          Resets the list of crafting recipes to the default.
 void savePlayers()
          Writes loaded players to disk
 void setDefaultGameMode(GameMode mode)
          Sets the default GameMode for new players
 void setSpawnRadius(int value)
          Sets the radius, in blocks, around each worlds spawn point to protect
 void setWhitelist(boolean value)
          Sets the whitelist on or off
 void shutdown()
          Shutdowns the server, stopping everything.
 void unbanIP(String address)
          Unbans the specified address from the server
 boolean unloadWorld(String name, boolean save)
          Unloads a world with the given name.
 boolean unloadWorld(World world, boolean save)
          Unloads the given world.
 boolean useExactLoginLocation()
          Gets whether to use vanilla (false) or exact behaviour (true).
 
Methods inherited from interface org.bukkit.plugin.messaging.PluginMessageRecipient
getListeningPluginChannels, sendPluginMessage
 

Field Detail

BROADCAST_CHANNEL_ADMINISTRATIVE

static final String BROADCAST_CHANNEL_ADMINISTRATIVE
Used for all administrative messages, such as an operator using a command.

For use in broadcast(java.lang.String, java.lang.String)

See Also:
Constant Field Values

BROADCAST_CHANNEL_USERS

static final String BROADCAST_CHANNEL_USERS
Used for all announcement messages, such as informing users that a player has joined.

For use in broadcast(java.lang.String, java.lang.String)

See Also:
Constant Field Values
Method Detail

getName

String getName()
Gets the name of this server implementation

Returns:
name of this server implementation

getVersion

String getVersion()
Gets the version string of this server implementation.

Returns:
version of this server implementation

getBukkitVersion

String getBukkitVersion()
Gets the Bukkit version that this server is running.

Returns:
Version of Bukkit

getOnlinePlayers

Player[] getOnlinePlayers()
Gets a list of all currently logged in players

Returns:
An array of Players that are currently online

getMaxPlayers

int getMaxPlayers()
Get the maximum amount of players which can login to this server

Returns:
The amount of players this server allows

getPort

int getPort()
Get the game port that the server runs on

Returns:
The port number of this server

getViewDistance

int getViewDistance()
Get the view distance from this server.

Returns:
The view distance from this server.

getIp

String getIp()
Get the IP that this server is bound to or empty string if not specified

Returns:
The IP string that this server is bound to, otherwise empty string

getServerName

String getServerName()
Get the name of this server

Returns:
The name of this server

getServerId

String getServerId()
Get an ID of this server. The ID is a simple generally alphanumeric ID that can be used for uniquely identifying this server.

Returns:
The ID of this server

getWorldType

String getWorldType()
Get world type (level-type setting) for default world

Returns:
The value of level-type (e.g. DEFAULT, FLAT, DEFAULT_1_1)

getGenerateStructures

boolean getGenerateStructures()
Get generate-structures setting

Returns:
true if structure generation is enabled, false if not

getAllowEnd

boolean getAllowEnd()
Gets whether this server allows the End or not.

Returns:
Whether this server allows the End or not.

getAllowNether

boolean getAllowNether()
Gets whether this server allows the Nether or not.

Returns:
Whether this server allows the Nether or not.

hasWhitelist

boolean hasWhitelist()
Gets whether this server has a whitelist or not.

Returns:
Whether this server has a whitelist or not.

setWhitelist

void setWhitelist(boolean value)
Sets the whitelist on or off

Parameters:
value - true if whitelist is on, otherwise false

getWhitelistedPlayers

Set<OfflinePlayer> getWhitelistedPlayers()
Gets a list of whitelisted players

Returns:
Set containing all whitelisted players

reloadWhitelist

void reloadWhitelist()
Reloads the whitelist from disk


broadcastMessage

int broadcastMessage(String message)
Broadcast a message to all players.

This is the same as calling broadcast(java.lang.String, java.lang.String) to BROADCAST_CHANNEL_USERS

Parameters:
message - the message
Returns:
the number of players

getUpdateFolder

String getUpdateFolder()
Gets the name of the update folder. The update folder is used to safely update plugins at the right moment on a plugin load.

The update folder name is relative to the plugins folder.

Returns:
The name of the update folder

getUpdateFolderFile

File getUpdateFolderFile()
Gets the update folder. The update folder is used to safely update plugins at the right moment on a plugin load.

Returns:
The name of the update folder

getConnectionThrottle

long getConnectionThrottle()
Gets the value of the connection throttle setting

Returns:
the value of the connection throttle setting

getTicksPerAnimalSpawns

int getTicksPerAnimalSpawns()
Gets default ticks per animal spawns value

Example Usage:

Note: If set to 0, animal spawning will be disabled. We recommend using spawn-animals to control this instead.

Minecraft default: 400.

Returns:
The default ticks per animal spawns value

getTicksPerMonsterSpawns

int getTicksPerMonsterSpawns()
Gets the default ticks per monster spawns value

Example Usage:

Note: If set to 0, monsters spawning will be disabled. We recommend using spawn-monsters to control this instead.

Minecraft default: 1.

Returns:
The default ticks per monsters spawn value

getPlayer

Player getPlayer(String name)
Gets a player object by the given username

This method may not return objects for offline players

Parameters:
name - Name to look up
Returns:
Player if it was found, otherwise null

getPlayerExact

Player getPlayerExact(String name)
Gets the player with the exact given name, case insensitive

Parameters:
name - Exact name of the player to retrieve
Returns:
Player object or null if not found

matchPlayer

List<Player> matchPlayer(String name)
Attempts to match any players with the given name, and returns a list of all possibly matches

This list is not sorted in any particular order. If an exact match is found, the returned list will only contain a single result.

Parameters:
name - Name to match
Returns:
List of all possible players

getPluginManager

PluginManager getPluginManager()
Gets the PluginManager for interfacing with plugins

Returns:
PluginManager for this Server instance

getScheduler

BukkitScheduler getScheduler()
Gets the Scheduler for managing scheduled events

Returns:
Scheduler for this Server instance

getServicesManager

ServicesManager getServicesManager()
Gets a services manager

Returns:
Services manager

getWorlds

List<World> getWorlds()
Gets a list of all worlds on this server

Returns:
A list of worlds

createWorld

World createWorld(WorldCreator creator)
Creates or loads a world with the given name using the specified options.

If the world is already loaded, it will just return the equivalent of getWorld(creator.name()).

Parameters:
creator - The options to use when creating the world.
Returns:
Newly created or loaded world

unloadWorld

boolean unloadWorld(String name,
                    boolean save)
Unloads a world with the given name.

Parameters:
name - Name of the world to unload
save - Whether to save the chunks before unloading.
Returns:
Whether the action was Successful

unloadWorld

boolean unloadWorld(World world,
                    boolean save)
Unloads the given world.

Parameters:
world - The world to unload
save - Whether to save the chunks before unloading.
Returns:
Whether the action was Successful

getWorld

World getWorld(String name)
Gets the world with the given name

Parameters:
name - Name of the world to retrieve
Returns:
World with the given name, or null if none exists

getWorld

World getWorld(UUID uid)
Gets the world from the given Unique ID

Parameters:
uid - Unique ID of the world to retrieve.
Returns:
World with the given Unique ID, or null if none exists.

getMap

MapView getMap(short id)
Gets the map from the given item ID.

Parameters:
id - ID of the map to get.
Returns:
The MapView if it exists, or null otherwise.

createMap

MapView createMap(World world)
Create a new map with an automatically assigned ID.

Parameters:
world - The world the map will belong to.
Returns:
The MapView just created.

reload

void reload()
Reloads the server, refreshing settings and plugin information


getLogger

Logger getLogger()
Returns the primary logger associated with this server instance

Returns:
Logger associated with this server

getPluginCommand

PluginCommand getPluginCommand(String name)
Gets a PluginCommand with the given name or alias

Parameters:
name - Name of the command to retrieve
Returns:
PluginCommand if found, otherwise null

savePlayers

void savePlayers()
Writes loaded players to disk


dispatchCommand

boolean dispatchCommand(CommandSender sender,
                        String commandLine)
                        throws CommandException
Dispatches a command on the server, and executes it if found.

Parameters:
sender - The apparent sender of the command
commandLine - command + arguments. Example: "test abc 123"
Returns:
returns false if no target is found.
Throws:
CommandException - Thrown when the executor for the given command fails with an unhandled exception

configureDbConfig

void configureDbConfig(com.avaje.ebean.config.ServerConfig config)
Populates a given ServerConfig with values attributes to this server

Parameters:
config - ServerConfig to populate

addRecipe

boolean addRecipe(Recipe recipe)
Adds a recipe to the crafting manager.

Parameters:
recipe - The recipe to add.
Returns:
True if the recipe was added, false if it wasn't for some reason.

getRecipesFor

List<Recipe> getRecipesFor(ItemStack result)
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.

Parameters:
result - The item whose recipes you want
Returns:
The list of recipes

recipeIterator

Iterator<Recipe> recipeIterator()
Get an iterator through the list of crafting recipes.

Returns:
The iterator.

clearRecipes

void clearRecipes()
Clears the list of crafting recipes.


resetRecipes

void resetRecipes()
Resets the list of crafting recipes to the default.


getCommandAliases

Map<String,String[]> getCommandAliases()
Gets a list of command aliases defined in the server properties.

Returns:
Map of aliases to command names

getSpawnRadius

int getSpawnRadius()
Gets the radius, in blocks, around each worlds spawn point to protect

Returns:
Spawn radius, or 0 if none

setSpawnRadius

void setSpawnRadius(int value)
Sets the radius, in blocks, around each worlds spawn point to protect

Parameters:
value - New spawn radius, or 0 if none

getOnlineMode

boolean getOnlineMode()
Gets whether the Server is in online mode or not.

Returns:
Whether the server is in online mode.

getAllowFlight

boolean getAllowFlight()
Gets whether this server allows flying or not.

Returns:
Whether this server allows flying or not.

isHardcore

boolean isHardcore()
Gets whether the server is in hardcore mode or not.

Returns:
Whether this server is in hardcore mode or not.

useExactLoginLocation

boolean useExactLoginLocation()
Gets whether to use vanilla (false) or exact behaviour (true). Vanilla behaviour: check for collisions and move the player if needed. Exact behaviour: spawn players exactly where they should be.

Returns:
Whether to use vanilla (false) or exact behaviour (true).

shutdown

void shutdown()
Shutdowns the server, stopping everything.


broadcast

int broadcast(String message,
              String permission)
Broadcasts the specified message to every user with the given permission

Parameters:
message - Message to broadcast
permission - Permission the users must have to receive the broadcast
Returns:
Amount of users who received the message

getOfflinePlayer

OfflinePlayer getOfflinePlayer(String name)
Gets the player by the given name, regardless if they are offline or online.

This will return an object even if the player does not exist. To this method, all players will exist.

Parameters:
name - Name of the player to retrieve
Returns:
OfflinePlayer object

getIPBans

Set<String> getIPBans()
Gets a set containing all current IPs that are banned

Returns:
Set containing banned IP addresses

banIP

void banIP(String address)
Bans the specified address from the server

Parameters:
address - IP address to ban

unbanIP

void unbanIP(String address)
Unbans the specified address from the server

Parameters:
address - IP address to unban

getBannedPlayers

Set<OfflinePlayer> getBannedPlayers()
Gets a set containing all banned players

Returns:
Set containing banned players

getOperators

Set<OfflinePlayer> getOperators()
Gets a set containing all player operators

Returns:
Set containing player operators

getDefaultGameMode

GameMode getDefaultGameMode()
Gets the default GameMode for new players

Returns:
Default game mode

setDefaultGameMode

void setDefaultGameMode(GameMode mode)
Sets the default GameMode for new players

Parameters:
mode - New game mode

getConsoleSender

ConsoleCommandSender getConsoleSender()
Gets the ConsoleCommandSender that may be used as an input source for this server.

Returns:
The Console CommandSender

getWorldContainer

File getWorldContainer()
Gets the folder that contains all of the various Worlds.

Returns:
World container folder

getOfflinePlayers

OfflinePlayer[] getOfflinePlayers()
Gets every player that has ever played on this server.

Returns:
Array containing all players

getMessenger

Messenger getMessenger()
Gets the Messenger responsible for this server.

Returns:
Messenger responsible for this server.

getHelpMap

HelpMap getHelpMap()
Gets the HelpMap providing help topics for this server.

Returns:
The server's HelpMap.

createInventory

Inventory createInventory(InventoryHolder owner,
                          InventoryType type)
Creates an empty inventory of the specified type. If the type is InventoryType.CHEST, the new inventory has a size of 27; otherwise the new inventory has the normal size for its type.

Parameters:
owner - The holder of the inventory; can be null if there's no holder.
type - The type of inventory to create.
Returns:
The new inventory.

createInventory

Inventory createInventory(InventoryHolder owner,
                          int size)
Creates an empty inventory of type InventoryType.CHEST with the specified size.

Parameters:
owner - The holder of the inventory; can be null if there's no holder.
size - The size of inventory to create; must be a multiple of 9.
Returns:
The new inventory.
Throws:
IllegalArgumentException - If the size is not a multiple of 9.

createInventory

Inventory createInventory(InventoryHolder owner,
                          int size,
                          String title)
Creates an empty inventory of type InventoryType.CHEST with the specified size and title.

Parameters:
owner - The holder of the inventory; can be null if there's no holder.
size - The size of inventory to create; must be a multiple of 9.
title - The title of the inventory, to be displayed when it is viewed.
Returns:
The new inventory.
Throws:
IllegalArgumentException - If the size is not a multiple of 9.

getMonsterSpawnLimit

int getMonsterSpawnLimit()
Gets user-specified limit for number of monsters that can spawn in a chunk

Returns:
The monster spawn limit

getAnimalSpawnLimit

int getAnimalSpawnLimit()
Gets user-specified limit for number of animals that can spawn in a chunk

Returns:
The animal spawn limit

getWaterAnimalSpawnLimit

int getWaterAnimalSpawnLimit()
Gets user-specified limit for number of water animals that can spawn in a chunk

Returns:
The water animal spawn limit

getAmbientSpawnLimit

int getAmbientSpawnLimit()
Gets user-specified limit for number of ambient mobs that can spawn in a chunk

Returns:
The ambient spawn limit

isPrimaryThread

boolean isPrimaryThread()
Returns true if the current Thread is the server's primary thread


getMotd

String getMotd()
Gets the message that is displayed on the server list

Returns:
the servers MOTD

getShutdownMessage

String getShutdownMessage()
Gets the default message that is displayed when the server is stopped

Returns:
the shutdown message

getWarningState

Warning.WarningState getWarningState()
Gets the current warning state for the server

Returns:
The configured WarningState

getItemFactory

ItemFactory getItemFactory()
Gets the instance of the item factory (for ItemMeta).

Returns:
the item factory
See Also:
ItemFactory


Copyright © 2013. All Rights Reserved.