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


Java BlockBreakEvent.setCancelled方法代码示例

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


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

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

示例2: onBlockBreak

import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
/**
 * Prevents blocks from being broken
 *
 * @param e
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onBlockBreak(final BlockBreakEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
    }
    if (Settings.allowAutoActivator && e.getPlayer().getName().equals("[CoFH]")) {
        return;
    }
    if (Util.inWorld(e.getPlayer())) {
        if (actionAllowed(e.getPlayer(), e.getBlock().getLocation(), SettingsFlag.BREAK_BLOCKS)) {
            return;
        }
        // Everyone else - not allowed
        Util.sendMessage(e.getPlayer(), plugin.getLocale(e.getPlayer().getUniqueId()).get("island.protected"));
        e.setCancelled(true);
    }
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:23,代码来源:IslandGuard.java

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

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

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

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

示例7: onBlockBreak

import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
    ArcadiaAPI api = Arcadia.getPlugin(Arcadia.class).getAPI();
    if(!api.getGameManager().isAlive(event.getPlayer())) event.setCancelled(true);
    if(api.getGameManager().getCurrentGame() != null) {
        MaterialData materialData = new MaterialData(event.getBlock().getType(), event.getBlock().getData());
        if(!api.getGameManager().getCurrentGame().breakableBlocks.contains(materialData)) {
            event.setCancelled(true);
        }
    }
}
 
开发者ID:ArcadiaPlugins,项目名称:Arcadia-Spigot,代码行数:12,代码来源:WorldListener.java

示例8: onBlockBreak

import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@EventHandler
public void onBlockBreak(BlockBreakEvent event){
    if (event.getBlock().getLocation().equals(Main.getCrateChestLocation()) || event.getBlock().getLocation().equals(Main.getVoteCrateChestLocation()) || event.getBlock().getLocation().equals(Main.getReleaseCrateChestLocation())){
        event.setCancelled(true);
        event.getPlayer().sendMessage(ChatColor.RED + "You can not break this block!");
    }
}
 
开发者ID:Warvale,项目名称:Scorch,代码行数:8,代码来源:BlockListener.java

示例9: onBlockPlace

import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
/**
 * Disable block breaking near chest
 *
 * @param event Block break event instance
 */
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onBlockPlace(BlockBreakEvent event)
{
    if (event.getBlock().getLocation().getWorld().equals(this.chestLocation.getWorld())
            && event.getBlock().getLocation().distanceSquared(this.chestLocation) < 25)
    {
        event.setCancelled(true);
        event.getPlayer().sendMessage(ChatColor.RED + "Il n'est pas possible de casser de blocs à proximité du coffre des minerais.");
    }
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:16,代码来源:RiskyRetrievalModule.java

示例10: onBreakBlock

import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@EventHandler
public void onBreakBlock(BlockBreakEvent event) {
	List<Material> list = new ArrayList<Material>();
	list.add(Material.RED_MUSHROOM);
	list.add(Material.BROWN_MUSHROOM);
	list.add(Material.YELLOW_FLOWER);
	list.add(Material.RED_ROSE);
	list.add(Material.LEAVES);
	list.add(Material.LONG_GRASS);
	list.add(Material.WEB);
	if (!list.contains(event.getBlock().getType()))
		event.setCancelled(true);
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:14,代码来源:GameEvents.java

示例11: onBlockPlaceCreative

import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onBlockPlaceCreative(BlockBreakEvent event) {
	Player player = event.getPlayer();
	if (player.getGameMode() == GameMode.CREATIVE && !player.hasPermission("base.command.gamemode")) {
		event.setCancelled(true);
		player.sendMessage(ChatColor.RED + "You are not allowed to be in gamemode! Setting you to default gamemode!");
		player.setGameMode(GameMode.SURVIVAL);
	}
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:10,代码来源:CreativeClickListener.java

示例12: onBlockBreakCreative

import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onBlockBreakCreative(BlockBreakEvent event) {
    Player player = event.getPlayer();
    if (player.getGameMode() == GameMode.CREATIVE && !player.hasPermission("base.command.gamemode")) {
        event.setCancelled(true);
        player.sendMessage(ChatColor.RED + "You are not allowed to be in gamemode! Setting you to default gamemode!");
        player.setGameMode(GameMode.SURVIVAL);
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:10,代码来源:CreativeClickListener.java

示例13: onPortalDestroy

import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@EventHandler
public void onPortalDestroy(BlockBreakEvent e) {
	if (e.getBlock() == null)
		return;
	if(e.getBlock().getType() == Material.PORTAL) {
		if(!e.getPlayer().isOp()) {
			e.setCancelled(true);
		}
	}
}
 
开发者ID:ThEWiZ76,项目名称:KingdomFactions,代码行数:11,代码来源:PortalTravelEventListener.java

示例14: onBlockBreak

import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGH)
public void onBlockBreak(BlockBreakEvent event) {
	Player p = event.getPlayer();
	if ( PermissionInterface.CheckEnabledWorld(p.getLocation())) {
		Block checkBlock;
		checkBlock = event.getBlock();
		int craftBlockId = checkBlock.getTypeId();

		Craft checkCraft = Craft.getCraft(checkBlock.getX(), checkBlock.getY(), checkBlock.getZ());

		if (checkCraft != null) {
			if ((craftBlockId == 46) && (p.getGameMode() != GameMode.CREATIVE)) {
				p.sendMessage(ChatColor.RED + "Can't break vehicle TNT.");
				event.setCancelled(true);
				return;
			} else if ((craftBlockId == 75) || (craftBlockId == 76) || (craftBlockId == 65) || (craftBlockId == 68) || (craftBlockId == 63) || (craftBlockId == 69) || (craftBlockId == 77) || (craftBlockId == 70) || (craftBlockId == 72) || (craftBlockId == 55) || (craftBlockId == 143) || (craftBlockId == 64) || (craftBlockId == 71)) {
				int arrayX = checkBlock.getX() - checkCraft.minX;
				int arrayY = checkBlock.getY() - checkCraft.minY;
				int arrayZ = checkBlock.getZ() - checkCraft.minZ;
				checkCraft.matrix[arrayX][arrayY][arrayZ] = -1;

				if (((craftBlockId == 64) && (checkBlock.getRelative(BlockFace.UP).getTypeId() == 64)) || ((craftBlockId == 71) && (checkBlock.getRelative(BlockFace.UP).getTypeId() == 71))) {
					checkBlock.getRelative(BlockFace.UP).setTypeId(0);
					checkCraft.matrix[arrayX][arrayY + 1][arrayZ] = -1;
				}
				if (((craftBlockId == 64) && (checkBlock.getRelative(BlockFace.DOWN).getTypeId() == 64)) || ((craftBlockId == 71) && (checkBlock.getRelative(BlockFace.DOWN).getTypeId() == 71))) {
					checkBlock.getRelative(BlockFace.DOWN).setTypeId(0);
					checkCraft.matrix[arrayX][arrayY - 1][arrayZ] = -1;
				}
				for (DataBlock complexBlock : checkCraft.complexBlocks) {
					if (complexBlock.locationMatches(arrayX, arrayY, arrayZ)) {
						checkCraft.complexBlocks.remove(complexBlock);
						break;
					}
				}
				for (DataBlock dataBlock : checkCraft.dataBlocks) {
					if (dataBlock.locationMatches(arrayX, arrayY, arrayZ)) {
						checkCraft.dataBlocks.remove(dataBlock);
						break;
					}
				}
			}
		}
	}
}
 
开发者ID:Maximuspayne,项目名称:NavyCraft2-Lite,代码行数:46,代码来源:NavyCraft_BlockListener.java

示例15: onBlockBreak

import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
	if (!event.getPlayer().hasPermission("mclink.build"))
		event.setCancelled(true);
}
 
开发者ID:GigaGamma,项目名称:McLink,代码行数:6,代码来源:BlockProtect.java


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