當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。