Package net.risingworld.api.objects
Klasse 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).-
Feldübersicht
-
Konstruktorübersicht
-
Methodenübersicht
Modifizierer und TypMethodeBeschreibungvoid
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).
-
Felddetails
-
INFINITE
An "infinite" area (more precisely, the largest possible area). It covers the whole world.
-
-
Konstruktordetails
-
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.- Parameter:
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.- Parameter:
startPosition
- the start position of the area.endPosition
- the end position of the area.
-
-
Methodendetails
-
getID
public long getID()Gets the internal unique global id of this area.- Gibt zurück:
- 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.- Parameter:
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.- Parameter:
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.- Parameter:
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.- Parameter:
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!- Parameter:
player
- the player you want to get the area permission for.- Gibt zurück:
- 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.- Parameter:
playerDbID
- the database ID of the player you want to get the area permission for.- Gibt zurück:
- 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!- Gibt zurück:
- 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.- Gibt zurück:
- 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)
).- Parameter:
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.- Gibt zurück:
- 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.- Parameter:
priority
- the new priority. Default is 0.
-
getName
Gets the currently set area name. May be null (if no name is set).- Gibt zurück:
- the optional area name, or null if no name is set.
- Siehe auch:
-
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.- Parameter:
name
- the new area name.- Siehe auch:
-
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).- Gibt zurück:
- true if the area name should be visible for the player, false if not.
- Siehe auch:
-
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).- Parameter:
set
- true to show the area name, false to hide it.- Siehe auch:
-
getStartPosition
Gets the start world position of the area. In combination with the end position, this determines the area position and size.- Gibt zurück:
- 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.- Gibt zurück:
- the end position.
-
getStartChunkPosition
-
getStartBlockPosition
-
getEndChunkPosition
-
getEndBlockPosition
-
setStartPosition
Sets a start position for this area (start and end position determine the area size).- Parameter:
startPosition
- the new start position.
-
setEndPosition
Sets an end position for this area (start and end position determine the area size).- Parameter:
endPosition
- the new end position.
-
set
Sets a new start and end position for this area.- Parameter:
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.- Gibt zurück:
- true if the values have been rearranged, false if rearranging was not necessary.
-
isPointInArea
Gets whether or not the point is inside this area.- Parameter:
point
- a global world position (as a Vector3f)- Gibt zurück:
- 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.- Parameter:
x
- the global x world position.y
- the global y world position.z
- the global z world position.- Gibt zurück:
- true if the position is inside this area, false if not.
-
intersects
Checks whether or not the provided area intersects this area.- Parameter:
area
- the area you want to check.- Gibt zurück:
- 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.- Parameter:
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.- 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.
-
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.
-
deleteAttribute
Removes an attribute from this area. Does nothing if the attribute doesn't exist.- Parameter:
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()
-