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 |
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
|
Entity |
getVehicle()
Get the entity which is used as vehicle.
|
float |
getWalkSpeed()
Get player walk speed
|
World |
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) |
boolean |
isDead()
Know if the player is dead
|
boolean |
isFlying()
Check if the player is flying
|
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 > spigot
OR
spigot > bungee
On the specified channel
|
default void |
sendPluginMessage(String channelId,
NegativityMessage message)
Send plugin message :
bungee > spigot
OR
spigot > 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 |
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 |
setPlayerVersion(Version version) |
void |
setProtocolVersion(int protocolVersion) |
void |
setSneaking(boolean b) |
void |
setSprinting(boolean b) |
void |
setVanished(boolean vanished)
Sets whether the play should be visible to other players.
|
void |
teleport(Entity et)
Teleport player to specified entity
|
void |
teleport(Location loc)
Teleport player to specified location
|
void |
updateInventory() |
getEyeHeight, getEyeLocation, getLocation, getRotation, getTheoricVelocity, getType, getUniqueId, getVelocity, isOnGround, isOnline, sendMessage, setVelocity
applyTheoricVelocity, getBoundingBox, getEntityId, getTargetBlock, isOp, isSameId, isSameId
getName
getDefault
@Nullable String getIP()
boolean isDead()
boolean isSleeping()
boolean isSwimming()
boolean isUsingRiptide()
boolean hasElytra()
boolean hasPermission(String perm)
perm
- the needed permissionboolean hasLineOfSight(Entity entity)
entity
- the entity to seeboolean isFlying()
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)
World getWorld()
Version getPlayerVersion()
void setPlayerVersion(Version version)
int getProtocolVersion()
void setProtocolVersion(int protocolVersion)
Entity 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 IDwriteMessage
- 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 visibleInetSocketAddress 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)