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


Java BlockRedstoneEvent.getBlock方法代码示例

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


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

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

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

示例3: CheckRedstone

import org.bukkit.event.block.BlockRedstoneEvent; //导入方法依赖的package包/类
@EventHandler
public void CheckRedstone(BlockRedstoneEvent event){
	if(ConfigOptimize.AntiRedstoneenable){
		if(event.getOldCurrent() > event.getNewCurrent()){
            return;
        }
        final Block block = event.getBlock();
        Location loc = block.getLocation();
        if(CheckedTimes.get(loc) == null){
            CheckedTimes.put(loc, 0);
        }
        CheckedTimes.put(loc, CheckedTimes.get(loc) + 1);

        if(CheckedTimes.get(loc) > ConfigOptimize.AntiRedstoneTimes){
            if(ConfigOptimize.AntiRedstoneRemoveBlockList.contains(block.getType().name())){
	Bukkit.getScheduler().runTaskLater(EscapeLag.MainThis,new Runnable(){
		public void run(){
			block.setType(Material.AIR);
		}
	},1);
                String message = ConfigOptimize.AntiRedstoneMessage;
                message = StringUtils.replace(message, "%location%", loc.toString());
                AzureAPI.bc(message);
            }
        }
	}
}
 
开发者ID:GelandiAssociation,项目名称:EscapeLag,代码行数:28,代码来源:AntiRedstone.java

示例4: onPower

import org.bukkit.event.block.BlockRedstoneEvent; //导入方法依赖的package包/类
@EventHandler
public void onPower(BlockRedstoneEvent event) {
	Block block = event.getBlock();
	String chunk = block.getLocation().getChunk().getX() + ";" + block.getLocation().getChunk().getZ();

	if (!powerable.get(block.getWorld().getName()).getList(chunk).contains(block.getLocation())) {
		block.getWorld().spawnParticle(Particle.SMOKE_NORMAL, block.getLocation().add(0.5, 1, 0.5), 7, 0, 0.2, 0,
				0.03);
		event.setNewCurrent(0);
	}
}
 
开发者ID:kadeska,项目名称:MT_Core,代码行数:12,代码来源:GeneratorListener.java

示例5: handleBlockRedstone

import org.bukkit.event.block.BlockRedstoneEvent; //导入方法依赖的package包/类
public void handleBlockRedstone(BlockRedstoneEvent event) {
    if ((event.getOldCurrent() != 0) == (event.getNewCurrent() != 0)) return;

    Block block = event.getBlock();

    for (BlockFace face : BridgeManager.faces) {
        Block faceBlock = block.getRelative(face);

        if(this.storage.getGearblock(new BlockCoord(faceBlock)) != null) {
            this.waitingBlocks.add(faceBlock);
        }
    }
}
 
开发者ID:Aleksey-Terzi,项目名称:CastleGates,代码行数:14,代码来源:BridgeEventHandler.java

示例6: onBlockRedstone

