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


Java BlockBreakEvent.getBlock方法代码示例

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


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

示例1: onWoodBreak

import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@EventHandler
public void onWoodBreak(BlockBreakEvent event) {
    final Block b = event.getBlock();
    if (b != null && (b.getType() == Material.LOG || b.getType() == Material.LOG_2)) {
        Material handType = event.getPlayer().getItemInHand().getType();
        if (handType == Material.WOOD_AXE || handType == Material.STONE_AXE || handType == Material.IRON_AXE || handType == Material.GOLD_AXE || handType == Material.DIAMOND_AXE) {
            dataMap.put(b, b.getData());
            b.setType(Material.WOOL);
            b.setData(DyeColor.BLACK.getWoolData());
            Player p = event.getPlayer();
            event.getPlayer().sendMessage("> +1 Woodcutting EXP");
            Location loc = b.getLocation();
            Vector v = p.getLocation().subtract(loc).toVector().normalize().multiply(0.5);
            DropManager.dropItem(new ItemStack(Material.LOG), loc, event.getPlayer().getUniqueId()).setVelocity(v);
            RScheduler.schedule(plugin, () -> {
                b.setType(Material.LOG);
                b.setData(dataMap.getOrDefault(b, (byte) 0));
            }, RTicks.seconds(2));
        }
    }
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:22,代码来源:SkillManager.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 (isEventSign(block))
  {
    BlockState state = block.getState();
    Sign sign = (Sign)state;
    ItemStack stack = new ItemStack(Material.SIGN, 1);
    ItemMeta meta = stack.getItemMeta();
    meta.setDisplayName(EVENT_SIGN_ITEM_NAME);
    meta.setLore(Arrays.asList(sign.getLines()));
    stack.setItemMeta(meta);
    
    Player player = event.getPlayer();
    World world = player.getWorld();
    Location blockLocation = block.getLocation();
    if ((player.getGameMode() != GameMode.CREATIVE) && (world.isGameRule("doTileDrops"))) {
      world.dropItemNaturally(blockLocation, stack);
    }
    event.setCancelled(true);
    block.setType(Material.AIR);
    state.update();
  }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:26,代码来源:EventSignListener.java

示例3: onBlockBreak

import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
/**
 * Drops the smelted form of items that spawn when a block is broken.
 *
 * @param event The event
 */
@EventHandler(ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) {
  Block block = event.getBlock();
  Material type = block.getType();

  BlockDropModule module = OpenUHC.getCurrentGame().getModuleHandler().getModule(BlockDropModule.class);
  if (type.equals(Material.IRON_ORE)) {
    module.addBlockDrop(block, new BlockDrop(new ItemStack(Material.IRON_INGOT), true));
    event.setExpToDrop(4);
  } else if (type.equals(Material.GOLD_ORE)) {
    module.addBlockDrop(block, new BlockDrop(new ItemStack(Material.GOLD_INGOT), true));
    event.setExpToDrop(8);
  } else if (type.equals(Material.POTATO)) {
    module.addBlockDrop(block, new BlockDrop(new ItemStack(Material.BAKED_POTATO), true));
    event.setExpToDrop(2);
  }
}
 
开发者ID:twizmwazin,项目名称:OpenUHC,代码行数:23,代码来源:Cutclean.java

示例4: onBlockBreak

import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@EventHandler
  public void onBlockBreak(BlockBreakEvent event) {
if (Walls.getSpectators().contains(event.getPlayer().getName())) {
	event.setCancelled(true);
	return;
}
  	
      if (State.PVP)
          return;
      
      Block b = event.getBlock();
      if (b == null)
          return;
      Team team = Team.getTeam(event.getPlayer());
      if (b.getX() < team.getMin().getX() + 1 || b.getZ() < team.getMin().getZ() + 1) {
          event.setCancelled(true);
      }
      if (b.getX() > team.getMax().getX() - 1 || b.getZ() > team.getMax().getZ() - 1) {
          event.setCancelled(true);
      }
  }
 
开发者ID:thekeenant,项目名称:mczone,代码行数:22,代码来源:Events.java

示例5: onBlockBreak

import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onBlockBreak(final BlockBreakEvent event) {
    final Player player = event.getPlayer();
    if(player.getGameMode() == GameMode.CREATIVE) {
        return;
    }
    if(player.getItemInHand().getEnchantments().containsKey(Enchantment.SILK_TOUCH)) return;;
    final Block block = event.getBlock();
    final Location blockLocation = block.getLocation();
    if(block.getType() == FoundDiamondsListener.SEARCH_TYPE && this.foundLocations.add(blockLocation.toString())) {
        int count = 1;
        for(int x = -5; x < 5; ++x) {
            for(int y = -5; y < 5; ++y) {
                for(int z = -5; z < 5; ++z) {
                    final Block otherBlock = blockLocation.clone().add((double) x, (double) y, (double) z).getBlock();
                    if(!otherBlock.equals(block) && otherBlock.getType() == FoundDiamondsListener.SEARCH_TYPE && this.foundLocations.add(otherBlock.getLocation().toString())) {
                        ++count;
                    }
                }
            }
        }
       
        String message;
        for(Player on : Bukkit.getOnlinePlayers()) {
            if(plugin.getFactionManager().getPlayerFaction(player.getUniqueId()) != null) {
                 message = plugin.getFactionManager().getPlayerFaction(player.getUniqueId()).getRelation(on).toChatColour() + player.getName() + ChatColor.GRAY + " has found " + ChatColor.AQUA + count + ChatColor.GRAY + " diamond(s).";
                on.sendMessage(message);
            }else{
                message = ChatColor.AQUA + "[" + ChatColor.GRAY + "♠" + ChatColor.AQUA + "]" + ChatColor.GRAY + " " + ChatColor.AQUA + player.getName() + ChatColor.GRAY + " has just spotted " + ChatColor.BLUE + count + ChatColor.GRAY +" diamonds!";
                on.sendMessage(message);
            }
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:35,代码来源:FoundDiamondsListener.java

示例6: onBreak

import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onBreak(BlockBreakEvent evt) {
    Block source = evt.getBlock();
    Structure s = match(source);
    if (s == null) return;
    
    s.onDestory(evt);
}
 
开发者ID:Recraft,项目名称:Recreator,代码行数:9,代码来源:StructureChangeListener.java

示例7: onBreak

import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@EventHandler
public void onBreak(BlockBreakEvent e) {
	KingdomFactionsPlayer p = PlayerModule.getInstance().getPlayer(e.getPlayer());
	if (e.getBlock() == null)
		return;
	if (!BuildModule.getInstance().isBuilding(e.getBlock()))
		return;
	e.setCancelled(true);
	if (BuildModule.getInstance().getBuilding(e.getBlock()).getNexus().getOwner() == p.getFaction()) {
		p.sendMessage(Messages.getInstance().getPrefix() + "Je kan dit blok niet breken.");
	} else {
		p.sendMessage(Messages.getInstance().getPrefix() + "Je moet de Nexus hebben. Niet dit blok!");
	}
}
 
开发者ID:ThEWiZ76,项目名称:KingdomFactions,代码行数:15,代码来源:BuildingHandleListener.java

示例8: onBlockBreak

import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public final void onBlockBreak(final BlockBreakEvent event) {
    final Block block = event.getBlock();
    final WorldBorder worldBorder = wbHandler.getBorder(block.getWorld());
    if (worldBorder != null && !worldBorder.isInBounds(block)) {
        event.setCancelled(true);
        event.getPlayer().sendMessage(DENY_BUILD);
    }
}
 
开发者ID:Mystiflow,项目名称:WorldBorder,代码行数:10,代码来源:WorldBorderListener.java

示例9: onBlockBreak

import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
	Player player = event.getPlayer();
	if(player.getInventory().getItemInMainHand() == null)
		return;
	if(!player.getInventory().getItemInMainHand().hasItemMeta())
		return;
	if(player.getInventory().getItemInMainHand().getItemMeta().getLore() == null)
		return;
	List<String> lore = player.getInventory().getItemInMainHand().getItemMeta().getLore();
	if(contains(lore,"2x2 Explosion")) {
		if(ConfigFile.isEnchantDisabled(player.getWorld().getName()))
			return;
		BlockFace playerDir = Convert.yawToFace(player.getLocation().getYaw());
		Block block = event.getBlock();
		Block up = block.getRelative(BlockFace.UP);
		Block left = block.getRelative(BlockFace.EAST);
		Block right = block.getRelative(BlockFace.WEST);
		if(playerDir.equals(BlockFace.EAST) || playerDir.equals(BlockFace.WEST)) {
			left = block.getRelative(BlockFace.NORTH);
			right = block.getRelative(BlockFace.SOUTH);
		}
		if(plugin.getWorldGuard().canBuild(player, block)) {
			player.getInventory().addItem(new ItemStack(block.getType()));
			block.setType(Material.AIR);
		}
		if(plugin.getWorldGuard().canBuild(player, up)) {
			player.getInventory().addItem(new ItemStack(up.getType()));
			up.setType(Material.AIR);
		}
		if(plugin.getWorldGuard().canBuild(player, left)) {
			player.getInventory().addItem(new ItemStack(left.getType()));
			left.setType(Material.AIR);
		}
		if(plugin.getWorldGuard().canBuild(player, right)) {
			player.getInventory().addItem(new ItemStack(right.getType()));
			right.setType(Material.AIR);
		}
	}
}
 
开发者ID:benNek,项目名称:AsgardAscension,代码行数:41,代码来源:CustomEnchantsListener.java

示例10: onBlockBreak

import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent e) {
	if (!cm.isAntiChestViewerDupe) {
		return;
	}
	if (e.getBlock() != null && e.getBlock().getState() instanceof InventoryHolder) {
		InventoryHolder inventory = (InventoryHolder) e.getBlock().getState();
		// 如果容器正在使用则不允许被破坏,以防止利用漏洞刷物品
		if (!inventory.getInventory().getViewers().isEmpty()) {
			e.setCancelled(true);
			e.getPlayer().sendMessage(i18n.tr("antiChestViewerDupeMessage"));
		}
	}
}
 
开发者ID:jiongjionger,项目名称:NeverLag,代码行数:15,代码来源:AntiChestViewerDupe.java

示例11: onBlockBreak

import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onBlockBreak(BlockBreakEvent event) {
    if (plugin.getEotwHandler().isEndOfTheWorld())
        return;

    Player player = event.getPlayer();
    if (player.getGameMode() == GameMode.CREATIVE && player.hasPermission(ProtectionListener.PROTECTION_BYPASS_PERMISSION)) {
        return;
    }

    Block block = event.getBlock();
    BlockState state = block.getState();

    Block subclaimObjectBlock = null;
    if (!(state instanceof Sign)) {
        subclaimObjectBlock = block;
    } else {
        Sign sign = (Sign) state;
        MaterialData signData = sign.getData();
        if (signData instanceof org.bukkit.material.Sign) {
            org.bukkit.material.Sign materialSign = (org.bukkit.material.Sign) signData;
            subclaimObjectBlock = block.getRelative(materialSign.getAttachedFace());
        }
    }

    if (subclaimObjectBlock != null && !this.checkSubclaimIntegrity(player, subclaimObjectBlock)) {
        event.setCancelled(true);
        player.sendMessage(ChatColor.RED + "You cannot break this subclaimed " + subclaimObjectBlock.getType().toString() + '.');
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:31,代码来源:SignSubclaimListener.java

示例12: onBreakBlock

import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@EventHandler
public void onBreakBlock(BlockBreakEvent event) {
	Player player = event.getPlayer();
	Block broken = event.getBlock();
	Location geckLocation = broken.getRelative(0, -1, 0).getLocation();

	if (broken.getType() == Material.LEVER) {
		if (main.getGeckObjectManager().getGeckObject(geckLocation) != null) {
			main.getGeckObjectManager().removeGeckLocation(geckLocation);
			player.sendMessage(ChatColor.RED + "GECK disabled.");
		}

	} else if (broken.getType() == Material.SPONGE
			&& main.getGeckObjectManager().getGeckObject(broken.getLocation()) != null) {
		main.getGeckObjectManager().removeGeckLocation(broken.getLocation());
		player.sendMessage(ChatColor.RED + "GECK disabled.");

	} else if (broken.getType() == Material.PISTON_BASE) {
		List<BlockFace> sides = Arrays.asList(BlockFace.EAST, BlockFace.NORTH, BlockFace.WEST, BlockFace.SOUTH);
		sides.forEach(side -> {
			Location bloc = broken.getRelative(side).getLocation();

			if (main.getGeckObjectManager().getGeckObject(bloc) != null) {
				main.getGeckObjectManager().removeGeckLocation(bloc);
				player.sendMessage(ChatColor.RED + "GECK disabled.");
			}
		});
	}
}
 
开发者ID:kadeska,项目名称:MT_Core,代码行数:30,代码来源:GeckPowerListener.java

示例13: onBlockBreak

import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onBlockBreak(final BlockBreakEvent event) {
    Player player = event.getPlayer();
    if (player.getGameMode() != GameMode.CREATIVE) {
        if (player.hasPermission("hcf.listener.autosmeltore")) {
            ItemStack stack = player.getItemInHand();
            if (stack != null && stack.getType() != Material.AIR
                    && !stack.containsEnchantment(Enchantment.SILK_TOUCH)) {
                Block block = event.getBlock();
                Material dropType = null;
                switch (block.getType()) {
                    case IRON_ORE: {
                        dropType = Material.IRON_INGOT;
                        break;
                    }
                    case GOLD_ORE: {
                        dropType = Material.GOLD_INGOT;
                        break;
                    }
                    default: {
                        return;
                    }
                }
                 Location location = block.getLocation();
                 World world = location.getWorld();
                 ItemStack drop = new ItemStack(dropType, 1);
                world.dropItemNaturally(location, drop);
                block.setType(Material.AIR);
                block.getState().update();
            }
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:34,代码来源:AutoSmeltOreListener.java

示例14: onBlockBroken

import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@EventHandler
public void onBlockBroken(BlockBreakEvent e) {
	if (e != null && e.getPlayer() != null && e.getBlock() != null) {
		ChunkHelper.cancelEventIfNotOwned(e.getPlayer(), e.getBlock().getChunk(), e);
	}
}
 
开发者ID:cjburkey01,项目名称:ClaimChunk,代码行数:7,代码来源:CancellableChunkEvents.java

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


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