Java 类org.bukkit.event.block.BlockDispenseEvent 实例源码

项目:bskyblock    文件:IslandGuard.java   
/**
 * Prevents water from being dispensed in hell biomes
 *
 * @param e
 */
@EventHandler(priority = EventPriority.LOW)
public void onNetherDispenser(final BlockDispenseEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
    }
    if (!Util.inWorld(e.getBlock().getLocation()) || !e.getBlock().getBiome().equals(Biome.HELL)) {
        return;
    }
    // plugin.getLogger().info("DEBUG: Item being dispensed is " +
    // e.getItem().getType().toString());
    if (e.getItem().getType().equals(Material.WATER_BUCKET)) {
        e.setCancelled(true);
        if (plugin.getServer().getVersion().contains("(MC: 1.8") || plugin.getServer().getVersion().contains("(MC: 1.7")) {
            e.getBlock().getWorld().playSound(e.getBlock().getLocation(), Sound.valueOf("FIZZ"), 1F, 2F);
        } else {
            e.getBlock().getWorld().playSound(e.getBlock().getLocation(), Sound.ENTITY_CREEPER_PRIMED, 1F, 2F);
        }
    }
}
项目:NavyCraft2-Lite    文件:AimCannonPlayerListener.java   
@SuppressWarnings("deprecation")
public static void onBlockDispense(BlockDispenseEvent event) {
    if( event.getBlock() != null && event.getBlock().getTypeId() == 23 )
    {
        //System.out.println("test1");
        for (OneCannon onec : AimCannon.getCannons()) 
        {
            //System.out.println("test2");
            if (onec.isThisCannon(event.getBlock().getLocation(), true)) 
            {
                //System.out.println("test3");
                event.setCancelled(true);
                return;
            }
        }
    }
   }
项目:NeverLag    文件:AntiNegativeItemDupe.java   
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onBlockDispense(BlockDispenseEvent e) {
    if (!cm.isAntiNegativeItemDupe) {
        return;
    }
    Inventory content = null;
    if (e.getBlock().getState() instanceof InventoryHolder) {
        content = ((InventoryHolder) e.getBlock().getState()).getInventory();
    }
    if (content == null || content.getSize() == 0) {
        return;
    }
    for (ItemStack item : content.getContents()) {
        if (item != null && item.getType() != Material.AIR) {
            if (item.getAmount() <= 0) {
                item.setType(Material.AIR);
            }
        }
    }
}
项目:Arcade2    文件:BlockTransformListeners.java   
@EventHandler(ignoreCancelled = true)
public void onBlockDispense(BlockDispenseEvent event) {
    if (!this.isBucket(event.getItem().getType())) {
        return;
    }

    Block target = event.getVelocity().toLocation(
            event.getWorld()).getBlock();
    Material content = this.getBucketContent(event.getItem().getType());

    if (!content.equals(Material.AIR)) {
        this.post(event,
                  target.getState(),
                  this.applyState(target, content));
    }
}
项目:buildinggame    文件:BlockDispenseItem.java   
/**
    * Handles players breaking join signs
    *
    * @param e an event indicating that a block has dispensed an item
    * @see BlockDispenseEvent
    * @since 4.0.4
    */
@EventHandler(ignoreCancelled = true)
public void onBlockDispense(BlockDispenseEvent e) {
       Location location = e.getBlock().getLocation();

       for (Arena arena : ArenaManager.getInstance().getArenas()) {
        for (Plot plot : arena.getPlots()) {
               Region boundary = plot.getBoundary();

               if (boundary == null)
                continue;

            if (boundary.isInside(location)) {
                e.setCancelled(true);
                return;
            }
        }
    }
}
项目:civcraft    文件:BlockListener.java   
@EventHandler(priority = EventPriority.NORMAL) 
public void onBlockDispenseEvent(BlockDispenseEvent event) {
    ItemStack stack = event.getItem();
    if (stack != null) {
        if (event.getItem().getType().equals(Material.POTION)) {
            int effect = event.getItem().getDurability() & 0x000F;          
            if (effect == 0xE) { 
                event.setCancelled(true);
                return;
            }
        }

        if (event.getItem().getType().equals(Material.INK_SACK)) {
            //if (event.getItem().getDurability() == 15) { 
                event.setCancelled(true);
                return;
            //}
        }
    }
}
项目:acidisland    文件:IslandGuard.java   
/**
 * Prevents water from being dispensed in hell biomes
 *
 * @param e
 */
@EventHandler(priority = EventPriority.LOW)
public void onNetherDispenser(final BlockDispenseEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
    }
    if (!inWorld(e.getBlock().getLocation()) || !e.getBlock().getBiome().equals(Biome.HELL)) {
        return;
    }
    // plugin.getLogger().info("DEBUG: Item being dispensed is " +
    // e.getItem().getType().toString());
    if (e.getItem().getType().equals(Material.WATER_BUCKET)) {
        e.setCancelled(true);
        if (plugin.getServer().getVersion().contains("(MC: 1.8") || plugin.getServer().getVersion().contains("(MC: 1.7")) {
            e.getBlock().getWorld().playSound(e.getBlock().getLocation(), Sound.valueOf("FIZZ"), 1F, 2F);
        } else {
            e.getBlock().getWorld().playSound(e.getBlock().getLocation(), Sound.ENTITY_CREEPER_PRIMED, 1F, 2F);
        }
    }
}
项目:askyblock    文件:IslandGuard.java   
/**
 * Prevents water from being dispensed in hell biomes
 *
 * @param e
 */
