Search in sources :

Example 1 with HangingPlaceEvent

use of org.bukkit.event.hanging.HangingPlaceEvent in project Glowstone by GlowstoneMC.

the class ItemItemFrame method rightClickBlock.

@Override
public void rightClickBlock(GlowPlayer player, GlowBlock target, BlockFace face, ItemStack holding, Vector clickedLoc, EquipmentSlot hand) {
    GlowItemFrame entity = new GlowItemFrame(player, target.getRelative(face).getLocation(), face);
    if (EventFactory.getInstance().callEvent(new HangingPlaceEvent(entity, player, target, face)).isCancelled()) {
        return;
    }
    List<Message> spawnMessage = entity.createSpawnMessage();
    entity.getWorld().getRawPlayers().stream().filter(p -> p.canSeeEntity(entity)).forEach(p -> p.getSession().sendAll(spawnMessage.toArray(new Message[spawnMessage.size()])));
}
Also used : Vector(org.bukkit.util.Vector) GlowBlock(net.glowstone.block.GlowBlock) List(java.util.List) EventFactory(net.glowstone.EventFactory) Message(com.flowpowered.network.Message) GlowPlayer(net.glowstone.entity.GlowPlayer) BlockFace(org.bukkit.block.BlockFace) GlowItemFrame(net.glowstone.entity.objects.GlowItemFrame) HangingPlaceEvent(org.bukkit.event.hanging.HangingPlaceEvent) EquipmentSlot(org.bukkit.inventory.EquipmentSlot) ItemStack(org.bukkit.inventory.ItemStack) HangingPlaceEvent(org.bukkit.event.hanging.HangingPlaceEvent) Message(com.flowpowered.network.Message) GlowItemFrame(net.glowstone.entity.objects.GlowItemFrame)

Aggregations

Message (com.flowpowered.network.Message)1 List (java.util.List)1 EventFactory (net.glowstone.EventFactory)1 GlowBlock (net.glowstone.block.GlowBlock)1 GlowPlayer (net.glowstone.entity.GlowPlayer)1 GlowItemFrame (net.glowstone.entity.objects.GlowItemFrame)1 BlockFace (org.bukkit.block.BlockFace)1 HangingPlaceEvent (org.bukkit.event.hanging.HangingPlaceEvent)1 EquipmentSlot (org.bukkit.inventory.EquipmentSlot)1 ItemStack (org.bukkit.inventory.ItemStack)1 Vector (org.bukkit.util.Vector)1