當前位置: 首頁>>代碼示例>>Java>>正文


Java BlockDamageEvent.setCancelled方法代碼示例

本文整理匯總了Java中org.bukkit.event.block.BlockDamageEvent.setCancelled方法的典型用法代碼示例。如果您正苦於以下問題:Java BlockDamageEvent.setCancelled方法的具體用法?Java BlockDamageEvent.setCancelled怎麽用?Java BlockDamageEvent.setCancelled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.event.block.BlockDamageEvent的用法示例。


在下文中一共展示了BlockDamageEvent.setCancelled方法的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: 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

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

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

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

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

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

示例10: onBlockDamage

import org.bukkit.event.block.BlockDamageEvent; //導入方法依賴的package包/類
/**
 * 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);
    }
}
 
開發者ID:tastybento,項目名稱:beaconz,代碼行數:17,代碼來源:SkyListeners.java

示例11: onBlockDamage

import org.bukkit.event.block.BlockDamageEvent; //導入方法依賴的package包/類
@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);
            }
        }
    }
}
 
開發者ID:ddonofrio,項目名稱:libelula,代碼行數:14,代碼來源:ToolBox.java

示例12: onBlockDamage

import org.bukkit.event.block.BlockDamageEvent; //導入方法依賴的package包/類
@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.");
    }
}
 
開發者ID:ddonofrio,項目名稱:libelula,代碼行數:9,代碼來源:Listener.java

示例13: onBlockDamage

import org.bukkit.event.block.BlockDamageEvent; //導入方法依賴的package包/類
@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);
    }
}
 
開發者ID:Steveice10,項目名稱:Peacecraft,代碼行數:10,代碼來源:LotsListener.java

示例14: onBlockDamage

import org.bukkit.event.block.BlockDamageEvent; //導入方法依賴的package包/類
@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));

        }
    }
}
 
開發者ID:WorldCretornica,項目名稱:PlotMe-Core,代碼行數:16,代碼來源:BukkitPlotListener.java

示例15: onBlockDamage

import org.bukkit.event.block.BlockDamageEvent; //導入方法依賴的package包/類
@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);
}
 
開發者ID:BossLetsPlays,項目名稱:Minotaurus,代碼行數:10,代碼來源:BukkitBlockEvent.java


注:本文中的org.bukkit.event.block.BlockDamageEvent.setCancelled方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。