Class FakePlayerController
java.lang.Object
net.minestom.server.entity.fakeplayer.FakePlayerController
This class acts as a client controller for
FakePlayer.
The main use is to simulate the receiving of ClientPacket
-
Constructor Summary
ConstructorsConstructorDescriptionFakePlayerController(@NotNull FakePlayer fakePlayer) Initializes a newFakePlayerControllerwith the givenFakePlayer. -
Method Summary
Modifier and TypeMethodDescriptionvoidattackEntity(Entity entity) Attacks the givenentity.voidclickWindow(boolean playerInventory, short slot, byte button, ClientClickWindowPacket.ClickType clickType) Simulates a click in a window.voidCloses the current opened inventory if there is any.voidconsumePacket(ServerPacket serverPacket) Makes the player receives a packet WARNING: pretty much unsafe, used internally to redirect packets here, you should instead usePlayerConnection.sendPacket(SendablePacket)voidfinishDigging(Point blockPosition, BlockFace blockFace) Finishes the digging process of the fake player.voidrespawn()Respawns the player.voidrotate(float yaw, float pitch) Rotates the fake player.voidsendArmAnimation(Player.Hand hand) Sends an animation packet that animates the specified arm.voidsendPluginMessage(String channel, byte[] message) Sends a plugin message to the player.voidsendPluginMessage(String channel, String message) Sends a plugin message to the player.voidsetHeldItem(short slot) Changes the current held slot for the player.voidstartDigging(Point blockPosition, BlockFace blockFace) Starts the digging process of the fake player.voidstopDigging(Point blockPosition, BlockFace blockFace) Stops the digging process of the fake player.voiduseItem(Player.Hand hand) Uses the item in the givenhand.
-
Constructor Details
-
FakePlayerController
Initializes a newFakePlayerControllerwith the givenFakePlayer.- Parameters:
fakePlayer- The fake player that should used the controller.
-
-
Method Details
-
clickWindow
public void clickWindow(boolean playerInventory, short slot, byte button, ClientClickWindowPacket.ClickType clickType) Simulates a click in a window.- Parameters:
playerInventory-trueif the window aPlayerInventory, otherwisefalse.slot- The slot where the fake player should click on.button- The mouse button that the fake player should used.clickType- The click type
-
closeWindow
public void closeWindow()Closes the current opened inventory if there is any. -
sendPluginMessage
Sends a plugin message to the player.- Parameters:
channel- The channel of the message.message- The message data.
-
sendPluginMessage
Sends a plugin message to the player.- Parameters:
channel- The channel of the message.message- The message data.
-
attackEntity
Attacks the givenentity.- Parameters:
entity- The entity that is to be attacked.
-
respawn
public void respawn()Respawns the player.- See Also:
-
setHeldItem
public void setHeldItem(short slot) Changes the current held slot for the player.- Parameters:
slot- The slot that the player has to held.- Throws:
IllegalArgumentException- Ifslotis not between0and8.
-
sendArmAnimation
Sends an animation packet that animates the specified arm.- Parameters:
hand- The hand of the arm to be animated.
-
useItem
Uses the item in the givenhand.- Parameters:
hand- The hand in which an ite mshould be.
-
rotate
public void rotate(float yaw, float pitch) Rotates the fake player.- Parameters:
yaw- The new yaw for the fake player.pitch- The new pitch for the fake player.
-
startDigging
Starts the digging process of the fake player.- Parameters:
blockPosition- The position of the block to be excavated.blockFace- From where the block is struck.
-
stopDigging
Stops the digging process of the fake player.- Parameters:
blockPosition- The position of the block to be excavated.blockFace- From where the block is struck.
-
finishDigging
Finishes the digging process of the fake player.- Parameters:
blockPosition- The position of the block to be excavated.blockFace- From where the block is struck.
-
consumePacket
Makes the player receives a packet WARNING: pretty much unsafe, used internally to redirect packets here, you should instead usePlayerConnection.sendPacket(SendablePacket)- Parameters:
serverPacket- the packet to consume
-