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


Java BlockDamageEvent.getBlock方法代码示例

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


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

示例1: processBlockDamage

import org.bukkit.event.block.BlockDamageEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void processBlockDamage(BlockDamageEvent event) {
    if(this.match.getWorld() != event.getBlock().getWorld()) return;

    Block block = event.getBlock();
    MaterialData material = block.getState().getData();
    MatchPlayer player = this.match.getPlayer(event.getPlayer());

    for(Destroyable destroyable : this.destroyables) {
        if(player != null &&
           player.getParty() == destroyable.getOwner() &&
           !destroyable.isDestroyed() &&
           destroyable.getBlockRegion().contains(block) &&
           destroyable.hasMaterial(material)) {

            event.setCancelled(true);
            player.sendWarning(new TranslatableComponent("match.destroyable.damageOwn"), true);
        }
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:21,代码来源:DestroyableMatchModule.java

示例2: onBlockDamage

import org.bukkit.event.block.BlockDamageEvent; //导入方法依赖的package包/类
/**
 * Filters BlockDamageEvent, Used for early warnings.
 *
 * <p>Applies to: block and block break<p/>
 */
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onBlockDamage(BlockDamageEvent event) {
  Match match = Cardinal.getMatch(event.getPlayer());
  if (match == null || !match.hasPlayer(event.getPlayer())) {
    return;
  }
  for (AppliedRegion reg : get(match, ApplyType.BLOCK, ApplyType.BLOCK_BREAK)) {
    Block evaluating = event.getBlock();

    if (apply(reg, evaluating.getLocation(), event.getPlayer(), event, event, evaluating, event.getPlayer())) {
      if (event.isCancelled()) {
        event.setCancelled(false);
      }
      break;
    }
  }
}
 
开发者ID:CardinalDevelopment,项目名称:Cardinal,代码行数:23,代码来源:AppliedModule.java

示例3: onInteract

import org.bukkit.event.block.BlockDamageEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGH)
public void onInteract(BlockDamageEvent event) {
    Player player = event.getPlayer();
    if (player.getGameMode() != GameMode.SURVIVAL) {
        return;
    }
    Plot plot = BukkitUtil.getLocation(player).getOwnedPlot();
    if (plot == null) {
        return;
    }
    if (Flags.INSTABREAK.isTrue(plot)) {
        Block block = event.getBlock();
        BlockBreakEvent call = new BlockBreakEvent(block, player);
        Bukkit.getServer().getPluginManager().callEvent(call);
        if (!call.isCancelled()) {
            event.getBlock().breakNaturally();
        }
    }
}
 
开发者ID:IntellectualSites,项目名称:PlotSquared,代码行数:20,代码来源:PlotPlusListener.java

示例4: onDamage

import org.bukkit.event.block.BlockDamageEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGH)
public void onDamage(BlockDamageEvent event)
{

    //plugin.getLogger().info("Clicked block not null confirmed!");
    Block b = event.getBlock();
    if (GarbageControl.DespawningIce.contains(b.getLocation()))
    {
        //plugin.getLogger().info("icePowerupBlock confirmed!");
        if (plugin.getConfig().getBoolean("Powerups.Ice.Breakable"))
        {
            //plugin.getLogger().info("Breakable confirmed!");
            event.setInstaBreak(true);
        }
    }
}
 
开发者ID:ColonelHedgehog,项目名称:Equestrian-Dash,代码行数:17,代码来源:BlockDamageListener.java

示例5: onBlockDamage

import org.bukkit.event.block.BlockDamageEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onBlockDamage(BlockDamageEvent event) {
  Sign sign;
  if (!event.isCancelled()
      && event.getBlock() != null
      && (event.getBlock().getType() == Material.WALL_SIGN || event
          .getBlock().getType() == Material.SIGN_POST)) {
    sign = (Sign) event.getBlock().getState();

    if (sign.getLine(0).equals(
        "" + ChatColor.GRAY + ChatColor.BOLD + "[" + ChatColor.YELLOW + "ATM"
            + ChatColor.GRAY + "]")
        && !tgym.Vault.HasPermissions(event.getPlayer(), "tgym.atm.create"))
      event.setCancelled(true);
  }
}
 
开发者ID:Vild,项目名称:TimeGivesYouMoney,代码行数:17,代码来源:BlockListener.java

示例6: onBlockDamage

