本文整理汇总了Java中org.bukkit.event.block.BlockBreakEvent.isCancelled方法的典型用法代码示例。如果您正苦于以下问题:Java BlockBreakEvent.isCancelled方法的具体用法?Java BlockBreakEvent.isCancelled怎么用?Java BlockBreakEvent.isCancelled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.block.BlockBreakEvent
的用法示例。
在下文中一共展示了BlockBreakEvent.isCancelled方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onBlockBreak
import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onBlockBreak(BlockBreakEvent event)
{
if(event.isCancelled()) return;
if(Survival.allowedBlocks.contains(event.getBlock().getType()))
{
ArmorStand drop = dropSeat(event.getBlock(), (Stairs)event.getBlock().getState().getData());
for(Entity e : drop.getNearbyEntities(0.5, 0.5, 0.5))
{
if(e != null && e instanceof ArmorStand && e.getCustomName() == "Chair")
e.remove();
}
drop.remove();
}
}
示例2: onBreak
import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@EventHandler
public void onBreak(BlockBreakEvent e) {
if (e.isCancelled()) {
return;
}
if (!Utils.isInArena(e.getPlayer())) {
return;
}
if (!Utils.isArenaWorld(e.getBlock().getWorld())) {
return;
}
if (e.getPlayer().isOp()) {
return;
}
e.setCancelled(true);
}
示例3: onBlockBreak
import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void onBlockBreak(BlockBreakEvent event) {
if (event.isCancelled()) {
return;
}
BlockUpdate.Update(event.getBlock());
BlockHitManager.breakBlock(event.getPlayer(), event.getBlock());
}
示例4: onBreak
import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@EventHandler
public void onBreak(BlockBreakEvent e) {
if (e.getBlock() == null)
return;
KingdomFactionsPlayer p = PlayerModule.getInstance().getPlayer(e.getPlayer());
if(p.hasBuildAction()) e.setCancelled(true);
if(p.isVanished()) return;
if(e.isCancelled()) return;
if(NexusModule.getInstance().isNexus(e.getBlock().getLocation())) return;
if(!p.canBuild(e.getBlock().getLocation())) {
e.setCancelled(!ProtectionModule.getInstance().tryInfluence(p, 200, e.getBlock()));
}
}
示例5: isProtected
import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
/**
* Is the given location protected to the given player?
* @param player
* @param loc
* @return protected
*/
public static boolean isProtected(Player player, Location loc) {
BlockBreakEvent evt = new BlockBreakEvent(loc.getBlock(), player);
evt.setDropItems(false);
Bukkit.getPluginManager().callEvent(evt);
return evt.isCancelled();
}
示例6: onBreakSnow
import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.HIGHEST)
public void onBreakSnow(BlockBreakEvent e)
{
if(e.isCancelled()) return;
Player player = e.getPlayer();
if(player.getGameMode() == GameMode.SURVIVAL || player.getGameMode() == GameMode.ADVENTURE)
{
ItemStack mainItem = player.getInventory().getItemInMainHand();
switch(mainItem.getType())
{
case WOOD_SPADE:
case GOLD_SPADE:
case STONE_SPADE:
case DIAMOND_SPADE:
case IRON_SPADE:
Block block = e.getBlock();
switch(block.getType())
{
case SNOW:
e.setCancelled(true);
mainItem.setDurability((short) (mainItem.getDurability() + 1));
if(mainItem.getDurability() >= mainItem.getType().getMaxDurability() + 1)
player.getInventory().setItemInMainHand(null);
player.updateInventory();
block.getWorld().dropItemNaturally(block.getLocation(), new ItemStack(Material.SNOW_BALL, block.getData() + 1));
block.setType(Material.AIR);
break;
case SNOW_BLOCK:
e.setCancelled(true);
mainItem.setDurability((short) (mainItem.getDurability() + 1));
if(mainItem.getDurability() >= mainItem.getType().getMaxDurability() + 1)
player.getInventory().setItemInMainHand(null);
player.updateInventory();
block.getWorld().dropItemNaturally(block.getLocation(), new ItemStack(Material.SNOW_BALL, 8));
block.setType(Material.AIR);
break;
default:
}
break;
default:
}
}
}
示例7: onBreakWorkbench
import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onBreakWorkbench(BlockBreakEvent e)
{
if(e.isCancelled()) return;
Block workbench = e.getBlock();
if (!workbench.hasMetadata("shared_players") || workbench.getType() != Material.WORKBENCH)
return;
@SuppressWarnings("unchecked")
List<UUID> list = (workbench.getMetadata("shared_players").get(0).value() instanceof List<?>) ? (List<UUID>)workbench.getMetadata("shared_players").get(0).value() : new ArrayList<UUID>();
Iterator<UUID> iterator = list.iterator();
Inventory sharedInventory = Bukkit.createInventory(null, InventoryType.WORKBENCH);
while (iterator.hasNext())
{
UUID next = iterator.next();
iterator.remove();
final Player idPlayer = Bukkit.getPlayer(next);
if (idPlayer != null)
{
idPlayer.removeMetadata("shared_inv", Survival.instance);
if(idPlayer.isOnline())
{
final Inventory open = idPlayer.getOpenInventory().getTopInventory();
if (open != null && open.getType() == InventoryType.WORKBENCH)
{
sharedInventory.setContents(open.getContents());
open.clear();
idPlayer.closeInventory();
}
}
}
}
for(int i = 1; i < sharedInventory.getSize(); i++)
{
ItemStack item = sharedInventory.getItem(i);
if(item != null)
workbench.getWorld().dropItem(workbench.getLocation(), item);
}
workbench.removeMetadata("shared_players", Survival.instance);
}
示例8: onBlockBreak
import org.bukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = false, priority = EventPriority.MONITOR)
public void onBlockBreak(BlockBreakEvent event) {
if (event.isCancelled() && NON_TRANSPARENT_ATTACK_BREAK_TYPES.contains(event.getBlock().getType())) {
cancelAttackingMillis(event.getPlayer().getUniqueId(), THRESHOLD);
}
}