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


Java BlockDamageEvent.getPlayer方法代碼示例

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


在下文中一共展示了BlockDamageEvent.getPlayer方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

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

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

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

示例4: onBlockDamage

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

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

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

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

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

import org.bukkit.event.block.BlockDamageEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.LOWEST)
public void blockDamage(BlockDamageEvent e) {
    if (this.blacklist.contains(e.getPlayer().getWorld().getName()))
        return;

    Player player = e.getPlayer();
    if (SkyApi.getLobbyManager().isInLobby(player) && !VaultManager.getInstance().perms.has(player, "ssba.admin.breakblocks")) {
        e.setCancelled(true);
        player.addPotionEffect(pe, true);
        player.addPotionEffect(ps);
        // player.sendMessage(SCB.MM.getErrorMessage("listeners.blockbreak.lobbyBreak"));

    }
}
 
開發者ID:Relicum,項目名稱:SuperSkyBros,代碼行數:15,代碼來源:BlockDamage.java

示例12: blockDamages

import org.bukkit.event.block.BlockDamageEvent; //導入方法依賴的package包/類
public void blockDamages(BlockDamageEvent e) {
    if (this.blacklist.contains(e.getPlayer().getWorld().getName()))
        return;

    Player player = e.getPlayer();
    if (SkyApi.getLobbyManager().isInLobby(player) && !VaultManager.getInstance().perms.has(player, "ssba.admin.breakblocks")) {
        e.setCancelled(true);
        player.addPotionEffect(pe);
        player.sendMessage(SkyApi.getMessageManager().getErrorMessage("listeners.blockbreak.lobbyBreak"));
        return;
    }
}
 
開發者ID:Relicum,項目名稱:SuperSkyBros,代碼行數:13,代碼來源:BlockDamage.java

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

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

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


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