Class PlayerSimulation

java.lang.Object
org.mockbukkit.mockbukkit.simulate.entity.PlayerSimulation

public class PlayerSimulation extends Object
  • Constructor Details

    • PlayerSimulation

      public PlayerSimulation(PlayerMock playerMock)
  • Method Details

    • simulateConsumeItem

      @NotNull public @NotNull ItemStack simulateConsumeItem(@NotNull @NotNull ItemStack consumable)
      Simulates a Player consuming an Edible Item
      Parameters:
      consumable - The Item to consume
      Returns:

      The consumed item

    • simulateBlockDamage

      @Nullable public @Nullable BlockDamageEvent simulateBlockDamage(@NotNull @NotNull Block block)
      Simulates the player damaging a block. Note that this method does not anything unless the player is in survival mode. If InstaBreak is set to true by an event handler, a BlockBreakEvent is immediately fired. The result will then still be whether the BlockDamageEvent was cancelled or not, not the later BlockBreakEvent.
      Parameters:
      block - The block to damage.
      Returns:
      the event that was fired, null if the player was not in survival game mode.
    • simulateBlockBreak

      @Nullable public @Nullable BlockBreakEvent simulateBlockBreak(@NotNull @NotNull Block block)
      Simulates the player breaking a block. This method will not break the block if the player is in adventure or spectator mode. If the player is in survival mode, the player will first damage the block.
      Parameters:
      block - The block to break.
      Returns:
      The event that was fired, null if it wasn't or if the player was in adventure mode or in spectator mode.
    • simulateBlockPlace

      @Nullable public @Nullable BlockPlaceEvent simulateBlockPlace(@NotNull @NotNull Material material, @NotNull @NotNull Location location)
      Simulates the player placing a block. This method will not place the block if the player is in adventure or spectator mode.
      Parameters:
      material - The material of the location to set to
      location - The location of the material to set to
      Returns:
      The event that was fired. null if it wasn't or the player was in adventure mode.
    • simulateInventoryClick

      @NotNull public @NotNull InventoryClickEvent simulateInventoryClick(int slot)
      Simulates the player clicking an Inventory.
      Parameters:
      slot - The slot in the player's open inventory
      Returns:
      The event that was fired.
    • simulateInventoryClick

      @NotNull public @NotNull InventoryClickEvent simulateInventoryClick(@NotNull @NotNull InventoryView inventoryView, int slot)
      Simulates the player clicking an Inventory.
      Parameters:
      inventoryView - The inventory view we want to click
      slot - The slot in the provided Inventory
      Returns:
      The event that was fired.
    • simulateInventoryClick

      @NotNull public @NotNull InventoryClickEvent simulateInventoryClick(@NotNull @NotNull InventoryView inventoryView, @NotNull @NotNull ClickType clickType, int slot)
      Simulates the player clicking an Inventory.
      Parameters:
      inventoryView - The inventory view we want to click
      clickType - The click type we want to fire
      slot - The slot in the provided Inventory
      Returns:
      The event that was fired.
    • respawn

      public PlayerRespawnEvent respawn()
      This method simulates the Player respawning and also calls a PlayerRespawnEvent. Should the Player not be dead (when Entity.isDead() returns false) then this will throw an UnsupportedOperationException. Otherwise, the Location will be set to Player.getBedSpawnLocation() or World.getSpawnLocation(). Lastly the health of this Player will be restored and set to the max health.
      Returns:

      The respawn event

    • simulatePlayerMove

      @NotNull public @NotNull PlayerMoveEvent simulatePlayerMove(@NotNull @NotNull Location moveLocation)
      This method moves player instantly with respect to PlayerMoveEvent
      Parameters:
      moveLocation - Location to move player to
      Returns:
      The event that is fired
    • simulateSneak

      @NotNull public @NotNull PlayerToggleSneakEvent simulateSneak(boolean sneak)
      Simulates sneaking.
      Parameters:
      sneak - Whether the player is beginning to sneak.
      Returns:
      The event.
    • simulateSprint

      @NotNull public @NotNull PlayerToggleSprintEvent simulateSprint(boolean sprint)
      Simulates sprinting.
      Parameters:
      sprint - Whether the player is beginning to sprint.
      Returns:
      The event.
    • simulateToggleFlight

      @NotNull public @NotNull PlayerToggleFlightEvent simulateToggleFlight(boolean fly)
      Simulates toggling flight.
      Parameters:
      fly - Whether the player is starting to fly.
      Returns:
      The event.