import org.bukkit.event.block.BlockDamageEvent; //导入方法依赖的package包/类
@EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true)
    public void onBlockDamage(BlockDamageEvent event){
        if(!active) return;
//        if(event.getPlayer().isOnGround()) return;
//        if(event.getPlayer().isFlying()) return;
        Block block = event.getBlock();
        Bukkit.getScheduler().runTaskLater(this, () -> event.getPlayer().sendBlockChange(block.getLocation(), block.getType(), block.getData()), 3);
    }
 
开发者ID:RypoFalem,项目名称:GhostBuster,代码行数:9,代码来源:GhostBusterPlugin.java

示例7: damageCheck

import org.bukkit.event.block.BlockDamageEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void damageCheck(BlockDamageEvent event) {
    Block block = event.getBlock();
    if(block.getWorld() != this.match.getWorld()) return;
    MatchPlayer player = this.match.getPlayer(event.getPlayer());
    Vector center = BlockUtils.center(block).toVector();

    for(Core core : this.cores) {
        if(!core.hasLeaked() && core.getCasingRegion().contains(center) && player.getParty() == core.getOwner()) {
            event.setCancelled(true);
            player.sendWarning(PGMTranslations.t("match.core.damageOwn", player), true);
        }
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:15,代码来源:CoreMatchModule.java

示例8: onBlockDamage

import org.bukkit.event.block.BlockDamageEvent; //导入方法依赖的package包/类
@Override
public void onBlockDamage(BlockDamageEvent event) {
    // the angelic block has just been hit by a player - insta-break it
    Player p = event.getPlayer();
    Block b = event.getBlock();
    if (SensibleToolbox.getBlockProtection().playerCanBuild(p, b, BlockProtection.Operation.BREAK)) {
        b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType());
        breakBlock(false);
        STBUtil.giveItems(p, toItemStack());
    }
    event.setCancelled(true);
}
 
开发者ID:desht,项目名称:sensibletoolbox,代码行数:13,代码来源:AngelicBlock.java

示例9: onPlayerDamageAttempt

import org.bukkit.event.block.BlockDamageEvent; //导入方法依赖的package包/类
@Override
@EventHandler
public void onPlayerDamageAttempt(BlockDamageEvent event) {
    Player p = event.getPlayer();
    Block b = event.getBlock();

    if(p.hasPermission("goldrushmc.bank.edit")) return;

    if(bankArea.contains(b)) event.setCancelled(true);
}
 
开发者ID:GoldRushMC,项目名称:GoldRushPlugin,代码行数:11,代码来源:Bank.java

示例10: onPlayerDamageAttempt

import org.bukkit.event.block.BlockDamageEvent; //导入方法依赖的package包/类
@Override
@EventHandler
public void onPlayerDamageAttempt(BlockDamageEvent event) {
    Player p = event.getPlayer();
    Block b = event.getBlock();

    //If the block to be damaged is a part of a trainstation types, we cancel it.
    if(this.trainStationBlocks.contains(b)) {
        //If the player has permission to edit the blocks, we are ok with them doing so.
        if(p.hasPermission("goldrushmc.types.edit")) return;
        p.sendMessage(ChatColor.DARK_RED + "You cannot damage this block! it belongs to a trainstation types!");
        event.setCancelled(true);
    }
}
 
开发者ID:GoldRushMC,项目名称:GoldRushPlugin,代码行数:15,代码来源:TrainStation.java

示例11: onBlockDamaged

import org.bukkit.event.block.BlockDamageEvent; //导入方法依赖的package包/类
/**
 * Called when a block is damaged.
 * 
 * @param event The block break event containing information on this event
 */
@EventHandler
public void onBlockDamaged(BlockDamageEvent event) {

	final Block block = event.getBlock();

	Map<String, Racecourse> courses = MineKart.getInstance().getAllRacecourses();
	for (Racecourse course : courses.values()) {
		if (course.isInCourseBounds(block.getLocation())) {
			event.setCancelled(true);
			return;
		}
	}

}
 
开发者ID:CodingBadgers,项目名称:MineKart,代码行数:20,代码来源:BlockListener.java

示例12: onBlockDamage

import org.bukkit.event.block.BlockDamageEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onBlockDamage(BlockDamageEvent event)
{
    Player player = event.getPlayer();
       if(!player.isSneaking()) return;
       
       if(!featureEnabled(Features.QuickDeposit, player)) return;
       
       Block clickedBlock = event.getBlock();
       if(clickedBlock == null) return;
       Material clickedMaterial = clickedBlock.getType();
       
       if(clickedMaterial != Material.CHEST && clickedMaterial != Material.TRAPPED_CHEST) return;
       
       @SuppressWarnings("deprecation")
       PlayerInteractEvent fakeEvent = AutomaticInventory.instance.new FakePlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, player.getItemInHand(), clickedBlock, BlockFace.EAST);
       Bukkit.getServer().getPluginManager().callEvent(fakeEvent);
       if(fakeEvent.isCancelled()) return;
       
       InventoryHolder chest = (InventoryHolder)clickedBlock.getState();
       Inventory chestInventory = chest.getInventory();
       PlayerInventory playerInventory = player.getInventory();
       
       event.setCancelled(true);
       
       @SuppressWarnings("deprecation")
       int aboveBlockID = clickedBlock.getRelative(BlockFace.UP).getTypeId();
       if(AutomaticInventory.preventsChestOpen(aboveBlockID))
       {
           AutomaticInventory.sendMessage(player, TextMode.Err, Messages.ChestLidBlocked);
           return;
       }
       
       DepositRecord deposits = AutomaticInventory.depositMatching(playerInventory, chestInventory, true);
       
       //send confirmation message to player with counts deposited.  if none deposited, give instructions on how to set up the chest.
       if(deposits.destinationFull && deposits.totalItems == 0)
       {
           AutomaticInventory.sendMessage(player, TextMode.Err, Messages.FailedDepositChestFull2);
       }
       else if(deposits.totalItems == 0)
       {
           AutomaticInventory.sendMessage(player, TextMode.Info, Messages.FailedDepositNoMatch);
       }
       else
       {
           AutomaticInventory.sendMessage(player, TextMode.Success, Messages.SuccessfulDeposit2, String.valueOf(deposits.totalItems));
           
           //make a note that quick deposit was used so that player will not be bothered with advertisement messages again.
           PlayerData playerData = PlayerData.FromPlayer(player);
           if(!playerData.isUsedQuickDeposit())
           {
               playerData.setUsedQuickDeposit(true);
           }
       }
}
 
