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


Java BlockBreakEvent类代码示例

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


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

示例1: onBlockBreak

import org.bukkit.event.block.BlockBreakEvent; //导入依赖的package包/类
/**
 * Prevents blocks from being broken
 *
 * @param e
 */
@EventHandler(priority = EventPriority.LOW)
public void onBlockBreak(final BlockBreakEvent e) {
    if (DEBUG)
        plugin.getLogger().info("DEBUG: " + e.getEventName());
    // plugin.getLogger().info("Block break");
    if ((e.getPlayer().getWorld().getName().equalsIgnoreCase(Settings.worldName + "_nether") && !Settings.netherIslands)
            || e.getPlayer().getWorld().getName().equalsIgnoreCase(Settings.worldName + "_the_end")) {
        if (VaultHelper.hasPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")) {
            return;
        }
        if (DEBUG)
            plugin.getLogger().info("Block break in island nether");
        if (!awayFromSpawn(e.getPlayer()) && !e.getPlayer().isOp()) {
            Util.sendMessage(e.getPlayer(), plugin.getLocale(e.getPlayer().getUniqueId()).get("nether.spawnisprotected"));
            e.setCancelled(true);
        }
    }

}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:25,代码来源:NetherEvents.java

示例2: onBlockBreak

import org.bukkit.event.block.BlockBreakEvent; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onBlockBreak(BlockBreakEvent event) {
    Block block = event.getBlock();
    if (isDeathSign(block)) {
        BlockState state = block.getState();
        Sign sign = (Sign) state;
        ItemStack stack = new ItemStack(Material.SIGN, 1);
        ItemMeta meta = stack.getItemMeta();
        meta.setDisplayName(DEATH_SIGN_ITEM_NAME);
        meta.setLore(Arrays.asList(sign.getLines()));
        stack.setItemMeta(meta);

        Player player = event.getPlayer();
        World world = player.getWorld();
        if (player.getGameMode() != GameMode.CREATIVE && world.isGameRule("doTileDrops")) {
            world.dropItemNaturally(block.getLocation(), stack);
        }

        // Manually handle the dropping
        event.setCancelled(true);
        block.setType(Material.AIR);
        state.update();
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:25,代码来源:DeathSignListener.java

示例3: onBlockBreak

import org.bukkit.event.block.BlockBreakEvent; //导入依赖的package包/类
/**
 * So far specifically handles these cases:
 * 
 * 1) Block broken is tracked
 * 2) Block breaks by not-players
 * 3) Block breaks by players
 * 4) Indirect block breaks -- destroying block supporting a crop or collapsible tree, or under mushrooms
 * 5) Indirect block break of cocoa bearing logs
 * 6) Block broken had mushroom on top and cocoa on the sides
 * 
 * @param e The event
 */
@EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent e) {
	Block block = e.getBlock();
	Player player = e.getPlayer();
	BreakType type = player != null ? BreakType.PLAYER : BreakType.NATURAL;
	UUID uuid = player != null ? player.getUniqueId() : null;
	if (maybeSideTracked(block)) {
		trySideBreak(block, type, uuid);
	}
	if (maybeBelowTracked(block)) {
		block = block.getRelative(BlockFace.UP);
	}
	Location loc = block.getLocation();
	if (!pendingChecks.contains(loc)) {
		pendingChecks.add(loc);
		handleBreak(block, type, uuid, null);
	}
}
 
开发者ID:DevotedMC,项目名称:CropControl,代码行数:31,代码来源:CropControlEventHandler.java

示例4: onBlockBreak

import org.bukkit.event.block.BlockBreakEvent; //导入依赖的package包/类
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
    for (Region region : regions) {
        if (region.contains(event.getBlock().getLocation())) {
            for (MatchTeam matchTeam : teams) {
                if (matchTeam.containsPlayer(event.getPlayer())) {
                    FilterResult filterResult = evaluator.evaluate(event.getPlayer());
                    if (filterResult == FilterResult.DENY) {
                        event.setCancelled(true);
                        event.getPlayer().sendMessage(message);
                    } else if (filterResult == FilterResult.ALLOW) {
                        event.setCancelled(false);
                    }
                }
            }
        }
    }
}
 
开发者ID:WarzoneMC,项目名称:Warzone,代码行数:19,代码来源:BuildFilterType.java

示例5: onBlockBreak

import org.bukkit.event.block.BlockBreakEvent; //导入依赖的package包/类
/**
 *
 * @param e BlockBreakEvent
 * @since 4.2.0
 */
