Java 类org.bukkit.event.block.BlockDamageEvent 实例源码

项目:AntiCheat    文件:OrebfuscatorBlockListener.java   
@EventHandler(priority = EventPriority.MONITOR)
public void onBlockDamage(BlockDamageEvent event) {
    if (event.isCancelled() || !OrebfuscatorConfig.UpdateOnDamage) {
        return;
    }

    if (!BlockUpdate.needsUpdate(event.getBlock())) {
        return;
    }

    if (!BlockHitManager.hitBlock(event.getPlayer(), event.getBlock())) {
        return;
    }

    BlockUpdate.Update(event.getBlock());
}
项目:ProjectAres    文件:EventRuleMatchModule.java   
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void checkBlockDamage(final BlockDamageEvent event) {
    MatchPlayer player = this.match.getParticipant(event.getPlayer());
    if(player == null) return;

    PlayerBlockEventQuery query = new PlayerBlockEventQuery(player, event, event.getBlock().getState());

    for(EventRule rule : this.ruleContext.get(EventRuleScope.BLOCK_BREAK)) {
        if(rule.earlyWarning() && rule.region().contains(event.getBlock())) {
            if(processQuery(rule, query)) {
                if(event.isCancelled() && rule.message() != null) {
                    player.sendWarning(rule.message(), true);
                }
                if(this.useRegionPriority) {
                    break;
                }
            }
        }
    }
}
项目:ProjectAres    文件:DestroyableMatchModule.java   
@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);
        }
    }
}
项目:Cardinal    文件:AppliedModule.java   
/**
 * 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;
    }
  }
}
项目:MinecraftPluginsJava8    文件:BlockChangerFinal.java   
public BlockChangerFinal() {
  Listeners(new Listener() {
    @EventHandler public void onBlockDamage(BlockDamageEvent event) {
      if (blockChangerUsers.containsKey(event.getPlayer())) {
        event.getBlock().setTypeId(blockChangerUsers.get(event.getPlayer()).getId());
      }
    }
  });
  Commands((Command(
      "bc",
      "Hit blocks to change them to the block with type blockId, or just /bc to turn it off.",
      opt(material),
      (p, om) -> om.foldV(
        () -> {
          blockChangerUsers.remove(p);
          p.sendMessage(ChatColor.RED + "BlockChanger has been disabled!");
        },
        m -> {
          blockChangerUsers.put(p, om.get());
            p.sendMessage(ChatColor.BLUE + "BlockChanger using: " + m.name());
        }
      )
  )));
}
项目:AntiCheat-COMPAT    文件:BlockListener.java   
@EventHandler(priority = EventPriority.MONITOR)
public void onBlockDamage(BlockDamageEvent event) {
    Player player = event.getPlayer();
    if (event.getInstaBreak() || Utilities.isInstantBreak(event.getBlock().getType())) {
        getBackend().logInstantBreak(player);
    }
    if (getCheckManager().willCheck(player, CheckType.AUTOTOOL)) {
        CheckResult result = getBackend().checkAutoTool(player);
        if (result.failed()) {
            event.setCancelled(!silentMode());
            log(result.getMessage(), player, CheckType.AUTOTOOL);
        }
    }

    AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
}
项目:PlotSquared    文件:PlotPlusListener.java   
@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();
        }
    }
}
项目:Equestrian-Dash    文件:BlockDamageListener.java   
@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);
        }
    }
}
项目:Core-Bukkit    文件:BukkitQuestManager.java   
@EventHandler
public void onBlockDamageEvent(BlockDamageEvent e) {
    Player p = e.getPlayer();
    long indexof = Managers.getGroupManager().indexOf(Managers.getPlatform().toPlayer(p));
    if (indexof == -1)
        return;
    Group g = Managers.getGroupManager().get(indexof);
    if (g.getQuestStatus() == QuestStatus.INQUEST) {
        Quest q = g.getQuest();
        // by default, I don't allow this to happen.
        e.setCancelled(true);

        // FIXME edits

        e.getPlayer().sendMessage(ChatColor.YELLOW + "[!] " + q.getDetails().getProperty(QuestDetails.QUEST_EDITMESSAGE));
    }
}
项目:TimeGivesYouMoney    文件:BlockListener.java   
@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);
  }
}
项目:AddGun    文件:Guns.java   
/**
 * Prevent using the gun-item to damage blocks (cancels even damaging)
 * @param event the damage event
 */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void preventBlockDamageWithGun(BlockDamageEvent event) {
    if (event.getItemInHand() == null)
        return;

    ItemStack item = event.getItemInHand();
    StandardGun gun = findGun(item);
    if (gun == null) // can't match it
        return;

    event.setCancelled(true);
}
项目:AddGun    文件:RailGun.java   
/**
 * Prevent using the gun-item to damage blocks (cancels even damaging)
 * @param event the damage event
 */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void preventBlockDamageWithGun(BlockDamageEvent event) {
    if (isGun(event.getItemInHand())) {
        event.setCancelled(true);
    }
}
项目:GhostBuster    文件:GhostBusterPlugin.java   
@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);
    }
