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


Java BlockCanBuildEvent类代码示例

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


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

示例1: init

import org.bukkit.event.block.BlockCanBuildEvent; //导入依赖的package包/类
@SuppressWarnings("null")
@Override
public boolean init(final Expression<?>[] vars, final int matchedPattern, final Kleenean isDelayed, final ParseResult parser) {
	if (isDelayed == Kleenean.TRUE) {
		Skript.error("Can't cancel an event anymore after is has already passed", ErrorQuality.SEMANTIC_ERROR);
		return false;
	}
	cancel = matchedPattern == 0;
	final Class<? extends Event>[] es = ScriptLoader.getCurrentEvents();
	if (es == null)
		return false;
	for (final Class<? extends Event> e : es) {
		if (Cancellable.class.isAssignableFrom(e) || BlockCanBuildEvent.class.isAssignableFrom(e))
			return true; // TODO warning if some event(s) cannot be cancelled even though some can (needs a way to be suppressed)
	}
	if (ScriptLoader.isCurrentEvent(PlayerLoginEvent.class))
		Skript.error("A connect event cannot be cancelled, but the player may be kicked ('kick player by reason of \"...\"')", ErrorQuality.SEMANTIC_ERROR);
	else
		Skript.error(Utils.A(ScriptLoader.getCurrentEventName()) + " event cannot be cancelled", ErrorQuality.SEMANTIC_ERROR);
	return false;
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:22,代码来源:EffCancelEvent.java

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

示例3: execute

import org.bukkit.event.block.BlockCanBuildEvent; //导入依赖的package包/类
@Override
public void execute(final Event e) {
	if (e instanceof Cancellable)
		((Cancellable) e).setCancelled(cancel);
	if (e instanceof PlayerInteractEvent) {
		((PlayerInteractEvent) e).setUseItemInHand(cancel ? Result.DENY : Result.DEFAULT);
		((PlayerInteractEvent) e).setUseInteractedBlock(cancel ? Result.DENY : Result.DEFAULT);
	} else if (e instanceof BlockCanBuildEvent) {
		((BlockCanBuildEvent) e).setBuildable(!cancel);
	} else if (e instanceof PlayerDropItemEvent) {
		PlayerUtils.updateInventory(((PlayerDropItemEvent) e).getPlayer());
	}
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:14,代码来源:EffCancelEvent.java

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

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

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

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

示例8: onPlayerPlacesBlock

import org.bukkit.event.block.BlockCanBuildEvent; //导入依赖的package包/类
@EventHandler
public void onPlayerPlacesBlock(BlockCanBuildEvent event) {
  event.setBuildable(true);
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:5,代码来源:ModeratorMode.java

示例9: onBlockAttempt

import org.bukkit.event.block.BlockCanBuildEvent; //导入依赖的package包/类
@EventHandler
public void onBlockAttempt(BlockCanBuildEvent event) {
	event.setBuildable(true);
}
 
开发者ID:ProjectRixor,项目名称:Rixor,代码行数:5,代码来源:PlayerEvents.java

示例10: 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类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。