Class FakePlayerController

java.lang.Object
net.minestom.server.entity.fakeplayer.FakePlayerController

public class FakePlayerController extends Object
This class acts as a client controller for FakePlayer.

The main use is to simulate the receiving of ClientPacket

  • Constructor Details

    • FakePlayerController

      public FakePlayerController(@NotNull @NotNull FakePlayer fakePlayer)
      Initializes a new FakePlayerController with the given FakePlayer.
      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 - true if the window a PlayerInventory, otherwise false.
      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

      public void sendPluginMessage(String channel, byte[] message)
      Sends a plugin message to the player.
      Parameters:
      channel - The channel of the message.
      message - The message data.
    • sendPluginMessage

      public void sendPluginMessage(String channel, String message)
      Sends a plugin message to the player.
      Parameters:
      channel - The channel of the message.
      message - The message data.
    • attackEntity

      public void attackEntity(Entity entity)
      Attacks the given entity.
      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 - If slot is not between 0 and 8.
    • sendArmAnimation

      public void sendArmAnimation(Player.Hand hand)
      Sends an animation packet that animates the specified arm.
      Parameters:
      hand - The hand of the arm to be animated.
    • useItem

      public void useItem(Player.Hand hand)
      Uses the item in the given hand.
      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

      public void startDigging(Point blockPosition, BlockFace blockFace)
      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

      public void stopDigging(Point blockPosition, BlockFace blockFace)
      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

      public void finishDigging(Point blockPosition, BlockFace blockFace)
      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

      public void consumePacket(ServerPacket serverPacket)
      Makes the player receives a packet WARNING: pretty much unsafe, used internally to redirect packets here, you should instead use PlayerConnection.sendPacket(SendablePacket)
      Parameters:
      serverPacket - the packet to consume