@EventHandler(priority = EventPriority.LOW)
public void onNetherDispenser(final BlockDispenseEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
    }
    if (!inWorld(e.getBlock().getLocation()) || !e.getBlock().getBiome().equals(Biome.HELL)) {
        return;
    }
    // plugin.getLogger().info("DEBUG: Item being dispensed is " +
    // e.getItem().getType().toString());
    if (e.getItem().getType().equals(Material.WATER_BUCKET)) {
        e.setCancelled(true);
        if (plugin.getServer().getVersion().contains("(MC: 1.8") || plugin.getServer().getVersion().contains("(MC: 1.7")) {
            e.getBlock().getWorld().playSound(e.getBlock().getLocation(), Sound.valueOf("FIZZ"), 1F, 2F);
        } else {
            e.getBlock().getWorld().playSound(e.getBlock().getLocation(), Sound.ENTITY_CREEPER_PRIMED, 1F, 2F);
        }
    }
}
项目:Zeus    文件:ZeusEventHandler.java   
@EventHandler
public void onBlockDispense(BlockDispenseEvent event) {
    if (event.getBlock().getType() == Material.DISPENSER) {
        Dispenser diq = (Dispenser) event.getBlock().getState();
        Block maybeSign = event
                .getBlock()
                .getWorld()
                .getBlockAt(event.getBlock().getX(),
                        event.getBlock().getY() - 1,
                        event.getBlock().getZ()); // TODO
        if (maybeSign.getState() instanceof Sign) {
            if (plugin.isUnlimitedSign(((Sign) maybeSign.getState())
                    .getLine(0))) {
                diq.getInventory().addItem(new ItemStack(event.getItem()));
            }
        }
    }
}
项目:xEssentials-deprecated-bukkit    文件:DispenseSignEvent.java   
@EventHandler
public void onPower(BlockDispenseEvent e) {
        if(e.getBlock().getType() == Material.DISPENSER) {
            if(hasNearbySign(e.getBlock())) {
                org.bukkit.block.Sign sign = getSign(e.getBlock());
                if(sign.getLine(0).equalsIgnoreCase(ChatColor.BLUE + "[Dispense]")) {
                    Dispenser disp = (Dispenser) e.getBlock().getState();
                    for(ItemStack stack : disp.getInventory().getContents()) {
                        if(stack != null) {
                            ItemStack clone = stack.clone();
                            clone.setAmount(64);
                            disp.getInventory().addItem(clone);
                        }
                    }
                }
            }
        }
}
项目:ProjectAres    文件:BlockTransformListener.java   
@EventWrapper
public void onDispenserDispense(final BlockDispenseEvent event) {
    if(Materials.isBucket(event.getItem())) {
        // Yes, the location the dispenser is facing is stored in "velocity" for some ungodly reason
        Block targetBlock = event.getVelocity().toLocation(event.getBlock().getWorld()).getBlock();
        Material contents = Materials.materialInBucket(event.getItem());

        if(Materials.isLiquid(contents) || (contents == Material.AIR && targetBlock.isLiquid())) {
            callEvent(event, targetBlock.getState(), BlockStateUtils.cloneWithMaterial(targetBlock, contents), blockResolver.getOwner(event.getBlock()));
        }
    }
}
项目:ProjectAres    文件:ItemModifyMatchModule.java   
@EventHandler
public void onArmorDispense(BlockDispenseEvent event) {
    // This covers armor being equipped by a dispenser, which does not call any of the other events
    ItemStack stack = event.getItem();
    if(applyRules(stack)) {
        event.setItem(stack);
    }
}
项目:NavyCraft2-Lite    文件:NavyCraft_BlockListener.java   
@EventHandler(priority = EventPriority.HIGH)
public void onBlockDispense(final BlockDispenseEvent event) {
    if (!event.isCancelled()) {
        if (PermissionInterface.CheckEnabledWorld(event.getBlock().getLocation()) && (event.getItem().getType() == Material.EMERALD)) {
            event.setCancelled(true);
        }

    }

    if(!event.isCancelled())
        AimCannonPlayerListener.onBlockDispense(event);
}
项目:NavyCraft2-Lite    文件:MoveCraft_BlockListener.java   
@EventHandler(priority = EventPriority.HIGH)
public void onBlockDispense(final BlockDispenseEvent event) {
    if (!event.isCancelled()) {
        if (PermissionInterface.CheckEnabledWorld(event.getBlock().getLocation()) && (event.getItem().getType() == Material.EMERALD)) {
            event.setCancelled(true);
        }

    }

    if(!event.isCancelled())
        AimCannonPlayerListener.onBlockDispense(event);
}
项目:GriefPreventionPlus    文件:BlockEventHandler.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onDispense(BlockDispenseEvent dispenseEvent)
{
    //don't track in worlds where claims are not enabled
       if(!GriefPrevention.instance.claimsEnabledForWorld(dispenseEvent.getBlock().getWorld())) return;

    //from where?
    Block fromBlock = dispenseEvent.getBlock();
    Dispenser dispenser = new Dispenser(fromBlock.getType(), fromBlock.getData());

    //to where?
    Block toBlock = fromBlock.getRelative(dispenser.getFacing());
    Claim fromClaim = this.dataStore.getClaimAt(fromBlock.getLocation(), false, null);
    Claim toClaim = this.dataStore.getClaimAt(toBlock.getLocation(), false, fromClaim);

    //into wilderness is NOT OK in creative mode worlds
    Material materialDispensed = dispenseEvent.getItem().getType();
    if((materialDispensed == Material.WATER_BUCKET || materialDispensed == Material.LAVA_BUCKET) && GriefPrevention.instance.creativeRulesApply(dispenseEvent.getBlock().getLocation()) && toClaim == null)
    {
        dispenseEvent.setCancelled(true);
        return;
    }

    //wilderness to wilderness is OK
    if(fromClaim == null && toClaim == null) return;

    //within claim is OK
    if(fromClaim == toClaim) return;

    //everything else is NOT OK
    dispenseEvent.setCancelled(true);
}
项目:CraftBukkit    文件:DispenseBehaviorProjectile.java   
public ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) {
    World world = isourceblock.k();
    IPosition iposition = BlockDispenser.a(isourceblock);
    EnumFacing enumfacing = BlockDispenser.b(isourceblock.h());
    IProjectile iprojectile = this.a(world, iposition);

    // CraftBukkit start
    ItemStack itemstack1 = itemstack.a(1);
    org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ());
    CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);

    BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector((double) enumfacing.getAdjacentX(), (double) ((float) enumfacing.getAdjacentY() + 0.1F), (double) enumfacing.getAdjacentZ()));
    if (!BlockDispenser.eventFired) {
        world.getServer().getPluginManager().callEvent(event);
    }

    if (event.isCancelled()) {
        itemstack.count++;
        return itemstack;
    }

    if (!event.getItem().equals(craftItem)) {
        itemstack.count++;
        // Chain to handler for new item
        ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
        IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.get(eventStack.getItem());
        if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
            idispensebehavior.a(isourceblock, eventStack);
            return itemstack;
        }
    }

    iprojectile.shoot(event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), this.b(), this.a());
    ((Entity) iprojectile).projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource((TileEntityDispenser) isourceblock.getTileEntity());
    // CraftBukkit end

    world.addEntity((Entity) iprojectile);
    // itemstack.a(1); // CraftBukkit - Handled during event processing
    return itemstack;
}
项目:beaconz    文件:BeaconProtectionListener.java   
/**
 * Prevents the tipping of liquids over the beacon using a dispenser
 * @param event
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onDispense(final BlockDispenseEvent event) {
    if (DEBUG)
        getLogger().info("DEBUG: " + event.getEventName());
    World world = event.getBlock().getWorld();
    if (!world.equals(getBeaconzWorld())) {
        return;
    }
    if (DEBUG)
        getLogger().info("DEBUG: " + event.getItem().getType());
    if (!event.getItem().getType().equals(Material.WATER_BUCKET) && !event.getItem().getType().equals(Material.LAVA_BUCKET)) {
        return;
    }
    if (DEBUG)
        getLogger().info("DEBUG: " + event.getBlock().getType());
    if (!event.getBlock().getType().equals(Material.DISPENSER)) {
        return;
    }
    Dispenser dispenser = (Dispenser)event.getBlock().getState().getData();
    Block b = event.getBlock().getRelative(dispenser.getFacing());
    if (DEBUG)
        getLogger().info("DEBUG: " + b.getLocation());
    if (getRegister().isAboveBeacon(b.getLocation())) {
        world.playSound(b.getLocation(), Sound.BLOCK_STONE_BREAK, 1F, 2F);
        event.setCancelled(true);
    }
}
项目:Almura-Server    文件:DispenseBehaviorProjectile.java   
public ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) {
    World world = isourceblock.k();
    IPosition iposition = BlockDispenser.a(isourceblock);
    EnumFacing enumfacing = BlockDispenser.l_(isourceblock.h());
    IProjectile iprojectile = this.a(world, iposition);

    // CraftBukkit start
    ItemStack itemstack1 = itemstack.a(1);
    org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ());
    CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);

    BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector((double) enumfacing.c(), (double) ((float) enumfacing.d() + 0.1F), (double) enumfacing.e()));
    if (!BlockDispenser.eventFired) {
        world.getServer().getPluginManager().callEvent(event);
    }

    if (event.isCancelled()) {
        itemstack.count++;
        return itemstack;
    }

    if (!event.getItem().equals(craftItem)) {
        itemstack.count++;
        // Chain to handler for new item
        ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
        IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.a(eventStack.getItem());
        if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
            idispensebehavior.a(isourceblock, eventStack);
            return itemstack;
        }
    }

    iprojectile.shoot(event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), this.b(), this.a());
    // CraftBukkit end

    world.addEntity((Entity) iprojectile);
    // itemstack.a(1); // CraftBukkit - Handled during event processing
    return itemstack;
}
项目:Tweakkit-Server    文件:DispenseBehaviorProjectile.java   
public ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) {
    World world = isourceblock.k();
    IPosition iposition = BlockDispenser.a(isourceblock);
    EnumFacing enumfacing = BlockDispenser.b(isourceblock.h());
    IProjectile iprojectile = this.a(world, iposition);

    // CraftBukkit start
    ItemStack itemstack1 = itemstack.a(1);
    org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ());
    CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);

    BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector((double) enumfacing.getAdjacentX(), (double) ((float) enumfacing.getAdjacentY() + 0.1F), (double) enumfacing.getAdjacentZ()));
    if (!BlockDispenser.eventFired) {
        world.getServer().getPluginManager().callEvent(event);
    }

    if (event.isCancelled()) {
        itemstack.count++;
        return itemstack;
    }

    if (!event.getItem().equals(craftItem)) {
        itemstack.count++;
        // Chain to handler for new item
        ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
        IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.get(eventStack.getItem());
        if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
            idispensebehavior.a(isourceblock, eventStack);
            return itemstack;
        }
    }

    iprojectile.shoot(event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), this.b(), this.a());
    ((Entity) iprojectile).projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource((TileEntityDispenser) isourceblock.getTileEntity());
    // CraftBukkit end

    world.addEntity((Entity) iprojectile);
    // itemstack.a(1); // CraftBukkit - Handled during event processing
    return itemstack;
}
项目:PlotSquared    文件:PlayerEvents.java   
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockDispense(BlockDispenseEvent event) {
    Material type = event.getItem().getType();
    switch (type) {
        case WATER_BUCKET:
        case LAVA_BUCKET: {
            if (event.getBlock().getType() == Material.DROPPER) return;
        }
    }
    Location location = BukkitUtil.getLocation(event.getBlock().getLocation());
    if (location.isPlotRoad()) {
        event.setCancelled(true);
    }
}
项目:SpigotSource    文件:DispenseBehaviorProjectile.java   
public ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) {
    World world = isourceblock.getWorld();
    IPosition iposition = BlockDispenser.a(isourceblock);
    EnumDirection enumdirection = BlockDispenser.e(isourceblock.f());
    IProjectile iprojectile = this.a(world, iposition, itemstack);

    // iprojectile.shoot((double) enumdirection.getAdjacentX(), (double) ((float) enumdirection.getAdjacentY() + 0.1F), (double) enumdirection.getAdjacentZ(), this.b(), this.a());
    // CraftBukkit start
    ItemStack itemstack1 = itemstack.cloneAndSubtract(1);
    org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
    CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);

    BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector((double) enumdirection.getAdjacentX(), (double) ((float) enumdirection.getAdjacentY() + 0.1F), (double) enumdirection.getAdjacentZ()));
    if (!BlockDispenser.eventFired) {
        world.getServer().getPluginManager().callEvent(event);
    }

    if (event.isCancelled()) {
        itemstack.count++;
        return itemstack;
    }

    if (!event.getItem().equals(craftItem)) {
        itemstack.count++;
        // Chain to handler for new item
        ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
        IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem());
        if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) {
            idispensebehavior.a(isourceblock, eventStack);
            return itemstack;
        }
    }

    iprojectile.shoot(event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), this.getPower(), this.a());
    ((Entity) iprojectile).projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource((TileEntityDispenser) isourceblock.getTileEntity());
    // CraftBukkit end
    world.addEntity((Entity) iprojectile);
    // itemstack.a(1); // CraftBukkit - Handled during event processing
    return itemstack;
}
项目:NBTEditor    文件:BookOfSoulsCI.java   
@Override
  public void onDispense(BlockDispenseEvent event, DispenserDetails details) {
BookOfSouls bos = BookOfSouls.getFromBook(event.getItem());
if (bos != null) {
    bos.getEntityNBT().spawn(details.getLocation());
}
event.setCancelled(true);
  }
项目:NBTEditor    文件:CustomItemListener.java   
@EventHandler
private void blockDispense(BlockDispenseEvent event) {
    if (event.getBlock().getType() != Material.DISPENSER) {
        return;
    }
    CustomItem customItem = CustomItemManager.getCustomItem(event.getItem());
    if (customItem != null) {
        if (verifyCustomItem(customItem, event.getBlock().getWorld())) {
            customItem.onDispense(event, new DispenserDetails(event, customItem._owner));
        } else {
            event.setCancelled(true);
        }
    }
}
项目:Craft-city    文件:DispenseBehaviorProjectile.java   
public ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) {
    World world = isourceblock.k();
    IPosition iposition = BlockDispenser.a(isourceblock);
    EnumFacing enumfacing = BlockDispenser.j_(isourceblock.h());
    IProjectile iprojectile = this.a(world, iposition);

    // CraftBukkit start
    ItemStack itemstack1 = itemstack.a(1);
    org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ());
    CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);

    BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector((double) enumfacing.c(), (double) ((float) enumfacing.d() + 0.1F), (double) enumfacing.e()));
    if (!BlockDispenser.eventFired) {
        world.getServer().getPluginManager().callEvent(event);
    }

    if (event.isCancelled()) {
        itemstack.count++;
        return itemstack;
    }

    if (!event.getItem().equals(craftItem)) {
        itemstack.count++;
        // Chain to handler for new item
        ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
        IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.a(eventStack.getItem());
        if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
            idispensebehavior.a(isourceblock, eventStack);
            return itemstack;
        }
    }

    iprojectile.shoot(event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), this.b(), this.a());
    // CraftBukkit end

    world.addEntity((Entity) iprojectile);
    // itemstack.a(1); // CraftBukkit - Handled during event processing
    return itemstack;
}
项目:ProjectAres    文件:CoreMatchModule.java   
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void breakCheck(final BlockTransformEvent event) {
    if(event.getWorld() != this.match.getWorld()) return;
    ParticipantState player = ParticipantBlockTransformEvent.getPlayerState(event);

    Vector blockVector = BlockUtils.center(event.getNewState()).toVector();

    for(Core core : this.cores) {
        if(!core.hasLeaked() && core.getCasingRegion().contains(blockVector)) {
            if(event.getNewState().getType() == Material.AIR) {
                if(player != null) {
                    Competitor team = player.getParty();

                    if(team == core.getOwner()) {
                        event.setCancelled(true, new TranslatableComponent("match.core.damageOwn"));
                    } else if (event.getOldState().getData().equals(core.getMaterial())) {
                        this.match.getPluginManager().callEvent(new CoreBlockBreakEvent(core, player, event.getOldState()));
                        core.touch(player);

                        // Note: team may not have touched a broken core if a different team broke it
                        if(!core.isCompleted(team) && !core.hasTouched(team)) {
                            this.match.getPluginManager().callEvent(new GoalStatusChangeEvent(core));
                        }
                    }
                } else if(event.getCause() instanceof EntityExplodeEvent) {
                    // this is a temp fix until there is a tracker for placed minecarts (only dispensed are tracked right now)
                    if(((EntityExplodeEvent) event.getCause()).getEntity() instanceof ExplosiveMinecart) {
                        event.setCancelled(true);
                    }
                } else if(event.getCause() instanceof BlockPistonRetractEvent) {
                    event.setCancelled(true);
                }
            } else if(event.getCause() instanceof BlockPistonExtendEvent) {
                event.setCancelled(true);
            } else if(event.getCause() instanceof BlockDispenseEvent) {
                event.setCancelled(true);
            }
            break;
        }
    }
}
项目:RPGInventory    文件:ArmorEquipListener.java   
@EventHandler
public void onDispenseEquip(BlockDispenseEvent event) {
    ArmorType type = ArmorType.matchType(event.getItem());
    if (type != null) {
        Location blockLoc = event.getBlock().getLocation();
        for (Player player : blockLoc.getWorld().getPlayers()) {
            Location playerLoc = player.getLocation();
            if (blockLoc.getBlockY() - playerLoc.getBlockY() >= -1
                    && blockLoc.getBlockY() - playerLoc.getBlockY() <= 1) {
                if (type == ArmorType.HELMET && player.getInventory().getHelmet() == null
                        || type == ArmorType.CHESTPLATE && player.getInventory().getChestplate() == null
                        || type == ArmorType.LEGGINGS && player.getInventory().getLeggings() == null
                        || type == ArmorType.BOOTS && player.getInventory().getBoots() == null) {
                    org.bukkit.block.Dispenser dispenser = (org.bukkit.block.Dispenser) event.getBlock().getState();
                    org.bukkit.material.Dispenser dis = (org.bukkit.material.Dispenser) dispenser.getData();
                    BlockFace directionFacing = dis.getFacing();
                    // Someone told me not to do big if checks because it's hard to read, look at me doing it -_-
                    if (directionFacing == BlockFace.EAST && playerLoc.getBlockX() != blockLoc.getBlockX()
                            && playerLoc.getX() <= blockLoc.getX() + 2.3 && playerLoc.getX() >= blockLoc.getX()
                            || directionFacing == BlockFace.WEST && playerLoc.getX() >= blockLoc.getX() - 1.3
                            && playerLoc.getX() <= blockLoc.getX()
                            || directionFacing == BlockFace.SOUTH
                            && playerLoc.getBlockZ() != blockLoc.getBlockZ()
                            && playerLoc.getZ() <= blockLoc.getZ() + 2.3 && playerLoc.getZ() >= blockLoc.getZ()
                            || directionFacing == BlockFace.NORTH && playerLoc.getZ() >= blockLoc.getZ() - 1.3
                            && playerLoc.getZ() <= blockLoc.getZ()) {
                        if (!InventoryManager.playerIsLoaded(player)) {
                            return;
                        }

                        Slot armorSlot = SlotManager.instance().getSlot(type.name());
                        event.setCancelled(armorSlot != null
                                && !InventoryManager.validateArmor(
                                player, InventoryAction.PLACE_ONE, armorSlot, event.getItem()));
                        return;
                    }
                }
            }
        }
    }
}
项目:BukkitOldCombatMechanics    文件:ArmourListener.java   
@EventHandler
public void dispenserFireEvent(BlockDispenseEvent e) {
    Block block = e.getBlock();
    if(block.getType().equals(Material.DISPENSER)){

        ArmourType type = ArmourType.matchType(e.getItem());
        if (ArmourType.matchType(e.getItem()) != null) {

            Location loc = block.getLocation();

            for (Player p : loc.getWorld().getPlayers()) {
                if (loc.getBlockY() - p.getLocation().getBlockY() >= -1 && loc.getBlockY() - p.getLocation().getBlockY() <= 1) {
                    if (p.getInventory().getHelmet() == null && type.equals(ArmourType.HELMET)
                            || p.getInventory().getChestplate() == null && type.equals(ArmourType.CHESTPLATE)
                            || p.getInventory().getLeggings() == null && type.equals(ArmourType.LEGGINGS)
                            || p.getInventory().getBoots() == null && type.equals(ArmourType.BOOTS)) {

                        org.bukkit.block.Dispenser dispenser = (org.bukkit.block.Dispenser) block.getState();
                        org.bukkit.material.Dispenser dis = (org.bukkit.material.Dispenser) dispenser.getData();
                        BlockFace directionFacing = dis.getFacing();

                        if (directionFacing == BlockFace.EAST && p.getLocation().getBlockX() != loc.getBlockX()
                                && p.getLocation().getX() <= loc.getX() + 2.3 && p.getLocation().getX() >= loc.getX()
                                || directionFacing == BlockFace.WEST && p.getLocation().getX() >= loc.getX() - 1.3
                                && p.getLocation().getX() <= loc.getX()
                                || directionFacing == BlockFace.SOUTH && p.getLocation().getBlockZ() != loc.getBlockZ()
                                && p.getLocation().getZ() <= loc.getZ() + 2.3
                                && p.getLocation().getZ() >= loc.getZ()
                                || directionFacing == BlockFace.NORTH && p.getLocation().getZ() >= loc.getZ() - 1.3
                                && p.getLocation().getZ() <= loc.getZ()) {

                            ArmourEquipEvent armourEquipEvent = new ArmourEquipEvent(p, EquipMethod.DISPENSER, ArmourType.matchType(e.getItem()), null, e.getItem());
                            Bukkit.getServer().getPluginManager().callEvent(armourEquipEvent);

                            if (armourEquipEvent.isCancelled())
                                e.setCancelled(true);

                            return;
                        }
                    }
                }
            }
        }
    }
}
项目:SharpSK    文件:ArmorEquipListener.java   
@EventHandler
public void dispenserFireEvent(BlockDispenseEvent e) {
    ArmorType type = ArmorType.matchType(e.getItem());
    if (e.getBlock() instanceof Dropper)
        return;
    if (ArmorType.matchType(e.getItem()) != null) {
        Location loc = e.getBlock().getLocation();
        for (Player p : loc.getWorld().getPlayers()) {
            if (loc.getBlockY() - p.getLocation().getBlockY() >= -1
                    && loc.getBlockY() - p.getLocation().getBlockY() <= 1) {
                if (p.getInventory().getHelmet() == null && type.equals(ArmorType.HELMET)
                        || p.getInventory().getChestplate() == null && type.equals(ArmorType.CHESTPLATE)
                        || p.getInventory().getLeggings() == null && type.equals(ArmorType.LEGGINGS)
                        || p.getInventory().getBoots() == null && type.equals(ArmorType.BOOTS)) {
                    org.bukkit.block.Dispenser dispenser = (org.bukkit.block.Dispenser) e.getBlock().getState();
                    org.bukkit.material.Dispenser dis = (org.bukkit.material.Dispenser) dispenser.getData();
                    BlockFace directionFacing = dis.getFacing();
                    // Someone told me not to do big if checks because it's hard to read, look at me
                    // doing it -_-
                    if (directionFacing == BlockFace.EAST && p.getLocation().getBlockX() != loc.getBlockX()
                            && p.getLocation().getX() <= loc.getX() + 2.3 && p.getLocation().getX() >= loc.getX()
                            || directionFacing == BlockFace.WEST && p.getLocation().getX() >= loc.getX() - 1.3
                                    && p.getLocation().getX() <= loc.getX()
                            || directionFacing == BlockFace.SOUTH && p.getLocation().getBlockZ() != loc.getBlockZ()
                                    && p.getLocation().getZ() <= loc.getZ() + 2.3
                                    && p.getLocation().getZ() >= loc.getZ()
                            || directionFacing == BlockFace.NORTH && p.getLocation().getZ() >= loc.getZ() - 1.3
                                    && p.getLocation().getZ() <= loc.getZ()) {
                        ArmorEquipEvent armorEquipEvent = new ArmorEquipEvent(p, EquipMethod.DISPENSER,
                                ArmorType.matchType(e.getItem()), e.getItem());
                        Bukkit.getServer().getPluginManager().callEvent(armorEquipEvent);
                        if (armorEquipEvent.isCancelled()) {
                            e.setCancelled(true);
                        }
                        return;
                    }
                }
            }
        }
    }
}
项目:RedProtect    文件:RPBlockListener.java   
@EventHandler
public void onDispenser(BlockDispenseEvent e){
    if (RPUtil.denyPotion(e.getItem())){
        e.setCancelled(true);
    }
}
项目:CraftBukkit    文件:DispenseBehaviorFilledBucket.java   
public ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) {
    ItemBucket itembucket = (ItemBucket) itemstack.getItem();
    int i = isourceblock.getBlockX();
    int j = isourceblock.getBlockY();
    int k = isourceblock.getBlockZ();
    EnumFacing enumfacing = BlockDispenser.b(isourceblock.h());

    // CraftBukkit start
    World world = isourceblock.k();
    int x = i + enumfacing.getAdjacentX();
    int y = j + enumfacing.getAdjacentY();
    int z = k + enumfacing.getAdjacentZ();
    if (world.isEmpty(x, y, z) || !world.getType(x, y, z).getMaterial().isBuildable()) {
        org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k);
        CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);

        BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(x, y, z));
        if (!BlockDispenser.eventFired) {
            world.getServer().getPluginManager().callEvent(event);
        }

        if (event.isCancelled()) {
            return itemstack;
        }

        if (!event.getItem().equals(craftItem)) {
            // Chain to handler for new item
            ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
            IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.get(eventStack.getItem());
            if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
                idispensebehavior.a(isourceblock, eventStack);
                return itemstack;
            }
        }

        itembucket = (ItemBucket) CraftItemStack.asNMSCopy(event.getItem()).getItem();
    }
    // CraftBukkit end

    if (itembucket.a(isourceblock.k(), i + enumfacing.getAdjacentX(), j + enumfacing.getAdjacentY(), k + enumfacing.getAdjacentZ())) {
        // CraftBukkit start - Handle stacked buckets
        Item item = Items.BUCKET;
        if (--itemstack.count == 0) {
            itemstack.setItem(Items.BUCKET);
            itemstack.count = 1;
        } else if (((TileEntityDispenser) isourceblock.getTileEntity()).addItem(new ItemStack(item)) < 0) {
            this.b.a(isourceblock, new ItemStack(item));
        }
        // CraftBukkit end

        return itemstack;
    } else {
        return this.b.a(isourceblock, itemstack);
    }
}
项目:CraftBukkit    文件:DispenseBehaviorArmor.java   
protected ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) {
    EnumFacing enumfacing = BlockDispenser.b(isourceblock.h());
    int i = isourceblock.getBlockX() + enumfacing.getAdjacentX();
    int j = isourceblock.getBlockY() + enumfacing.getAdjacentY();
    int k = isourceblock.getBlockZ() + enumfacing.getAdjacentZ();
    AxisAlignedBB axisalignedbb = AxisAlignedBB.a((double) i, (double) j, (double) k, (double) (i + 1), (double) (j + 1), (double) (k + 1));
    List list = isourceblock.k().a(EntityLiving.class, axisalignedbb, (IEntitySelector) (new EntitySelectorEquipable(itemstack)));

    if (list.size() > 0) {
        EntityLiving entityliving = (EntityLiving) list.get(0);
        int l = entityliving instanceof EntityHuman ? 1 : 0;
        int i1 = EntityInsentient.b(itemstack);

        // CraftBukkit start
        ItemStack itemstack1 = itemstack.a(1);
        World world = isourceblock.k();
        org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ());
        CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);

        BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0));
        if (!BlockDispenser.eventFired) {
            world.getServer().getPluginManager().callEvent(event);
        }

        if (event.isCancelled()) {
            itemstack.count++;
            return itemstack;
        }

        if (!event.getItem().equals(craftItem)) {
            itemstack.count++;
            // Chain to handler for new item
            ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
            IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.get(eventStack.getItem());
            if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
                idispensebehavior.a(isourceblock, eventStack);
                return itemstack;
            }
        }
        // CraftBukkit end

        itemstack1.count = 1;
        entityliving.setEquipment(i1 - l, itemstack1);
        if (entityliving instanceof EntityInsentient) {
            ((EntityInsentient) entityliving).a(i1, 2.0F);
        }

        // --itemstack.count; // CraftBukkit - handled above
        return itemstack;
    } else {
        return super.b(isourceblock, itemstack);
    }
}
项目:CraftBukkit    文件:DispenseBehaviorFireball.java   
public ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) {
    EnumFacing enumfacing = BlockDispenser.b(isourceblock.h());
    IPosition iposition = BlockDispenser.a(isourceblock);
    double d0 = iposition.getX() + (double) ((float) enumfacing.getAdjacentX() * 0.3F);
    double d1 = iposition.getY() + (double) ((float) enumfacing.getAdjacentY() * 0.3F);
    double d2 = iposition.getZ() + (double) ((float) enumfacing.getAdjacentZ() * 0.3F);
    World world = isourceblock.k();
    Random random = world.random;
    double d3 = random.nextGaussian() * 0.05D + (double) enumfacing.getAdjacentX();
    double d4 = random.nextGaussian() * 0.05D + (double) enumfacing.getAdjacentY();
    double d5 = random.nextGaussian() * 0.05D + (double) enumfacing.getAdjacentZ();

    // CraftBukkit start
    ItemStack itemstack1 = itemstack.a(1);
    org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ());
    CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);

    BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(d3, d4, d5));
    if (!BlockDispenser.eventFired) {
        world.getServer().getPluginManager().callEvent(event);
    }

    if (event.isCancelled()) {
        itemstack.count++;
        return itemstack;
    }

    if (!event.getItem().equals(craftItem)) {
        itemstack.count++;
        // Chain to handler for new item
        ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
        IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.get(eventStack.getItem());
        if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
            idispensebehavior.a(isourceblock, eventStack);
            return itemstack;
        }
    }

    EntitySmallFireball entitysmallfireball = new EntitySmallFireball(world, d0, d1, d2, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ());
    entitysmallfireball.projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource((TileEntityDispenser) isourceblock.getTileEntity());

    world.addEntity(entitysmallfireball);
    // itemstack.a(1); // Handled during event processing
    // CraftBukkit end

    return itemstack;
}
项目:CraftBukkit    文件:DispenseBehaviorFireworks.java   
public ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) {
    EnumFacing enumfacing = BlockDispenser.b(isourceblock.h());
    double d0 = isourceblock.getX() + (double) enumfacing.getAdjacentX();
    double d1 = (double) ((float) isourceblock.getBlockY() + 0.2F);
    double d2 = isourceblock.getZ() + (double) enumfacing.getAdjacentZ();

    // CraftBukkit start
    World world = isourceblock.k();
    ItemStack itemstack1 = itemstack.a(1);
    org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ());
    CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);

    BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(d0, d1, d2));
    if (!BlockDispenser.eventFired) {
        world.getServer().getPluginManager().callEvent(event);
    }

    if (event.isCancelled()) {
        itemstack.count++;
        return itemstack;
    }

    if (!event.getItem().equals(craftItem)) {
        itemstack.count++;
        // Chain to handler for new item
        ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
        IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.get(eventStack.getItem());
        if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
            idispensebehavior.a(isourceblock, eventStack);
            return itemstack;
        }
    }

    itemstack1 = CraftItemStack.asNMSCopy(event.getItem());
    EntityFireworks entityfireworks = new EntityFireworks(isourceblock.k(), event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), itemstack1);

    isourceblock.k().addEntity(entityfireworks);
    // itemstack.a(1); // Handled during event processing
    // CraftBukkit end

    return itemstack;
}
项目:CraftBukkit    文件:DispenseBehaviorMonsterEgg.java   
public ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) {
    EnumFacing enumfacing = BlockDispenser.b(isourceblock.h());
    double d0 = isourceblock.getX() + (double) enumfacing.getAdjacentX();
    double d1 = (double) ((float) isourceblock.getBlockY() + 0.2F);
    double d2 = isourceblock.getZ() + (double) enumfacing.getAdjacentZ();

    // CraftBukkit start
    World world = isourceblock.k();
    ItemStack itemstack1 = itemstack.a(1);
    org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ());
    CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);

    BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(d0, d1, d2));
    if (!BlockDispenser.eventFired) {
        world.getServer().getPluginManager().callEvent(event);
    }

    if (event.isCancelled()) {
        itemstack.count++;
        return itemstack;
    }

    if (!event.getItem().equals(craftItem)) {
        itemstack.count++;
        // Chain to handler for new item
        ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
        IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.get(eventStack.getItem());
        if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
            idispensebehavior.a(isourceblock, eventStack);
            return itemstack;
        }
    }

    itemstack1 = CraftItemStack.asNMSCopy(event.getItem());

    Entity entity = ItemMonsterEgg.spawnCreature(isourceblock.k(), itemstack.getData(), event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DISPENSE_EGG);

    if (entity instanceof EntityLiving && itemstack.hasName()) {
        ((EntityInsentient) entity).setCustomName(itemstack.getName());
    }

    // itemstack.a(1); // Handled during event processing
    // CraftBukkit end
    return itemstack;
}
项目:CraftBukkit    文件:DispenseBehaviorItem.java   
public static boolean a(World world, ItemStack itemstack, int i, EnumFacing enumfacing, ISourceBlock isourceblock) {
    IPosition iposition = BlockDispenser.a(isourceblock);
    // CraftBukkit end
    double d0 = iposition.getX();
    double d1 = iposition.getY();
    double d2 = iposition.getZ();
    EntityItem entityitem = new EntityItem(world, d0, d1 - 0.3D, d2, itemstack);
    double d3 = world.random.nextDouble() * 0.1D + 0.2D;

    entityitem.motX = (double) enumfacing.getAdjacentX() * d3;
    entityitem.motY = 0.20000000298023224D;
    entityitem.motZ = (double) enumfacing.getAdjacentZ() * d3;
    entityitem.motX += world.random.nextGaussian() * 0.007499999832361937D * (double) i;
    entityitem.motY += world.random.nextGaussian() * 0.007499999832361937D * (double) i;
    entityitem.motZ += world.random.nextGaussian() * 0.007499999832361937D * (double) i;

    // CraftBukkit start
    org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ());
    CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);

    BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(entityitem.motX, entityitem.motY, entityitem.motZ));
    if (!BlockDispenser.eventFired) {
        world.getServer().getPluginManager().callEvent(event);
    }

    if (event.isCancelled()) {
        return false;
    }

    entityitem.setItemStack(CraftItemStack.asNMSCopy(event.getItem()));
    entityitem.motX = event.getVelocity().getX();
    entityitem.motY = event.getVelocity().getY();
    entityitem.motZ = event.getVelocity().getZ();

    if (!event.getItem().equals(craftItem)) {
        // Chain to handler for new item
        ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
        IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.get(eventStack.getItem());
        if (idispensebehavior != IDispenseBehavior.a && idispensebehavior.getClass() != DispenseBehaviorItem.class) {
            idispensebehavior.a(isourceblock, eventStack);
        } else {
            world.addEntity(entityitem);
        }
        return false;
    }

    world.addEntity(entityitem);

    return true;
    // CraftBukkit end
}
项目:Almura-Server    文件:DispenseBehaviorFilledBucket.java   
public ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) {
    ItemBucket itembucket = (ItemBucket) itemstack.getItem();
    int i = isourceblock.getBlockX();
    int j = isourceblock.getBlockY();
    int k = isourceblock.getBlockZ();
    EnumFacing enumfacing = BlockDispenser.l_(isourceblock.h());

    // CraftBukkit start
    World world = isourceblock.k();
    int x = i + enumfacing.c();
    int y = j + enumfacing.d();
    int z = k + enumfacing.e();
    if (world.isEmpty(x, y, z) || !world.getMaterial(x, y, z).isBuildable()) {
        org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k);
        CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);

        BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(x, y, z));
        if (!BlockDispenser.eventFired) {
            world.getServer().getPluginManager().callEvent(event);
        }

        if (event.isCancelled()) {
            return itemstack;
        }

        if (!event.getItem().equals(craftItem)) {
            // Chain to handler for new item
            ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
            IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.a(eventStack.getItem());
            if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
                idispensebehavior.a(isourceblock, eventStack);
                return itemstack;
            }
        }

        itembucket = (ItemBucket) CraftItemStack.asNMSCopy(event.getItem()).getItem();
    }
    // CraftBukkit end

    if (itembucket.a(isourceblock.k(), i + enumfacing.c(), j + enumfacing.d(), k + enumfacing.e())) {
        // CraftBukkit start - Handle stacked buckets
        Item item = Item.BUCKET;
        if (--itemstack.count == 0) {
            itemstack.id = item.id;
            itemstack.count = 1;
        } else if (((TileEntityDispenser) isourceblock.getTileEntity()).addItem(new ItemStack(item)) < 0) {
            this.b.a(isourceblock, new ItemStack(item));
        }
        // CraftBukkit end

        return itemstack;
    } else {
        return this.b.a(isourceblock, itemstack);
    }
}
项目:Almura-Server    文件:DispenseBehaviorArmor.java   
protected ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) {
    EnumFacing enumfacing = BlockDispenser.l_(isourceblock.h());
    int i = isourceblock.getBlockX() + enumfacing.c();
    int j = isourceblock.getBlockY() + enumfacing.d();
    int k = isourceblock.getBlockZ() + enumfacing.e();
    AxisAlignedBB axisalignedbb = AxisAlignedBB.a().a((double) i, (double) j, (double) k, (double) (i + 1), (double) (j + 1), (double) (k + 1));
    List list = isourceblock.k().a(EntityLiving.class, axisalignedbb, (IEntitySelector) (new EntitySelectorEquipable(itemstack)));

    if (list.size() > 0) {
        EntityLiving entityliving = (EntityLiving) list.get(0);
        int l = entityliving instanceof EntityHuman ? 1 : 0;
        int i1 = EntityInsentient.b(itemstack);

        // CraftBukkit start
        ItemStack itemstack1 = itemstack.a(1);
        World world = isourceblock.k();
        org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ());
        CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);

        BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0));
        if (!BlockDispenser.eventFired) {
            world.getServer().getPluginManager().callEvent(event);
        }

        if (event.isCancelled()) {
            itemstack.count++;
            return itemstack;
        }

        if (!event.getItem().equals(craftItem)) {
            itemstack.count++;
            // Chain to handler for new item
            ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
            IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.a(eventStack.getItem());
            if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
                idispensebehavior.a(isourceblock, eventStack);
                return itemstack;
            }
        }
        // CraftBukkit end

        itemstack1.count = 1;
        entityliving.setEquipment(i1 - l, itemstack1);
        if (entityliving instanceof EntityInsentient) {
            ((EntityInsentient) entityliving).a(i1, 2.0F);
        }

        // --itemstack.count; // CraftBukkit - handled above
        return itemstack;
    } else {
        return super.b(isourceblock, itemstack);
    }
}
项目:Almura-Server    文件:DispenseBehaviorFireball.java   
public ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) {
    EnumFacing enumfacing = BlockDispenser.l_(isourceblock.h());
    IPosition iposition = BlockDispenser.a(isourceblock);
    double d0 = iposition.getX() + (double) ((float) enumfacing.c() * 0.3F);
    double d1 = iposition.getY() + (double) ((float) enumfacing.c() * 0.3F);
    double d2 = iposition.getZ() + (double) ((float) enumfacing.e() * 0.3F);
    World world = isourceblock.k();
    Random random = world.random;
    double d3 = random.nextGaussian() * 0.05D + (double) enumfacing.c();
    double d4 = random.nextGaussian() * 0.05D + (double) enumfacing.d();
    double d5 = random.nextGaussian() * 0.05D + (double) enumfacing.e();

    // CraftBukkit start
    ItemStack itemstack1 = itemstack.a(1);
    org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ());
    CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);

    BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(d3, d4, d5));
    if (!BlockDispenser.eventFired) {
        world.getServer().getPluginManager().callEvent(event);
    }

    if (event.isCancelled()) {
        itemstack.count++;
        return itemstack;
    }

    if (!event.getItem().equals(craftItem)) {
        itemstack.count++;
        // Chain to handler for new item
        ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
        IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.a(eventStack.getItem());
        if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
            idispensebehavior.a(isourceblock, eventStack);
            return itemstack;
        }
    }

    world.addEntity(new EntitySmallFireball(world, d0, d1, d2, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ()));
    // itemstack.a(1); // Handled during event processing
    // CraftBukkit end

    return itemstack;
}
项目:Almura-Server    文件:DispenseBehaviorFireworks.java   
public ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) {
    EnumFacing enumfacing = BlockDispenser.l_(isourceblock.h());
    double d0 = isourceblock.getX() + (double) enumfacing.c();
    double d1 = (double) ((float) isourceblock.getBlockY() + 0.2F);
    double d2 = isourceblock.getZ() + (double) enumfacing.e();

    // CraftBukkit start
    World world = isourceblock.k();
    ItemStack itemstack1 = itemstack.a(1);
    org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ());
    CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);

    BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(d0, d1, d2));
    if (!BlockDispenser.eventFired) {
        world.getServer().getPluginManager().callEvent(event);
    }

    if (event.isCancelled()) {
        itemstack.count++;
        return itemstack;
    }

    if (!event.getItem().equals(craftItem)) {
        itemstack.count++;
        // Chain to handler for new item
        ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
        IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.a(eventStack.getItem());
        if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
            idispensebehavior.a(isourceblock, eventStack);
            return itemstack;
        }
    }

    itemstack1 = CraftItemStack.asNMSCopy(event.getItem());
    EntityFireworks entityfireworks = new EntityFireworks(isourceblock.k(), event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), itemstack1);

    isourceblock.k().addEntity(entityfireworks);
    // itemstack.a(1); // Handled during event processing
    // CraftBukkit end

    return itemstack;
}
项目:Almura-Server    文件:DispenseBehaviorMonsterEgg.java   
public ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) {
    EnumFacing enumfacing = BlockDispenser.l_(isourceblock.h());
    double d0 = isourceblock.getX() + (double) enumfacing.c();
    double d1 = (double) ((float) isourceblock.getBlockY() + 0.2F);
    double d2 = isourceblock.getZ() + (double) enumfacing.e();

    // CraftBukkit start
    World world = isourceblock.k();
    ItemStack itemstack1 = itemstack.a(1);
    org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ());
    CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);

    BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(d0, d1, d2));
    if (!BlockDispenser.eventFired) {
        world.getServer().getPluginManager().callEvent(event);
    }

    if (event.isCancelled()) {
        itemstack.count++;
        return itemstack;
    }

    if (!event.getItem().equals(craftItem)) {
        itemstack.count++;
        // Chain to handler for new item
        ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
        IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.a(eventStack.getItem());
        if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
            idispensebehavior.a(isourceblock, eventStack);
            return itemstack;
        }
    }

    itemstack1 = CraftItemStack.asNMSCopy(event.getItem());

    Entity entity = ItemMonsterEgg.a(isourceblock.k(), itemstack.getData(), event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ());

    if (entity instanceof EntityLiving && itemstack.hasName()) {
        ((EntityInsentient) entity).setCustomName(itemstack.getName());
    }

    // itemstack.a(1); // Handled during event processing
    // CraftBukkit end
    return itemstack;
}