Package net.risingworld.api
Klasse Server
java.lang.Object
net.risingworld.api.Server
Represents the server object. This is basically the "core element", it will
be used to control everything related to the game context.
-
Verschachtelte Klassen - Übersicht
-
Methodenübersicht
Modifizierer und TypMethodeBeschreibungstatic void
Adds a temporaryArea
to the server.static void
Adds anArea
to the server.static void
Bans the player with the specified UID for a given amount of time.static void
broadcastTextMessage
(String message) Broadcasts a text message, i.e send it to all players.static void
broadcastYellMessage
(String message, float duration, boolean pulsate) Broadcasts a yell message, i.e send it to all players.static Player
findNearestPlayer
(Vector3f position) Gets the player who has the shortest distance to a particular world position.static Area[]
Gets an array containing allAreas
that are currently registered with the server.static CustomImage[]
Gets an array containing all custom images (creates a new array).static CustomImage[]
getAllCustomImages
(int playerDbID) Gets an array containing all custom images which were uploaded by a particular player.static String[]
Gets all available permission group names.static Player[]
Gets a new array containing all players that are currently connected to the server.static Area
getArea
(long id) Gets theArea
with the provided global id.static int
getBuild()
Gets the current build of the game as an int (e.g 201807210).static WeatherDefs.Weather
Gets the current weather.static CustomImage
getCustomImage
(long id) Gets a custom image.static Inventory
Gets the default spawn inventory (i.e the items you always spawn with).static Vector3f
Gets the global default spawn position.static Quaternion
Gets the default spawn rotation.static Time
Gets the internal time object which manages the ingame time and date.static int
getGameTime
(Time.Unit unit) Gets the current ingame time.static float
Gets the game time speed.static String
getIP()
Gets the server ip.static String
getLastKnownPlayerName
(int playerDbID) Gets the last known name of the player with the specified database ID.static String
getLastKnownPlayerName
(String playerUID) Gets the last known name of the player with the specified UID.static String[]
getLastKnownPlayerUIDs
(String playerName) Gets the last known UIDs of all players who used the specified name recently.static String
Gets the full file path to the log file.static int
Gets the maximum amount of players allowed on this server.static String
getName()
Gets the server name.static WeatherDefs.Weather
Gets the next weather type.static String
Gets a server option from the "server.properties" file.
Note: This method cannot be used to retrieve passwords or login names.static Platform
Gets the game/server platform.static Player
getPlayer
(int playerid) Gets a player object representing the player with the provided playerid.static Player
getPlayerByDbID
(int playerDbID) Gets a player object representing the player with the provided unique database ID.static Player
getPlayerByName
(String playername) Gets a player object representing the player with the provided playername.static Player
getPlayerByUID
(String playerUID) Gets a player object representing the player with the provided unique ID (for Steam users, this is the SteamID64).static int
Gets the amount of players that are currently connected to this server.static String
getPlayerUID
(int playerDbID) Gets the UID of the player (irrespective of whether or not he's currently online) with the provided database ID.static int
getPort()
Gets the server port.static float
Gets the amount of seconds that have passed since game/server start.static long
Gets the UID of the server.static int
Gets the total amount of players that were ever connected to this server in the past.static Server.Type
getType()
Gets the current type of the server.static String
Gets the current game version as a String (e.g "0.9.1.5").static float
Gets the transition between the current weather type (0.0) and the next weather type (1.0).static boolean
Gets whether or not this server is password protected.static boolean
isPlayerAdmin
(String playerUID) Gets whether the particular player is an admin or not.static boolean
isPlayerBanned
(String playerUID) Gets whether the particular player (who has the provided UID) is banned or not.static boolean
isPlayerConnected
(int playerid) Gets whether or not this player is connected to the server.static boolean
isPlayerConnected
(String playername) Gets whether or not this player is connected to the server.static boolean
Gets whether or not the weather is enabled.static void
removeArea
(Area area) Removes anArea
that has been added to the server previously.static void
removeCustomImage
(long id, boolean destroyInstances) Deletes a custom image (and also removes all placed instances in the world).static void
restart()
Attempts to restart the server process.static void
saveAll()
Forces the server to save all pending changes (world, players, npcs, storages etc).static void
saveNpcs()
Forces the server to save all npcs.static void
Forces the server to save all players and inventories.static void
Forces the server to save all storages (chests etc).static void
sendInputCommand
(String input) Sends an input command to the InputStream (System.in) of the server.static void
setDefaultSpawnInventory
(Inventory inventory) Sets the default spawn inventory (i.e the items you always spawn with).static void
setDefaultSpawnPosition
(float x, float y, float z) Sets the global default spawn position.static void
setDefaultSpawnPosition
(Vector3f position) Sets the global default spawn position.static void
setDefaultSpawnRotation
(float pitch, float yaw, float roll) Sets the default spawn rotation.static void
setDefaultSpawnRotation
(Quaternion quaternion) Sets the default spawn rotation.static void
setGameTime
(int hour, int min) Sets the ingame time.static void
setGameTimeSpeed
(float value) Changes the game time speed.static void
setWeather
(WeatherDefs.Weather newWeather, boolean instant) Sets the weather.static void
setWeatherEnabled
(boolean enabled) Enables or disables the weather.static void
shutdown()
Forces the server to shutdown gracefully.static void
unbanPlayer
(String playerUID) Unbans the player with the specified name (i.e removes him from the ban list).
-
Methodendetails
-
getType
Gets the current type of the server. Sometimes it's useful to find out if this server is currently a singleplayer server or a dedicated server (more precisely, it indicates if this plugin is executed in a singleplayer or multiplayer environment).- Gibt zurück:
- the current server type.
- Example: Check if the plugin is running on a dedicated server
-
getPlatform
Gets the game/server platform.- Gibt zurück:
- the game/server platform, i.e if this is a Steam version, a standalone version etc.
-
getServerUID
public static long getServerUID()Gets the UID of the server. If this is a Steam server, the SteamID64 is returned. Some platforms may not have a proper UID and return -1 in this case. If this is a singleplayer or locally hosted game, the UID of the host user is returned.- Gibt zurück:
- the UID of the server/host, or -1 if this server has no UID.
-
getName
Gets the server name.- Gibt zurück:
- the name of the server.
-
getIP
Gets the server ip.- Gibt zurück:
- the ip of the server.
-
getPort
public static int getPort()Gets the server port.- Gibt zurück:
- the port of the server.
-
isPassworded
public static boolean isPassworded()Gets whether or not this server is password protected.- Gibt zurück:
- true if players have to enter a password to enter the server, false if not (default).
-
getRunningTime
public static float getRunningTime()Gets the amount of seconds that have passed since game/server start.- Gibt zurück:
- the running time of the game/server (in seconds).
- Example: Shutdown server when it's running for more than 24 hours
-
getOption
Gets a server option from the "server.properties" file.
Note: This method cannot be used to retrieve passwords or login names.- Parameter:
key
- the name of the option key.- Gibt zurück:
- a string representing the value, or null if the key was not found.
- Example: Determine if pvp is enabled (setting "settings_pvp_enabled")
-
getAllPermissionGroups
Gets all available permission group names.- Gibt zurück:
- a new array containing all permission group names.
-
getVersion
Gets the current game version as a String (e.g "0.9.1.5").- Gibt zurück:
- the current game version.
-
getBuild
public static int getBuild()Gets the current build of the game as an int (e.g 201807210). The build number always contains the year, month and day as well as an incrementing number.- Gibt zurück:
- the current build of the game.
- Siehe auch:
-
saveAll
public static void saveAll()Forces the server to save all pending changes (world, players, npcs, storages etc). -
savePlayers
public static void savePlayers()Forces the server to save all players and inventories. -
saveStorages
public static void saveStorages()Forces the server to save all storages (chests etc). -
saveNpcs
public static void saveNpcs()Forces the server to save all npcs. -
sendInputCommand
Sends an input command to the InputStream (System.in) of the server. This only works for the dedicated server.- Parameter:
input
- the input command.- Example: Send chat message
-
getLogFilePath
Gets the full file path to the log file.- Gibt zurück:
- the absolute file path to the log file.
-
shutdown
public static void shutdown()Forces the server to shutdown gracefully. This takes ~ 10 seconds. If you want to shutdown the server immediately (without removing all connections gracefully), you can useSystem.exit(0);
instead. -
restart
public static void restart()Attempts to restart the server process. This first shuts down and terminates the server process, then instructs the OS to restart the process. This only works for the dedicated server (check viagetType()
)! You can't execute this method in singleplayer! -
setDefaultSpawnPosition
Sets the global default spawn position.- Parameter:
position
- the new spawn position.
-
setDefaultSpawnPosition
public static void setDefaultSpawnPosition(float x, float y, float z) Sets the global default spawn position.- Parameter:
x
- the new x coordinate.y
- the new y coordinate.z
- the new z coordinate.
-
getDefaultSpawnPosition
Gets the global default spawn position.- Gibt zurück:
- the spawn position as a Vector3f.
-
setDefaultSpawnRotation
Sets the default spawn rotation. ProvideQuaternion.IDENTITY
if the spawn rotation should face towards north.- Parameter:
quaternion
- the spawn rotation as a Quaternion.
-
setDefaultSpawnRotation
public static void setDefaultSpawnRotation(float pitch, float yaw, float roll) Sets the default spawn rotation. Builds the rotation from euler angles.- Parameter:
pitch
- pitch (euler x)yaw
- yaw (euler y)roll
- roll (euler z)
-
getDefaultSpawnRotation
Gets the default spawn rotation.- Gibt zurück:
- the default spawn rotation as a Quaternion.
-
setDefaultSpawnInventory
Sets the default spawn inventory (i.e the items you always spawn with).- Parameter:
inventory
- the default spawn inventory.
-
getDefaultSpawnInventory
Gets the default spawn inventory (i.e the items you always spawn with).- Gibt zurück:
- the default spawn inventory.
-
setGameTime
public static void setGameTime(int hour, int min) Sets the ingame time.- Parameter:
hour
- hours (0-23)min
- minutes (0-59)- Example: Set ingame time to 3:30 p.m. (15:30)
-
getGameTime
Gets the current ingame time.- Parameter:
unit
- the time unit you want to get (e.g hours, minutes, days etc)- Gibt zurück:
- the current ingame time.
- Example:
-
getGameTime
Gets the internal time object which manages the ingame time and date.- Gibt zurück:
- the internal time object.
-
setGameTimeSpeed
public static void setGameTimeSpeed(float value) Changes the game time speed. The value represents the amount of realtime seconds one ingame minute should take (e.g a value of 60 indicates that one ingame minute takes 60 realtime seconds).- Parameter:
value
- the amount of realtime seconds one ingame minute should take.- Example: Plugin which sets realtime time speed (1 ingame min == 60 realtime seconds)
-
getGameTimeSpeed
public static float getGameTimeSpeed()Gets the game time speed. Or more precisely, the amount of realtime seconds one ingame minute takes (e.g a value of 60 indicates that one ingame minute takes 60 realtime seconds).- Gibt zurück:
- the game time speed (realtime seconds -> ingame minutes)
-
setWeather
Sets the weather.- Parameter:
newWeather
- the new weather.instant
- if set to true, the weather will change instantly. Otherwise, there will be a smooth transition between the current weather type and the new weather type.- Example: Set sunny weather forever
-
getCurrentWeather
Gets the current weather.- Gibt zurück:
- the current weather type.
-
getNextWeather
Gets the next weather type. In other words, if the weather is changing, this function returns the next weather type. Otherwise, null will be returned.- Gibt zurück:
- the next weather type, or null if the weather is currently not changing.
-
setWeatherEnabled
public static void setWeatherEnabled(boolean enabled) Enables or disables the weather. If the weather is disabled, the current weather stays active until it will be changed manually. Note that if the weather is currently changing while calling this method, the transition will still be completed.- Parameter:
enabled
- true to enable weather, false to disable it.
-
isWeatherEnabled
public static boolean isWeatherEnabled()Gets whether or not the weather is enabled.- Gibt zurück:
- true if the weather is enabled, false if not.
-
getWeatherTransition
public static float getWeatherTransition()Gets the transition between the current weather type (0.0) and the next weather type (1.0). If the weather is currently not changing, this function always returns 0.0, otherwise a value between 0.0 and 1.0 will be returned.- Gibt zurück:
- the transition interpolation value between the current and the next weather type. If the weather is currently not changing, this function always returns 0.0
-
getPlayerCount
public static int getPlayerCount()Gets the amount of players that are currently connected to this server.- Gibt zurück:
- the current amount of players.
-
getMaxPlayerCount
public static int getMaxPlayerCount()Gets the maximum amount of players allowed on this server.- Gibt zurück:
- the max amount of players that can play on this server simultaneously.
-
getTotalPlayerCount
public static int getTotalPlayerCount()Gets the total amount of players that were ever connected to this server in the past.- Gibt zurück:
- the total amount of entries in the player database.
-
isPlayerConnected
public static boolean isPlayerConnected(int playerid) Gets whether or not this player is connected to the server.- Parameter:
playerid
- the player ID (not the database ID).- Gibt zurück:
- true if the player is online, false if not.
-
isPlayerConnected
Gets whether or not this player is connected to the server.- Parameter:
playername
- the name of the player.- Gibt zurück:
- true if the player is online, false if not.
-
getPlayer
Gets a player object representing the player with the provided playerid. This function only works for players who are currently connected to the server.- Parameter:
playerid
- the player ID (neither the database ID nor the unique ID)- Gibt zurück:
- the player, or null if no player with the given ID was found.
-
getPlayerByUID
Gets a player object representing the player with the provided unique ID (for Steam users, this is the SteamID64). This ID never changes for a player. This function only works for players who are currently connected to the server.- Parameter:
playerUID
- the unique player ID.- Gibt zurück:
- the player, or null if no player with the given UID was found.
-
getPlayerByDbID
Gets a player object representing the player with the provided unique database ID. The database ID never changes for a player. This function only works for players who are currently connected to the server.- Parameter:
playerDbID
- the player database ID (not to be confused with the regular player ID or UID)- Gibt zurück:
- the player, or null if no player with the given db ID was found.
-
getPlayerByName
Gets a player object representing the player with the provided playername. This function only works for players who are currently connected to the server.- Parameter:
playername
- the name of the player.- Gibt zurück:
- the player, or null if no player was found.
-
getPlayerUID
Gets the UID of the player (irrespective of whether or not he's currently online) with the provided database ID.- Parameter:
playerDbID
- the player database ID (not to be confused with the regular player ID)- Gibt zurück:
- the player UID (no matter if the player is currently online or offline), or null if no such player was found.
-
getAllPlayers
Gets a new array containing all players that are currently connected to the server.- Gibt zurück:
- a new array containing all players which are online.
- Example: Heal broken bones for all players
-
isPlayerBanned
Gets whether the particular player (who has the provided UID) is banned or not.- Parameter:
playerUID
- the unique id of the player (for Steam users, it's the SteamID64).- Gibt zurück:
- true if the player is banned, false if not.
-
isPlayerAdmin
Gets whether the particular player is an admin or not.- Parameter:
playerUID
- the unique id of the player (for Steam users, it's the SteamID64).- Gibt zurück:
- true if the player is an admin, false if not.
-
banPlayer
Bans the player with the specified UID for a given amount of time.- Parameter:
playerUID
- the unique id of the player you want to ban (for Steam users, it's the SteamID64).reason
- a string containing the reason why the player was banned.duration
- the duration (in seconds) how long the player will be banned. Use '-1' to ban the player permanently.
-
unbanPlayer
Unbans the player with the specified name (i.e removes him from the ban list).- Parameter:
playerUID
- the unique id of the player you want to unban (for Steam users, it's the SteamID64).
-
findNearestPlayer
Gets the player who has the shortest distance to a particular world position.- Parameter:
position
- the world position.- Gibt zurück:
- the nearest player, or null if no player is currently online.
- Siehe auch:
-
getLastKnownPlayerName
Gets the last known name of the player with the specified UID. Please note that names are not unique and can be changed by the player at any time.- Parameter:
playerUID
- the unique id of the player.- Gibt zurück:
- the last known name of the player (if he ever joined the server in the past), or null if no such player data was found.
-
getLastKnownPlayerName
Gets the last known name of the player with the specified database ID. Please note that names are not unique and can be changed by the player at any time.- Parameter:
playerDbID
- the unique database ID of the player.- Gibt zurück:
- the last known name of the player (if he ever joined the server in the past), or null if no such player data was found.
-
getLastKnownPlayerUIDs
Gets the last known UIDs of all players who used the specified name recently. Please note that names are not unique and can be changed by the player at any time.- Parameter:
playerName
- the name of the player.- Gibt zurück:
- an array containing all UIDs of all players who used the specified name recently (as their lastest name), or null if no players were found.
-
addArea
Adds a temporaryArea
to the server. Once an area is added to the server,PlayerEnterAreaEvent
andPlayerLeaveAreaEvent
events will be triggered when a player enters/leaves an area.
Note: This area will not be stored in the area database! If you want to store the area permanently, useaddArea(net.risingworld.api.objects.Area, boolean)
instead!- Parameter:
area
- theArea
you want to add to the server.- Siehe auch:
-
addArea
Adds anArea
to the server. Once an area is added to the server,PlayerEnterAreaEvent
andPlayerLeaveAreaEvent
events will be triggered when a player enters/leaves an area.- Parameter:
area
- theArea
you want to add to the server.storeInDatabase
- if true, the area will also be stored persistently in the database!- Siehe auch:
-
removeArea
Removes anArea
that has been added to the server previously. Once an area is removed, events likePlayerEnterAreaEvent
orPlayerLeaveAreaEvent
will no longer be triggered for this area.- Parameter:
area
- theArea
you want to remove from the server. Note: you can still re-add the area to the server at any time.- Siehe auch:
-
getArea
Gets theArea
with the provided global id.- Parameter:
id
- the id of the area.- Gibt zurück:
- the associated area, or null if no such area was found.
-
getAllAreas
Gets an array containing allAreas
that are currently registered with the server.- Gibt zurück:
- a newly created array containing all registered areas.
- Example: Check if player is inside areas
-
getCustomImage
Gets a custom image.- Parameter:
id
- the image id. For ObjectElements, this is typically stored in the "info" field.- Gibt zurück:
- the custom image, or null if the image does not exist.
-
removeCustomImage
public static void removeCustomImage(long id, boolean destroyInstances) Deletes a custom image (and also removes all placed instances in the world). If the image does not exist, nothing happens.- Parameter:
id
- the image id.destroyInstances
- if true, all image instances (posters) in the world using this custom image will be destroyed automatically. Otherwise they will remain in the world (without showing an image anymore).
-
getAllCustomImages
Gets an array containing all custom images (creates a new array).- Gibt zurück:
- a new array containing all images.
-
getAllCustomImages
Gets an array containing all custom images which were uploaded by a particular player. This method creates a new array.- Parameter:
playerDbID
- the player database id (seePlayer.getDbID()
).- Gibt zurück:
- a new array containing all images uploaded by a particular player.
-
broadcastTextMessage
Broadcasts a text message, i.e send it to all players. This is exactly the same as callingPlayer.sendTextMessage(java.lang.String)
for every player.- Parameter:
message
- the message you want to broadcast.- Siehe auch:
-
broadcastYellMessage
Broadcasts a yell message, i.e send it to all players. This is exactly the same as callingPlayer.sendYellMessage(java.lang.String, float, boolean)
for every player.- Parameter:
message
- the yell message you want to broadcast.duration
- amount of seconds how long the message should stay visible. Use "5f" for example.pulsate
- if true, the message will pulsate on the screen.- Siehe auch:
-