Search in sources :

Example 1 with PlayerHarvestBlockEvent

use of org.bukkit.event.player.PlayerHarvestBlockEvent in project Mohist by MohistMC.

the class CraftEventFactory method callPlayerHarvestBlockEvent.

/**
 * Player Harvest Block Event
 */
public static PlayerHarvestBlockEvent callPlayerHarvestBlockEvent(Level world, BlockPos blockposition, net.minecraft.world.entity.player.Player who, List<ItemStack> itemsToHarvest) {
    List<org.bukkit.inventory.ItemStack> bukkitItemsToHarvest = new ArrayList<>(itemsToHarvest.stream().map(CraftItemStack::asBukkitCopy).collect(Collectors.toList()));
    Player player = (Player) who.getBukkitEntity();
    PlayerHarvestBlockEvent playerHarvestBlockEvent = new PlayerHarvestBlockEvent(player, CraftBlock.at(world, blockposition), bukkitItemsToHarvest);
    Bukkit.getPluginManager().callEvent(playerHarvestBlockEvent);
    return playerHarvestBlockEvent;
}
Also used : CraftItemStack(org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack) ServerPlayer(net.minecraft.server.level.ServerPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer) Player(org.bukkit.entity.Player) ArrayList(java.util.ArrayList) PlayerHarvestBlockEvent(org.bukkit.event.player.PlayerHarvestBlockEvent) ItemStack(net.minecraft.world.item.ItemStack) CraftItemStack(org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack)

Example 2 with PlayerHarvestBlockEvent

use of org.bukkit.event.player.PlayerHarvestBlockEvent in project Magma-1.16.x by magmafoundation.

the class CraftEventFactory method callPlayerHarvestBlockEvent.

/**
 * Player Harvest Block Event
 */
public static PlayerHarvestBlockEvent callPlayerHarvestBlockEvent(World world, BlockPos blockposition, PlayerEntity who, List<ItemStack> itemsToHarvest) {
    List<org.bukkit.inventory.ItemStack> bukkitItemsToHarvest = new ArrayList<>(itemsToHarvest.stream().map(CraftItemStack::asBukkitCopy).collect(Collectors.toList()));
    Player player = (Player) who.getBukkitEntity();
    PlayerHarvestBlockEvent playerHarvestBlockEvent = new PlayerHarvestBlockEvent(player, CraftBlock.at(world, blockposition), bukkitItemsToHarvest);
    Bukkit.getPluginManager().callEvent(playerHarvestBlockEvent);
    return playerHarvestBlockEvent;
}
Also used : CraftItemStack(org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack) Player(org.bukkit.entity.Player) CraftPlayer(org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer) ArrayList(java.util.ArrayList) PlayerHarvestBlockEvent(org.bukkit.event.player.PlayerHarvestBlockEvent) ItemStack(net.minecraft.item.ItemStack) CraftItemStack(org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack)

Example 3 with PlayerHarvestBlockEvent

use of org.bukkit.event.player.PlayerHarvestBlockEvent in project LoliServer by Loli-Server.

the class CraftEventFactory method callPlayerHarvestBlockEvent.

/**
 * Player Harvest Block Event
 */
public static PlayerHarvestBlockEvent callPlayerHarvestBlockEvent(World world, BlockPos blockPos, PlayerEntity who, List<ItemStack> itemsToHarvest) {
    List<org.bukkit.inventory.ItemStack> bukkitItemsToHarvest = new ArrayList<>(itemsToHarvest.stream().map(CraftItemStack::asBukkitCopy).collect(Collectors.toList()));
    Player player = (Player) who.getBukkitEntity();
    PlayerHarvestBlockEvent playerHarvestBlockEvent = new PlayerHarvestBlockEvent(player, CraftBlock.at(world, blockPos), bukkitItemsToHarvest);
    Bukkit.getPluginManager().callEvent(playerHarvestBlockEvent);
    return playerHarvestBlockEvent;
}
Also used : CraftItemStack(org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack) CraftPlayer(org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer) ArrayList(java.util.ArrayList) PlayerHarvestBlockEvent(org.bukkit.event.player.PlayerHarvestBlockEvent) ItemStack(net.minecraft.item.ItemStack) CraftItemStack(org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack)

Aggregations

ArrayList (java.util.ArrayList)3 PlayerHarvestBlockEvent (org.bukkit.event.player.PlayerHarvestBlockEvent)3 ItemStack (net.minecraft.item.ItemStack)2 CraftPlayer (org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer)2 CraftItemStack (org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack)2 Player (org.bukkit.entity.Player)2 ServerPlayer (net.minecraft.server.level.ServerPlayer)1 ItemStack (net.minecraft.world.item.ItemStack)1 CraftPlayer (org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer)1 CraftItemStack (org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack)1