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


Java BlockPlaceEvent.isCancelled方法代码示例

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


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

示例1: PlaceCheckDoor

import org.bukkit.event.block.BlockPlaceEvent; //导入方法依赖的package包/类
@EventHandler
 public void PlaceCheckDoor(BlockPlaceEvent e) {
     if(ConfigPatch.AntiInfSuagrenable){
if(e.isCancelled()){
	Player p = e.getPlayer();
             List<Entity> entities = p.getNearbyEntities(2, 2, 2);
             for(int i=0;i<entities.size();i++){
                 Entity ent = entities.get(i);
                 if(ent.getType() == EntityType.DROPPED_ITEM){
                     Item item = (Item)ent;
                     if(item.getItemStack().getType() == Material.SUGAR_CANE||item.getItemStack().getType() == Material.CACTUS){
                         ent.remove();
                     }
                 }
             }
}
     }
 }
 
开发者ID:GelandiAssociation,项目名称:EscapeLag,代码行数:19,代码来源:AntiInfSuagr.java

示例2: ignite

import org.bukkit.event.block.BlockPlaceEvent; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public boolean ignite(Player igniter, Location loc, IgniteCause cause) {
    Random rand = new Random();

    loc.add(0.5, 0.5, 0.5);
    
    BlockIgniteEvent igniteEvent = new BlockIgniteEvent(loc.getBlock(), 
            cause, (org.bukkit.entity.Entity) igniter);
    Bukkit.getServer().getPluginManager().callEvent(igniteEvent);
    if (igniteEvent.isCancelled()) {
        return false;
    }
 
    BlockState blockState = loc.getBlock().getState();
 
    BlockPlaceEvent placeEvent = new BlockPlaceEvent(loc.getBlock(), 
            blockState, loc.getBlock(), igniter.getItemInHand(), igniter, true);
    Bukkit.getServer().getPluginManager().callEvent(placeEvent);
 
    if (placeEvent.isCancelled() || !placeEvent.canBuild()) {
        placeEvent.getBlockPlaced().setTypeIdAndData(0, (byte) 0, false);
        return false;
    }

    loc.getWorld().playSound(loc, Sound.ITEM_FLINTANDSTEEL_USE, 1.0F, rand.nextFloat() * 0.4F + 0.8F);
    loc.getBlock().setType(Material.FIRE);
    
    return true;
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:30,代码来源:FirestrikerClick.java

示例3: onBlockBreak

import org.bukkit.event.block.BlockPlaceEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = false, priority = EventPriority.MONITOR)
public void onBlockBreak(BlockPlaceEvent event) {
    if (event.isCancelled()) {
        Player player = event.getPlayer();
        if (player.getGameMode() == GameMode.CREATIVE || player.getAllowFlight()) {
            return;
        }

        Block block = event.getBlockPlaced();
        if (block.getType().isSolid() && !(block.getState() instanceof Sign)) {
            int playerY = player.getLocation().getBlockY();
            int blockY = block.getLocation().getBlockY();
            if (playerY > blockY) {
                Vector vector = player.getVelocity();
                vector.setX(-0.1);
                vector.setZ(-0.1);
                player.setVelocity(vector.setY(vector.getY() - 0.41999998688697815D)); // Magic number acquired from EntityLiving#bj()
            }
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:22,代码来源:BlockJumpGlitchFixListener.java

示例4: onPlace

import org.bukkit.event.block.BlockPlaceEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlace(BlockPlaceEvent 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);
}
 
开发者ID:Soldier233,项目名称:ArchersBattle,代码行数:17,代码来源:WorldListener.java

示例5: onPlace

import org.bukkit.event.block.BlockPlaceEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlace(BlockPlaceEvent e) {
	if (e.isCancelled()) {
		return;
	}
	if (!e.getBlock().getType().equals(Material.CAULDRON)) {
		return;
	}
	Block b = e.getBlock();
	Location loc = b.getLocation();
	loc.setY(loc.getY() + 1);
	Block upon = loc.getBlock();
	if (upon.getType().equals(Material.AIR)) {
		return;
	}
	e.setCancelled(true);
	e.getPlayer().sendMessage(Messages.getMessages().getNoPlace().replace("&", "§"));
}
 
开发者ID:Soldier233,项目名称:SlimefunBugFixer,代码行数:19,代码来源:Listeners.java

示例6: onPlace

import org.bukkit.event.block.BlockPlaceEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlace(BlockPlaceEvent e) {
	KingdomFactionsPlayer p = PlayerModule.getInstance().getPlayer(e.getPlayer());
	if(p.hasBuildAction()) e.setCancelled(true);
	if(p.isVanished()) return;
	if(e.isCancelled()) return;
	if(!p.canBuild(e.getBlock().getLocation())) {
		e.setCancelled(!ProtectionModule.getInstance().tryInfluence(p, 200, e.getBlock()));
		
	} 
}
 
开发者ID:ThEWiZ76,项目名称:KingdomFactions,代码行数:12,代码来源:BuildEventListener.java

示例7: ignite

import org.bukkit.event.block.BlockPlaceEvent; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public boolean ignite(Player igniter, Location loc, IgniteCause cause) {
    Random rand = new Random();

    loc.add(0.5, 0.5, 0.5);
    
    BlockIgniteEvent igniteEvent = new BlockIgniteEvent(loc.getBlock(), 
            cause, (org.bukkit.entity.Entity) igniter);
    Bukkit.getServer().getPluginManager().callEvent(igniteEvent);
    if (igniteEvent.isCancelled()) {
        return false;
    }
    
    List<Location> locations = new ArrayList<Location>();
    
    for(double x = loc.getX() - 2;x <= loc.getX() + 2;x++)
    {
    	for(double y = loc.getY() - 1;y <= loc.getY() + 1;y++)
    	{
    		for(double z = loc.getZ() - 2;z <= loc.getZ() + 2;z++)
    		{
    			locations.add(new Location(loc.getWorld(),x,y,z));
    		}
    	}
    }
    
    for(Location l : locations)
    {
	    BlockIgniteEvent igniteEvent2 = new BlockIgniteEvent(l.getBlock(), 
	            cause, (org.bukkit.entity.Entity) igniter);
	    Bukkit.getServer().getPluginManager().callEvent(igniteEvent2);
	    if (igniteEvent2.isCancelled()) {
	        continue;
	    }
	    
	    BlockState blockState = l.getBlock().getState();
	    
	    BlockPlaceEvent placeEvent = new BlockPlaceEvent(l.getBlock(), 
	            blockState, l.getBlock(), igniter.getItemInHand(), igniter, true);
	    Bukkit.getServer().getPluginManager().callEvent(placeEvent);
	    
	    if (placeEvent.isCancelled() || !placeEvent.canBuild()) {
	        continue;
	    }
    	
    	if(l.getBlock() == null || l.getBlock().getType() == Material.AIR)
    		l.getBlock().setType(Material.FIRE);
    }

   	loc.getWorld().playSound(loc, Sound.ITEM_FIRECHARGE_USE, 1.0F, rand.nextFloat() * 0.4F + 0.8F);
    
    return true;
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:54,代码来源:BlazeSword.java

示例8: handle

import org.bukkit.event.block.BlockPlaceEvent; //导入方法依赖的package包/类
@Override
public void handle( ConnectionHandler connectionHandler, MessageC1FBlockPlacement message ) {
    FlexPlayer player = connectionHandler.getPlayer();
    synchronized ( player.getInventory() ) {
        int heldSlot = player.getHeldItemSlot();
        ItemStack stack = player.getInventory().getItem( heldSlot );
        if( stack != null ) {
            stack.setAmount( stack.getAmount() - 1 );
            if( stack.getAmount() <= 0 ) {
                stack = null;
            } else {
                ItemStack itemInHand = player.getItemInHand();
                Vector3i position = message.getPosition();
                switch ( message.getFace()  ) {
                    case 0:
                        position.modify( 0,-1,0 );
                        break;
                    case 1:
                        position.modify( 0, 1, 0 );
                        break;
                    case 2:
                        position.modify( 0, 0, -1 );
                        break;
                    case 3:
                        position.modify( 0, 0, 1 );
                        break;
                    case 4:
                        position.modify( -1, 0, 0 );
                        break;
                    case 5:
                        position.modify( 1, 0, 0 );
                        break;
                    default:
                        return;
                }
                BlockPlaceEvent event = new BlockPlaceEvent( player.getWorld().getBlock0( position.getX(), position.getY(), position.getZ(), true ), null, null, itemInHand, player, true, EquipmentSlot.HAND );
                BlockState pr = new BlockState( event.getBlock().getType(), event.getBlock().getData() );
                EventFactory.call( event );
                if( !event.isCancelled() && event.canBuild() ) {
                    player.getWorld().setBlock( position, new BlockState( stack.getType(), stack.getDurability() ) );
                } else {
                    player.getWorld().setBlock( position, pr );
                }
            }
        }
        player.getInventory().setItem( heldSlot, stack );
    }
}
 
开发者ID:lukas81298,项目名称:FlexMC,代码行数:49,代码来源:BlockPlaceListener.java


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