开发者ID:BigScary,项目名称:AutomaticInventory,代码行数:57,代码来源:AIEventHandler.java

示例13: onBeaconDamage

import org.bukkit.event.block.BlockDamageEvent; //导入方法依赖的package包/类
/**
 * Handles damage to, but not breakage of a beacon. Warns players to clear a beacon before
 * capture can occur. See block break event for capture.
 * @param event
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onBeaconDamage(BlockDamageEvent event) {
    if (DEBUG)
        getLogger().info("DEBUG: " + event.getEventName());
    World world = event.getBlock().getWorld();
    if (!world.equals(getBeaconzWorld())) {
        return;
    }
    Player player = event.getPlayer();
    // Only Ops can break or place blocks in the lobby
    if (getGameMgr().isPlayerInLobby(player)) {
        if (player.isOp()) {
            return;
        } else {
            event.setCancelled(true);
            return;
        }
    }

    // Get the player's team
    Team team = getGameMgr().getPlayerTeam(player);
    if (team == null) {
        if (player.isOp()) {
            return;
        } else {
            event.setCancelled(true);
            return;
        }
    }

    // Check if the block is a beacon or the surrounding pyramid
    Block block = event.getBlock();
    BeaconObj beacon = getRegister().getBeacon(block);
    if (beacon == null) {
        return;
    }
    // Check that the integrity of the beacon is sound
    beacon.checkIntegrity();
    // Check for obsidian/glass breakage - i.e., capture
    if (block.getRelative(BlockFace.DOWN).getType().equals(Material.BEACON)) {
        // Check if this is a real beacon
        if (getRegister().isBeacon(block.getRelative(BlockFace.DOWN))) {
            // It is a real beacon
            // Check that the beacon is clear of blocks
            if (!beacon.isClear() && (beacon.getOwnership() == null || !beacon.getOwnership().equals(team))) {
                // You can't capture an uncleared beacon
                player.sendMessage(ChatColor.GOLD + Lang.errorClearAroundBeacon);
                event.setCancelled(true);
                return;
            }
        }
    } else {
        // Attempt to break another part of the beacon
    }

}
 
开发者ID:tastybento,项目名称:beaconz,代码行数:62,代码来源:BeaconCaptureListener.java

示例14: onBeaconDamage

import org.bukkit.event.block.BlockDamageEvent; //导入方法依赖的package包/类
/**
 * Handles damage to, but not breakage of a beacon. Warns players to clear a beacon before
 * capture can occur. See block break event for capture.
 * @param event
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onBeaconDamage(BlockDamageEvent event) {
    if (DEBUG)
        getLogger().info("DEBUG: " + event.getEventName());
    World world = event.getBlock().getWorld();
    if (!world.equals(getBeaconzWorld())) {
        return;
    }
    Player player = event.getPlayer();
    // Only Ops can break or place blocks in the lobby
    if (getGameMgr().isPlayerInLobby(player)) {
        if (player.isOp()) {
            return;
        } else {
            event.setCancelled(true);
            return;
        }
    }

    // Get the player's team
    Team team = getGameMgr().getPlayerTeam(player);
    if (team == null) {
        if (player.isOp()) {
            return;
        } else {
            event.setCancelled(true);
            return;
        }
    }

    // Check if the block is a beacon or the surrounding pyramid
    Block block = event.getBlock();
    BeaconObj beacon = getRegister().getBeacon(block);
    if (beacon == null) {
        return;
    }
    // Check for obsidian/glass breakage - i.e., capture
    if (block.getRelative(BlockFace.DOWN).getType().equals(Material.BEACON)) {
        // Check if this is a real beacon
        if (getRegister().isBeacon(block.getRelative(BlockFace.DOWN))) {
            // It is a real beacon
            // Check that the beacon is clear of blocks
            if (!beacon.isClear() && (beacon.getOwnership() == null || !beacon.getOwnership().equals(team))) {
                // You can't capture an uncleared beacon
                player.sendMessage(ChatColor.GOLD + Lang.errorClearAroundBeacon);
                event.setCancelled(true);
                return;
            }
        }
    } else {
        // Attempt to break another part of the beacon
    }

}
 
开发者ID:tastybento,项目名称:beaconz,代码行数:60,代码来源:BeaconProtectionListener.java

示例15: onBlockDamageHigher

import org.bukkit.event.block.BlockDamageEvent; //导入方法依赖的package包/类
/**
 * Handle BlockDamage events where the event is modified.
 *
 * @param event The event to modify
 */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockDamageHigher(BlockDamageEvent event) {
    if (event instanceof FakeBlockDamageEvent) {
        return;
    }

    Player player = event.getPlayer();

    if (!UserManager.hasPlayerDataKey(player)) {
        return;
    }

    McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
    ItemStack heldItem = player.getItemInHand();
    Block block = event.getBlock();
    BlockState blockState = block.getState();

    /*
     * ABILITY TRIGGER CHECKS
     *
     * We don't need to check permissions here because they've already been checked for the ability to even activate.
     */
    if (mcMMOPlayer.getAbilityMode(AbilityType.GREEN_TERRA) && BlockUtils.canMakeMossy(blockState)) {
        if (mcMMOPlayer.getHerbalismManager().processGreenTerra(blockState)) {
            blockState.update(true);
        }
    }
    else if (mcMMOPlayer.getAbilityMode(AbilityType.BERSERK) && heldItem.getType() == Material.AIR) {
        if (AbilityType.BERSERK.blockCheck(block.getState()) && EventUtils.simulateBlockBreak(block, player, true)) {
            event.setInstaBreak(true);
            player.playSound(block.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
        }
        else if (mcMMOPlayer.getUnarmedManager().canUseBlockCracker() && BlockUtils.affectedByBlockCracker(blockState) && EventUtils.simulateBlockBreak(block, player, true)) {
            if (mcMMOPlayer.getUnarmedManager().blockCrackerCheck(blockState)) {
                blockState.update();
            }
        }
    }
    else if (mcMMOPlayer.getWoodcuttingManager().canUseLeafBlower(heldItem) && BlockUtils.isLeaves(blockState) && EventUtils.simulateBlockBreak(block, player, true)) {
        event.setInstaBreak(true);
        player.playSound(blockState.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
    }
}
 
开发者ID:Pershonkey,项目名称:McMMOPlus,代码行数:49,代码来源:BlockListener.java


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