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


Java BlockRedstoneEvent类代码示例

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


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

示例1: onBlockRedstoneChange

import org.bukkit.event.block.BlockRedstoneEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGH)
public void onBlockRedstoneChange(BlockRedstoneEvent event) {
	int blockId = event.getBlock().getTypeId();
	Location loc = event.getBlock().getLocation();
	// System.out.println(blockId);

	if ((blockId == 29) || (blockId == 33)) { // piston / sticky piston (base)
		Craft craft = Craft.getCraft(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());

		if (craft != null) {
			Player p = plugin.getServer().getPlayer(craft.driverName);
			if (p != null) {
				p.sendMessage("You just did something with a piston, didn't you?");
			}
		}
	}
}
 
开发者ID:Maximuspayne,项目名称:NavyCraft2-Lite,代码行数:18,代码来源:NavyCraft_BlockListener.java

示例2: doPhysics

import org.bukkit.event.block.BlockRedstoneEvent; //导入依赖的package包/类
public void doPhysics(World world, int i, int j, int k, Block block) {
    if (!world.isStatic) {
        boolean flag = world.isBlockIndirectlyPowered(i, j, k);
        int l = world.getData(i, j, k);
        boolean flag1 = (l & 1) != 0;

        // CraftBukkit start
        org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(i, j, k);
        int old = flag1 ? 15 : 0;
        int current = flag ? 15 : 0;

        BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, old, current);
        world.getServer().getPluginManager().callEvent(eventRedstone);
        // CraftBukkit end

        if (eventRedstone.getNewCurrent() > 0 && !(eventRedstone.getOldCurrent() > 0)) { // CraftBukkit
            world.setData(i, j, k, l | 1, 4);
            world.a(i, j, k, this, this.a(world));
        } else if (!(eventRedstone.getNewCurrent() > 0) && eventRedstone.getOldCurrent() > 0) { // CraftBukkit
            world.setData(i, j, k, l & -2, 4);
        }
    }
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:24,代码来源:BlockCommand.java

示例3: onBlockRedstoneEvent

import org.bukkit.event.block.BlockRedstoneEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL) 
public void onBlockRedstoneEvent(BlockRedstoneEvent event) {
	
	bcoord.setFromLocation(event.getBlock().getLocation());

	CampBlock cb = CivGlobal.getCampBlock(bcoord);
	if (cb != null) {
		if (ItemManager.getId(event.getBlock()) == CivData.WOOD_DOOR ||
				ItemManager.getId(event.getBlock()) == CivData.IRON_DOOR) {
			event.setNewCurrent(0);
			return;
		}
	}
	
	if (War.isWarTime()) {
		event.setNewCurrent(0);
		return;
	}

}
 
开发者ID:netizen539,项目名称:civcraft,代码行数:21,代码来源:BlockListener.java

示例4: doPhysics

import org.bukkit.event.block.BlockRedstoneEvent; //导入依赖的package包/类
public void doPhysics(World world, int i, int j, int k, int l) {
    if (!world.isStatic) {
        boolean flag = world.isBlockIndirectlyPowered(i, j, k);
        int i1 = world.getData(i, j, k);
        boolean flag1 = (i1 & 1) != 0;

        // CraftBukkit start
        org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k);
        int old = flag1 ? 15 : 0;
        int current = flag ? 15 : 0;

        BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, old, current);
        world.getServer().getPluginManager().callEvent(eventRedstone);
        // CraftBukkit end

        if (eventRedstone.getNewCurrent() > 0 && !(eventRedstone.getOldCurrent() > 0)) { // CraftBukkit
            world.setData(i, j, k, i1 | 1, 4);
            world.a(i, j, k, this.id, this.a(world));
        } else if (!(eventRedstone.getNewCurrent() > 0) && eventRedstone.getOldCurrent() > 0) { // CraftBukkit
            world.setData(i, j, k, i1 & -2, 4);
        }
    }
}
 
开发者ID:AlmuraDev,项目名称:Almura-Server,代码行数:24,代码来源:BlockCommand.java

示例5: onBlockRedstone

