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


Java BlockCanBuildEvent.isBuildable方法代码示例

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


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

示例1: onBlockCanBuild

import org.bukkit.event.block.BlockCanBuildEvent; //导入方法依赖的package包/类
@EventHandler
protected void onBlockCanBuild(BlockCanBuildEvent e) {
	if (!e.isBuildable()) {
		Location blockL = e.getBlock().getLocation(); 
		
		boolean allowed = false; 
		
		for (Player target : SkyWarsReloaded.get().getServer().getOnlinePlayers()) {
			if (target.getWorld().equals(e.getBlock().getWorld()) && SkyWarsReloaded.getPC().getPlayer(target.getUniqueId()).isSpectating()) { 
				Location playerL = target.getLocation();
				
				if (playerL.getX() > blockL.getBlockX()-1 && playerL.getX() < blockL.getBlockX()+1) {
					if (playerL.getZ() > blockL.getBlockZ()-1 && playerL.getZ() < blockL.getBlockZ()+1) { 
						if (playerL.getY() > blockL.getBlockY()-2 && playerL.getY() < blockL.getBlockY()+1) {
							if (SkyWarsReloaded.getPC().getPlayer(target.getUniqueId()).isSpectating()) {
								allowed = true;
								target.teleport(e.getBlock().getLocation().add(0, 5, 0), TeleportCause.PLUGIN);
								target.sendMessage(new Messaging.MessageFormatter().withPrefix().format("spectate.teleport-from-block"));
							} else {
								allowed = false;
								break;
							}
						}
					}
				}
				
			}
		}
		e.setBuildable(allowed);
	}
}
 
开发者ID:smessie,项目名称:SkyWarsReloaded,代码行数:32,代码来源:SpectatorListener.java

示例2: mayPlace

import org.bukkit.event.block.BlockCanBuildEvent; //导入方法依赖的package包/类
public boolean mayPlace(Block block, int i, int j, int k, boolean flag, int l, Entity entity, ItemStack itemstack) {
    Block block1 = this.getType(i, j, k);
    AxisAlignedBB axisalignedbb = flag ? null : block.a(this, i, j, k);

    // CraftBukkit start - store default return
    boolean defaultReturn = axisalignedbb != null && !this.a(axisalignedbb, entity) ? false : (block1.getMaterial() == Material.ORIENTABLE && block == Blocks.ANVIL ? true : block1.getMaterial().isReplaceable() && block.canPlace(this, i, j, k, l, itemstack));

    // CraftBukkit start
    BlockCanBuildEvent event = new BlockCanBuildEvent(this.getWorld().getBlockAt(i, j, k), CraftMagicNumbers.getId(block), defaultReturn);
    this.getServer().getPluginManager().callEvent(event);

    return event.isBuildable();
    // CraftBukkit end
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:15,代码来源:World.java

示例3: mayPlace

import org.bukkit.event.block.BlockCanBuildEvent; //导入方法依赖的package包/类
public boolean mayPlace(int i, int j, int k, int l, boolean flag, int i1, Entity entity, ItemStack itemstack) {
    int j1 = this.getTypeId(j, k, l);
    Block block = Block.byId[j1];
    Block block1 = Block.byId[i];
    AxisAlignedBB axisalignedbb = block1.b(this, j, k, l);

    if (flag) {
        axisalignedbb = null;
    }

    boolean defaultReturn; // CraftBukkit - store the default action

    if (axisalignedbb != null && !this.a(axisalignedbb, entity)) {
        defaultReturn = false; // CraftBukkit
    } else {
        if (block != null && (block == Block.WATER || block == Block.STATIONARY_WATER || block == Block.LAVA || block == Block.STATIONARY_LAVA || block == Block.FIRE || block.material.isReplaceable())) {
            block = null;
        }

        // CraftBukkit
        defaultReturn = block != null && block.material == Material.ORIENTABLE && block1 == Block.ANVIL ? true : i > 0 && block == null && block1.canPlace(this, j, k, l, i1, itemstack);
    }

    // CraftBukkit start
    BlockCanBuildEvent event = new BlockCanBuildEvent(this.getWorld().getBlockAt(j, k, l), i, defaultReturn);
    this.getServer().getPluginManager().callEvent(event);

    return event.isBuildable();
    // CraftBukkit end
}
 
开发者ID:AlmuraDev,项目名称:Almura-Server,代码行数:31,代码来源:World.java

示例4: canPlaceEntityOnSide

import org.bukkit.event.block.BlockCanBuildEvent; //导入方法依赖的package包/类
public boolean canPlaceEntityOnSide(Block p_147472_1_, int p_147472_2_, int p_147472_3_, int p_147472_4_, boolean p_147472_5_, int p_147472_6_, Entity p_147472_7_, ItemStack p_147472_8_)
{
    Block block1 = this.getBlock(p_147472_2_, p_147472_3_, p_147472_4_);
    if (block1 == null) return false; // Cauldron
    AxisAlignedBB axisalignedbb = p_147472_5_ ? null : p_147472_1_.getCollisionBoundingBoxFromPool(this, p_147472_2_, p_147472_3_, p_147472_4_);
    // CraftBukkit start - store default return
    boolean defaultReturn = axisalignedbb != null && !this.checkNoEntityCollision(axisalignedbb, p_147472_7_) ? false : (block1.getMaterial() == Material.circuits && p_147472_1_ == Blocks.anvil ? true : block1.isReplaceable(this, p_147472_2_, p_147472_3_, p_147472_4_) && p_147472_1_.canReplace(this, p_147472_2_, p_147472_3_, p_147472_4_, p_147472_6_, p_147472_8_));
    BlockCanBuildEvent event = new BlockCanBuildEvent(this.getWorld().getBlockAt(p_147472_2_, p_147472_3_, p_147472_4_), CraftMagicNumbers.getId(p_147472_1_), defaultReturn);
    this.getServer().getPluginManager().callEvent(event);
    return event.isBuildable();
    // CraftBukkit end
}
 
开发者ID:xtrafrancyz,项目名称:Cauldron,代码行数:13,代码来源:World.java

示例5: a

import org.bukkit.event.block.BlockCanBuildEvent; //导入方法依赖的package包/类
public boolean a(Block block, BlockPosition blockposition, boolean flag, EnumDirection enumdirection, @Nullable Entity entity, @Nullable ItemStack itemstack) {
    IBlockData iblockdata = this.getType(blockposition);
    AxisAlignedBB axisalignedbb = flag ? null : block.getBlockData().d(this, blockposition);

    // CraftBukkit start - store default return
    boolean defaultReturn = axisalignedbb != Block.k && !this.a(axisalignedbb.a(blockposition), entity) ? false : (iblockdata.getMaterial() == Material.ORIENTABLE && block == Blocks.ANVIL ? true : iblockdata.getMaterial().isReplaceable() && block.canPlace(this, blockposition, enumdirection, itemstack));
    BlockCanBuildEvent event = new BlockCanBuildEvent(this.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), CraftMagicNumbers.getId(block), defaultReturn);
    this.getServer().getPluginManager().callEvent(event);

    return event.isBuildable();
    // CraftBukkit end
}
 
