Package com.welcome234.pluginsystem
Class Player
java.lang.Object
com.welcome234.pluginsystem.CommandSender
com.welcome234.pluginsystem.Player
Represents a player, both online and offline
-
Method Summary
Modifier and TypeMethodDescriptionGets the IP address that this player is connected withintGets the port that this player is connected withintGets the number of health points this player hasgetName()Gets the name of this playerintgetSlotAmount(int slot)Gets the amount at specified inventory slotgetSlotBlock(int slot)Gets the block type at specified inventory slotintGets the current strength value this player hasdoublegetX()Gets the current X-coordinate of this playerdoublegetY()Gets the current Y-coordinate of this playerbooleanGives the player the block with the amount specifiedbooleanGets if this player has played on the serverbooleanisAdmin()Gets if this player is an adminbooleanGets if this player has authenticated (logged in) to the server.booleanisBanned()Gets if this player is bannedbooleanisInEnd()Gets whether the player is currently in the end dimensionbooleanisOnline()Gets if this player is currently onlinebooleanGets if this player is whitelistedvoidkick()Kicks this player from the servervoidKicks this player from the server with the specified reasonvoidsave()Saves this players data to the diskvoidsendMessage(String message)Sends a chat message to this playervoidsetAdmin(boolean admin)Sets the admin status of this playervoidsetBanned(boolean banned)Sets the banned status of this playervoidsetHealth(int health)Sets the number of health points of this playervoidsetPos(double x, double y, boolean endDimension)Sets the current position of this playervoidsetSlotBlock(int slot, Block block, int amount)Sets the specified inventory slot to the block and amountvoidsetStrength(int strength)Sets the strength value of this playervoidsetWhitelisted(boolean whitelisted)Sets the whitelisted status of this playervoidTransfers this player to the specified server address and port
-
Method Details
-
isOnline
public boolean isOnline()Gets if this player is currently online- Returns:
- Whether online
-
hasPlayed
public boolean hasPlayed()Gets if this player has played on the server- Returns:
- Whether played
-
isAuthenticated
public boolean isAuthenticated()Gets if this player has authenticated (logged in) to the server.- Returns:
- Whether authenticated
- Throws:
IllegalStateException- if player is offline
-
getName
Gets the name of this playerIf online, this will return the name case of online player
If offline, this will return the name case of the stored offline player
- Overrides:
getNamein classCommandSender- Returns:
- Player name
-
getConnectedIP
Gets the IP address that this player is connected with- Returns:
- Connected IP address
- Throws:
IllegalStateException- if player is offline
-
getConnectedPort
public int getConnectedPort()Gets the port that this player is connected with- Returns:
- Connected port
- Throws:
IllegalStateException- if player is offline
-
getX
public double getX()Gets the current X-coordinate of this player- Returns:
- X-coordinate position
- Throws:
IllegalStateException- if player is offline
-
getY
public double getY()Gets the current Y-coordinate of this player- Returns:
- Y-coordinate position
- Throws:
IllegalStateException- if player is offline
-
isInEnd
public boolean isInEnd()Gets whether the player is currently in the end dimension- Returns:
- Whether in end dimension
- Throws:
IllegalStateException- if player is offline
-
setPos
public void setPos(double x, double y, boolean endDimension)Sets the current position of this player- Parameters:
x- X-coordinate of the playery- Y-coordinate of the playerendDimension- Dimension of this player (false = Overworld, true = End)- Throws:
IllegalStateException- if player is offline
-
getHealth
public int getHealth()Gets the number of health points this player has- Returns:
- Health points
- Throws:
IllegalStateException- if player is offline
-
setHealth
public void setHealth(int health)Sets the number of health points of this player- Parameters:
health- Health points- Throws:
IllegalStateException- if player is offline
-
getStrength
public int getStrength()Gets the current strength value this player has- Returns:
- Strength value
- Throws:
IllegalStateException- if player is offline
-
setStrength
public void setStrength(int strength)Sets the strength value of this player- Parameters:
strength- Strength value- Throws:
IllegalStateException- if player is offline
-
giveBlock
Gives the player the block with the amount specified- Parameters:
block- Block type to giveamount- Amount of blocks- Returns:
- Whether the item was given, can return false if inventory was full
- Throws:
IllegalStateException- if player is offlineIllegalArgumentException- if block is null
-
setSlotBlock
Sets the specified inventory slot to the block and amountIf set to AIR, the slot will become empty
- Parameters:
slot- Inventory slotblock- Block typeamount- Amount of blocks- Throws:
IllegalStateException- if player is offlineIllegalArgumentException- if slot is out of boundsIllegalArgumentException- if block is null
-
getSlotBlock
Gets the block type at specified inventory slot- Parameters:
slot- Inventory slot- Returns:
- Block type
- Throws:
IllegalStateException- if player is offlineIllegalArgumentException- if slot is out of bounds
-
getSlotAmount
public int getSlotAmount(int slot)Gets the amount at specified inventory slot- Parameters:
slot- Inventory slot- Returns:
- Amount of block
- Throws:
IllegalStateException- if player is offlineIllegalArgumentException- if slot is out of bounds
-
sendMessage
Sends a chat message to this player- Overrides:
sendMessagein classCommandSender- Parameters:
message- Message to send- Throws:
IllegalStateException- if player is offlineIllegalArgumentException- if message is null
-
isAdmin
public boolean isAdmin()Gets if this player is an admin- Returns:
- Whether admin
-
setAdmin
public void setAdmin(boolean admin)Sets the admin status of this player- Parameters:
admin- Whether admin
-
isBanned
public boolean isBanned()Gets if this player is banned- Returns:
- Whether banned
-
setBanned
public void setBanned(boolean banned)Sets the banned status of this player- Parameters:
banned- Whether banned
-
isWhitelisted
public boolean isWhitelisted()Gets if this player is whitelistedThis always return true if whitelist is disabled on the server
- Returns:
- Whether whitelisted
-
setWhitelisted
public void setWhitelisted(boolean whitelisted)Sets the whitelisted status of this player- Parameters:
whitelisted- Whether whitelisted- Throws:
IllegalArgumentException- if server whitelist is not enabled
-
kick
public void kick()Kicks this player from the server- Throws:
IllegalStateException- if player is already currently leavingIllegalStateException- if player is offline
-
kick
Kicks this player from the server with the specified reason- Parameters:
reason- Kick reason- Throws:
IllegalStateException- if player is already currently leavingIllegalStateException- if player is offlineIllegalArgumentException- if reason is null
-
transfer
Transfers this player to the specified server address and portThis will cause the player to be kicked from the server and they will be connected to the specified address
- Parameters:
address- Server addressport- Server port- Throws:
IllegalStateException- if player is already currently leavingIllegalStateException- if player is offlineIllegalArgumentException- if address is null
-
save
public void save()Saves this players data to the disk- Throws:
IllegalStateException- if player is offline
-