import org.bukkit.event.block.BlockRedstoneEvent; //导入依赖的package包/类
/**
 * Stop redstone if team members are offline and disableOfflineRedstone is TRUE.
 * @param e
 */
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onBlockRedstone(BlockRedstoneEvent e){
    if(Settings.disableOfflineRedstone) {
        // Check world
        if (!inWorld(e.getBlock())) {
            return;
        }
        // Check if this is on an island
        Island island = plugin.getGrid().getIslandAt(e.getBlock().getLocation());
        if (island == null || island.isSpawn()) {
            return;
        }
        for(UUID member : island.getMembers()){
            if(plugin.getServer().getPlayer(member) != null) return;
        }
        e.setNewCurrent(0);
    }
}
 
开发者ID:tastybento,项目名称:acidisland,代码行数:23,代码来源:IslandGuard.java

示例6: onNeighborBlockChange

import org.bukkit.event.block.BlockRedstoneEvent; //导入依赖的package包/类
public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_)
{
    if (!p_149695_1_.isRemote)
    {
        boolean flag = p_149695_1_.isBlockIndirectlyGettingPowered(p_149695_2_, p_149695_3_, p_149695_4_);
        int l = p_149695_1_.getBlockMetadata(p_149695_2_, p_149695_3_, p_149695_4_);
        boolean flag1 = (l & 1) != 0;
        // CraftBukkit start
        org.bukkit.block.Block bukkitBlock = p_149695_1_.getWorld().getBlockAt(p_149695_2_, p_149695_3_, p_149695_4_);
        int old = flag1 ? 15 : 0;
        int current = flag ? 15 : 0;
        BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, old, current);
        p_149695_1_.getServer().getPluginManager().callEvent(eventRedstone);
        // CraftBukkit end

        if (eventRedstone.getNewCurrent() > 0 && !(eventRedstone.getOldCurrent() > 0))   // CraftBukkit
        {
            p_149695_1_.setBlockMetadataWithNotify(p_149695_2_, p_149695_3_, p_149695_4_, l | 1, 4);
            p_149695_1_.scheduleBlockUpdate(p_149695_2_, p_149695_3_, p_149695_4_, this, this.tickRate(p_149695_1_));
        }
        else if (!(eventRedstone.getNewCurrent() > 0) && eventRedstone.getOldCurrent() > 0)     // CraftBukkit
        {
            p_149695_1_.setBlockMetadataWithNotify(p_149695_2_, p_149695_3_, p_149695_4_, l & -2, 4);
        }
    }
}
 
开发者ID:xtrafrancyz,项目名称:Cauldron,代码行数:27,代码来源:BlockCommandBlock.java

示例7: onEvent

import org.bukkit.event.block.BlockRedstoneEvent; //导入依赖的package包/类
@EventHandler
public void onEvent(BlockRedstoneEvent event) {
	if (!this.running) { return; }
	final Location currentLocation = event.getBlock().getLocation();

	for (Location location : this.locationSet) {
		if (location.distanceSquared(currentLocation) < this.distSqrd) {
			// Found a nearby location, so increase its activity count and return
			int count = this.locationMap.get(location);
			this.locationMap.put(location, count + 1);

			return;
		}
	}

	// Could not find any location nearby, so create an entry
	this.locationMap.put(currentLocation, 1);
	this.locationSet.add(currentLocation);
}
 
开发者ID:Craftolution,项目名称:CraftoPlugin,代码行数:20,代码来源:FindRedstoneComponent.java

示例8: onBlockRedstone

import org.bukkit.event.block.BlockRedstoneEvent; //导入依赖的package包/类
@EventHandler
public void onBlockRedstone(BlockRedstoneEvent event) {
    if (event.getBlock().getState() instanceof Sign) {
        Sign sign = (Sign) event.getBlock().getState();
        if (sign.getLine(0).equalsIgnoreCase(ChatColor.GRAY + "[portcullis]")) {
            World world = Bukkit.getServer().getWorld(sign.getLine(1));
            int x1 = Integer.parseInt(sign.getLine(2).split(",")[0]);
            int y1 = Integer.parseInt(sign.getLine(2).split(",")[1]);
            int z1 = Integer.parseInt(sign.getLine(2).split(",")[2]);
            int x2 = Integer.parseInt(sign.getLine(3).split(",")[0]);
            int y2 = Integer.parseInt(sign.getLine(3).split(",")[1]);
            int z2 = Integer.parseInt(sign.getLine(3).split(",")[2]);
            for (int x = Math.min(x1, x2); x <= Math.max(x1, x2); x++) {
                for (int y = Math.min(y1, y2); y <= Math.max(y1, y2); y++) {
                    for (int z = Math.min(z1, z2); z <= Math.max(z1, z2); z++) {
                        if (world.getBlockAt(x, y, z).getType() == Material.AIR) {
                            world.getBlockAt(x, y, z).setType(Material.IRON_FENCE);
                        } else {
                            world.getBlockAt(x, y, z).setType(Material.AIR);
                        }
                    }
                }
            }
        }
    }
}
 
