Class FakePlayer
java.lang.Object
net.minestom.server.entity.Entity
net.minestom.server.entity.LivingEntity
net.minestom.server.entity.Player
net.minestom.server.entity.fakeplayer.FakePlayer
- All Implemented Interfaces:
CommandSender
,DataContainer
,EventHandler
,EquipmentHandler
,PermissionHandler
,Viewable
public class FakePlayer extends Player
A fake player will behave exactly the same way as would do a
Player
backed by a netty connection
(events, velocity, gravity, player list, etc...) with the exception that you need to control it server-side
using a FakePlayerController
(see getController()
).
You can create one using initPlayer(UUID, String, Consumer)
. Be aware that this really behave exactly like a player
and this is a feature not a bug, you will need to check at some place if the player is a fake one or not (instanceof) if you want to change it.
-
Nested Class Summary
Nested classes/interfaces inherited from class net.minestom.server.entity.Player
Player.ChatMode, Player.FacePoint, Player.Hand, Player.MainHand, Player.PlayerSettings
-
Field Summary
Fields inherited from class net.minestom.server.entity.Player
experiencePickupCooldown, onGround, playerConnection, viewableChunks, viewableEntities
Fields inherited from class net.minestom.server.entity.LivingEntity
canPickupItem, expandedBoundingBox, invulnerable, isDead, itemPickupCooldown, lastDamageSource
Fields inherited from class net.minestom.server.entity.Entity
air, cachePitch, cacheX, cacheY, cacheYaw, cacheZ, crouched, customName, customNameVisible, eyeHeight, glowing, gravityDragPerTick, instance, invisible, lastPitch, lastVelocityUpdateTime, lastX, lastY, lastYaw, lastZ, METADATA_BOOLEAN, METADATA_BYTE, METADATA_CHAT, METADATA_FLOAT, METADATA_OPTCHAT, METADATA_PARTICLE, METADATA_POSE, METADATA_POSITION, METADATA_ROTATION, METADATA_SLOT, METADATA_STRING, METADATA_VARINT, nextTick, noGravity, onFire, pose, position, silent, sprinting, swimming, UNUSED_METADATA, usingElytra, uuid, vehicle, velocity, viewers
-
Method Summary
Modifier and Type Method Description FakePlayerController
getController()
FakePlayerOption
getOption()
Gets the fake player option container.static void
initPlayer(java.util.UUID uuid, java.lang.String username, java.util.function.Consumer<FakePlayer> spawnCallback)
Inits a newFakePlayer
without adding it in cache.static void
initPlayer(java.util.UUID uuid, java.lang.String username, FakePlayerOption option, java.util.function.Consumer<FakePlayer> spawnCallback)
Inits a newFakePlayer
.protected void
showPlayer(PlayerConnection connection)
Sends all the related packet to have the player sent to another with related data (create player, spawn position, velocity, metadata, equipments, passengers, team).Methods inherited from class net.minestom.server.entity.Player
addPacketToQueue, addViewer, callItemUpdateStateEvent, chat, closeInventory, didAnswerKeepAlive, didCloseInventory, dropItem, facePosition, facePosition, fillMetadataIndex, getAdditionalHearts, getAddPlayerToList, getAttributeValue, getBoots, getChestplate, getChunkRange, getCustomBlockTarget, getDefaultEatingTime, getDimensionType, getDisplayName, getExp, getFlyingSpeed, getFood, getFoodSaturation, getGameMode, getHeldSlot, getHelmet, getInventory, getItemInMainHand, getItemInOffHand, getLastKeepAlive, getLatency, getLeggings, getLevel, getMetadataConsumer, getOpenInventory, getPermissionLevel, getPlayerConnection, getRemovePlayerToList, getRespawnPoint, getSettings, getSkin, getStatisticValueMap, getUsername, getVehicleInformation, getViewableChunks, getWalkingSpeed, hasReducedDebugScreenInformation, hideTitle, init, isAllowFlying, isCreative, isEating, isEnableRespawnScreen, isFlying, isImmune, isInstantBreak, isInvulnerable, isOnGround, isOnline, isSneaking, isSprinting, kick, kick, kill, openInventory, playEffect, playerConnectionInit, playSound, playSound, refreshAbilities, refreshAfterTeleport, refreshAnswerKeepAlive, refreshEating, refreshEating, refreshFlying, refreshHealth, refreshHeldSlot, refreshKeepAlive, refreshLatency, refreshOnGround, refreshVehicleSteer, refreshVisibleChunks, refreshVisibleEntities, remove, removeViewer, resetTargetBlock, resetTitle, respawn, sendActionBarMessage, sendDimension, sendExperienceUpdatePacket, sendHeaderFooter, sendJsonMessage, sendLegacyMessage, sendLegacyMessage, sendMessage, sendMessage, sendPluginMessage, sendPluginMessage, sendSubtitleMessage, sendTitleMessage, sendTitleSubtitleMessage, sendTitleTime, sendUpdateHealthPacket, setAdditionalHearts, setAllowFlying, setAttribute, setBelowNameTag, setBoots, setChestplate, setDefaultEatingTime, setDisplayName, setEnableRespawnScreen, setExp, setFlying, setFlyingSpeed, setFood, setFoodSaturation, setGameMode, setHealth, setHeldItemSlot, setHelmet, setInstance, setInstantBreak, setInvulnerable, setItemInMainHand, setItemInOffHand, setLeggings, setLevel, setPermissionLevel, setReducedDebugScreenInformation, setResourcePack, setRespawnPoint, setSkin, setTargetBlock, setTeam, setUsername, setWalkingSpeed, spawn, spectate, stopSound, stopSpectating, teleport, teleport, UNSAFE_changeDidCloseInventory, update, updatePlayerPosition, updateViewPosition
Methods inherited from class net.minestom.server.entity.LivingEntity
canPickupItem, damage, getArrowCount, getFireDamagePeriod, getHealth, getLastDamageSource, getMaxHealth, getPropertiesPacket, getTeam, handleVoid, heal, isDead, refreshActiveHand, refreshIsDead, setArrowCount, setBoundingBox, setCanPickupItem, setFireDamagePeriod, setFireForDuration, setFireForDuration, swingMainHand, swingOffHand
Methods inherited from class net.minestom.server.entity.Entity
addPassenger, askSynchronization, callEvent, getAliveTicks, getAllPermissions, getBoundingBox, getChunk, getCustomName, getData, getDistance, getEntity, getEntityId, getEntityType, getEventCallbacksMap, getEyeHeight, getInstance, getMetadataPacket, getPassengers, getPassengersPacket, getPosition, getUuid, getVehicle, getVelocity, getVelocityPacket, getVelocityUpdatePeriod, getViewers, hasNoGravity, hasPassenger, hasVelocity, isActive, isAutoViewable, isCustomNameVisible, isGlowing, isInvisible, isOnFire, isRemoved, isRemoveScheduled, isSilent, refreshPosition, refreshPosition, refreshView, removePassenger, sameChunk, sameChunk, scheduleNextTick, scheduleRemove, sendMetadataIndex, sendSynchronization, sendVelocityPacket, setAutoViewable, setCustomName, setCustomNameVisible, setData, setEyeHeight, setGlowing, setGravity, setInvisible, setNoGravity, setOnFire, setSilent, setSneaking, setSprinting, setUuid, setVelocity, setVelocityUpdatePeriod, setView, setView, shouldRemove, shouldSendVelocityUpdate, tick, triggerStatus
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.minestom.server.command.CommandSender
asConsole, asPlayer, isConsole, isPlayer, sendMessage
Methods inherited from interface net.minestom.server.inventory.EquipmentHandler
getEquipment, getEquipmentsPacket, getItemInHand, setItemInHand, syncEquipment, syncEquipments, syncEquipments
Methods inherited from interface net.minestom.server.event.handler.EventHandler
addEventCallback, callCancellableEvent, getEventCallbacks, getEventCallbacks, removeEventCallback
Methods inherited from interface net.minestom.server.permission.PermissionHandler
addPermission, getAllPermissions, hasPermission, hasPermission, hasPermission, hasPermission, removePermission
Methods inherited from interface net.minestom.server.Viewable
isViewer, sendPacketsToViewers, sendPacketToViewers, sendPacketToViewersAndSelf
-
Method Details
-
initPlayer
public static void initPlayer(@NotNull java.util.UUID uuid, @NotNull java.lang.String username, @NotNull FakePlayerOption option, @Nullable java.util.function.Consumer<FakePlayer> spawnCallback)Inits a newFakePlayer
.- Parameters:
uuid
- the FakePlayer uuidusername
- the FakePlayer usernamespawnCallback
- the optional callback called when the fake player first spawn
-
initPlayer
public static void initPlayer(@NotNull java.util.UUID uuid, @NotNull java.lang.String username, @Nullable java.util.function.Consumer<FakePlayer> spawnCallback)Inits a newFakePlayer
without adding it in cache.If you want the fake player to be obtainable with the
ConnectionManager
you need to specify it in aFakePlayerOption
and useinitPlayer(UUID, String, FakePlayerOption, Consumer)
.- Parameters:
uuid
- the FakePlayer uuidusername
- the FakePlayer usernamespawnCallback
- the optional callback called when the fake player first spawn
-
getOption
Gets the fake player option container.- Returns:
- the fake player option
-
getController
-
showPlayer
Description copied from class:Player
Sends all the related packet to have the player sent to another with related data (create player, spawn position, velocity, metadata, equipments, passengers, team).WARNING: this alone does not sync the player, please use
Player.addViewer(Player)
.- Overrides:
showPlayer
in classPlayer
- Parameters:
connection
- the connection to show the player to
-