Package net.risingworld.api.objects
Klasse Player
java.lang.Object
net.risingworld.api.objects.Player
Represents a player. This only applies to players which are currently connected
to the server.
-
Verschachtelte Klassen - Übersicht
-
Methodenübersicht
Modifizierer und TypMethodeBeschreibungvoid
addDamage
(int damage) Causes damage to the player (reduces health, plays a hurt sound and the screen flashes red).void
addGameObject
(GameObject gameObject) Adds the providedGameObject
to the player's world.void
addUIElement
(UIElement element) Attaches a UI element to the player's HUD.void
addUIElement
(UIElement element, UITarget target) Attaches a UI element to the player's screen (to a specific target, e.g HUD, inventory etc).void
Bans the player permanently from the server.void
Bans the player from the server for a given amount of time.void
connectToDiscord
(String url) Connects the client to a Discord server, or more precisely, it opens the url to the Discord server in the web browser.void
connectToOtherServer
(String target, String password, Callback<Boolean> callback) Connects the client to another multiplayer server.void
connectToTeamSpeak
(String ip, int port, String channel) Connects the client to a TeamSpeak server, but only as long as TeamSpeak is installed on the client computer, and only if the client accepts to connect.void
createScreenshot
(float sizeFactor, float quality, boolean includeUI, Callback<BufferedImage> callback) Creates a screenshot of the player screen and converts it into a BufferedImage.void
createScreenshot
(int width, int height, float quality, boolean includeUI, Callback<BufferedImage> callback) Creates a screenshot of the player screen with the desired resolution and converts it into a BufferedImage.void
createScreenshot
(Vector3f position, Vector3f direction, int width, int height, float quality, boolean includeUI, Callback<BufferedImage> callback) Creates a screenshot from an arbitrary world position with the desired resolution and converts it into a BufferedImage.void
deleteAttribute
(String key) Removes a player attribute.void
Disables the "area selection tool" for this player.void
disableClientsideKeys
(Key... keys) Disables certain game keys for the client.void
Disables the ingame music.void
Enables the "area selection tool" for this player.void
Re-enables all keys which have been disabled by this plugin by callingdisableClientsideKeys(net.risingworld.api.utils.Key...)
.void
enableClientsideKeys
(Key... keys) Re-enables certain keys which have been disabled by callingdisableClientsideKeys(net.risingworld.api.utils.Key...)
.void
Enables the ingame music.void
executeCommand
(String command) Executes a console command for this player.Gets the name of the currently active area permission for this player (i.e the name of the area the player is currently inside).getAllGameObjects
(boolean includeFromOtherPlugins) Gets allGameObjects
which were added to the player's world.getAllUIElements
(boolean includeFromOtherPlugins) Gets all UI elements which were added to the player's screen.float
Gets the altitude (i.e y position) of the player.void
getAreaInLineOfSight
(float distance, Callback<Area> callback) Gets the area in line-of-sight of the player (i.e the area the player is currently looking at).void
getAreaSelectionData
(Callback<Area> callback) Gets the currently selected area.int
getArmor()
Gets the current armor level of the player.getAttribute
(String key) Gets the value to which the specified key is mapped, or null if no attribute is stored for that key.Gets a set containing all keys and attributes.Gets a Vector3i containing the current block position (x, y and z) of the player within the current chunk.int
Gets the player breath level.Returns the cardinal direction of the player.Gets a Vector3i containing the x, y and z coordinates of the current chunk the player is in.Gets aClothes
object which contains the clothes the character is currently wearing.Gets the highest ranking (i.e most relevant) Area the player is currently inside.Area[]
Gets an array of all Areas the player is currently inside.int
Gets the amount of time the player is connected to the server.int
getDbID()
Gets the database ID of the player.Gets the currently equipped item (i.e the item the player currently holds in his hands), or null if no item is equipped.float
Returns the heading/facing, i.e the player rotation around the y axis (vertical axis) in degrees.int
Gets the current health of the player.int
Gets the current hunger level of the player.int
getID()
Gets the current ID of this player.int
Gets the player idle time in seconds.Gets the inventory of the player.getIP()
Gets the ip of the player (only relevant in multiplayer).Gets the current ingame language of the player.long
Gets a timestamp (i.e the number of milliseconds since 00:00:00 UTC on January 1, 1970) when the player was online on this server most recently.int
Gets the local time zone offset (in seconds) of this player to GMT/UTC time.int
Gets the maximum armor level the player can have.int
Gets the maximum health the player can have.int
Gets the maximum stamina of the player.getMount()
Gets the mount the player is currently riding on.getName()
Gets the name of the player.void
getNpcInLineOfSight
(float distance, Callback<Npc> callback) Gets the npc in line-of-sight of the player (i.e the npc the player is currently looking at).void
getObjectElementInLineOfSight
(float distance, Callback<ObjectElement> callback) Gets the object element in line-of-sight of the player (i.e the object element the player is currently looking at).Gets the operating system of the user.void
Gets a setting from the client (a setting from his config.properties file).Gets the current permission group name of the player.getPermissionValue
(String key, boolean includeAreas) Gets a particular permission value (usually boolean, int, String) from the current player permission.int
getPing()
Gets the current ping of the player, in other words, the amount of time (in milliseconds) that passes until a player packet arrives at the server.Gets the type of version the player is using, e.g standalone version, Steam version etc.Gets a Vector3f containing the current x, y and z coordinate of the player (world position).Gets an object representing post-processing overrides for this player.Gets the previous position of the player (the player had the last frame).Key[]
getRegisteredKeys
(boolean global) Gets all keys that are registered by this plugin.Gets the current player rotation.int
Gets the current screen width (horizontal resolution) the player set for his game.int
Gets the current screen height (vertical resolution) the player set for his game.Gets a Vector2i containing the x and z coordinates of the current sector the player is in.getSkin()
Gets aSkin
object which represents the appearance of the character, i.e gender, haircut, skin color, hair color etc.getSpawnName
(SpawnPointType spawnPoint) Gets the optional spawn name for a spawn point of this player.getSpawnPosition
(SpawnPointType spawnPoint) Gets the spawn position for this player (i.e where the player would respawn upon death).getSpawnRotation
(SpawnPointType spawnPoint) Gets the spawn rotation for this player (i.e where the player would respawn upon death).int
Gets the player stamina.getState()
Gets the current player state (determines if player is currently sitting, lying etc).int
getStatistic
(String name) Gets the value of a statistic (e.g distance walked, trees cut etc).Gets the current system language of the player.int
Gets the current player temperature (in celsius).int
Gets the current thirst level of the player.int
Gets the total amount of time the player has spent on this server (or more precisely, the amount of time the player has spent on this world).getUID()
Gets the globally unique ID of the player.If the player is currently passenger in a vehicle, this method returns the vehicle.Gets the current view direction of the player.Gets the view position of the player, i.e the world position of the player eyes.int
Gets the current damp/wetness level of the player (0-100).Gets a Vector2i containing the x and z coordinates of the current world part the player is in.boolean
hasAttribute
(String key) Gets whether or not the provided attribute exists.boolean
hasAttribute
(String key, Class type) Gets whether or not the provided attribute exists (also checks if it has a specific type).boolean
Gets whether the player has broken bones or not.boolean
Gets whether the player has healed bones or not.void
void
hideChat
(float fadeDuration) Hides the chatvoid
void
void
hideRadialMenu
(boolean immediately) Hides any currently active radial menus.void
Hides the chest/storage content.boolean
isAdmin()
Gets wheter or not the player is an admin (according to the server.properties file).boolean
Gets whether the player is bleeding or not.boolean
Gets whether or not the player is (still) connected.boolean
Gets whether or not creative mode is currently enabled.boolean
Gets whether or not the player is currently crouching.boolean
isDead()
Gets whether or not the player is dead.boolean
isFlying()
Gets whether or not the player is currently flying (i.e flymode enabled).boolean
isInCave()
Gets whether or not the player is inside a cave.boolean
isIndoor()
Gets whether or not the player is inside a building.boolean
Gets whether or not the player is currently inside a vehicle (either as driver or passenger).boolean
Gets whether or not the player is sible (i.e if a plugin has set the player invisible).boolean
Gets whether or not the player is currently in water.boolean
isKeyPressed
(Key key) Checks if a particular key is currently pressed.boolean
isKeyRegistered
(Key key, boolean global) Checks if a particular key is registered, i.e the client listens for input.boolean
isListeningForKeyInput
(boolean global) Determines if this plugin is listening for key input.boolean
isListeningForMouseInput
(boolean global) Determines if this plugin is listening for mouse button input.boolean
isLying()
Gets whether or not the player is currently lying in a bed, tent or shelter.boolean
Gets whether or not the player is currently standing stable on the groundboolean
Gets whether or not the player is currently on a mount (e.g a horse, donkey or camel).boolean
Gets whether or not the player is currently sitting on a chair.boolean
Gets whether or not this player is currently sleeping.boolean
Gets whether or not the player is already spawned, i.e if he's no longer in the loading screen.boolean
Gets whether or not the player is currently sprinting.boolean
Gets whether or not the player is currently swimming (i.e in water with no stable contact to ground).boolean
Gets whether or not the player is currently under water.boolean
Gets whether or not the player is currently walking slowly.void
Kicks the player from the server.void
kill()
Kills the player instantly.void
moveTo
(float x, float y, float z, float speed) Moves the player (smoothly) to the target position.void
Moves the player (smoothly) to the target position.playSound
(SoundAsset sound) Plays a custom 2D sound (i.e it can be heard everywhere, but only by this player).playSound
(SoundAsset sound, boolean loop, float volume, float pitch, float minDistance, float maxDistance, Vector3f position) Plays a custom 3D sound at the given position.playSound
(SoundAsset sound, boolean loop, float volume, float pitch, Vector3f position) Plays a custom 3D sound at the given position.playSound
(SoundAsset sound, Vector3f position) Plays a custom 3D sound at the given position.void
raycast
(float distance, int layerMask, boolean includeTriggers, Callback<RaycastResult> callback) Performs a raycast from the player view position to the player view direction.void
raycast
(int layerMask, Callback<RaycastResult> callback) Performs a raycast from the player view position to the player view direction.void
raycast
(Vector3f direction, float distance, int layerMask, boolean includeTriggers, Callback<RaycastResult> callback) Performs a raycast from the player view position to the provided direction.void
raycastFromScreenPosition
(float x, float y, boolean relative, float distance, int layerMask, boolean includeTriggers, Callback<RaycastResult> callback) Performs a raycast from the screen xy position.void
raycastFromWorldPosition
(Vector3f position, Vector3f direction, float distance, int layerMask, boolean includeTriggers, Callback<RaycastResult> callback) Performs a raycast from a world position.void
registerKeys
(Key... keys) Defines key inputs the client should forward to the server.void
removeGameObject
(GameObject gameObject) Removes aGameObject
from the player's world.void
removeUIElement
(UIElement element) Removes a UI element from the player's screen.boolean
respawn
(SpawnPointType spawnPoint) Respawns the player at a specific spawn point (0 for default server spawn, 1 for primary spawn point, 2 for secondary spawn point, 3 for tertiary spawn point.void
respawn
(Vector3f position, Quaternion rotation) Respawns the player at the given position.void
sendTextMessage
(String message) Sends a text message to the player's chat.void
sendYellMessage
(String message, float duration, boolean pulsate) Displays a message with big letters in the middle of the screen of the player for a few seconds (depending on the length of the message).void
setAdmin
(boolean set) Gives admin rights to the player.void
setAreaSelectionData
(Area area) Sets an area for the "area selection tool" for this player, i.e the selection tool will adapt to the position and size of the provided area.void
setAttribute
(String key, Object value) Stores an attribute for the player.void
setBleeding
(boolean set) Sets the bleeding state of the player.void
setBreath
(int breath) Sets a new breath level for the player.void
setBrokenBones
(boolean set) Sets the broken bone state of the player.void
setChunkAndBlockPosition
(int cx, int cy, int cz, int bx, int by, int bz) Sets the chunk and block position of the player (resulting in the total global position).void
setChunkAndBlockPosition
(Vector3i chunkPosition, Vector3i blockPosition) Sets the chunk and block position of the player (resulting in the total global position).void
setCreativeModeEnabled
(boolean set) Enables or disables creative mode for this player.void
setEquippedItem
(int quickslot) Changes the equipped item (i.e the item the player currently holds in his hands).void
setEquippedItem
(int slot, Inventory.SlotType slotType) Changes the equipped item (i.e the item the player currently holds in his hands).void
setFlying
(boolean set) Sets the flymode for the player.void
setFlyingSpeed
(float speed) Changes the flying speed factor for this player.void
setGravity
(float gravity) Changes the gravity for this player.void
setHealth
(int health) Sets the health of the player.void
setHunger
(int hunger) Sets the hunger level of the player.void
setInvisible
(boolean set) Sets the player invisible.void
setJumpSpeed
(float speed) Sets the jump height for the player.void
setListenForKeyInput
(boolean set) Sets if the client should forward his key input to the server or not.void
setListenForMouseInput
(boolean set) Sets if the client should forward his mouse button input to the server or not.void
setMaxHealth
(int maxHealth) void
setMaxStamina
(int maxStamina) void
setMouseCursorCoordinates
(float x, float y, boolean relative) Moves the mouse cursor of the client to the specified xy coordinates.void
setMouseCursorVisible
(boolean set) Toggles the visibility of the mouse cursor.void
setMoveSpeed
(float speed) Sets the move speed for the player, i.e the default movement speed.void
Changes the name of the player.void
Sets the graphics/audio/game settings for the client.void
setPermissionGroup
(String groupName) Sets the permission group of the player.void
setPermissionValue
(String key, Object value) Overrides a permission value.void
setPosition
(float x, float y, float z) Sets the world position of the player.void
setPosition
(Vector3f position) Sets the world position of the player.void
setPostProcessing
(PostProcessing postProcessing) Applies a post-processing object to the player.void
setRotation
(float pitch, float yaw, float roll) Sets the player rotation from euler angles.void
setRotation
(Quaternion quaternion) Sets the player rotation.void
setSpawnPoint
(SpawnPointType spawnPoint, Vector3f position, Quaternion rotation, String name) void
setSpawnPoint
(SpawnPointType spawnPoint, Vector3f position, Quaternion rotation, String name, long relatedObjectID, int chunkPosX, int chunkPosY, int chunkPosZ) void
setSprintSpeed
(float speed) Sets the sprint speed for the player, i.e fast movement.void
setStamina
(int stamina) Sets a new stamina value for the player.void
setStatistic
(String name, int value) Sets a new value for a statistic.void
setSwimmingSpeed
(float speed) Changes the swimming speed factor for this player.void
setTemperature
(int temperature) Sets the player temperature (in celsius).void
setThirst
(int thirst) Sets the thirst level of the player.void
setViewDirection
(float directionx, float directiony, float directionz) Sets the view direction of the player.void
setViewDirection
(Vector3f direction) Sets the view direction of the player.void
setWalkSpeed
(float speed) Sets the walk speed for the player.void
setWetness
(int wetness) Sets the player damp/wetness level.void
shake
(float intensity, float duration) Shakes the player screen, like an earthquake.void
void
showChat
(boolean focus) Shows the chat.void
Shows the chat, gains focus and also enters the provided text automatically to the input field.void
showColorPicker
(String title, int initialColor, Callback<Integer> callback) Shows a color picker dialog to the player.void
showContextMenu
(String[] entries, Callback<String> callback) Shows a context menu with the given entries.void
void
showErrorMessageBox
(String title, String message) Shows a simple error message box to the player.void
showFontDialog
(String title, Font selectedFont, Callback<Font> callback) Shows a font selection dialog to the player.void
showInfoMessageBox
(String title, String message) Shows a simple info message box to the player.void
Shows a text input message box to the player.void
void
showLocationTicker
(String text, float duration) Shows a location ticker text in the lower left screen corner.void
showMessageBox
(MessageBoxButtons buttons, String title, String message, int timeout, Callback<Integer> callback) Shows a default message box to the player.void
showRadialMenu
(TextureAsset[] icons, String[] descriptions, String[] overrideTexts, boolean closeOnSelect, Callback<Integer> callback) Shows a "radial menu" or "pie menu" to the player.void
showStatusMessage
(String message, int duration) Shows a status text message (centered, bottom of the screen).void
showStorage
(long storageID) Shows the content of a chest/storage.void
showSuccessMessageBox
(String title, String message) Shows a simple success message box to the player.void
showWarningMessageBox
(String title, String message) Shows a simple warning message box to the player.void
stopInput
(boolean stopMovement, boolean stopActions) Stops / aborts the current input actions.void
Releases input from a particular key.void
stopSound
(int id) void
void
unregisterKeys
(Key... keys) Unregisters one or more keys, so the client no longer forwards input from these keys to the server.
-
Methodendetails
-
getID
public int getID()Gets the current ID of this player. This ID will change the next time the player joins the server (or if the player leaves the server, another player might get this ID).- Gibt zurück:
- the current player ID.
-
getUID
Gets the globally unique ID of the player. This ID will never change, even if the player joins another server. For Steam users, this method returns the SteamID64.- Gibt zurück:
- the globally unique player ID as a string. The game stores the UID as string
because some platforms use strings to identify the account.
- Example: Display the UID of the player
- Example: Check if player uses Steam and get a link to his profile
-
getDbID
public int getDbID()Gets the database ID of the player. This ID is only unique on the current world. If the player joins another server (or loads another world), he will get a different database ID.
The database ID is useful for database queries.- Gibt zurück:
- the player database ID.
-
getName
Gets the name of the player.- Gibt zurück:
- the player name.
-
setName
Changes the name of the player.- Parameter:
name
- the new player name.
-
getLastTimeOnline
public long getLastTimeOnline()Gets a timestamp (i.e the number of milliseconds since 00:00:00 UTC on January 1, 1970) when the player was online on this server most recently.- Gibt zurück:
- a timestamp (milliseconds).
-
getCurrentPlayTime
public int getCurrentPlayTime()Gets the amount of time the player is connected to the server.- Gibt zurück:
- the current play time.
-
getTotalPlayTime
public int getTotalPlayTime()Gets the total amount of time the player has spent on this server (or more precisely, the amount of time the player has spent on this world).- Gibt zurück:
- the total play time of this player (in seconds).
-
getLocalTimeZoneOffset
public int getLocalTimeZoneOffset()Gets the local time zone offset (in seconds) of this player to GMT/UTC time.- Gibt zurück:
- the offset in seconds of the local time zone of the player compared to GMT/UTC time.
-
getPermissionGroup
Gets the current permission group name of the player.- Gibt zurück:
- the player permission group name or null if no group is set.
- Siehe auch:
-
setPermissionGroup
Sets the permission group of the player.- Parameter:
groupName
- the group name. Set to null to remove the player from any permission groups.
-
getActiveAreaPermission
Gets the name of the currently active area permission for this player (i.e the name of the area the player is currently inside). If the player is inside multiple, overlapping areas, the game uses the area permission with highest priority (seeArea.getPriority()
). If the player is not inside an area (or if this area has no permissions assigned), null is returned.- Gibt zurück:
- the name of the currently active area permission for this player, or null if the player is not inside an area.
-
getPermissionValue
Gets a particular permission value (usually boolean, int, String) from the current player permission.- Parameter:
key
- the name of the particular permission key.includeAreas
- if true, the game returns the "resolved" permission value, i.e. taking any currently active area permissions into account. If false, only the permission value of the group permission is returned (this was the behaviour of the Java version).- Gibt zurück:
- the permission value which belongs to the provided key, or null if
the permission key does not exist.
- Example: Check if the general->keepinventory permission is set to true
- Example: Check if player is currently allowed to fly
-
setPermissionValue
Overrides a permission value. This does not change the permission group of the player, but grants him individual permissions. These permissions, however, do not overwrite area permissions!
Note that these changes are not permanent, i.e if the player reconnects or if the player gets assigned to another permission group ("setplayergroup"), these changes will be reverted.- Parameter:
key
- the permission key.value
- the value.- Example: Disable fly mode, irrespective of the actual permission group
- Example: Increase the max amount of uploadable custom images to 20
-
isAdmin
public boolean isAdmin()Gets wheter or not the player is an admin (according to the server.properties file).- Gibt zurück:
- true if the player is an admin, false if not.
-
setAdmin
public void setAdmin(boolean set) Gives admin rights to the player.- Parameter:
set
- set true to give admin rights to the player, or false to revoke admin rights.
-
getInventory
Gets the inventory of the player.- Gibt zurück:
- the inventory of the player.
-
getEquippedItem
Gets the currently equipped item (i.e the item the player currently holds in his hands), or null if no item is equipped.- Gibt zurück:
- the equipped item, or null if no item is equipped.
- Example: Check equipped item type
-
setEquippedItem
public void setEquippedItem(int quickslot) Changes the equipped item (i.e the item the player currently holds in his hands).- Parameter:
quickslot
- the quickslot focus (hotbar) which holds the desired item.
-
setEquippedItem
Changes the equipped item (i.e the item the player currently holds in his hands).- Parameter:
slot
- the slot which holds the desired item.slotType
- the according slot type.
-
getStatistic
Gets the value of a statistic (e.g distance walked, trees cut etc). Statistics are always stored as integer values.- Parameter:
name
- the name of the statistic.- Gibt zurück:
- the stat value as int, or -1 if the stat was not found.
- Siehe auch:
-
setStatistic
Sets a new value for a statistic. This works for both built-in stats as well as custom stats. The statistic is stored persistently in the "Statistics.db" database.- Parameter:
name
- the name of the statistic (you may use a custom name if you want to store your own stats).value
- the associated value you want to store.- Siehe auch:
-
sendTextMessage
Sends a text message to the player's chat. Rich text is supported, so you can define different font styles or colors for parts of the text. For example, you can use the<color>
tag to change the color (e.g "<color=yellow>This is yellow text</color>) or <b> for bold text etc.- Parameter:
message
- the message you want to send to the player.- Example: Send a regular text message
- Example: Send a red text message
- Example: Send a text message with hex color
- Example: Send a multicolor text message
-
sendYellMessage
Displays a message with big letters in the middle of the screen of the player for a few seconds (depending on the length of the message).- Parameter:
message
- the message you want to display on the player's screen.duration
- amount of seconds how long the message should stay visible. Use "5f" for 5 seconds, for example.pulsate
- if true, the message will pulsate on the screen.- Example:
-
showStatusMessage
Shows a status text message (centered, bottom of the screen). Status messages are used by the game to display certain information to the player, e.g status of object placement, food consume info etc.- Parameter:
message
- the message you want to show.duration
- the duration (seconds) how long the message will be displayed.
-
setOption
Sets the graphics/audio/game settings for the client. This only works for settings which are also accessible from the options menu.- Parameter:
setting
- the name of the setting (seeconfig.properties
file).value
- the new value. Setnull
to reset this setting to default.
-
getOption
Gets a setting from the client (a setting from his config.properties file). The returned setting is always a string, so you have to parse it accordingly. If the setting is not set (i.e field in the config.properties file is blank), an empty string is returned. If the setting does not exist, null is returned.
Since the data is queried from the client, you do not get the result as a return value, instead you have to use a callback to receive the result.- Parameter:
setting
- the setting you want to query, e.g "input_interaction" or "graphic_fullscreen" etc.callback
- theCallback
object. It will be called once the data has been retrieved from the player. The result will be passed as a string argument (empty string if setting is not set, null if setting does not exist).- Example: Check if player has the debug console enabled
- Example: Get player key mapping for inventory key, and use it for your own purposes (e.g inventory extension)
-
setAttribute
Stores an attribute for the player. You can store any type. Note that all attributes will be reset upon server restart!- Parameter:
key
- the name of the attribute.value
- the value/object you want to store. Set null to remove the attribute.
-
getAttribute
Gets the value to which the specified key is mapped, or null if no attribute is stored for that key.- Parameter:
key
- the name of the attribute.- Gibt zurück:
- the attribute that is stored for that key, or null of the
key does not exists.
- Example:
-
hasAttribute
Gets whether or not the provided attribute exists.- Parameter:
key
- the name of the attribute.- Gibt zurück:
- true if the attribute exists, false if not.
-
hasAttribute
Gets whether or not the provided attribute exists (also checks if it has a specific type).- Parameter:
key
- the name of the attribute.type
- the type of the attribute- Gibt zurück:
- true if the attribute exists and if it has the desired type, false if not.
-
deleteAttribute
Removes a player attribute. Does nothing if the attribute doesn't exist.- Parameter:
key
- the name of the attribute you want to delete.
-
getAttributes
Gets a set containing all keys and attributes.
Be careful when modifying the set, because that affects the attributes.- Gibt zurück:
- a set containing all keys and attributes.
- Example: Print all keys and their values
-
getLanguage
Gets the current ingame language of the player.- Gibt zurück:
- the language as a string.
-
getSystemLanguage
Gets the current system language of the player.- Gibt zurück:
- the language as a string.
-
getOperatingSystem
Gets the operating system of the user.- Gibt zurück:
- the operating system of the user.
-
getPlatform
Gets the type of version the player is using, e.g standalone version, Steam version etc.- Gibt zurück:
- the platform / version type
-
getPosition
Gets a Vector3f containing the current x, y and z coordinate of the player (world position).- Gibt zurück:
- the player world position as a Vector3f (float).
-
getAltitude
public float getAltitude()Gets the altitude (i.e y position) of the player. Same asgetPosition().y
- Gibt zurück:
- the current player altitude (y position).
-
getPreviousPosition
Gets the previous position of the player (the player had the last frame).- Gibt zurück:
- the old player position.
-
setPosition
Sets the world position of the player.- Parameter:
position
- the new world position you want to set.- Example:
-
setPosition
public void setPosition(float x, float y, float z) Sets the world position of the player.- Parameter:
x
- x world coordinate to set (horizontally).y
- y world coordinate to set (vertically).z
- z world coordinate to set (horizontally).
-
moveTo
Moves the player (smoothly) to the target position.- Parameter:
position
- the target position.speed
- the speed (how long it should take to move the player to the target position).
-
moveTo
public void moveTo(float x, float y, float z, float speed) Moves the player (smoothly) to the target position.- Parameter:
x
- the target x coordinate.y
- the target y coordinate.z
- the target z coordinate.speed
- the speed (how long it should take to move the player to the target position).
-
getChunkPosition
Gets a Vector3i containing the x, y and z coordinates of the current chunk the player is in.- Gibt zurück:
- the chunk offset as a Vector3i (int).
-
getBlockPosition
Gets a Vector3i containing the current block position (x, y and z) of the player within the current chunk. X ranges from 0-15 (inclusive), Y ranges from 0-63 (inclusive), Z ranges from 0-15 (inclusive).- Gibt zurück:
- the block position within the current chunk as a Vector3i (int).
-
setChunkAndBlockPosition
Sets the chunk and block position of the player (resulting in the total global position).- Parameter:
chunkPosition
- chunk offset as a Vector3i (int).blockPosition
- block position within the chunk as a Vector3i (int).
-
setChunkAndBlockPosition
public void setChunkAndBlockPosition(int cx, int cy, int cz, int bx, int by, int bz) Sets the chunk and block position of the player (resulting in the total global position).- Parameter:
cx
- x chunk offset.cy
- y chunk offset.cz
- z chunk offset.bx
- x block position within the chunk.by
- y block position within the chunk.bz
- z block position within the chunk.
-
getWorldPartPosition
Gets a Vector2i containing the x and z coordinates of the current world part the player is in.- Gibt zurück:
- the world part offset as a Vector2i (int).
-
getSectorPosition
Gets a Vector2i containing the x and z coordinates of the current sector the player is in.- Gibt zurück:
- the sector offset as a Vector2i (int).
-
getRotation
Gets the current player rotation.- Gibt zurück:
- the player rotation as a Quaternion.
-
setRotation
Sets the player rotation.- Parameter:
quaternion
- the quaternion which describes the desired rotation.
-
setRotation
public void setRotation(float pitch, float yaw, float roll) Sets the player rotation from euler angles.- Parameter:
pitch
- the rotation around the x axis (left axis).yaw
- the rotation around the y axis (vertical/up axis), "heading".roll
- the rotation around the z axis (forward axis)
-
getViewPosition
Gets the view position of the player, i.e the world position of the player eyes.- Gibt zurück:
- the view/camera position as a Vector3f (float).
-
getViewDirection
Gets the current view direction of the player.- Gibt zurück:
- the view direction as a Vector3f (float).
-
setViewDirection
Sets the view direction of the player. You can use this function to force the player to look into a certain direction.- Parameter:
direction
- the new view direction as a Vector3f (float). Make sure to use a unit vector.- Example: How to let the player look to a certain point in the world
-
setViewDirection
public void setViewDirection(float directionx, float directiony, float directionz) Sets the view direction of the player. You can use this function to force the player to look into a certain direction.- Parameter:
directionx
- y component of the new view direction vector.directiony
- y component of the new view direction vector.directionz
- z component of the new view direction vector.
-
getHeading
public float getHeading()Returns the heading/facing, i.e the player rotation around the y axis (vertical axis) in degrees. If the player looks exactly to north, 0 will be returned, if he looks to south, 180 (degrees) will be returned.- Gibt zurück:
- the player heading/facing, i.e the rotation around the y axis.
-
getCardinalDirection
Returns the cardinal direction of the player. If the player faces towards north, this function returns "N", if he faces towards east, it returns "E", if he faces towards north-east, it returns "NE" etc.- Gibt zurück:
- the cardinal direction. Returns either "N", "NE", "E", "SE", "S", "SW", "W" or "NW"
-
getCurrentArea
Gets the highest ranking (i.e most relevant) Area the player is currently inside. May be null.- Gibt zurück:
- the area with the highest priority the player is currently inside, or null if the player is not inside an Area at the moment
-
getCurrentAreas
Gets an array of all Areas the player is currently inside.- Gibt zurück:
- a new array containing all Areas the player is inside.
- Example: Check all areas the player is currently inside
- Siehe auch:
-
showLocationTicker
Shows a location ticker text in the lower left screen corner.- Parameter:
text
- the text you want to show.duration
- the duration (in seconds). -1 to show the text indefinitely (until it gets overridden).
-
shake
public void shake(float intensity, float duration) Shakes the player screen, like an earthquake.- Parameter:
intensity
- the intensity (default: 1.0f)duration
- the duration, in seconds.- Example: Simulate an earthquake for 10 seconds
-
isSpawned
public boolean isSpawned()Gets whether or not the player is already spawned, i.e if he's no longer in the loading screen.- Gibt zurück:
- true if the player is fully spawned, false if he is still in the loading screen (loading the world or connecting to the server).
-
isInVehicle
public boolean isInVehicle()Gets whether or not the player is currently inside a vehicle (either as driver or passenger).- Gibt zurück:
- true if the player is in a vehicle (e.g boat, car, train etc), false if not.
-
isOnMount
public boolean isOnMount()Gets whether or not the player is currently on a mount (e.g a horse, donkey or camel).- Gibt zurück:
- true if the player is on a mount, false if not.
- Siehe auch:
-
isSprinting
public boolean isSprinting()Gets whether or not the player is currently sprinting.- Gibt zurück:
- true if the player is sprinting at the moment, false if not.
-
isWalking
public boolean isWalking()Gets whether or not the player is currently walking slowly.- Gibt zurück:
- true if the player is walking slowly, false if not.
-
isCrouching
public boolean isCrouching()Gets whether or not the player is currently crouching.- Gibt zurück:
- true if the player is crouching, false if not.
-
isSwimming
public boolean isSwimming()Gets whether or not the player is currently swimming (i.e in water with no stable contact to ground).- Gibt zurück:
- true if the player is swimming, false if not.
-
isLying
public boolean isLying()Gets whether or not the player is currently lying in a bed, tent or shelter.- Gibt zurück:
- true if the player is lying in a bed (or tent or shelter), false if not.
-
isSitting
public boolean isSitting()Gets whether or not the player is currently sitting on a chair.- Gibt zurück:
- true if the player is sitting on a chair, false if not.
-
getState
Gets the current player state (determines if player is currently sitting, lying etc).- Gibt zurück:
- the player
Player.State
.
-
isInWater
public boolean isInWater()Gets whether or not the player is currently in water.- Gibt zurück:
- true if the player is in water, false if not.
-
isUnderwater
public boolean isUnderwater()Gets whether or not the player is currently under water.- Gibt zurück:
- true if the player is under water, false if not.
-
isOnGround
public boolean isOnGround()Gets whether or not the player is currently standing stable on the ground- Gibt zurück:
- true if the player is standing stable on ground, false if not.
-
isIndoor
public boolean isIndoor()Gets whether or not the player is inside a building.- Gibt zurück:
- true if the player is inside a building, false if not.
-
isInCave
public boolean isInCave()Gets whether or not the player is inside a cave. Note: If the player is inside a building in a cave, this function returns false.- Gibt zurück:
- true if the player is currently inside a cave.
-
isSleeping
public boolean isSleeping()Gets whether or not this player is currently sleeping.- Gibt zurück:
- true if the player is currently sleeping, false if not.
- Example: Jump to next day if at least 50% of all players are sleeping
-
setCreativeModeEnabled
public void setCreativeModeEnabled(boolean set) Enables or disables creative mode for this player.- Parameter:
set
- set true to enable creative mode, false to disable it.
-
isCreativeModeEnabled
public boolean isCreativeModeEnabled()Gets whether or not creative mode is currently enabled.- Gibt zurück:
- true if creative mode is currently active, false if not.
-
getMaxHealth
public int getMaxHealth()Gets the maximum health the player can have.- Gibt zurück:
- the maximum possible player health (usually 100).
-
setMaxHealth
public void setMaxHealth(int maxHealth) -
getHealth
public int getHealth()Gets the current health of the player.- Gibt zurück:
- the current health of the player.
-
setHealth
public void setHealth(int health) Sets the health of the player.- Parameter:
health
- the new player health.- Siehe auch:
-
addDamage
public void addDamage(int damage) Causes damage to the player (reduces health, plays a hurt sound and the screen flashes red).- Parameter:
damage
- the amount of damage you want to add to the player.
-
getArmor
public int getArmor()Gets the current armor level of the player.- Gibt zurück:
- the current armor level of the player. Returns 0 if the player has no protection.
-
getMaxArmor
public int getMaxArmor()Gets the maximum armor level the player can have.- Gibt zurück:
- the maximum possible armor level of the player.
-
getHunger
public int getHunger()Gets the current hunger level of the player. 100 means the player is not hungry, 0 means the player is starving (i.e the player looses health).- Gibt zurück:
- the current hunger level of the player.
- Example: Automatically reset hunger of the player if it is below a certain value
-
setHunger
public void setHunger(int hunger) Sets the hunger level of the player. 100 means the player is not hungry, 0 means the player is starving (i.e the player looses health).- Parameter:
hunger
- the new hunger level (0-100).
-
getThirst
public int getThirst()Gets the current thirst level of the player. 100 means the player is not thirsty, 0 means the player is dying of dehydration (i.e the player looses health).- Gibt zurück:
- the current thirst level of the player (0-100).
- Example: Automatically reset thirst of the player if it is below a certain value
-
setThirst
public void setThirst(int thirst) Sets the thirst level of the player. 100 means the player is not thirsty, 0 means the player is dying of dehydration (i.e the player looses health).- Parameter:
thirst
- the new thirst level.
-
hasBrokenBones
public boolean hasBrokenBones()Gets whether the player has broken bones or not.- Gibt zurück:
- true if the player has broken bones, false if not.
- Example: Heal broken bones if necessary
-
setBrokenBones
public void setBrokenBones(boolean set) Sets the broken bone state of the player.- Parameter:
set
- set true to break the bones of the player, or false to heal the broken bones.
-
hasHealedBones
public boolean hasHealedBones()Gets whether the player has healed bones or not.- Gibt zurück:
- true if the player has healed bones (after applying a splint), false if not.
-
isBleeding
public boolean isBleeding()Gets whether the player is bleeding or not.- Gibt zurück:
- true if the player is bleeding, false if not.
-
setBleeding
public void setBleeding(boolean set) Sets the bleeding state of the player.- Parameter:
set
- set true if the player should be bleeding, or false to stop bleeding.
-
getMaxStamina
public int getMaxStamina()Gets the maximum stamina of the player.- Gibt zurück:
- the maximum possible player stamina (usually 100).
-
setMaxStamina
public void setMaxStamina(int maxStamina) -
getStamina
public int getStamina()Gets the player stamina. 0 means the player is fully exhausted (so the player cannot sprint anymore), 100 is the max value.- Gibt zurück:
- the player stamina (0-100).
- Example: If player is exhausted, he cannot execute a certain command anymore
-
setStamina
public void setStamina(int stamina) Sets a new stamina value for the player.- Parameter:
stamina
- the new stamina level.
-
getBreath
public int getBreath()Gets the player breath level. It's decreasing while the player is at a place where he can't breath (e.g underwater). 0 means the player suffocates, 100 is the max value.- Gibt zurück:
- the current player breath level (0-100).
-
setBreath
public void setBreath(int breath) Sets a new breath level for the player.- Parameter:
breath
- the new breath level.
-
getWetness
public int getWetness()Gets the current damp/wetness level of the player (0-100). The wetness level increases if the player is exposed to rain, for example, or if he's inside water etc. Otherwise the wetness level slowly decreases over time.- Gibt zurück:
- the current player damp/wet level.
-
setWetness
public void setWetness(int wetness) Sets the player damp/wetness level.- Parameter:
wetness
- the new wetness value (0-100). 0 means player is not damp at all, 100 means the player is wet all over.
-
isFlying
public boolean isFlying()Gets whether or not the player is currently flying (i.e flymode enabled).- Gibt zurück:
- true if the player is currently flying, false if not.
-
setFlying
public void setFlying(boolean set) Sets the flymode for the player.- Parameter:
set
- true to enable flymode, false if not (be careful when the player is currently in mid-air :D)
-
isDead
public boolean isDead()Gets whether or not the player is dead.- Gibt zurück:
- true if the player is dead, false if not.
-
kill
public void kill()Kills the player instantly. -
respawn
Respawns the player at a specific spawn point (0 for default server spawn, 1 for primary spawn point, 2 for secondary spawn point, 3 for tertiary spawn point.- Parameter:
spawnPoint
- primary (1), secondary (2) or tertiary (3) spawn points (if available) or the default server spawn (0).- Gibt zurück:
- true if the desired spawn point was available (and the player respawned successfully), or false if the player could not spawn at that point.
-
respawn
Respawns the player at the given position.- Parameter:
position
- the respawn position. You can get the default player spawnrotation
- the respawn rotation. Use "null" if you want to use the default rotation.
-
getSpawnPosition
Gets the spawn position for this player (i.e where the player would respawn upon death).- Parameter:
spawnPoint
- the spawn point type (default spawn, primary spawn, secondary spawn etc).- Gibt zurück:
- the respawn position as a Vector3f, or null if the desired spawn point is not available.
-
getSpawnRotation
Gets the spawn rotation for this player (i.e where the player would respawn upon death).- Parameter:
spawnPoint
- the spawn point type (default spawn, primary spawn, secondary spawn etc).- Gibt zurück:
- the respawn rotation, or null if the desired spawn point is not available.
-
getSpawnName
Gets the optional spawn name for a spawn point of this player.- Parameter:
spawnPoint
- the spawn point type (default spawn, primary spawn, secondary spawn etc).- Gibt zurück:
- the optional name for the spawn point (if set).
-
setSpawnPoint
public void setSpawnPoint(SpawnPointType spawnPoint, Vector3f position, Quaternion rotation, String name) -
setSpawnPoint
public void setSpawnPoint(SpawnPointType spawnPoint, Vector3f position, Quaternion rotation, String name, long relatedObjectID, int chunkPosX, int chunkPosY, int chunkPosZ) -
getTemperature
public int getTemperature()Gets the current player temperature (in celsius). Note that this is not exactly the body temperature, instead this temperature value slowly adapts to the environment temperature (depending on various factors, e.g clothing, weather etc).- Gibt zurück:
- the current player temperature (in celsius).
-
setTemperature
public void setTemperature(int temperature) Sets the player temperature (in celsius). Please note that the player temperature will still slowly adapt the environment temperature.- Parameter:
temperature
- the player temperature (in celsius). Value must be between -100 and 100 (inclusive).
-
isInvisible
public boolean isInvisible()Gets whether or not the player is sible (i.e if a plugin has set the player invisible).- Gibt zurück:
- true if the player is invisible, false if not.
-
setInvisible
public void setInvisible(boolean set) Sets the player invisible.- Parameter:
set
- true to set the player invisible, false to make him visible again.
-
getIdleTime
public int getIdleTime()Gets the player idle time in seconds.- Gibt zurück:
- the player idle time in seconds.
-
getMount
Gets the mount the player is currently riding on. If the player is not riding on an npc at the moment, this function returns null.- Gibt zurück:
- the mount the player is currently riding on, or null if the player
is not riding on any mounts.
- Example: Check if player is riding on a mount
- Siehe auch:
-
getVehicle
If the player is currently passenger in a vehicle, this method returns the vehicle. Otherwise null is returned.- Gibt zurück:
- the vehicle the player is currently a passenger of, or null if player is not in a vehicle.
-
setWalkSpeed
public void setWalkSpeed(float speed) Sets the walk speed for the player. Default is 1.0- Parameter:
speed
- the new walk speed factor.
-
setMoveSpeed
public void setMoveSpeed(float speed) Sets the move speed for the player, i.e the default movement speed. Default is 1.0- Parameter:
speed
- the new running speed factor.
-
setSprintSpeed
public void setSprintSpeed(float speed) Sets the sprint speed for the player, i.e fast movement. Default is 1.0- Parameter:
speed
- the new sprint speed factor.
-
setJumpSpeed
public void setJumpSpeed(float speed) Sets the jump height for the player. Default is 1.0- Parameter:
speed
- the new jump height.
-
setFlyingSpeed
public void setFlyingSpeed(float speed) Changes the flying speed factor for this player. Default is 1.0- Parameter:
speed
- the new flying speed factor.
-
setSwimmingSpeed
public void setSwimmingSpeed(float speed) Changes the swimming speed factor for this player. Default is 1.0- Parameter:
speed
- the new swimming speed factor.
-
setGravity
public void setGravity(float gravity) Changes the gravity for this player. To get the global default gravity, seeWorld.getDefaultGravity()
- Parameter:
gravity
- the new gravity you want to set for this player.- Siehe auch:
-
getSkin
Gets aSkin
object which represents the appearance of the character, i.e gender, haircut, skin color, hair color etc.- Gibt zurück:
- a
Skin
object representing the visual appearance of the character. Never null. - Example: Set red skin color for player once he connects to the server
- Example: Check gender of a player
-
getClothes
Gets aClothes
object which contains the clothes the character is currently wearing. The object is updated automatically when the player changes his clothes.- Gibt zurück:
- a
Clothes
object representing the clothes of the character. Never null. - Example: Remove all player clothes and spawn them as items in the world
-
getPostProcessing
Gets an object representing post-processing overrides for this player.- Gibt zurück:
- a
PostProcessing
object which allows you to override certain post-processing settings of this player.
-
setPostProcessing
Applies a post-processing object to the player.- Parameter:
postProcessing
- the post-processing object you want to apply to the player.- Example: Change screen contrast and hue for 5 seconds
-
showInventory
public void showInventory() -
hideInventory
public void hideInventory() -
showStorage
public void showStorage(long storageID) Shows the content of a chest/storage.- Parameter:
storageID
- the storage ID
-
hideStorage
public void hideStorage()Hides the chest/storage content. -
showChat
public void showChat(boolean focus) Shows the chat. Optionally gains focus- Parameter:
focus
- if true, the chat will also be focused, i.e the input field gets the focus. Otherwise, the chat simply shows up (just as if a new chat message came in)
-
showChat
Shows the chat, gains focus and also enters the provided text automatically to the input field.- Parameter:
text
- the text that should be entered to the input field automatically (without sending it)
-
hideChat
public void hideChat(float fadeDuration) Hides the chat- Parameter:
fadeDuration
- fade-out duration (seconds). Set to 0 to hide the chat instantly
-
showBlueprints
public void showBlueprints() -
hideBlueprints
public void hideBlueprints() -
showCrafting
public void showCrafting() -
hideCrafting
public void hideCrafting() -
showContextMenu
Shows a context menu with the given entries. Once the player selects an entry, the provided callback will be called (and the selected string will be passed as argument).- Parameter:
entries
- the entries of the context menu, as a string array.callback
- the callback which will be called once the player selects an entry. The selected entry is provided as parameter (never null). If the player just closes the context menu (i.e if he doesn't select anything), an empty string will be provided.- Example:
- Example: Show context menu and use the mouse cursor to select an entry
-
stopInput
public void stopInput(boolean stopMovement, boolean stopActions) Stops / aborts the current input actions. For example, if the player is currently digging with a pickaxe (by holding his left mouse button), and you call this method, the player will stop his actions. If he wants to continue to dig, he has to release his mouse button and press it again.- Parameter:
stopMovement
- true if you want to stop movement input (e.g WASD). It causes the character to stop (if he's currently moving).stopActions
- true if you want to stop interaction input, e.g primary and secondary mouse buttons and interaction key (F by default).
-
stopInput
Releases input from a particular key. This only affects keys registered viaregisterKeys(net.risingworld.api.utils.Key...)
. This doesn't stop input from that key entirely, it only forces the player to release the key and press it again to trigger a newPlayerKeyEvent
. Calling this method triggers aPlayerKeyEvent
immediately (withPlayerKeyEvent.isPressed()
false). This method does not interfere with ingame input, i.e regular ingame controls are unaffected.- Parameter:
key
- the key you want to force-release.
-
registerKeys
Defines key inputs the client should forward to the server. Each key input will trigger aPlayerKeyEvent
.
Please note: This will accumulate with registered keys by other plugins: For example, if you register Key.A and another plugin registers Key.S, thePlayerKeyEvent
will be triggered for both keys. In most cases, however, that should not cause any problems. If really necessary, you can use the methodisKeyRegistered(net.risingworld.api.utils.Key, boolean)
to find out if your plugin still has the key registered (but please bear in mind that this may have performance implications if used in the key input event).- Parameter:
keys
- all keys the game should listen for.- Example: Listen for W, A, S and D input
- Siehe auch:
-
unregisterKeys
Unregisters one or more keys, so the client no longer forwards input from these keys to the server.
Please note that this does not remove keys which are still registered by other plugins, so thePlayerKeyEvent
may still be triggered as long as another plugin keeps this key registered.- Parameter:
keys
- the keys you want to unregister.
-
isKeyRegistered
Checks if a particular key is registered, i.e the client listens for input. This is handled per plugin, so this method only checks if your plugin is still listening for input - unless the "global" parameter is set to true, then the method will check this for all plugins.- Parameter:
key
- the key you want to check if it's registered.global
- if true, the method will check if any plugin has this key registered. If false, this will only be checked for your plugin.- Gibt zurück:
- true if the key is registered, false if not.
-
isKeyPressed
Checks if a particular key is currently pressed. Note that this only works for keys which have been registered (seeregisterKeys(net.risingworld.api.utils.Key...)
) and if the player is listening for key input.
This method may be useful in the PlayerKeyEvent (if you want to implement key combos, e.g check if the shift key is also pressed etc).- Parameter:
key
- the key you want to check if it's currently pressed.- Gibt zurück:
- true if the key is pressed, false if not.
- Example: Check if player pressed shift + c
-
getRegisteredKeys
Gets all keys that are registered by this plugin. If tue "global" parameter is set to true, this returns a list containing all keys registered by any plugins.- Parameter:
global
- if true, the method will return all registered keys by any plugin, else it just returns the key registered by this plugin.- Gibt zurück:
- an array (which will be created upon call) containing all keys, or null if no keys are registered.
-
setListenForKeyInput
public void setListenForKeyInput(boolean set) Sets if the client should forward his key input to the server or not.
Please note: This is handled per plugin, so if another plugin still enabled key input, the client will continue forwarding input to the server and the event will also be triggered.- Parameter:
set
- true to forward the key inputs, false if not.- Siehe auch:
-
isListeningForKeyInput
public boolean isListeningForKeyInput(boolean global) Determines if this plugin is listening for key input.- Parameter:
global
- if true, this method checks if any plugin is listening for key input, else this is only checked for this plugin.- Gibt zurück:
- true if input will be forwarded to the server, false if not.
-
setListenForMouseInput
public void setListenForMouseInput(boolean set) Sets if the client should forward his mouse button input to the server or not.
Please note: This is handled per plugin, so if another plugin still enabled mouse button input, the client will continue forwarding input to the server and the event will also be triggered.- Parameter:
set
- true to forward the mouse button inputs, false if not.- Siehe auch:
-
isListeningForMouseInput
public boolean isListeningForMouseInput(boolean global) Determines if this plugin is listening for mouse button input.- Parameter:
global
- if true, this method checks if any plugin is listening for mouse input, else this is only checked for this plugin.- Gibt zurück:
- true if mouse button input will be forwarded to the server, false if not.
- Siehe auch:
-
disableClientsideKeys
Disables certain game keys for the client. That means that the game will no longer process regular input of these keys (e.g if you disable the inventory key, the player won't be able to open his inventory anymore etc). This does not affect text input like chat or console. If you want to re-enable the keys again, you can callenableClientsideKeys()
.
Important: This does not interfere with keys registered by plugins (seeregisterKeys(net.risingworld.api.utils.Key...)
, so you will still receive the according input event (the keys just won't be processed any further by the client).- Parameter:
keys
- the keys you want to disable from being processed by the client.- Example: Disable keys W, A, S, D
- Siehe auch:
-
enableClientsideKeys
public void enableClientsideKeys()Re-enables all keys which have been disabled by this plugin by callingdisableClientsideKeys(net.risingworld.api.utils.Key...)
.
Important: This method has nothing to do withregisterKeys(net.risingworld.api.utils.Key...)
orsetListenForKeyInput(boolean)
-
enableClientsideKeys
Re-enables certain keys which have been disabled by callingdisableClientsideKeys(net.risingworld.api.utils.Key...)
. If you want to enable all keys again, callenableClientsideKeys()
instead.
Important: This method has nothing to do withregisterKeys(net.risingworld.api.utils.Key...)
orsetListenForKeyInput(boolean)
- Parameter:
keys
- the keys you want to enable again.- Siehe auch:
-
setMouseCursorVisible
public void setMouseCursorVisible(boolean set) Toggles the visibility of the mouse cursor. Useful if any custom gui interactions are needed.
If the cursor is set to visible, the player is unable to move anymore. You have to hide the cursor explicitly in order to unfreeze the player (in other words, the player has no chance to hide the cursor by himself).- Parameter:
set
- true to show the mouse cursor, false to hide it.
-
setMouseCursorCoordinates
public void setMouseCursorCoordinates(float x, float y, boolean relative) Moves the mouse cursor of the client to the specified xy coordinates.
Note: This even works when the cursor isn't visible (so the cursor position will still be updated in the background).- Parameter:
x
- the x target coordinatey
- the y target coordinaterelative
- if set to true, relative target coordinates (0.0-1.0) will be used, otherwise the target coordinates will be treated as absolute coordinates.
-
executeCommand
Executes a console command for this player. The ingame console can be opened by pressing ` or ~ or # or ^ (depending on the keyboard layout).
If a preceding slash '/' is added, the command will be treated like an API command instead - this means a PlayerCommandEvent will be invoked for all event listeners across all plugins.
Note that this function does not override any permissions, this means if the player is not allowed to execute a certain command, you cannot execute it with this function either (first you have to change the permissions in this case).- Parameter:
command
- the command you want to execute. It's exactly the same as if the player typed this command into his console (he even get a response in the console).- Example: Toggle hud for a player
- Example: Send command from player (invoke PlayerCommandEvent) to all plugins)
-
isConnected
public boolean isConnected()Gets whether or not the player is (still) connected.- Gibt zurück:
- true if the player is connected to the server, false if not.
-
getPing
public int getPing()Gets the current ping of the player, in other words, the amount of time (in milliseconds) that passes until a player packet arrives at the server. Only relevant in multiplayer.- Gibt zurück:
- the current ping (ms) of the player.
-
getIP
Gets the ip of the player (only relevant in multiplayer). When playing via Steam P2P, this function returns the SteamID64 of the player (e.g "76561197970685866").- Gibt zurück:
- a string containing the ip address of the player (or the SteamID64 when playing via Steam P2P, or an empty string when playing singleplayer).
-
kick
Kicks the player from the server. The provided reason is displayed on the screen of the kicked player.- Parameter:
reason
- a string containing the reason why the player was kicked.
-
ban
Bans the player permanently from the server. The provided reason is displayed on the screen of the banned player.- Parameter:
reason
- a string containing the reason why the player was banned.
-
ban
Bans the player from the server for a given amount of time. The provided reason is displayed on the screen of the banned player.- Parameter:
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.- Example: Ban a player for 3 days (a day has 60 * 60 * 24 seconds)
-
enableAreaSelectionTool
public void enableAreaSelectionTool()Enables the "area selection tool" for this player. This enables the player to select an area. To stop the "area selection tool", you can calldisableAreaSelectionTool()
. If you want to retrieve the selection result (i.e the selected area), you can callgetAreaSelectionData(net.risingworld.api.callbacks.Callback)
and provide a properCallback
object.
- Example: Enable area selection tool for a player when he types a command
- Siehe auch:
-
setAreaSelectionData
Sets an area for the "area selection tool" for this player, i.e the selection tool will adapt to the position and size of the provided area.
This only works if the area selection tool is currently active (to enable it, callenableAreaSelectionTool()
)- Parameter:
area
- the area you want to adapt the selected area to. Provide null to reset the selected area (this means the player has to set a new start and end position).
-
getAreaSelectionData
Gets the currently selected area. This only returns a properArea
if the "area selection tool" is currently enabled and if a start and end position is selected. Otherwise, null is returned.
Since all data needs to be queried from the client, this method uses aCallback
.- Parameter:
callback
- theCallback
object. It will be called once theArea
object has been retrieved from the player. The particularArea
will be passed as argument (or null if no area was selected).- Example: Retrieve the selected area. Using lambda expression (Java 8))
- Example: Same example as above, but without using lambda expression (instead pass "old style" anonymous class)
- Siehe auch:
-
disableAreaSelectionTool
public void disableAreaSelectionTool()Disables the "area selection tool" for this player. Does nothing if the "area selection tool" is currently not active.
Remember to get the currently selectedArea
by callinggetAreaSelectionData(net.risingworld.api.callbacks.Callback)
first, otherwise the selected area will be discarded.- Siehe auch:
-
raycast
Performs a raycast from the player view position to the player view direction. The game checks the nearest collision (e.g terrain, constructions etc, this can be specified with the layer bitmask).
Since all data needs to be queried from the client, this method uses aCallback
- Parameter:
layerMask
- the collision layer bitmask. This value specifies which colliders should be taken into account when performing the raycast. SeeLayer.getBitmask(int...)
callback
- theCallback
object. It will be called once theRaycastResult
object has been retrieved from the player. The particularRaycastResult
will be passed as argument (or null if no collision was found, for example when the player looks towards the sky etc).- Example: Find out if player looks at another player
- Example: Find collision point (on terrain, constructions or objects)
- Siehe auch:
-
raycast
public void raycast(float distance, int layerMask, boolean includeTriggers, Callback<RaycastResult> callback) Performs a raycast from the player view position to the player view direction. The game checks the nearest collision (e.g terrain, constructions etc, this can be specified with the layer bitmask).
Since all data needs to be queried from the client, this method uses aCallback
- Parameter:
distance
- the max distance you want to perform the raycast.layerMask
- the collision layer bitmask. This value specifies which colliders should be taken into account when performing the raycast. SeeLayer.getBitmask(int...)
includeTriggers
- if true, trigger colliders ("ghost colliders") will also be taken into account, else the raycast will ignore them (default: false).callback
- theCallback
object. It will be called once theRaycastResult
object has been retrieved from the player. The particularRaycastResult
will be passed as argument (or null if no collision was found, for example when the player looks towards the sky etc).- Siehe auch:
-
raycast
public void raycast(Vector3f direction, float distance, int layerMask, boolean includeTriggers, Callback<RaycastResult> callback) Performs a raycast from the player view position to the provided direction. The game checks the nearest collision (e.g terrain, constructions etc, this can be specified with a bitmask).
Since all data needs to be queried from the client, this method uses aCallback
.
Please keep in mind that raycasting can have a noticeable impact on the client performance (framerate), so use it with caution!- Parameter:
direction
- the direction of the ray. If you want to use the player view direction, you can useraycast(float, int, boolean, net.risingworld.api.callbacks.Callback)
instead.distance
- the max distance you want to perform the raycast.layerMask
- the collision layer bitmask. This value specifies which colliders should be taken into account when performing the raycast. SeeLayer.getBitmask(int...)
includeTriggers
- if true, trigger colliders ("ghost colliders") will also be taken into account, else the raycast will ignore them (default: false).callback
- theCallback
object. It will be called once theRaycastResult
object has been retrieved from the player. The particularRaycastResult
will be passed as argument (or null if no collision was found).- Siehe auch:
-
raycastFromScreenPosition
public void raycastFromScreenPosition(float x, float y, boolean relative, float distance, int layerMask, boolean includeTriggers, Callback<RaycastResult> callback) Performs a raycast from the screen xy position. In other words, the game checks the nearest collision at the given screen position (e.g terrain, constructions etc, this can be specified with a bitmask).
Since all data needs to be queried from the client, this method uses aCallback
- Parameter:
x
- the horizontal screen position (x).y
- the vertical screen position (y).relative
- set to false to use absolute screen coordinates (i.e pixel coordinates), or true to use relative screen coordinates (range between 0.0 and 1.0)distance
- the max distance you want to perform the raycast.layerMask
- the collision layer bitmask. This value specifies which colliders should be taken into account when performing the raycast. SeeLayer.getBitmask(int...)
includeTriggers
- if true, trigger colliders ("ghost colliders") will also be taken into account, else the raycast will ignore them (default: false).callback
- theCallback
object. It will be called once theRaycastResult
object has been retrieved from the player. The particularRaycastResult
will be passed as argument (or null if no collision was found, for example when the player looks towards the sky etc).
-
raycastFromWorldPosition
public void raycastFromWorldPosition(Vector3f position, Vector3f direction, float distance, int layerMask, boolean includeTriggers, Callback<RaycastResult> callback) Performs a raycast from a world position. The game checks the nearest collision (e.g terrain, constructions etc, this can be specified with a bitmask). The raycast is executed by the client (the player), so it can only take the world that's currently rendered into account (i.e you can only perfom this raycast in the proximity of the player, depending on his view settings).
Since all data needs to be queried from the client, this method uses aCallback
.
Please keep in mind that raycasting can have a noticeable impact on the client performance (framerate), so use it with caution!- Parameter:
position
- the origin of the ray, i.e where the world position you want to start the ray from.direction
- the direction of the ray.distance
- the max distance you want to perform the raycast.layerMask
- the collision layer bitmask. This value specifies which colliders should be taken into account when performing the raycast. SeeLayer.getBitmask(int...)
includeTriggers
- if true, trigger colliders ("ghost colliders") will also be taken into account, else the raycast will ignore them.callback
- theCallback
object. It will be called once theRaycastResult
object has been retrieved from the player. The particularRaycastResult
will be passed as argument (or null if no collision was found, e.g if the player looks towards the sky etc).
-
getAreaInLineOfSight
Gets the area in line-of-sight of the player (i.e the area the player is currently looking at). This is a convenience method which performs a raycast under the hood.- Parameter:
distance
- the max allowed distance, i.e only elements within this range will be detected.callback
- the callback that will be invoked once the result is available. It contains the area the player is currently looking at (within the distance), or null if no area was found.
-
getNpcInLineOfSight
Gets the npc in line-of-sight of the player (i.e the npc the player is currently looking at). This is a convenience method which performs a raycast under the hood.- Parameter:
distance
- the max allowed distance, i.e only elements within this range will be detected.callback
- the callback that will be invoked once the result is available. It contains the npc the player is currently looking at (within the distance), or null if no npc was found.- Example: Set a name for the npc that is in front of player
-
getObjectElementInLineOfSight
Gets the object element in line-of-sight of the player (i.e the object element the player is currently looking at). This is a convenience method which performs a raycast under the hood.- Parameter:
distance
- the max allowed distance, i.e only elements within this range will be detected.callback
- the callback that will be invoked once the result is available. It contains the object element the player is currently looking at (within the distance), or null if no object was found.- Example: Open door in front of player
-
addUIElement
Attaches a UI element to the player's HUD.
Note: It's not recommendable to call this method multiple times per player and element (e.g if you want to update the UI element). If you want to sync Style changes, callUIElement.updateStyle()
instead, which is a lot faster. Other UI element changes are synced automatically.- Parameter:
element
- the UI element you want to attach to this player's screen.
-
addUIElement
Attaches a UI element to the player's screen (to a specific target, e.g HUD, inventory etc).
Note: It's not recommendable to call this method multiple times per player and element (e.g if you want to update the UI element). If you want to sync Style changes, callUIElement.updateStyle()
instead, which is a lot faster. Other UI element changes are synced automatically.- Parameter:
element
- the UI element you want to attach to this player's screen.target
- the UI target where the element should be attached to (default: UITarget.HUD)
-
removeUIElement
Removes a UI element from the player's screen. If the specified UI element is is not attached to the screen, nothing happens.- Parameter:
element
- the UI element you want to remove from this player's screen.
-
getAllUIElements
Gets all UI elements which were added to the player's screen. If no UI elements had been added to the player, null is returned.- Parameter:
includeFromOtherPlugins
- if true, this method will include all UI elements which had been added to the player's screen, also including UI elements created by another plugin. If false, only UI elements created by this plugin will be included.- Gibt zurück:
- a new array containing all UI elements (added by this plugin or another plugin),
or null if no UI elements were added to the player.
- Example: Remove all UI elements which were added by our plugin
-
getScreenResolutionX
public int getScreenResolutionX()Gets the current screen width (horizontal resolution) the player set for his game.- Gibt zurück:
- the screen width (e.g 1920 in case of FullHD)
-
getScreenResolutionY
public int getScreenResolutionY()Gets the current screen height (vertical resolution) the player set for his game.- Gibt zurück:
- the screen height (e.g 1080 in case of FullHD)
-
showMessageBox
public void showMessageBox(MessageBoxButtons buttons, String title, String message, int timeout, Callback<Integer> callback) Shows a default message box to the player. When the player hits a button, the Callback will be invoked.- Parameter:
buttons
- the message box type (determines which buttons should be visible).title
- the title/headline of the message box.message
- the message box text/body.timeout
- optional timeout (seconds) when the message box should close automatically. Set to -1 for no timeout.callback
- optional callback that will be invoked when the player hits a button. The selected button will be provided as int parameter (0 == ok/yes/accept, 1 == no/decline, 2 == cancel/timeout)
-
showInputMessageBox
public void showInputMessageBox(String title, String message, String text, Callback<String> callback) Shows a text input message box to the player. When the player hits a button, the Callback will be invoked (and the String that was entered into the input field will be passed as parameter).- Parameter:
title
- the title/headline of the message box.message
- the message box text/body.text
- an optional filler text for the input field (provide null for an empty field).callback
- callback that will be invoked when the player hits a button. The entered input text will be passed as String parameter (or null if input was canceled).
-
showSuccessMessageBox
Shows a simple success message box to the player. It only has a single "Ok" button.- Parameter:
title
- the title/headline of the message box.message
- the message you want to show to the player.
-
showInfoMessageBox
Shows a simple info message box to the player. It only has a single "Ok" button.- Parameter:
title
- the title/headline of the message box.message
- the message you want to show to the player.
-
showWarningMessageBox
Shows a simple warning message box to the player. It only has a single "Ok" button.- Parameter:
title
- the title/headline of the message box.message
- the message you want to show to the player.
-
showErrorMessageBox
Shows a simple error message box to the player. It only has a single "Ok" button.- Parameter:
title
- the title/headline of the message box.message
- the message you want to show to the player.
-
showColorPicker
Shows a color picker dialog to the player. This enables the player to select an individual RGB or HSL color.- Parameter:
title
- the title/headline of the color picker dialog.initialColor
- the color that is initially set, as int rgb value.callback
- callback that will be invoked when the player hits a button. The selected color will be passed as int parameter (or null if dialog was canceled).
-
showFontDialog
Shows a font selection dialog to the player. This enables the player to select a font (the same font selection that's used by the game for the sign editor, for example).- Parameter:
title
- the title/headline of the font selection dialog.selectedFont
- the font that will be pre-selected.callback
- callback that will be invoked when the player hits a button. The selected font will be passed as parameter (or null if dialog was canceled).
-
showRadialMenu
public void showRadialMenu(TextureAsset[] icons, String[] descriptions, String[] overrideTexts, boolean closeOnSelect, Callback<Integer> callback) Shows a "radial menu" or "pie menu" to the player. The menu may contain up to 13 entries. The selected entry is sent back to the API callback.- Parameter:
icons
- an array containing icons for the individual entries. Make sure the array has the same dimension as the "descriptions" array.descriptions
- an array containing the labels for the individual entries. Make sure the array has the same dimension as the "icons" array.overrideTexts
- optional array to override the text that is shown for a selected entry. Set null if you just want to use the texts from the "descriptions" array. If you provide an array, make sure it has the same dimension as the "description" and "icon" array.closeOnSelect
- if true, the radial menu closes automatically when the player selects an entry. Otherwise you have to close it manually by callinghideRadialMenu(boolean)
callback
- a callback that will be invoked once the player has selected an entry. The selected entry index is passed as parameter (e.g 0 for the first entry, 1 for the second entry etc). If nothing was selected (i.e the player just closed the radial menu), the value is -1
-
hideRadialMenu
public void hideRadialMenu(boolean immediately) Hides any currently active radial menus.- Parameter:
immediately
- true to hide the radial menu immediately, otherwise it fades out (default behaviour).
-
addGameObject
Adds the providedGameObject
to the player's world.
Note: It's not recommendable to call this method multiple times per player and object - just call this method once to register a game object with the player. Changes to the game object are then synced with all linked players automatically.- Parameter:
gameObject
- TheGameObject
you want to add to the player's world.
-
removeGameObject
Removes aGameObject
from the player's world. If the specified element does not exist in the player's world, nothing happens.- Parameter:
gameObject
- theGameObject
you want to remove.
-
getAllGameObjects
Gets allGameObjects
which were added to the player's world. If no game object had been added to the player, null is returned.- Parameter:
includeFromOtherPlugins
- if true, this method will include all game objects which had been added to the player, also including game objects created by another plugin. If false, only game objects created by this plugin will be included.- Gibt zurück:
- a new array containing all game objects, or null if no game objects were added to the player.
-
playSound
Plays a custom 2D sound (i.e it can be heard everywhere, but only by this player). This sound only plays once with default volume and pitch (1.0)
Note: Make sure you use a mono sound when playing it as a 2D sound.- Parameter:
sound
- the SoundAsset object which refers to the custom sound file.- Gibt zurück:
- an internal ID of this new sound instance. This may be relevant when playing a loop sound, then you can stop the sound by providing this ID.
-
playSound
Plays a custom 3D sound at the given position. This sound can only be heard by this player. This sound only plays once with default volume and pitch (1.0)- Parameter:
sound
- the SoundAsset object which refers to the custom sound file.position
- the world position of the sound. Providenull
if you want to play this sound as a 2D sound instead (this means the sound has no actual position and can be heard everywhere).- Gibt zurück:
- an internal ID of this new sound instance. This may be relevant when playing a loop sound, then you can stop the sound by providing this ID.
-
playSound
public Sound playSound(SoundAsset sound, boolean loop, float volume, float pitch, Vector3f position) Plays a custom 3D sound at the given position. This sound can only be heard by this player.- Parameter:
sound
- the SoundAsset object which refers to the custom sound file.loop
- determines if this sound should play as a loop (i.e it repeats indefinitely). If true, the sound will only stop when callingstopSound(int)
.volume
- the sound volume (default: 1.0)pitch
- the sound pitch (default: 1.0)position
- the world position of the sound. Providenull
if you want to play a 2D sound instead (this means the sound has no actual position and can be heard everywhere).- Gibt zurück:
- an internal ID of this new sound instance. This may be relevant when playing a loop sound, then you can stop the sound by providing this ID.
-
playSound
public Sound playSound(SoundAsset sound, boolean loop, float volume, float pitch, float minDistance, float maxDistance, Vector3f position) Plays a custom 3D sound at the given position. This sound can only be heard by this player.- Parameter:
sound
- the SoundAsset object which refers to the custom sound file.loop
- determines if this sound should play as a loop (i.e it repeats indefinitely). If true, the sound will only stop when callingstopSound(int)
.volume
- the sound volume (default: 1.0)pitch
- the sound pitch (default: 1.0)minDistance
- the distance that the sound emitter will cease to continue growing louder at (the further you move to the center of the sound). Within the minimum distance, the sound stays at the constant loudest possible volume (default: 1.0)maxDistance
- the distance the sound becomes silent. The sound volume is interpolated between minDistance and maxDistance (default: 50.0). Sound uses a linear-square-rolloff (minDistance == full volume, maxDistance == silence).position
- the world position of the sound. Providenull
if you want to play a 2D sound instead (this means the sound has no actual position and can be heard everywhere).- Gibt zurück:
- an internal ID of this new sound instance. This may be relevant when
playing a loop sound, then you can stop the sound by providing this ID.
- Example: Play a loop sound for a wind mill
-
stopSound
-
stopSound
public void stopSound(int id) -
enableGameMusic
public void enableGameMusic()Enables the ingame music. This only has an effect ifdisableGameMusic()
has been called previously. -
disableGameMusic
public void disableGameMusic()Disables the ingame music. This stops the currently playing (if any) music track and prevents the game from playing another music track untilenableGameMusic()
was called. This does not affect the main theme (which can be heared only in main menu and during the loading screen).- Example: Disable default game music and play custom music track every 10 minutes instead
-
connectToOtherServer
Connects the client to another multiplayer server. Asks the client if he accepts the redirection, then the provided callback will be invoked (with a boolean parameter indicating whether or not the client accepted). NOTE: This will disconnect the player from the server (like a regular disconnect), the only difference is that the player will immediately try to connect to the other server.- Parameter:
target
- the target ip address (and optional port)password
- optional password (if the target server is password-protected). Set null to not provide a passwordcallback
- callback which will be invoked once the player accepted or declined the redirection
-
connectToTeamSpeak
Connects the client to a TeamSpeak server, but only as long as TeamSpeak is installed on the client computer, and only if the client accepts to connect.
Please note: This does only work if the client uses Windows!- Parameter:
ip
- the target ip address of the TeamSpeak server.port
- the target port of the TeamSpeak server.channel
- the target channel the client should join on connect. To join a subchannel, you have to use a slash (e.g"channel/subchannel"
).- Example:
-
connectToDiscord
Connects the client to a Discord server, or more precisely, it opens the url to the Discord server in the web browser.- Parameter:
url
- the url to the Discord server, for example "https://discord.gg/ay21koSP" or "https://discordapp.com/invite/example" etc.- Example:
-
createScreenshot
public void createScreenshot(float sizeFactor, float quality, boolean includeUI, Callback<BufferedImage> callback) Creates a screenshot of the player screen and converts it into a BufferedImage.- Parameter:
sizeFactor
- the size factor of the image (1.0f is original width/height, 0.5f is half widht/height etc).quality
- the quality of the image (0-1).includeUI
- if true, the UI (HUD, active menus etc) will be visible on the screenshot.callback
- this callback will be called once the screenshot has been uploaded to the server. The screenshot is passed as BufferedImage object. Uploading the screenshot may take a few seconds depending on the bandwidth, traffic and screenshot size.
-
createScreenshot
public void createScreenshot(int width, int height, float quality, boolean includeUI, Callback<BufferedImage> callback) Creates a screenshot of the player screen with the desired resolution and converts it into a BufferedImage.- Parameter:
width
- the width of the screenshot.height
- the height of the screenshot.quality
- the quality of the image (0-1).includeUI
- if true, the UI (HUD, active menus etc) will be visible on the screenshot.callback
- this callback will be called once the screenshot has been uploaded to the server. The screenshot is passed as BufferedImage object. Uploading the screenshot may take a few seconds depending on the bandwidth, traffic and screenshot size.
-
createScreenshot
public void createScreenshot(Vector3f position, Vector3f direction, int width, int height, float quality, boolean includeUI, Callback<BufferedImage> callback) Creates a screenshot from an arbitrary world position with the desired resolution and converts it into a BufferedImage. Please note that only parts of the world which are currently generated for the player will be visible on the screenshot.- Parameter:
position
- the world position from where the screenshot should be taken.direction
- the view direction for the camera.width
- the width of the screenshot.height
- the height of the screenshot.quality
- the quality of the image (0-1).includeUI
- if true, the UI (HUD, active menus etc) will be visible on the screenshot.callback
- this callback will be called once the screenshot has been uploaded to the server. The screenshot is passed as BufferedImage object. Uploading the screenshot may take a few seconds depending on the bandwidth, traffic and screenshot size.
-