开发者ID:WaywardRealms,项目名称:Wayward,代码行数:27,代码来源:PortcullisBlockRedstoneListener.java

示例9: interact

import org.bukkit.event.block.BlockRedstoneEvent; //导入依赖的package包/类
public boolean interact(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman, EnumHand enumhand, @Nullable ItemStack itemstack, EnumDirection enumdirection, float f, float f1, float f2) {
    if (((Boolean) iblockdata.get(BlockButtonAbstract.POWERED)).booleanValue()) {
        return true;
    } else {
        // CraftBukkit start
        boolean powered = ((Boolean) iblockdata.get(POWERED));
        org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
        int old = (powered) ? 15 : 0;
        int current = (!powered) ? 15 : 0;

        BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, old, current);
        world.getServer().getPluginManager().callEvent(eventRedstone);

        if ((eventRedstone.getNewCurrent() > 0) != (!powered)) {
            return true;
        }
        // CraftBukkit end
        world.setTypeAndData(blockposition, iblockdata.set(BlockButtonAbstract.POWERED, Boolean.valueOf(true)), 3);
        world.b(blockposition, blockposition);
        this.a(entityhuman, world, blockposition);
        this.c(world, blockposition, (EnumDirection) iblockdata.get(BlockButtonAbstract.FACING));
        world.a(blockposition, (Block) this, this.a(world));
        return true;
    }
}
 
开发者ID:bergerkiller,项目名称:SpigotSource,代码行数:26,代码来源:BlockButtonAbstract.java

示例10: b

import org.bukkit.event.block.BlockRedstoneEvent; //导入依赖的package包/类
public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
    if (!world.isClientSide) {
        if (((Boolean) iblockdata.get(BlockButtonAbstract.POWERED)).booleanValue()) {
            if (this.I) {
                this.e(iblockdata, world, blockposition);
            } else {
                // CraftBukkit start
                org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());

                BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, 15, 0);
                world.getServer().getPluginManager().callEvent(eventRedstone);

                if (eventRedstone.getNewCurrent() > 0) {
                    return;
                }
                // CraftBukkit end
                world.setTypeUpdate(blockposition, iblockdata.set(BlockButtonAbstract.POWERED, Boolean.valueOf(false)));
                this.c(world, blockposition, (EnumDirection) iblockdata.get(BlockButtonAbstract.FACING));
                this.b(world, blockposition);
                world.b(blockposition, blockposition);
            }

        }
    }
}
 
开发者ID:bergerkiller,项目名称:SpigotSource,代码行数:26,代码来源:BlockButtonAbstract.java

示例11: onBlockRedstoneChange

import org.bukkit.event.block.BlockRedstoneEvent; //导入依赖的package包/类
@EventHandler
public void onBlockRedstoneChange(BlockRedstoneEvent evt) {
	if (!(evt.getBlock().getState() instanceof Sign))
		return;
	Sign siq = (Sign) evt.getBlock().getState();
	try {
		if (!plugin.isCommBlock(siq.getLine(0).substring(0, 5)) || plugin.isSenderPlayer(siq.getLine(0).substring(0, 5)))
			return;
	} catch (IndexOutOfBoundsException error) {}
	
	if (evt.getBlock().isBlockIndirectlyPowered()
			|| evt.getBlock().isBlockPowered()) {
		
		Boolean hasRun = commandSigns.get(siq.getLocation());
		if (hasRun == null || !hasRun) {
			this.tryCommand(evt.getBlock().getState());
			commandSigns.put(siq.getLocation(), true);
		}
	}
	else {
		commandSigns.put(siq.getLocation(), false);
	}
}
 
