Interface ServerPlayer
-
- All Superinterfaces:
ArmorEquipable
,AttributeHolder
,Audience
,Carrier
,Contextual
,CopyableDataHolder
,DataHolder
,DataHolder.Mutable
,DataSerializable
,Entity
,EntityProjectileSource
,Equipable
,HoverEventSource<HoverEvent.ShowEntity>
,Humanoid
,Identifiable
,Identified
,Living
,LocaleSource
,Locatable
,Nameable
,Player
,Pointered
,ProjectileSource
,RandomProvider
,SerializableDataHolder
,SerializableDataHolder.Mutable
,Sound.Emitter
,Subject
,Tamer
,TeamMember
,ValueContainer
,Viewer
public interface ServerPlayer extends Player, Subject
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.spongepowered.api.data.DataHolder
DataHolder.Immutable<I extends DataHolder.Immutable<I>>, DataHolder.Mutable
-
Nested classes/interfaces inherited from interface org.spongepowered.api.data.SerializableDataHolder
SerializableDataHolder.Immutable<I extends SerializableDataHolder.Immutable<I>>, SerializableDataHolder.Mutable
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default Value.Mutable<java.lang.Boolean>
chatColorsEnabled()
PlayerChatFormatter
chatFormatter()
Gets the chat router.default Value.Mutable<ChatVisibility>
chatVisibility()
boolean
closeInventory()
Closes the currently viewed entity of this player, if it is currently viewing one.ServerPlayerConnection
connection()
Gets the appropriateServerPlayerConnection
linking this player to a client.CooldownTracker
cooldownTracker()
Gets theCooldownTracker
for this player, allowing control over the player's item cooldowns.default SetValue.Mutable<SkinPart>
displayedSkinParts()
default java.util.Optional<Value.Mutable<java.time.Instant>>
firstJoined()
default Value.Mutable<GameMode>
gameMode()
default boolean
hasPlayedBefore()
default Value.Mutable<java.lang.Boolean>
hasViewedCredits()
default java.util.Optional<Value.Mutable<java.lang.Double>>
healthScale()
boolean
isOnline()
Returns whether this player is online or not.default boolean
isViewingInventory()
Returns whether this player has an open inventory at the moment or not.boolean
kick()
Kicks the player, showing the default kick reason (the translation keydisconnect.disconnected
).boolean
kick(Component reason)
Kicks the player given a reason.default java.util.Optional<Value.Mutable<java.time.Instant>>
lastJoined()
default java.util.Optional<Value.Mutable<java.time.Instant>>
lastPlayed()
java.util.Optional<Container>
openInventory()
Gets the currently viewed inventory of this player, if it is currently viewing one.java.util.Optional<Container>
openInventory(Inventory inventory)
Opens the given Inventory for the player to view.java.util.Optional<Container>
openInventory(Inventory inventory, Component displayName)
Opens a given Inventory for the player to view with a custom displayName.default Value<GameMode>
previousGameMode()
AdvancementProgress
progress(Advancement advancement)
Gets theAdvancementProgress
for the specifiedAdvancement
.boolean
respawn()
Manually respawns the player.Scoreboard
scoreboard()
Gets theScoreboard
displayed to the player.void
sendResourcePack(ResourcePack pack)
Sends a givenResourcePack
to this player.void
setChatFormatter(PlayerChatFormatter router)
Sets the chat router.void
setScoreboard(Scoreboard scoreboard)
Sets theScoreboard
displayed to the player.java.util.Optional<WorldBorder>
setWorldBorder(@Nullable WorldBorder border)
Sets theWorldBorder
that this player sees.PlayerChatEvent
simulateChat(Component message, Cause cause)
Simulates a chat message from a player.default Value.Mutable<Entity>
spectatorTarget()
default MapValue.Mutable<Statistic,java.lang.Long>
statistics()
TabList
tabList()
Gets this player'sTabList
.java.util.Collection<AdvancementTree>
unlockedAdvancementTrees()
Gets all theAdvancementTree
s that thisPlayer
already unlocked.User
user()
default Value.Mutable<java.lang.Integer>
viewDistance()
ServerWorld
world()
Gets theWorld
.java.util.Optional<WorldBorder>
worldBorder()
Gets theWorldBorder
for this player, if present.-
Methods inherited from interface org.spongepowered.api.item.inventory.ArmorEquipable
chest, feet, head, itemInHand, itemInHand, legs, setChest, setFeet, setHead, setItemInHand, setItemInHand, setLegs
-
Methods inherited from interface org.spongepowered.api.entity.attribute.AttributeHolder
attribute, attribute
-
Methods inherited from interface net.kyori.adventure.audience.Audience
clearTitle, deleteMessage, deleteMessage, filterAudience, forEachAudience, hideBossBar, openBook, openBook, playSound, playSound, playSound, resetTitle, sendActionBar, sendActionBar, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendPlayerListFooter, sendPlayerListFooter, sendPlayerListHeader, sendPlayerListHeader, sendPlayerListHeaderAndFooter, sendPlayerListHeaderAndFooter, sendTitlePart, showBossBar, showTitle, stopSound, stopSound
-
Methods inherited from interface org.spongepowered.api.service.context.Contextual
friendlyIdentifier, identifier
-
Methods inherited from interface org.spongepowered.api.data.DataHolder.Mutable
copyFrom, copyFrom, offer, offer, offer, offer, offerAll, offerAll, offerAll, offerAll, offerAll, offerAll, offerSingle, offerSingle, offerSingle, offerSingle, remove, remove, remove, removeAll, removeAll, removeAll, removeAll, removeAll, removeAll, removeKey, removeKey, removeSingle, removeSingle, transform, transform, tryOffer, tryOffer, tryOffer, undo
-
Methods inherited from interface org.spongepowered.api.data.persistence.DataSerializable
contentVersion, toContainer
-
Methods inherited from interface org.spongepowered.api.entity.Entity
age, asHoverEvent, baseSize, baseVehicle, boundingBox, canSee, copy, createArchetype, createSnapshot, creator, customName, customNameVisible, damage, damage, direction, displayName, eyeHeight, eyePosition, fallDistance, fireImmuneTicks, fireTicks, glowing, gravityAffected, height, invisible, invulnerabilityTicks, invulnerable, isLoaded, isRemoved, isTransient, lookAt, maxAir, nearbyEntities, nearbyEntities, notifier, onGround, passengers, position, remainingAir, remove, rotation, scale, scoreboardTags, setLocation, setLocationAndRotation, setLocationAndRotation, setPosition, setRotation, setScale, setTransform, silent, sneaking, sprinting, swiftness, transferToWorld, transferToWorld, transform, type, vanish, vanishIgnoresCollision, vanishPreventsTargeting, vanishState, vehicle, velocity, wet
-
Methods inherited from interface org.spongepowered.api.item.inventory.Equipable
canEquip, canEquip, canEquip, canEquip, equip, equip, equipment, equipped, equipped
-
Methods inherited from interface net.kyori.adventure.text.event.HoverEventSource
asHoverEvent
-
Methods inherited from interface org.spongepowered.api.entity.living.Humanoid
skinProfile
-
Methods inherited from interface org.spongepowered.api.util.Identifiable
uniqueId
-
Methods inherited from interface org.spongepowered.api.entity.living.Living
absorption, activeItem, bodyRotations, canGrief, chestRotation, elytraFlying, headDirection, headRotation, health, lastAttacker, lastDamageReceived, maxHealth, potionEffects, stuckArrows, walkingSpeed
-
Methods inherited from interface org.spongepowered.api.util.locale.LocaleSource
locale
-
Methods inherited from interface org.spongepowered.api.world.Locatable
blockPosition, location, serverLocation
-
Methods inherited from interface org.spongepowered.api.entity.living.player.Player
affectsSpawning, canFly, dominantHand, enderChestInventory, exhaustion, experience, experienceFromStartToLevel, experienceLevel, experienceSinceLevel, flying, flyingSpeed, foodLevel, identity, inventory, maxExhaustion, maxFoodLevel, maxSaturation, profile, saturation, sleeping, sleepingIgnored, sleepTimer
-
Methods inherited from interface net.kyori.adventure.pointer.Pointered
get, getOrDefault, getOrDefaultFrom, pointers
-
Methods inherited from interface org.spongepowered.api.projectile.source.ProjectileSource
launchProjectile, launchProjectile, launchProjectile, launchProjectile, launchProjectileTo, launchProjectileTo
-
Methods inherited from interface org.spongepowered.api.util.RandomProvider
random
-
Methods inherited from interface org.spongepowered.api.data.SerializableDataHolder
validateRawData
-
Methods inherited from interface org.spongepowered.api.data.SerializableDataHolder.Mutable
setRawData
-
Methods inherited from interface org.spongepowered.api.service.permission.Subject
associatedObject, asSubjectReference, containingCollection, contextCause, hasPermission, hasPermission, hasPermission, isChildOf, isChildOf, isChildOf, isSubjectDataPersisted, option, option, option, parents, parents, parents, permissionValue, permissionValue, permissionValue, subjectData, transientSubjectData
-
Methods inherited from interface org.spongepowered.api.scoreboard.TeamMember
teamRepresentation
-
Methods inherited from interface org.spongepowered.api.data.value.ValueContainer
get, getDouble, getInt, getKeys, getLong, getOrElse, getOrNull, getValue, getValues, require, requireValue, supports, supports
-
Methods inherited from interface org.spongepowered.api.effect.Viewer
playMusicDisc, playSound, resetBlockChange, resetBlockChange, sendBlockChange, sendBlockChange, sendWorldType, spawnParticles, spawnParticles, stopMusicDisc
-
-
-
-
Method Detail
-
world
ServerWorld world()
Description copied from interface:Locatable
Gets theWorld
.
-
user
User user()
-
isOnline
boolean isOnline()
Returns whether this player is online or not.If this returns false, this player should be considered stale and all references to it should be discarded immediately.
- Returns:
- True if online, false if not
-
isViewingInventory
default boolean isViewingInventory()
Returns whether this player has an open inventory at the moment or not.- Returns:
- Whether this player is viewing an inventory or not
-
openInventory
java.util.Optional<Container> openInventory()
Gets the currently viewed inventory of this player, if it is currently viewing one.- Returns:
- An inventory if this player is viewing one, otherwise
Optional.empty()
-
openInventory
java.util.Optional<Container> openInventory(Inventory inventory) throws java.lang.IllegalArgumentException
Opens the given Inventory for the player to view.- Parameters:
inventory
- The inventory to view- Returns:
- The opened Container if the inventory was opened, otherwise
Optional.empty()
- Throws:
java.lang.IllegalArgumentException
- if aPluginContainer
is not the root of the cause
-
openInventory
java.util.Optional<Container> openInventory(Inventory inventory, Component displayName)
Opens a given Inventory for the player to view with a custom displayName.Note that not all inventories support a custom display name.
- Parameters:
inventory
- The inventory to viewdisplayName
- The display name to set- Returns:
- The opened Container if the inventory was opened, otherwise
Optional.empty()
-
closeInventory
boolean closeInventory() throws java.lang.IllegalArgumentException
Closes the currently viewed entity of this player, if it is currently viewing one.- Returns:
- whether or not closing the inventory succeeded
- Throws:
java.lang.IllegalArgumentException
- if aPluginContainer
is not the root of the cause
-
viewDistance
default Value.Mutable<java.lang.Integer> viewDistance()
- Returns:
- The player's view distance
-
chatVisibility
default Value.Mutable<ChatVisibility> chatVisibility()
- Returns:
- Chat visibility setting
-
chatColorsEnabled
default Value.Mutable<java.lang.Boolean> chatColorsEnabled()
- Returns:
- Whether colors are enabled in chat
-
simulateChat
PlayerChatEvent simulateChat(Component message, Cause cause)
Simulates a chat message from a player.This method sends a message as if it came from this player. To send a message to this player instead, see
Audience.sendMessage(Identity, Component)
.If text formatting is not supported in the implementation it will be displayed as plain text.
- Parameters:
message
- The message to sendcause
- The cause for the message- Returns:
- The event that was thrown from sending the message
-
displayedSkinParts
default SetValue.Mutable<SkinPart> displayedSkinParts()
- Returns:
- A set of skin parts displayed
-
connection
ServerPlayerConnection connection()
Gets the appropriateServerPlayerConnection
linking this player to a client.- Returns:
- The connection
-
sendResourcePack
void sendResourcePack(ResourcePack pack)
Sends a givenResourcePack
to this player.- Parameters:
pack
- The ResourcePack to send
-
kick
boolean kick()
Kicks the player, showing the default kick reason (the translation keydisconnect.disconnected
).- Returns:
- whether or not kicking the player succeeded
-
kick
boolean kick(Component reason)
Kicks the player given a reason.- Parameters:
reason
- The reason for the kick- Returns:
- whether or not kicking the player succeeded
-
scoreboard
Scoreboard scoreboard()
Gets theScoreboard
displayed to the player.- Returns:
- The scoreboard displayed to the player
-
setScoreboard
void setScoreboard(Scoreboard scoreboard)
Sets theScoreboard
displayed to the player.- Parameters:
scoreboard
- The scoreboard to display
-
respawn
boolean respawn()
Manually respawns the player.If the player is not dead, this method will return
false
- Returns:
- Whether the respawn was successful
-
worldBorder
java.util.Optional<WorldBorder> worldBorder()
Gets theWorldBorder
for this player, if present. If no border is set, an emptyOptional
is returned.- Returns:
- The
WorldBorder
of this player as anOptional
, if present
-
setWorldBorder
java.util.Optional<WorldBorder> setWorldBorder(@Nullable WorldBorder border)
Sets theWorldBorder
that this player sees. Ifnull
, the border is unset, reverting to the border of the world the player is currently in.The values that are set may be altered by events, so users should check the returned value if they need to know if an event altered the values in some way. If no alterations were made, the supplied object and the returned object (within the optional) will be the same.
- Parameters:
border
- The world border to be used, may benull
- Returns:
- the values that were actually set, which may be different from those requested. If the result is an empty optional, then the player does not have a personal border, and uses that of the world they are in instead.
-
cooldownTracker
CooldownTracker cooldownTracker()
Gets theCooldownTracker
for this player, allowing control over the player's item cooldowns.- Returns:
- This player's cooldown tracker
-
progress
AdvancementProgress progress(Advancement advancement)
Gets theAdvancementProgress
for the specifiedAdvancement
.- Parameters:
advancement
- The advancement- Returns:
- The advancement progress
-
unlockedAdvancementTrees
java.util.Collection<AdvancementTree> unlockedAdvancementTrees()
Gets all theAdvancementTree
s that thisPlayer
already unlocked.- Returns:
- The advancement trees
-
hasViewedCredits
default Value.Mutable<java.lang.Boolean> hasViewedCredits()
- Returns:
- True if this player has viewed the credits
-
hasPlayedBefore
default boolean hasPlayedBefore()
- Returns:
- True if played before, false otherwise
-
spectatorTarget
default Value.Mutable<Entity> spectatorTarget()
- Returns:
- The entity this player is "spectating"
-
chatFormatter
PlayerChatFormatter chatFormatter()
Gets the chat router.- Returns:
- The chat router
-
setChatFormatter
void setChatFormatter(PlayerChatFormatter router)
Sets the chat router.- Parameters:
router
- the chat router
-
gameMode
default Value.Mutable<GameMode> gameMode()
- Returns:
- The game mode the player has
-
previousGameMode
default Value<GameMode> previousGameMode()
- Returns:
- The previous game mode of the player
-
statistics
default MapValue.Mutable<Statistic,java.lang.Long> statistics()
- Returns:
- The statistics of the player
-
healthScale
default java.util.Optional<Value.Mutable<java.lang.Double>> healthScale()
- Returns:
- The value the player max-health (excluding absorption) in the GUI will scale to
-
firstJoined
default java.util.Optional<Value.Mutable<java.time.Instant>> firstJoined()
- Returns:
- The timestamp value when this player first joined
-
lastJoined
default java.util.Optional<Value.Mutable<java.time.Instant>> lastJoined()
- Returns:
- The last timestamp value when this player has joined
-
lastPlayed
default java.util.Optional<Value.Mutable<java.time.Instant>> lastPlayed()
- Returns:
- The last timestamp value when this player has played
-
-