开发者ID:bergerkiller,项目名称:SpigotSource,代码行数:13,代码来源:World.java

示例6: onBlockCanBuild

import org.bukkit.event.block.BlockCanBuildEvent; //导入方法依赖的package包/类
/**
 * Used to prevent spectators from blocking players from placing blocks.
 */
@EventHandler (priority = EventPriority.HIGHEST)
public void onBlockCanBuild(final BlockCanBuildEvent ev)
{
	if (!ev.isBuildable())
	{
		// Get location of the block that is going to be placed
		Location blockLocation = ev.getBlock().getLocation(); // event.getBlock() returns the block to be placed -1 y

		boolean allowed = false; // If there are any actual players there, the event should not be over-wrote.

		for (Player target : p.getServer().getOnlinePlayers())
		{
			if (target.getWorld().equals(ev.getBlock().getWorld())) // Player in same world?
			{
				Location playerLocation = target.getLocation();

				// If the player is at this location
				if (playerLocation.getX() > blockLocation.getBlockX() - 1
						&& playerLocation.getX() < blockLocation.getBlockX() + 1
						&& playerLocation.getZ() > blockLocation.getBlockZ() - 1
						&& playerLocation.getZ() < blockLocation.getBlockZ() + 1
						&& playerLocation.getY() > blockLocation.getBlockY() - 2
						&& playerLocation.getY() < blockLocation.getBlockY() + 1)
				{
					if (p.getPlayerData(target).isSpectating())
					{
						allowed = true;
					}
					else
					{
						allowed = false;
						break;
					}
				}

			}
		}

		ev.setBuildable(allowed);
	}
}
 
开发者ID:pgmann,项目名称:SpectatorPlus,代码行数:45,代码来源:SpectatorsInteractionsListener.java


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