开发者ID:illegalprime,项目名称:Zeus,代码行数:24,代码来源:ZeusEventHandler.java

示例12: onBlockRedstone

import org.bukkit.event.block.BlockRedstoneEvent; //导入依赖的package包/类
@EventHandler(priority=EventPriority.HIGH )
public void onBlockRedstone(BlockRedstoneEvent event) 
{
	System.out.println("  ");
	Block block = event.getBlock();
	int iBlockID = block.getTypeId();
	if (iBlockID==69 || iBlockID==77 || iBlockID==143) {  return; }
	if(event.getOldCurrent() >=1 && event.getNewCurrent() == 0 ) { return; }
	System.out.println(" plugin:  onBlockRedstone()  ");
	System.out.println("     iBlockID = " + iBlockID);
	if(plugin.itemFrame1 != null)
	{
		//  funzelt  :-)
		//ItemStack  item01 = new ItemStack( Helper.random_IntRange(2, 128) );
		//plugin.itemFrame1.setItem(item01);
	}
	if(event.getNewCurrent()>=1) {
		plugin.umschauenNachSchild(block, event);
	}
	return;
}
 
开发者ID:Kryssi79,项目名称:RahmenTests,代码行数:22,代码来源:RahmenListener.java

示例13: handleRedstoneEvent

import org.bukkit.event.block.BlockRedstoneEvent; //导入依赖的package包/类
public void handleRedstoneEvent(Block block, BlockRedstoneEvent event, int delayTicks) 
{
       if (istSchild(block)) 
       {
       	System.out.println(" plugin:  handleRedstoneEvent()  ");
           Sign signBlock = (Sign) block.getState();
           if (signBlock == null) {
               return;
           }
           if (signBlock.getLine(1) == null) {
               return;
           }
           String sLine1 = signBlock.getLine(1);
           System.out.println("   .getLine(0)  " + signBlock.getLine(0) );
           System.out.println("   .getLine(1)  " + sLine1 );
           System.out.println("   .getLine(2)  " + signBlock.getLine(2) );
           istAutomat(signBlock, block);
       }
}
 
开发者ID:Kryssi79,项目名称:RahmenTests,代码行数:20,代码来源:main.java

示例14: onBlockRedstone

import org.bukkit.event.block.BlockRedstoneEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockRedstone(BlockRedstoneEvent e)
{
	if (e.getBlock().getType() == Material.REDSTONE_TORCH_OFF
			|| e.getBlock().getType() == Material.REDSTONE_TORCH_ON)
	{
		final Block above = e.getBlock().getRelative(BlockFace.UP);
		String[] arguments = DropperManager.getSpecialDropper(above);
		
		if (arguments == null)
			return;
		
		if (e.getOldCurrent() == 0 && e.getNewCurrent() > 0
				&& !above.isBlockPowered()
				&& !DropperManager.isRegistered(above))
		{
			DropperManager.register(above, arguments);
		}
		else if (e.getOldCurrent() > 0 && e.getNewCurrent() == 0
				&& above.isBlockPowered()
				&& DropperManager.isRegistered(above))
		{
			DropperManager.unregister(above);
		}
	}
}
 
开发者ID:riking,项目名称:GrandVide,代码行数:27,代码来源:GVEventListener.java

示例15: onBlockRedstone

import org.bukkit.event.block.BlockRedstoneEvent; //导入依赖的package包/类
@EventHandler
public void onBlockRedstone(BlockRedstoneEvent event) {
    if (event.getOldCurrent() != 0 || event.getNewCurrent() == 0) {
        return;
    }
    Block block = event.getBlock();
    World world = block.getWorld();
    String worldName = world.getName();
    Map<BlockVector, BankSet> worldInteresting = bankInfo.get(worldName);
    if (worldInteresting == null) {
        worldInteresting = buildWorldInteresting(worldName);
        bankInfo.put(worldName, worldInteresting);
    }
    BlockVector target = new BlockVector(block.getX(), block.getY(), block.getZ());
    BankSet targetBank = worldInteresting.get(target);
    if (targetBank != null) {
        targetBank.shelveItems(world);
    }
}
 
开发者ID:crast,项目名称:MondoChest,代码行数:20,代码来源:RedstoneListener.java


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