public class CompensatedPlayer extends AbstractPlayer
location, playerVersion, protocolVersion, velocity
Constructor and Description |
---|
CompensatedPlayer(int entityId,
UUID uuid,
CompensatedWorld world) |
Modifier and Type | Method and Description |
---|---|
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
|
BoundingBox |
getBoundingBox()
Get the bounding box of the current entity
|
Object |
getDefault()
Get default object which is abstracted by Negativity structure.
|
int |
getEntityId()
Get the entity ID
|
double |
getEyeHeight() |
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
|
String |
getName() |
List<Entity> |
getNearbyEntities(double x,
double y,
double z) |
Inventory |
getOpenInventory() |
int |
getPing()
Get current player latency
|
Optional<PotionEffect> |
getPotionEffect(PotionEffectType type) |
String |
getServerName()
Get the name of the server where the player is actually
|
Vector |
getTheoricVelocity()
Get the velocity that the entity SHOULD be take
|
UUID |
getUniqueId() |
Entity |
getVehicle()
Get the entity which is used as vehicle.
|
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
|
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.
|
boolean |
isOnline() |
boolean |
isOp()
Check if the actual entity is OP or not
|
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) |
void |
removePotionEffect(PotionEffectType type) |
void |
sendPluginMessage(String channelId,
byte[] writeMessage)
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 |
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 |
setWorld(CompensatedWorld world) |
void |
teleport(Entity et)
Teleport player to specified entity
|
void |
teleport(Location loc)
Teleport player to specified location
|
String |
toString() |
void |
updateInventory() |
applyTheoricVelocity, equals, getLocation, getPlayerVersion, getProtocolVersion, getTargetBlock, getVelocity, init, setInternalWorld, setLocation, setPlayerVersion, setProtocolVersion
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addPotionEffect, hasPlayedBefore, hasThorns, isInBoat, isSamePlayer, queuePacket, sendPacket, sendPluginMessage, setSleeping
getType, isOnGround, sendMessage
getEyeLocation, getRotation, isSameId, isSameId, isSameId
public CompensatedPlayer(int entityId, UUID uuid, CompensatedWorld world)
public double getEyeHeight()
public CompensatedWorld getWorld()
Player
getWorld
in interface Entity
getWorld
in interface OfflinePlayer
getWorld
in interface Player
getWorld
in class AbstractPlayer
public void setWorld(CompensatedWorld world)
public int getEntityId()
Entity
public @Nullable String getIP()
Player
public boolean isDead()
Player
public boolean isSleeping()
Player
public boolean isSwimming()
Player
public boolean isUsingRiptide()
Player
public boolean hasElytra()
Player
public boolean hasPermission(String perm)
Player
perm
- the needed permissionpublic boolean hasLineOfSight(Entity entity)
Player
entity
- the entity to seepublic boolean isFlying()
Player
public void setFlying(boolean b)
public boolean getAllowFlight()
Player
public void setAllowFlight(boolean b)
Player
b
- true if the player is allowed to flypublic int getPing()
Player
public int getLevel()
Player
public float getFlySpeed()
Player
public float getWalkSpeed()
Player
public float getFallDistance()
Player
public double getHealth()
Player
public double getMaxHealth()
Player
public void setHealth(double health)
Player
health
- next healthpublic int getFoodLevel()
Player
public void setFoodLevel(int foodlevel)
Player
foodlevel
- the new food levelpublic GameMode getGameMode()
Player
public void setGameMode(GameMode gameMode)
Player
gameMode
- the new player gamemodepublic void damage(double amount)
Player
amount
- the quantity of damagepublic void kick(String reason)
Player
reason
- the reason of kickpublic void teleport(Location loc)
Player
loc
- location destinationpublic void teleport(Entity et)
Player
et
- entity destinationpublic boolean isSneaking()
public void setSneaking(boolean b)
public boolean isSprinting()
public void setSprinting(boolean b)
public Vector getTheoricVelocity()
Player
public void setVelocity(Vector vel)
Player
vel
- the new velocitypublic Entity getVehicle()
Player
public boolean isInsideVehicle()
Player
public ItemStack getItemInHand()
Player
public ItemStack getItemInOffHand()
Player
public boolean hasPotionEffect(PotionEffectType type)
public List<PotionEffect> getActivePotionEffect()
public Optional<PotionEffect> getPotionEffect(PotionEffectType type)
public void addPotionEffect(PotionEffectType type, int duration, int amplifier)
public void removePotionEffect(PotionEffectType type)
public void sendPluginMessage(String channelId, byte[] writeMessage)
Player
channelId
- the channel IDwriteMessage
- the message to sentpublic PlayerInventory getInventory()
public Inventory getOpenInventory()
public boolean hasOpenInventory()
public void openInventory(Inventory inv)
public void closeInventory()
public void updateInventory()
public void setVanished(boolean vanished)
Player
vanished
- true is the player should NOT be visiblepublic InetSocketAddress getAddress()
Player
public void sendToServer(String serverName)
Player
serverName
- the name of the proxy serverpublic String getServerName()
Player
public UUID getUniqueId()
public boolean isOnline()
public boolean isOp()
Entity
public BoundingBox getBoundingBox()
Entity
public String getName()
public Object getDefault()
NegativityObject
For example, when we use World
, beside there is the Spigot/Sponge... world.
We can get the default platform object, in the example, the platform world.