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


Java BlockBreakEvent.isCancelled方法代码示例

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


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

示例1: onBlockBreak

import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onBlockBreak(BlockBreakEvent event)
{
	if(event.isCancelled()) return;
	if(Survival.allowedBlocks.contains(event.getBlock().getType()))
	{
		ArmorStand drop = dropSeat(event.getBlock(), (Stairs)event.getBlock().getState().getData());
		
		for(Entity e : drop.getNearbyEntities(0.5, 0.5, 0.5))
		{
			if(e != null && e instanceof ArmorStand && e.getCustomName() == "Chair")
				e.remove();
		}
		
		drop.remove();
	}
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:18,代码来源:Chairs.java

示例2: onBreak

import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@EventHandler
public void onBreak(BlockBreakEvent e) {
    if (e.isCancelled()) {
        return;
    }
    if (!Utils.isInArena(e.getPlayer())) {
        return;
    }
    if (!Utils.isArenaWorld(e.getBlock().getWorld())) {
        return;
    }
    if (e.getPlayer().isOp()) {
        return;
    }
    e.setCancelled(true);
}
 
开发者ID:Soldier233,项目名称:ArchersBattle,代码行数:17,代码来源:WorldListener.java

示例3: onBlockBreak

import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void onBlockBreak(BlockBreakEvent event) {
    if (event.isCancelled()) {
        return;
    }

    BlockUpdate.Update(event.getBlock());
    BlockHitManager.breakBlock(event.getPlayer(), event.getBlock());
}
 
开发者ID:SamaGames,项目名称:AntiCheat,代码行数:10,代码来源:OrebfuscatorBlockListener.java

示例4: onBreak

import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@EventHandler
public void onBreak(BlockBreakEvent e) {
	if (e.getBlock() == null)
		return;
	KingdomFactionsPlayer p = PlayerModule.getInstance().getPlayer(e.getPlayer());
	if(p.hasBuildAction()) e.setCancelled(true);
	if(p.isVanished()) return;
	if(e.isCancelled()) return;
	if(NexusModule.getInstance().isNexus(e.getBlock().getLocation())) return;
	if(!p.canBuild(e.getBlock().getLocation())) {
		e.setCancelled(!ProtectionModule.getInstance().tryInfluence(p, 200, e.getBlock()));
	} 
}
 
开发者ID:ThEWiZ76,项目名称:KingdomFactions,代码行数:14,代码来源:BuildEventListener.java

示例5: isProtected

import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
/**
 * Is the given location protected to the given player?
 * @param player
 * @param loc
 * @return protected
 */
public static boolean isProtected(Player player, Location loc) {
    BlockBreakEvent evt = new BlockBreakEvent(loc.getBlock(), player);
    evt.setDropItems(false);
    Bukkit.getPluginManager().callEvent(evt);
    return evt.isCancelled();
}
 
开发者ID:Kneesnap,项目名称:Kineticraft,代码行数:13,代码来源:Utils.java

示例6: onBreakSnow

import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.HIGHEST)
public void onBreakSnow(BlockBreakEvent e)
{
	if(e.isCancelled()) return;
	Player player = e.getPlayer();
	if(player.getGameMode() == GameMode.SURVIVAL || player.getGameMode() == GameMode.ADVENTURE)
	{
		ItemStack mainItem = player.getInventory().getItemInMainHand();
		switch(mainItem.getType())
		{
			case WOOD_SPADE:
			case GOLD_SPADE:
			case STONE_SPADE:
			case DIAMOND_SPADE:
			case IRON_SPADE:
				Block block = e.getBlock();
				switch(block.getType())
				{
					case SNOW:
						e.setCancelled(true);
						mainItem.setDurability((short) (mainItem.getDurability() + 1));
						if(mainItem.getDurability() >= mainItem.getType().getMaxDurability() + 1)
							player.getInventory().setItemInMainHand(null);
			            player.updateInventory();
			            block.getWorld().dropItemNaturally(block.getLocation(), new ItemStack(Material.SNOW_BALL, block.getData() + 1));
			            block.setType(Material.AIR);
						break;
					case SNOW_BLOCK:
						e.setCancelled(true);
						mainItem.setDurability((short) (mainItem.getDurability() + 1));
						if(mainItem.getDurability() >= mainItem.getType().getMaxDurability() + 1)
							player.getInventory().setItemInMainHand(null);
			            player.updateInventory();
			            block.getWorld().dropItemNaturally(block.getLocation(), new ItemStack(Material.SNOW_BALL, 8));
			            block.setType(Material.AIR);
			            break;
					default:
				}
				break;
			default:
		}
	}
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:45,代码来源:SnowballThrow.java

示例7: onBreakWorkbench

import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onBreakWorkbench(BlockBreakEvent e)
{
	if(e.isCancelled()) return;
	Block workbench = e.getBlock();

	if (!workbench.hasMetadata("shared_players") || workbench.getType() != Material.WORKBENCH)
		return;
	
	@SuppressWarnings("unchecked")
	List<UUID> list = (workbench.getMetadata("shared_players").get(0).value() instanceof List<?>) ? (List<UUID>)workbench.getMetadata("shared_players").get(0).value() : new ArrayList<UUID>();
	
	Iterator<UUID> iterator = list.iterator();
	
	Inventory sharedInventory = Bukkit.createInventory(null, InventoryType.WORKBENCH);
	
	while (iterator.hasNext())
	{
		UUID next = iterator.next();
		
		iterator.remove();
		
		final Player idPlayer = Bukkit.getPlayer(next);
		
		if (idPlayer != null)
		{
			idPlayer.removeMetadata("shared_inv", Survival.instance);
			
			if(idPlayer.isOnline())
			{
				final Inventory open = idPlayer.getOpenInventory().getTopInventory();
				
				if (open != null && open.getType() == InventoryType.WORKBENCH)
				{
					sharedInventory.setContents(open.getContents());
					open.clear();
					idPlayer.closeInventory();
				}
			}
		}
	}
	
	for(int i = 1; i < sharedInventory.getSize(); i++)
	{
		ItemStack item = sharedInventory.getItem(i);
		if(item != null)
			workbench.getWorld().dropItem(workbench.getLocation(), item);
	}
	
	workbench.removeMetadata("shared_players", Survival.instance);
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:52,代码来源:WorkbenchShare.java

示例8: onBlockBreak

import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = false, priority = EventPriority.MONITOR)
public void onBlockBreak(BlockBreakEvent event) {
    if (event.isCancelled() && NON_TRANSPARENT_ATTACK_BREAK_TYPES.contains(event.getBlock().getType())) {
        cancelAttackingMillis(event.getPlayer().getUniqueId(), THRESHOLD);
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:7,代码来源:BlockHitFixListener.java


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