Package net.risingworld.api.objects
Class Area
java.lang.Object
net.risingworld.api.objects.Area
An
Note: If you create a new area and you don't need it anymore, call
Area
describes an area in the game world. It has a start and end position. Note: If you create a new area and you don't need it anymore, call
destroy()
so the native resources will be released.
Only do that to areas you've created using the new keyword. Do not destroy areas returned by the server (unless you really want
to get rid of them).-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
deleteAttribute
(String key) Removes an attribute from this area.void
destroy()
Destroys this area.boolean
Gets a map containing all player permissions (player database ID mapped to area permission name).getAttribute
(String key) Gets the value to which the specified key is mapped, or null if no attribute is stored for that key.Gets the default area permission for this area.Gets the end world position of the area.long
getID()
Gets the internal unique global id of this area.getName()
Gets the currently set area name.getPlayerPermission
(int playerDbID) Gets the permission of a player in this area.getPlayerPermission
(Player player) Gets the permission of a player in this area.int
Gets the area priority.getSize()
Gets the start world position of the area.boolean
hasAttribute
(String key) Gets whether or not the provided attribute exists.int
hashCode()
boolean
intersects
(Area area) Checks whether or not the provided area intersects this area.boolean
Gets whether or not the area name should be shown to the player whenever he enters the area (shown in the lower left corner of the screen).boolean
isPointInArea
(float x, float y, float z) Gets whether or not the provided position is inside this area.boolean
isPointInArea
(Vector3f point) Gets whether or not the point is inside this area.boolean
isValid()
boolean
Rearranges the values of this area, i.e the start position will be compared with the end position, and if the start position is less than the end position, the values will be swapped.
Note: This method is called automatically when a new area is created or when the start/end position has been changed.void
removePlayerPermission
(int playerDbID) Removes a player from the area/permissions.void
removePlayerPermission
(Player player) Removes a player from the area/permissions.void
Sets a new start and end position for this area.void
setAttribute
(String key, Object value) Stores an attribute for this area.void
setDefaultPermission
(String areaPermission) Sets a default area permission for this area.void
setEndPosition
(Vector3f endPosition) Sets an end position for this area (start and end position determine the area size).void
Changes the area name.void
setNameVisible
(boolean set) Determines if the area name should be shown to the player whenever he enters the area (shown in the lower left corner of the screen).void
setPlayerPermission
(int playerDbID, String areaPermission) Sets the area permission for a player.void
setPlayerPermission
(Player player, String areaPermission) Sets the area permission for a player.void
setPriority
(int priority) Changes the area priority.void
setStartPosition
(Vector3f startPosition) Sets a start position for this area (start and end position determine the area size).toString()
Gets a String representation of this area (containing the global id, start and end positions).
-
Field Details
-
INFINITE
An "infinite" area (more precisely, the largest possible area). It covers the whole world.
-
-
Constructor Details
-
Area
public Area()Creates an "empty" area. Note: If you no longer need the area,destroy()
it. -
Area
Creates an area with the same size as the provided area. Note: If you no longer need the area,destroy()
it.- Parameters:
area
- the Area you want this Area to be adapted to.
-
Area
Creates a new area. Note: If you no longer need the area,destroy()
it.- Parameters:
startPosition
- the start position of the area.endPosition
- the end position of the area.
-
-
Method Details
-
getID
public long getID()Gets the internal unique global id of this area.- Returns:
- the id of this area.
-
isValid
public boolean isValid() -
setPlayerPermission
Sets the area permission for a player. This permission is then active for the player while he's inside the area.- Parameters:
player
- the player you want to add to the area.areaPermission
- the name of the area permission that should be assigned to the player.
-
setPlayerPermission
Sets the area permission for a player. This permission is then active for the player while he's inside the area. This method also works for offline players.- Parameters:
playerDbID
- the database ID of the player.areaPermission
- the name of the area permission that should be assigned to the player. Must not be null!
-
removePlayerPermission
Removes a player from the area/permissions.- Parameters:
player
- the player you want to remove from the area.
-
removePlayerPermission
public void removePlayerPermission(int playerDbID) Removes a player from the area/permissions. This method also works for offline players.- Parameters:
playerDbID
- the database ID of the player you want to remove from the area.
-
getPlayerPermission
Gets the permission of a player in this area. If the player was not assigned to the area yet (seesetPlayerPermission(net.risingworld.api.objects.Player, java.lang.String)
), null is returned!- Parameters:
player
- the player you want to get the area permission for.- Returns:
- the name of the area permission for this player, or null if the player was not assigned to the area yet.
-
getPlayerPermission
Gets the permission of a player in this area. If the player was not assigned to the area yet (seesetPlayerPermission(net.risingworld.api.objects.Player, java.lang.String)
), null is returned! This method also works for offline players.- Parameters:
playerDbID
- the database ID of the player you want to get the area permission for.- Returns:
- the name of the area permission for this player, or null if the player was not assigned to the area yet.
-
getAllPlayerPermissions
Gets a map containing all player permissions (player database ID mapped to area permission name). If no players are assigned to this area yet, null is returned!- Returns:
- a new map containing all players and player area permission names, or null if no players are
assigned to this area yet.
- Example: Print all players/permissions assigned to an area
-
getDefaultPermission
Gets the default area permission for this area.- Returns:
- the default area permission, or null if no specific permission was assigned as default permission to this area.
-
setDefaultPermission
Sets a default area permission for this area. This affects all players who enter the area, unless the player was added with a specific permission to that area (seesetPlayerPermission(net.risingworld.api.objects.Player, java.lang.String)
).- Parameters:
areaPermission
- the name of the area permission you want to assign as default permission for this area.
-
getPriority
public int getPriority()Gets the area priority. Default is 0. This is usually relevant if multiple areas are overlapping - then the permission of the area with the highest priority is used.- Returns:
- the area priority (the higher the value, the higher the area priority).
-
setPriority
public void setPriority(int priority) Changes the area priority. This is usually relevant if multiple areas are overlapping - then the permission of the area with the highest priority is used.- Parameters:
priority
- the new priority. Default is 0.
-
getName
Gets the currently set area name. May be null (if no name is set).- Returns:
- the optional area name, or null if no name is set.
- See Also:
-
setName
Changes the area name. Area names are optional. IfisNameVisible()
is set, the area name will be shown to the player whenever he enters the area.- Parameters:
name
- the new area name.- See Also:
-
isNameVisible
public boolean isNameVisible()Gets whether or not the area name should be shown to the player whenever he enters the area (shown in the lower left corner of the screen).- Returns:
- true if the area name should be visible for the player, false if not.
- See Also:
-
setNameVisible
public void setNameVisible(boolean set) Determines if the area name should be shown to the player whenever he enters the area (shown in the lower left corner of the screen).- Parameters:
set
- true to show the area name, false to hide it.- See Also:
-
getStartPosition
Gets the start world position of the area. In combination with the end position, this determines the area position and size.- Returns:
- the start position.
-
getEndPosition
Gets the end world position of the area. In combination with the start position, this determines the area position and size.- Returns:
- the end position.
-
getStartChunkPosition
-
getStartBlockPosition
-
getEndChunkPosition
-
getEndBlockPosition
-
setStartPosition
Sets a start position for this area (start and end position determine the area size).- Parameters:
startPosition
- the new start position.
-
setEndPosition
Sets an end position for this area (start and end position determine the area size).- Parameters:
endPosition
- the new end position.
-
set
Sets a new start and end position for this area.- Parameters:
startPosition
- the new start position.endPosition
- the new end position.
-
getSize
-
rearrange
public boolean rearrange()Rearranges the values of this area, i.e the start position will be compared with the end position, and if the start position is less than the end position, the values will be swapped.
Note: This method is called automatically when a new area is created or when the start/end position has been changed.- Returns:
- true if the values have been rearranged, false if rearranging was not necessary.
-
isPointInArea
Gets whether or not the point is inside this area.- Parameters:
point
- a global world position (as a Vector3f)- Returns:
- true if the point is inside this area, false if not.
-
isPointInArea
public boolean isPointInArea(float x, float y, float z) Gets whether or not the provided position is inside this area.- Parameters:
x
- the global x world position.y
- the global y world position.z
- the global z world position.- Returns:
- true if the position is inside this area, false if not.
-
intersects
Checks whether or not the provided area intersects this area.- Parameters:
area
- the area you want to check.- Returns:
- true if there is an intersection between this area and the provided area, false if not.
-
destroy
public void destroy()Destroys this area. This releases all native resources. It's important to call this method as soon as you don't need the area anymore. Do not use this area anymore after calling this method! -
setAttribute
Stores an attribute for this area. You can store any type of object. Note that all attributes will be reset upon server restart.- Parameters:
key
- the name of the attribute.value
- the value/object you want to store.
-
getAttribute
Gets the value to which the specified key is mapped, or null if no attribute is stored for that key.- Parameters:
key
- the name of the attribute.- Returns:
- the attribute that is stored for that key, or null of the key does not exists.
-
hasAttribute
Gets whether or not the provided attribute exists.- Parameters:
key
- the name of the attribute.- Returns:
- true if the attribute exists, false if not.
-
deleteAttribute
Removes an attribute from this area. Does nothing if the attribute doesn't exist.- Parameters:
key
- the name of the attribute you want to delete.
-
toString
Gets a String representation of this area (containing the global id, start and end positions). -
equals
-
hashCode
public int hashCode()
-