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


Java BlockDamageEvent类代码示例

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


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

示例1: onBlockDamage

import org.bukkit.event.block.BlockDamageEvent; //导入依赖的package包/类
@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());
}
 
开发者ID:SamaGames,项目名称:AntiCheat,代码行数:17,代码来源:OrebfuscatorBlockListener.java

示例2: checkBlockDamage

import org.bukkit.event.block.BlockDamageEvent; //导入依赖的package包/类
@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;
                }
            }
        }
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:21,代码来源:EventRuleMatchModule.java

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

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

示例5: BlockChangerFinal

import org.bukkit.event.block.BlockDamageEvent; //导入依赖的package包/类
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());
        }
      )
  )));
}
 
开发者ID:joshcough,项目名称:MinecraftPluginsJava8,代码行数:25,代码来源:BlockChangerFinal.java

示例6: onBlockDamage

import org.bukkit.event.block.BlockDamageEvent; //导入依赖的package包/类
@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());
}
 
开发者ID:Obsidian-Realm,项目名称:AntiCheat-COMPAT,代码行数:17,代码来源:BlockListener.java

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

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

示例9: onBlockDamageEvent

import org.bukkit.event.block.BlockDamageEvent; //导入依赖的package包/类
@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));
	}
}
 
开发者ID:Minequest,项目名称:Core-Bukkit,代码行数:18,代码来源:BukkitQuestManager.java

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

示例11: preventBlockDamageWithGun

import org.bukkit.event.block.BlockDamageEvent; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:ProgrammerDan,项目名称:AddGun,代码行数:17,代码来源:Guns.java

示例12: preventBlockDamageWithGun

import org.bukkit.event.block.BlockDamageEvent; //导入依赖的package包/类
/**
 * 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);
	}
}
 
开发者ID:ProgrammerDan,项目名称:AddGun,代码行数:11,代码来源:RailGun.java

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

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

示例15: onBlockDamage

import org.bukkit.event.block.BlockDamageEvent; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:12,代码来源:HardObsidianModule.java


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