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


Java CommandBlock.getCommand方法代码示例

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


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

示例1: onBlockRedstone

import org.bukkit.block.CommandBlock; //导入方法依赖的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

示例2: updateFrom

import org.bukkit.block.CommandBlock; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public void updateFrom(Block block, Set<Material> restrictedMaterials) {
    if (block == null) {
        isValid = false;
        return;
    }
    if (!block.getChunk().isLoaded()) {
        block.getChunk().load(true);
        return;
    }

    Material blockMaterial = block.getType();
    if (restrictedMaterials != null && restrictedMaterials.contains(blockMaterial)) {
        isValid = false;
        return;
    }
    // Look for special block states
    extraData = null;

    material = blockMaterial;
    data = (short)block.getData();

    try {
        BlockState blockState = block.getState();
        if (material == Material.FLOWER_POT || blockState instanceof InventoryHolder || blockState instanceof Sign) {
            extraData = new BlockTileEntity(NMSUtils.getTileEntityData(block.getLocation()));
        } else if (blockState instanceof CommandBlock){
            // This seems to occasionally throw exceptions...
            CommandBlock command = (CommandBlock)blockState;
            extraData = new BlockCommand(command.getCommand(), command.getName());
        } else if (blockState instanceof Skull) {
            Skull skull = (Skull)blockState;
            data = (short)skull.getSkullType().ordinal();
            extraData = new BlockSkull(CompatibilityUtils.getSkullProfile(skull), skull.getSkullType(), skull.getRotation());
        } else if (blockState instanceof CreatureSpawner) {
            CreatureSpawner spawner = (CreatureSpawner)blockState;
            extraData = new BlockMobSpawner(spawner.getCreatureTypeName());
        } else if (blockMaterial == Material.STANDING_BANNER || blockMaterial == Material.WALL_BANNER) {
            if (blockState != null && blockState instanceof Banner) {
                Banner banner = (Banner)blockState;
                DyeColor color = banner.getBaseColor();
                extraData = new BlockBanner(banner.getPatterns(), color);
            }
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }

    isValid = true;
}
 
开发者ID:elBukkit,项目名称:MagicLib,代码行数:51,代码来源:MaterialAndData.java

示例3: SerializableBlockEntity

import org.bukkit.block.CommandBlock; //导入方法依赖的package包/类
/**
 * Constructor.
 *
 * @param blockState  The {@link org.bukkit.block.BlockState} that needs to be serialized.
 */
public SerializableBlockEntity(BlockState blockState) {
    PreCon.notNull(blockState);

    _location = blockState.getLocation();
    _material = blockState.getType();
    _data = blockState.getRawData();

    if (blockState instanceof InventoryHolder) {
        _contents = ((InventoryHolder) blockState).getInventory().getContents();
    }

    if (blockState instanceof CommandBlock) {
        CommandBlock commandBlock = (CommandBlock)blockState;
        _commandName = commandBlock.getName();
        _command = commandBlock.getCommand();
    }

    if (blockState instanceof CreatureSpawner) {
        CreatureSpawner spawner = (CreatureSpawner)blockState;
        _creatureTypeName = spawner.getCreatureTypeName();
        _creatureDelay = spawner.getDelay();
    }

    if (blockState instanceof NoteBlock) {
        NoteBlock noteBlock = (NoteBlock)blockState;

        _noteTone = noteBlock.getNote().getTone();
        _noteOctave = noteBlock.getNote().getOctave();
        _noteSharped = noteBlock.getNote().isSharped();
    }

    if (blockState instanceof Sign) {
        Sign sign = (Sign)blockState;

        _signLines = sign.getLines().clone();
    }

    if (blockState instanceof Skull) {
        Skull skull =  (Skull)blockState;

        _skullType = skull.getSkullType();
        _skullRotation = skull.getRotation();
        _skullOwner = skull.getOwner();
    }
}
 
开发者ID:JCThePants,项目名称:NucleusFramework,代码行数:51,代码来源:SerializableBlockEntity.java

示例4: onCommand

import org.bukkit.block.CommandBlock; //导入方法依赖的package包/类
@Override
public boolean onCommand(CommandSender cs, Command cmd, String strLabel, String[] args) 
{
   	if(cmd.getName().equals("MCB")) 
   	{
    	if(args.length == 0)  //  nur  /MCB  ohne Params
    	{
    		if(bLogToConsole==true)  { System.out.println("  MCB   sendet ...   "); }
    		return true;
    	}
    	else
		{
			if ((cs instanceof BlockCommandSender)) 
			{
				final BlockCommandSender blockCmdSender = (BlockCommandSender)cs;
				Block block = blockCmdSender.getBlock();
				CommandBlock m_CommandBlock = (CommandBlock)block.getState();
				m_CommandsString = m_CommandBlock.getCommand();
				System.out.println("     ");
				System.out.println(" BlockCommandSender sendet ... ");
				System.out.println("     " + m_CommandsString );
				ParsedCommand[] commands = getCommands(m_CommandsString, block);
				
				int iVorGesTime = 0;
				for (int i=0; i < commands.length;i++)
				{	
					final String fiStr = commands[i].getCommand();
					int iIntTime = 0;
					if(i == 0) {
						iIntTime = commands[i].getInterval() * 20;
						iVorGesTime += iIntTime;
					}
					else {
						iIntTime = iVorGesTime + (commands[i].getInterval() * 20);
						iVorGesTime += iIntTime;
					}
					
			        Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() 
			        {
			        	public void run() 
			        	{
			        		//hier rein:  sendeBefehl 
			        		sendeBefehl(blockCmdSender, fiStr);
			        	}
			        }, iIntTime );   //   * 20  ????
			        
					/*
					try {
						Thread.sleep(commands[i].getInterval());  // commands[i].getInterval()
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
					*/
				}
			}
			return true;
		}
   	}
   	return false;
}
 
开发者ID:memoryleakx,项目名称:MultiCommandBlockPlugin,代码行数:61,代码来源:main_MCBP.java


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