public interface Player extends OfflinePlayer
Modifier and Type | Method and Description |
---|---|
default void |
addPotionEffect(PotionEffect pe) |
void |
addPotionEffect(PotionEffectType type,
int duration,
int amplifier) |
void |
applyTheoricVelocity() |
void |
closeInventory() |
void |
damage(double amount)
Damage player according to damage amount
|
List<PotionEffect> |
getActivePotionEffect() |
InetSocketAddress |
getAddress()
Get the player address
|
boolean |
getAllowFlight()
Check if the player is authorized to fly
|
float |
getFallDistance()
Get the player fall distance when player fall
|
float |
getFlySpeed()
Get player fly speed
|
int |
getFoodLevel()
Get the current player food level
|
GameMode |
getGameMode()
Get player gamemode
|
double |
getHealth()
Get the player health
|
PlayerInventory |
getInventory() |
@Nullable String |
getIP()
Get the player IP
|
ItemStack |
getItemInHand()
Get the item in main hand
Return null if there is not any item in hand
|
ItemStack |
getItemInOffHand()
Get the item in second hand
Compatible with 1.8 and lower.
|
int |
getLevel()
Get player XP level
|
double |
getMaxHealth()
Get the max player health
|
List<Entity> |
getNearbyEntities(double x,
double y,
double z) |
Inventory |
getOpenInventory() |
int |
getPing()
Get current player latency
|
Version |
getPlayerVersion()
Get player version
(Compatible with ViaVersion and ProtocolSupport for multiple client version)
|
Optional<PotionEffect> |
getPotionEffect(PotionEffectType type) |
int |
getProtocolVersion() |
String |
getServerName()
Get the name of the server where the player is actually
|
List<Block> |
getTargetBlock(int maxDistance) |
Vector |
getTheoricVelocity()
Get the velocity that the entity SHOULD be take
|
Entity |
getVehicle()
Get the entity which is used as vehicle.
|
Vector |
getVelocity()
Get current entity velocity
|
float |
getWalkSpeed()
Get player walk speed
|
CompensatedWorld |
getWorld()
Get player world
|
boolean |
hasElytra()
Check if the player is using elytra (flying with it)
(compatible with 1.8 and lower)
|
boolean |
hasLineOfSight(Entity entity)
Check if player can see the specified entity
|
boolean |
hasOpenInventory() |
boolean |
hasPermission(String perm)
Check if the player has the specified permission
|
default boolean |
hasPlayedBefore()
Check if it's a new player
|
boolean |
hasPotionEffect(PotionEffectType type) |
default boolean |
hasThorns() |
boolean |
isDead()
Know if the player is dead
|
boolean |
isFlying()
Check if the player is flying
|
default boolean |
isInBoat() |
boolean |
isInsideVehicle()
Check if player is in a vehicle.
|
static boolean |
isSamePlayer(Player player1,
Player player2) |
boolean |
isSleeping()
Know if the player is sleeping
|
boolean |
isSneaking() |
boolean |
isSprinting() |
boolean |
isSwimming()
Know if the player is swimming
(compatible with 1.8 and lower)
|
boolean |
isUsingRiptide()
Know if the player is currently using riptide effect
(compatible with 1.12 and lower)
|
void |
kick(String reason)
Kick player with the specified reason
|
void |
openInventory(Inventory inv) |
default void |
queuePacket(NPacket packet) |
void |
removePotionEffect(PotionEffectType type) |
default void |
sendPacket(NPacket packet)
Send packet to the given player
|
void |
sendPluginMessage(String channelId,
byte[] writeMessage)
Send plugin message :
bungee to spigot
OR
spigot to bungee
On the specified channel
|
default void |
sendPluginMessage(String channelId,
NegativityMessage message)
Send plugin message :
bungee to spigot
OR
spigot to bungee
On the specified channel
|
void |
sendToServer(String serverName)
Send current player to the given server name.
|
void |
setAllowFlight(boolean b)
Edit the authorization to fly
|
void |
setFlying(boolean b) |
void |
setFoodLevel(int foodlevel)
Change the food level
|
void |
setGameMode(GameMode gameMode)
Set the player gamemode
Warn: support only default gamemode.
|
void |
setHealth(double health)
Change the player health
|
void |
setInternalWorld(CompensatedWorld w)
This does NOT change the platform world (aka teleport)
|
void |
setLocation(Location loc) |
void |
setPlayerVersion(Version version) |
void |
setProtocolVersion(int protocolVersion) |
default void |
setSleeping(boolean b) |
void |
setSneaking(boolean b) |
void |
setSprinting(boolean b) |
void |
setVanished(boolean vanished)
Sets whether the play should be visible to other players.
|
void |
setVelocity(Vector vel)
Edit the entity velocity
|
void |
teleport(Entity et)
Teleport player to specified entity
|
void |
teleport(Location loc)
Teleport player to specified location
|
void |
updateInventory() |
getBoundingBox, getEntityId, getEyeHeight, getLocation, getType, getUniqueId, isOnGround, isOnline, sendMessage
getEyeLocation, getRotation, isOp, isSameId, isSameId, isSameId
getName
getDefault
@Nullable String getIP()
boolean isDead()
isDead
in interface Entity
isDead
in interface OfflinePlayer
boolean isSleeping()
default void setSleeping(boolean b)
boolean isSwimming()
boolean isUsingRiptide()
boolean hasElytra()
boolean hasPermission(String perm)
perm
- the needed permissionboolean hasLineOfSight(Entity entity)
entity
- the entity to seeboolean isFlying()
void setFlying(boolean b)
boolean getAllowFlight()
void setAllowFlight(boolean b)
b
- true if the player is allowed to flyint getPing()
int getLevel()
float getFlySpeed()
float getWalkSpeed()
float getFallDistance()
double getHealth()
double getMaxHealth()
void setHealth(double health)
health
- next healthint getFoodLevel()
void setFoodLevel(int foodlevel)
foodlevel
- the new food levelGameMode getGameMode()
void setGameMode(GameMode gameMode)
gameMode
- the new player gamemodevoid damage(double amount)
amount
- the quantity of damagevoid kick(String reason)
reason
- the reason of kickvoid teleport(Location loc)
loc
- location destinationvoid teleport(Entity et)
et
- entity destinationboolean isSneaking()
void setSneaking(boolean b)
boolean isSprinting()
void setSprinting(boolean b)
CompensatedWorld getWorld()
getWorld
in interface Entity
getWorld
in interface OfflinePlayer
void setInternalWorld(CompensatedWorld w)
w
- the new worldVersion getPlayerVersion()
void setPlayerVersion(Version version)
int getProtocolVersion()
void setProtocolVersion(int protocolVersion)
void applyTheoricVelocity()
Vector getTheoricVelocity()
Vector getVelocity()
void setVelocity(Vector vel)
vel
- the new velocityEntity getVehicle()
boolean isInsideVehicle()
ItemStack getItemInHand()
ItemStack getItemInOffHand()
boolean hasPotionEffect(PotionEffectType type)
List<PotionEffect> getActivePotionEffect()
Optional<PotionEffect> getPotionEffect(PotionEffectType type)
default void addPotionEffect(PotionEffect pe)
void addPotionEffect(PotionEffectType type, int duration, int amplifier)
void removePotionEffect(PotionEffectType type)
default void sendPluginMessage(String channelId, NegativityMessage message)
channelId
- the channel IDmessage
- the message to sentvoid sendPluginMessage(String channelId, byte[] writeMessage)
channelId
- the channel IDwriteMessage
- the message to sentPlayerInventory getInventory()
Inventory getOpenInventory()
boolean hasOpenInventory()
void openInventory(Inventory inv)
void closeInventory()
void updateInventory()
void setVanished(boolean vanished)
vanished
- true is the player should NOT be visiblevoid setLocation(Location loc)
InetSocketAddress getAddress()
default boolean hasPlayedBefore()
hasPlayedBefore
in interface OfflinePlayer
void sendToServer(String serverName)
serverName
- the name of the proxy serverString getServerName()
default void sendPacket(NPacket packet)
packet
- the packet to senddefault void queuePacket(NPacket packet)
default boolean isInBoat()
default boolean hasThorns()