當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。