import org.bukkit.event.block.BlockRedstoneEvent; //导入方法依赖的package包/类
public void onBlockRedstone(BlockRedstoneEvent event) 
{
	//wenn: am Block  redstone  gebaut/abgebaut   bzw. Signal sich �ndert
	Block block = event.getBlock();
	int iBlockID = block.getTypeId();
	int iPower = 0;
	if ( !(iBlockID==137) )   { return; }
	BlockState blState = event.getBlock().getState();
	if (blState instanceof CommandBlock)   // Kommandoblock
	{
		m_CommandBlock = (CommandBlock)blState;
		try
		{
			iPower = block.getBlockPower();
			if(iPower==0) { return; }
		}  catch  ( Exception exc ) { iPower = 0; return; }
		System.out.println(" MCBP plugin:  Kommandoblock  onBlockRedstone()  ");
		System.out.println(" MCBP plugin:   BlockPower =  " + iPower);
		
		m_CommandsString = m_CommandBlock.getCommand();
		
		System.out.println(" MCBP plugin:    " + m_CommandsString);
		// logTo(String sLogStr)
		//  =>  weiter an   CommandParser()
		ParsedCommand[] commands = getCommands(m_CommandsString, block);
		for (int i=0; i < commands.length;i++)
		{	
			//CommandSender oSender = (CommandSender) m_CommandBlock.getBlock();
			//BlockCommandSender bcs = (BlockCommandSender)m_CommandBlock;
			sendeBefehl(commands[i].getCommand());
			System.out.println("send Command: " + commands[i].getCommand());
			try {
				Thread.sleep(commands[i].getInterval());
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
}
 
开发者ID:memoryleakx,项目名称:MultiCommandBlockPlugin,代码行数:41,代码来源:CommandBlockExt.java

示例7: onRedstoneEvent

import org.bukkit.event.block.BlockRedstoneEvent; //导入方法依赖的package包/类
@EventHandler
public void onRedstoneEvent(BlockRedstoneEvent event) {
    Block block = event.getBlock();
    Location loc = BukkitUtil.getLocation(block.getLocation());
    if (!PlotSquared.isPlotWorld(loc.getWorld())) {
        return;
    }
    Plot plot = MainUtil.getPlot(loc);
    if (plot == null) {
        return;
    }
    if (Settings.REDSTONE_DISABLER) {
        if (UUIDHandler.getPlayer(plot.owner) == null) {
            boolean disable = true;
            for (UUID trusted : plot.trusted) {
                if (UUIDHandler.getPlayer(trusted) != null) {
                    disable = false;
                    break;
                }
            }
            if (disable) {
                event.setNewCurrent(0);
                return;
            }
        }
    }
    Flag redstone = FlagManager.getPlotFlag(plot, "redstone");
    if (redstone == null || (Boolean) redstone.getValue()) {
        return;
    }
    switch (block.getType()) {
        case REDSTONE_LAMP_OFF:
        case REDSTONE_LAMP_ON:
        case PISTON_BASE:
        case PISTON_STICKY_BASE:
        case IRON_DOOR_BLOCK:
        case LEVER:
        case WOODEN_DOOR:
        case FENCE_GATE:
        case WOOD_BUTTON:
        case STONE_BUTTON:
        case IRON_PLATE:
        case WOOD_PLATE:
        case STONE_PLATE:
        case GOLD_PLATE:
        case SPRUCE_DOOR:
        case BIRCH_DOOR:
        case JUNGLE_DOOR:
        case ACACIA_DOOR:
        case DARK_OAK_DOOR:
        case IRON_TRAPDOOR:
        case SPRUCE_FENCE_GATE:
        case BIRCH_FENCE_GATE:
        case JUNGLE_FENCE_GATE:
        case ACACIA_FENCE_GATE:
        case DARK_OAK_FENCE_GATE:
        case POWERED_RAIL: {
            return;
        }
    }
    event.setNewCurrent(0);
}
 
开发者ID:Mayomi,项目名称:PlotSquared-Chinese,代码行数:63,代码来源:PlayerEvents.java

示例8: redstoneChange

import org.bukkit.event.block.BlockRedstoneEvent; //导入方法依赖的package包/类
/**
 * Called when a block is charged.
 * When the furnace block is powered, starts the factory and toggles on any attached levers.
 * On completion, toggles off any attached levers.
 */
   @EventHandler()
public void redstoneChange(BlockRedstoneEvent e)
{	
	// Only trigger on transition from 0 to positive
	if (e.getOldCurrent() > 0 || e.getNewCurrent() == 0) {
		return;
	}
	
	// Allow this to be disabled with config
	if (!FactoryModPlugin.REDSTONE_START_ENABLED) {
		return;
	}
	
	Block rsBlock = e.getBlock();
	BlockFace[] directions = null;
	if (rsBlock.getType() == Material.REDSTONE_WIRE) {
		directions = ProductionFactory.REDSTONE_FACES;
	} else if (rsBlock.getType() == Material.WOOD_BUTTON) {
		directions = new BlockFace[] {((Attachable) rsBlock.getState().getData()).getAttachedFace()};
	} else if (rsBlock.getType() == Material.STONE_BUTTON) {
		directions = new BlockFace[] {((Attachable) rsBlock.getState().getData()).getAttachedFace()};
	} else if (rsBlock.getType() == Material.LEVER) {
		directions = new BlockFace[] {((Attachable) rsBlock.getState().getData()).getAttachedFace()};
	} else {
		return; // Don't care
	}
	
	
	for (BlockFace direction : directions) {
		Block block = rsBlock.getRelative(direction);
		
		//Is the block part of a factory?
		if(block.getType() == Material.FURNACE || block.getType() == Material.BURNING_FURNACE)
		{
			if (factoryMan.factoryExistsAt(block.getLocation()))
			{					
				//Is the factory a production factory?
				if (productionMan.factoryExistsAt(block.getLocation()))
				{
					ProductionFactory factory = (ProductionFactory) productionMan.getFactory(block.getLocation());
					
					Block lever = factory.findActivationLever();
					if (lever == null) {
						// No lever - don't respond to redstone
						return;
					}
					
					if (!factory.getActive()) {
						// Try to start the factory
						factory.togglePower();
					}
				}
			}
		}
	}
}
 
开发者ID:gmlaxfanatic,项目名称:FactoryMod,代码行数:62,代码来源:RedstoneListener.java


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