项目:ProjectAres    文件:CoreMatchModule.java   
@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);
        }
    }
}
项目:SurvivalAPI    文件:HardObsidianModule.java   
/**
 * Set obsidian only breakable by a diamond pickage
 *
 * @param event Event
 */
@EventHandler
public void onBlockDamage(BlockDamageEvent event)
{
    if (event.getBlock().getType() == Material.OBSIDIAN && event.getItemInHand().getType() != Material.DIAMOND_PICKAXE)
        event.setCancelled(true);
}
项目:DynamicAC    文件:BlockListener.java   
@EventHandler
public void onBlockDamage(BlockDamageEvent e) {
    Player player = e.getPlayer();
    if(e.getInstaBreak() || Utilities.isInstantBreak(e.getBlock().getType())) {
        DACManager.getBackend().logInstantBreak(player);
    }
    DACManager.getBackend().checkAutoTool(player);
}
项目:world-of-icerealm    文件:BreakBlockSession.java   
public void onBlockDamage(BlockDamageEvent event) {
    if (event.getBlock().getLocation().equals(_locations)) {
        for (Monster m : _spawnedMonsters) {
            m.setTarget(event.getPlayer());
        }
    }

}
项目:world-of-icerealm    文件:ObsidianMission.java   
@EventHandler(priority = EventPriority.NORMAL)
public void onBlockDamaged(BlockDamageEvent event) {

    for (BreakBlockSession s : _breaks) {
        s.onBlockDamage(event);
    }
}
项目:Skellett    文件:ExprInstaBreak.java   
public boolean init(Expression<?>[] args, int arg1, Kleenean arg2, SkriptParser.ParseResult arg3) {
    if (!ScriptLoader.isCurrentEvent(BlockDamageEvent.class)) {
        Skript.error("You can not use Insta Break expression in any event but on block damage event!");
        return false;
    }
    return true;
}
项目:Skellett    文件:ExprInstaBreak.java   
@Override
public void change(Event e, Object[] delta, Changer.ChangeMode mode){
    if (mode == ChangeMode.SET) {
        ((BlockDamageEvent)e).setInstaBreak(((Boolean)delta[0]));
    }
    if (mode == ChangeMode.RESET) {
        ((BlockDamageEvent)e).setInstaBreak(((BlockDamageEvent)e).getInstaBreak());
    }
}
项目:FastSurvival    文件:FasterObsidian.java   
@EventHandler
public void onBeginBreak(BlockDamageEvent event) {
    event.getPlayer().removePotionEffect(PotionEffectType.SLOW_DIGGING);
    if (event.getBlock().getType() == Material.OBSIDIAN)
        event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, 20000, 2, true, true));
    else
        event.getPlayer().removePotionEffect(PotionEffectType.FAST_DIGGING);
}
项目:beaconz    文件:SkyListeners.java   
/**
 * Protects damage to blocks
 * @param event
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onBlockDamage(BlockDamageEvent event) {
    World world = event.getBlock().getWorld();
    if (!world.equals(getBeaconzWorld())) {
        return;
    }
    Player player = event.getPlayer();
    if (!player.isOp() && event.getBlock().getY() == BLOCK_HEIGHT) {
        event.setCancelled(true);
        event.getPlayer().sendMessage(ChatColor.RED + Lang.errorYouCannotDoThat);
    }
}
项目:PlotSquared-Chinese    文件:PlotPlusListener.java   
@EventHandler(priority = EventPriority.HIGH)
public void onInteract(final BlockDamageEvent event) {
    final Player player = event.getPlayer();
    if (player.getGameMode() != GameMode.SURVIVAL) {
        return;
    }
    final Plot plot = MainUtil.getPlot(BukkitUtil.getLocation(player));
    if (plot == null) {
        return;
    }
    if (FlagManager.isBooleanFlag(plot, "instabreak", false)) {
        event.getBlock().breakNaturally();
    }
}
项目:libelula    文件:ToolBox.java   
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
private void onBlockDamage(BlockDamageEvent e) {
    Player player = e.getPlayer();
    if (assignedTools.containsKey(player)) {
        Tool tool = assignedTools.get(player);
        if (tool.item.equals(player.getItemInHand())) {
            e.setCancelled(true);
            if (tool.type == ToolType.DISCOVERY) {
                plugin.meode.asyncTellBlockInfo(e.getBlock(), player, true);
            }
        }
    }
}
项目:libelula    文件:Listener.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onBlockDamage(BlockDamageEvent e) {
    if (plugin.winner != null) {
        e.setCancelled(true);
        e.getPlayer().sendMessage(ChatColor.YELLOW + "El jugador " + 
        ChatColor.GOLD + plugin.winner + ChatColor.YELLOW + " ha ganado la partida.");
    }
}
项目:Peacecraft    文件:LotsListener.java   
@EventHandler
public void onBlockDamage(BlockDamageEvent event) {
    Lot lot = this.module.getLotManager().getLot(event.getBlock().getLocation());
    Town town = this.module.getLotManager().getTown(event.getBlock().getLocation());
    if(((lot != null && !lot.canBuild(event.getPlayer())) || (lot == null && town != null)) && !event.getPlayer().hasPermission(LotPermissions.BUILD_ANYWHERE)) {
        sendMessage(event.getPlayer(), "lots.cannot-do");
        event.setCancelled(true);
    }
}
项目:MinecraftPluginsJava8    文件:BlockChanger.java   
public void onEnable() {
  getServer().getPluginManager().registerEvents(new Listener (){
    @EventHandler public void onBlockDamage(BlockDamageEvent event) {
      if (blocks.containsKey(event.getPlayer())) {
        event.getBlock().setTypeId(blocks.get(event.getPlayer()).getId());
      }
    }
  }, this);
}
项目:MinecraftPluginsJava8    文件:BlockChangerGoldV2.java   
public void onEnable() {
  register(new Listener(){
    @EventHandler
    public void onBlockDamage(BlockDamageEvent event) {
      event.getBlock().setType(Material.GOLD_BLOCK);
    }
  });
}
项目:MinecraftPluginsJava8    文件:BlockChangerV2.java   
public void onEnable() {
  getServer().getPluginManager().registerEvents(new Listener (){
    @EventHandler public void onBlockDamage(BlockDamageEvent event) {
      if (blocks.containsKey(event.getPlayer())) {
        event.getBlock().setTypeId(blocks.get(event.getPlayer()).getId());
      }
    }
  }, this);
}
项目:PlotMe-Core    文件:BukkitPlotListener.java   
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onBlockDamage(BlockDamageEvent event) {
    Location location = BukkitUtil.adapt(event.getBlock().getLocation());

    if (manager.isPlotWorld(location)) {
        PlotId id = manager.getPlotId(location);

        if (id == null) {
            event.setCancelled(true);
        } else {
            event.setCancelled(api.isPlotLocked(id));

        }
    }
}
项目:Minotaurus    文件:BukkitBlockEvent.java   
@EventHandler(ignoreCancelled = true)
public void onBlockDamage(BlockDamageEvent e) {
    Arena a = ArenaManager.getArena(e.getPlayer());
    if (a == null) return;
    Player p = e.getPlayer();

    if (!p.hasPermission("minotaurus.arena.breakblocks"))
        e.setCancelled(true);
}
项目:sensibletoolbox    文件:AngelicBlock.java   
@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);
}
项目:GoldRushPlugin    文件:Bank.java   
@Override
public void remove() {

    //Abandon all conversations, and nullify map.
    for(Conversation c : conversations.values()) {
        if(!c.getState().equals(Conversation.ConversationState.ABANDONED)) c.abandon();
    }
    conversations = null;

    //Clear all employees, and nullify list.
    for(NPC e : employees) {
        e.destroy();
    }
    employees = null;

    //Nullify the bank area. This may not matter.
    bankArea = null;



    //Unregister all related events to this.
    PlayerMoveEvent.getHandlerList().unregister(this);
    //BlockFinder Class stuff.
    BlockBreakEvent.getHandlerList().unregister(this);
    BlockDamageEvent.getHandlerList().unregister(this);
    BlockPlaceEvent.getHandlerList().unregister(this);

    //Remove bank from the master list of banks.
    banks.remove(this);
}
项目:GoldRushPlugin    文件:Bank.java   
@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);
}
项目:GoldRushPlugin    文件:Mine.java   
@Override
public void remove() {
       removeFromDB(); //Remove from DB.
       PlayerMoveEvent.getHandlerList().unregister(this);
       BlockBreakEvent.getHandlerList().unregister(this);
       BlockDamageEvent.getHandlerList().unregister(this);
       BlockPlaceEvent.getHandlerList().unregister(this);
       mines.remove(this);
}
项目:GoldRushPlugin    文件:TrainStation.java   
@Override
public void remove() {

    //Unregister handlers for events.
    ChunkUnloadEvent.getHandlerList().unregister(this);
    PlayerMoveEvent.getHandlerList().unregister(this);
    MemberBlockChangeEvent.getHandlerList().unregister(this);
    PlayerInteractEvent.getHandlerList().unregister(this);
    //BlockFinder Class stuff.
    BlockPlaceEvent.getHandlerList().unregister(this);
    BlockBreakEvent.getHandlerList().unregister(this);
    BlockDamageEvent.getHandlerList().unregister(this);

    //Remove from the DB.
    removeFromDB();

    //Remove ALL NPC's in the area.
    for(NPC npc : this.workers) CitizensAPI.getNPCRegistry().deregister(npc);

    //Clear sign logic and change signs to air.
    this.signs = null;
    for(Block b : this.trainArea) {
        if(b.getState() instanceof Sign) {
            b.setType(Material.AIR);
        }
    }

    //Clear trains.
    this.departingTrains = null;
    this.trains = null;

    //Clear visitors
    this.visitors = null;

    //Clear name
    this.stationName = null;

    //Remove from the list
    trainStations.remove(this);
}
项目:GoldRushPlugin    文件:TrainStation.java   
@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);
    }
}
项目:NPlugins    文件:BuildFlagListener.java   
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onBlockDamage(final BlockDamageEvent event) {
    final GeneralRegion region = this.getPlugin().getDb().getPriorByLocation(event.getBlock().getLocation());
    if (region != null && region.getFlag(Flag.BUILD) && !region.isUser(event.getPlayer())) {
        event.setCancelled(true);
    }
}
项目:MineKart    文件:BlockListener.java   
/**
 * 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;
        }
    }

}
项目:SpectatorPlus    文件:ArenaSetupListener.java   
/**
 * Used to setup an arena (if the command was sent before by the sender).
 */
@EventHandler
protected void onBlockDamage(BlockDamageEvent ev)
{
    if(handleSetup(ev.getPlayer(), ev.getBlock().getLocation()))
        ev.setCancelled(true);
}