当前位置: 首页>>代码示例>>Java>>正文


Java BlockDispenseEvent.setCancelled方法代码示例

本文整理汇总了Java中org.bukkit.event.block.BlockDispenseEvent.setCancelled方法的典型用法代码示例。如果您正苦于以下问题:Java BlockDispenseEvent.setCancelled方法的具体用法?Java BlockDispenseEvent.setCancelled怎么用?Java BlockDispenseEvent.setCancelled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.event.block.BlockDispenseEvent的用法示例。


在下文中一共展示了BlockDispenseEvent.setCancelled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onNetherDispenser

import org.bukkit.event.block.BlockDispenseEvent; //导入方法依赖的package包/类
/**
 * 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);
        }
    }
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:25,代码来源:IslandGuard.java

示例2: onBlockDispense

import org.bukkit.event.block.BlockDispenseEvent; //导入方法依赖的package包/类
@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;
		    }
		}
   	}
   }
 
开发者ID:Maximuspayne,项目名称:NavyCraft2-Lite,代码行数:18,代码来源:AimCannonPlayerListener.java

示例3: onBlockDispense

import org.bukkit.event.block.BlockDispenseEvent; //导入方法依赖的package包/类
/**
    * 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;
			}
		}
	}
}
 
开发者ID:stefvanschie,项目名称:buildinggame,代码行数:26,代码来源:BlockDispenseItem.java

示例4: onBlockDispenseEvent

import org.bukkit.event.block.BlockDispenseEvent; //导入方法依赖的package包/类
@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;
			//}
		}
	}
}
 
开发者ID:netizen539,项目名称:civcraft,代码行数:21,代码来源:BlockListener.java

示例5: onNetherDispenser

import org.bukkit.event.block.BlockDispenseEvent; //导入方法依赖的package包/类
/**
 * 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);
        }
    }
}
 
开发者ID:tastybento,项目名称:acidisland,代码行数:25,代码来源:IslandGuard.java

示例6: onBlockDispense

import org.bukkit.event.block.BlockDispenseEvent; //导入方法依赖的package包/类
@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);
}
 
开发者ID:Maximuspayne,项目名称:NavyCraft2-Lite,代码行数:13,代码来源:NavyCraft_BlockListener.java

示例7: onDispense

import org.bukkit.event.block.BlockDispenseEvent; //导入方法依赖的package包/类
@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);
}
 
开发者ID:john01dav,项目名称:GriefPreventionPlus,代码行数:33,代码来源:BlockEventHandler.java

示例8: onDispense

import org.bukkit.event.block.BlockDispenseEvent; //导入方法依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:tastybento,项目名称:beaconz,代码行数:32,代码来源:BeaconProtectionListener.java

示例9: onBlockDispense

import org.bukkit.event.block.BlockDispenseEvent; //导入方法依赖的package包/类
@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);
    }
}
 
开发者ID:IntellectualSites,项目名称:PlotSquared,代码行数:15,代码来源:PlayerEvents.java

示例10: onDispense

import org.bukkit.event.block.BlockDispenseEvent; //导入方法依赖的package包/类
@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);
  }
 
开发者ID:goncalomb,项目名称:NBTEditor,代码行数:9,代码来源:BookOfSoulsCI.java

示例11: blockDispense

import org.bukkit.event.block.BlockDispenseEvent; //导入方法依赖的package包/类
@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);
		}
	}
}
 
开发者ID:goncalomb,项目名称:NBTEditor,代码行数:15,代码来源:CustomItemListener.java

示例12: onDispenseEquip

import org.bukkit.event.block.BlockDispenseEvent; //导入方法依赖的package包/类
@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;
                    }
                }
            }
        }
    }
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:42,代码来源:ArmorEquipListener.java

示例13: dispenserFireEvent

import org.bukkit.event.block.BlockDispenseEvent; //导入方法依赖的package包/类
@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;
						}
					}
				}
			}
		}
	}
}
 
开发者ID:gvlfm78,项目名称:BukkitOldCombatMechanics,代码行数:46,代码来源:ArmourListener.java

示例14: dispenserFireEvent

import org.bukkit.event.block.BlockDispenseEvent; //导入方法依赖的package包/类
@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;
					}
				}
			}
		}
	}
}
 
开发者ID:Sharpjaws,项目名称:SharpSK,代码行数:42,代码来源:ArmorEquipListener.java

示例15: onDispenser

import org.bukkit.event.block.BlockDispenseEvent; //导入方法依赖的package包/类
@EventHandler
public void onDispenser(BlockDispenseEvent e){
	if (RPUtil.denyPotion(e.getItem())){
		e.setCancelled(true);
	}
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:7,代码来源:RPBlockListener.java


注:本文中的org.bukkit.event.block.BlockDispenseEvent.setCancelled方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。