Class PlayerSimulation
java.lang.Object
org.mockbukkit.mockbukkit.simulate.entity.PlayerSimulation
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionrespawn()This method simulates thePlayerrespawning and also calls aPlayerRespawnEvent.@Nullable BlockBreakEventsimulateBlockBreak(@NotNull Block block) Simulates the player breaking a block.@Nullable BlockDamageEventsimulateBlockDamage(@NotNull Block block) Simulates the player damaging a block.@Nullable BlockPlaceEventsimulateBlockPlace(@NotNull Material material, @NotNull Location location) Simulates the player placing a block.@NotNull ItemStacksimulateConsumeItem(@NotNull ItemStack consumable) Simulates a Player consuming an Edible Item@NotNull InventoryClickEventsimulateInventoryClick(int slot) Simulates the player clicking an Inventory.@NotNull InventoryClickEventsimulateInventoryClick(@NotNull InventoryView inventoryView, int slot) Simulates the player clicking an Inventory.@NotNull InventoryClickEventsimulateInventoryClick(@NotNull InventoryView inventoryView, @NotNull ClickType clickType, int slot) Simulates the player clicking an Inventory.@NotNull PlayerMoveEventsimulatePlayerMove(@NotNull Location moveLocation) This method moves player instantly with respect to PlayerMoveEvent@NotNull PlayerToggleSneakEventsimulateSneak(boolean sneak) Simulates sneaking.@NotNull PlayerToggleSprintEventsimulateSprint(boolean sprint) Simulates sprinting.@NotNull PlayerToggleFlightEventsimulateToggleFlight(boolean fly) Simulates toggling flight.
-
Constructor Details
-
PlayerSimulation
-
-
Method Details
-
simulateConsumeItem
Simulates a Player consuming an Edible Item- Parameters:
consumable- The Item to consume- Returns:
The consumed item
-
simulateBlockDamage
Simulates the player damaging a block. Note that this method does not anything unless the player is in survival mode. IfInstaBreakis set to true by an event handler, aBlockBreakEventis immediately fired. The result will then still be whether theBlockDamageEventwas cancelled or not, not the laterBlockBreakEvent.- Parameters:
block- The block to damage.- Returns:
- the event that was fired,
nullif the player was not in survival game mode.
-
simulateBlockBreak
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,
nullif 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 tolocation- The location of the material to set to- Returns:
- The event that was fired.
nullif it wasn't or the player was in adventure mode.
-
simulateInventoryClick
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 clickslot- 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 clickclickType- The click type we want to fireslot- The slot in the provided Inventory- Returns:
- The event that was fired.
-
respawn
This method simulates thePlayerrespawning and also calls aPlayerRespawnEvent. Should thePlayernot be dead (whenEntity.isDead()returns false) then this will throw anUnsupportedOperationException. Otherwise, theLocationwill be set toPlayer.getBedSpawnLocation()orWorld.getSpawnLocation(). Lastly the health of thisPlayerwill 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
Simulates sneaking.- Parameters:
sneak- Whether the player is beginning to sneak.- Returns:
- The event.
-
simulateSprint
Simulates sprinting.- Parameters:
sprint- Whether the player is beginning to sprint.- Returns:
- The event.
-
simulateToggleFlight
Simulates toggling flight.- Parameters:
fly- Whether the player is starting to fly.- Returns:
- The event.
-