@EventHandler
public void onBlockBreak(BlockBreakEvent e) {
	List<ItemStack> drops = new ArrayList<ItemStack>();
	ItemStack item = e.getPlayer().getInventory().getItemInMainHand();
	int fortune = 1;

	if (item != null) {
		if (item.getEnchantments().containsKey(Enchantment.LOOT_BONUS_BLOCKS) && !item.getEnchantments().containsKey(Enchantment.SILK_TOUCH)) {
			fortune = SlimefunStartup.randomize(item.getEnchantmentLevel(Enchantment.LOOT_BONUS_BLOCKS) + 2) - 1;
			if (fortune <= 0) fortune = 1;
			fortune = (e.getBlock().getType() == Material.LAPIS_ORE ? 4 + SlimefunStartup.randomize(5) : 1) * (fortune + 1);
		}

		if (!item.getEnchantments().containsKey(Enchantment.SILK_TOUCH) && e.getBlock().getType().toString().endsWith("_ORE")) {
			if (Talisman.checkFor(e, SlimefunItem.getByID("MINER_TALISMAN"))) {
				if (drops.isEmpty()) drops = (List<ItemStack>) e.getBlock().getDrops();
				for (ItemStack drop : new ArrayList<ItemStack>(drops)) {
					if (!drop.getType().isBlock()) drops.add(new CustomItem(drop, fortune * 2));
				}
			}
		}
	}
}
 
开发者ID:StarWishsama,项目名称:Slimefun4-Chinese-Version,代码行数:29,代码来源:TalismanListener.java

示例6: removeBlock

import org.bukkit.event.block.BlockBreakEvent; //导入依赖的package包/类
public void removeBlock(BlockBreakEvent e) {
		for (Entity en : e.getBlock().getWorld().getEntities()) {
			if (en.getCustomName() != null && en.getCustomName().equals(getName()) && en.getLocation().add(-0.5, 0, -0.5).equals(e.getBlock().getLocation())) {
				en.remove();
				en.getWorld().getBlockAt(en.getLocation().add(-0.5, 0, -0.5)).setType(Material.AIR);
				
				ItemStack block = new ItemStack(Material.MONSTER_EGG, 1);
				
				ItemMeta bmeta = block.getItemMeta();
				
				bmeta.setDisplayName(name);
				
				block.setItemMeta(bmeta);
				
				if (e.getPlayer() != null && e.getPlayer().getGameMode().equals(GameMode.CREATIVE)) {
					e.getPlayer().getInventory().addItem(block);
				} else {
					e.getBlock().getWorld().dropItemNaturally(en.getLocation().add(-0.5, 0, -0.5), block);
				}
			}
		}
	//}
}
 
开发者ID:GigaGamma,项目名称:SuperiorCraft,代码行数:24,代码来源:CustomBlock.java

示例7: removeBlock

import org.bukkit.event.block.BlockBreakEvent; //导入依赖的package包/类
@Override
public void removeBlock(BlockBreakEvent e) {
		if (e.getPlayer() == null) {return;}
		for (Entity en : e.getPlayer().getNearbyEntities(10, 10, 10)) {
			System.out.println("Removal has Begun");
			if (en.getCustomName() != null && en.getCustomName().equals(getName()) && /*en.getLocation().add(-0.5, 0, -0.5).equals(e.getBlock().getLocation())*/ en.getLocation().distance(e.getBlock().getLocation()) < 2) {
				for (Entity ent : en.getNearbyEntities(0.5, 0.5, 0.5)) {
					if (ent.getCustomName().equals("CustomBlock")) {
						ent.remove();
						break;
					}
				}
				en.remove();
				//en.getWorld().getBlockAt(en.getLocation().add(-0.5, 0, -0.5)).setType(Material.AIR);
				if (e.getPlayer() != null && e.getPlayer().getGameMode().equals(GameMode.CREATIVE)) {
					e.getPlayer().getInventory().addItem(getItem());
				} else {
					e.getBlock().getWorld().dropItemNaturally(en.getLocation().add(-0.5, 0, -0.5), getItem());
				}
				
				return;
			}
		}
}
 
开发者ID:GigaGamma,项目名称:SuperiorCraft,代码行数:25,代码来源:CustomTexturedBlock.java

示例8: 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

示例9: onBlockBreak

import org.bukkit.event.block.BlockBreakEvent; //导入依赖的package包/类
@EventHandler
private void onBlockBreak(final BlockBreakEvent event) {
    Material material = event.getBlock().getType();
    byte data = event.getBlock().getData();
    ItemStack mainHandItem = event.getPlayer().getInventory().getItemInMainHand();
    DatabaseQueryWorker.getInstance().submit(() -> {
        try {
            BlockBreakDAO.storeRecord(
                    event.getPlayer().getUniqueId(), event.getPlayer().getType().name(),
                    material, data,
                    event.getBlock().getLocation(), mainHandItem
            );
        } catch (SQLException e) {
            e.printStackTrace();
        }
    });
}
 
开发者ID:Lolmewn,项目名称:Stats4,代码行数:18,代码来源:BlockBreakStat.java

示例10: Woodcutter

import org.bukkit.event.block.BlockBreakEvent; //导入依赖的package包/类
@EventHandler
public void Woodcutter(BlockBreakEvent event) {
	if (State.PRE)
		return;

	Player p = event.getPlayer();
	if (Kit.getKit(p).getName().equalsIgnoreCase("woodcutter")
			&& event.getBlock().getType().equals(Material.LOG)
			&& (p.getItemInHand().getType().toString().contains("AXE"))) {
		for (int i = 0; i <= 50; i++) {
			Location loc = event.getBlock().getLocation();
			loc.setY(loc.getY() + i);
			if (loc.getBlock().getType().equals(Material.LOG))
				loc.getBlock().breakNaturally();
			else
				break;
		}
	}
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:20,代码来源:KitEvents.java

示例11: onBlockBreak

import org.bukkit.event.block.BlockBreakEvent; //导入依赖的package包/类
@EventHandler
public void onBlockBreak(BlockBreakEvent e) {
	Player p = e.getPlayer();
	Faction faction = hcf.getFactionManager().getFactionAt(e.getBlock());
	if(e.getBlock().getType().equals(Material.GLOWSTONE) && e.getBlock().getLocation().getWorld().getName().equalsIgnoreCase("world_nether")) {
		if(faction.getName().equalsIgnoreCase("GlowstoneMountain")) {
			e.setCancelled(true);
			e.getBlock().setType(Material.BEDROCK);
			Bukkit.getScheduler().scheduleSyncDelayedTask(hcf, new Runnable() {
				public void run() {
					if(e.getBlock().getType().equals(Material.BEDROCK)) {
						e.getBlock().setType(Material.GLOWSTONE);
					}
				}
			}, 20L*60L*10L);
			p.getInventory().addItem(new ItemStack(Material.GLOWSTONE));
		}
	}
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:20,代码来源:GlowstoneListener.java

示例12: onBlockBreak

import org.bukkit.event.block.BlockBreakEvent; //导入依赖的package包/类
@EventHandler
public void onBlockBreak(BlockBreakEvent e)
{
    User user = MWAPI.getUserHandler().findById(e.getPlayer().getUniqueId());

    if (user.getGame() != null)
    {
        if (user.getGame().getSpectators().contains(user) || user.getGame().getState().equals(GameState.LOBBY))
        {
            e.setCancelled(true);
            return;
        }

        // TODO handle other stuff like the castles and walls
    }
}
 
开发者ID:WoutDev,项目名称:Mega-Walls,代码行数:17,代码来源:BlockBreakListener.java

示例13: 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

示例14: onBlockBreak

import org.bukkit.event.block.BlockBreakEvent; //导入依赖的package包/类
/**
 * Private block breaking handling
 *
 * @param event Event
 */
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onBlockBreak(BlockBreakEvent event)
{
    if (this.blocksOwner.containsKey(event.getBlock().getLocation()) && this.blocksOwner.get(event.getBlock().getLocation()) != event.getPlayer().getUniqueId())
    {
        UUID id = this.blocksOwner.get(event.getBlock().getLocation());

        if (id == null || id.equals(event.getPlayer().getUniqueId()) || (this.game instanceof SurvivalTeamGame && ((SurvivalTeamGame) this.game).getPlayerTeam(id) == ((SurvivalTeamGame) this.game).getPlayerTeam(event.getPlayer().getUniqueId())))
        {
            this.blocksOwner.remove(event.getBlock().getLocation());
        }
        else if (!this.game.isPvPActivated())
        {
            event.getPlayer().sendMessage(ChatColor.RED + "Ce bloc appartient à " + Bukkit.getOfflinePlayer(this.blocksOwner.get(event.getBlock().getLocation())).getName()  + ". Vous ne pouvez pas le casser actuellement !");
            event.setCancelled(true);
        }
    }
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:24,代码来源:PersonalBlocksModule.java

示例15: onBlockBreak

import org.bukkit.event.block.BlockBreakEvent; //导入依赖的package包/类
/**
 * Write a message when a player mine a diamond
 *
 * @param event Event
 */
@EventHandler(ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event)
{
    if (event.getBlock().getType() != Material.DIAMOND_ORE)
        return;

    Location location = event.getBlock().getLocation();

    StringBuilder builder = new StringBuilder();
    builder.append(ChatColor.GOLD).append("[").append(ChatColor.YELLOW);
    builder.append("Paranoïa");
    builder.append(ChatColor.GOLD).append("]").append(ChatColor.YELLOW);
    builder.append(" Le joueur ").append(ChatColor.GOLD).append(event.getPlayer().getName()).append(ChatColor.YELLOW);
    builder.append(" a miné un bloc de diamant aux coordonnées ").append(ChatColor.GOLD);
    builder.append(location.getBlockX()).append("; ").append(location.getBlockY()).append("; ").append(location.getBlockZ());
    builder.append(ChatColor.YELLOW).append(" !");

    Bukkit.broadcastMessage(builder.toString());
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:25,代码来源:ParanoidModule.java


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