當前位置: 首頁>>代碼示例>>Java>>正文


Java CreatureSpawner.setDelay方法代碼示例

本文整理匯總了Java中org.bukkit.block.CreatureSpawner.setDelay方法的典型用法代碼示例。如果您正苦於以下問題:Java CreatureSpawner.setDelay方法的具體用法?Java CreatureSpawner.setDelay怎麽用?Java CreatureSpawner.setDelay使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.block.CreatureSpawner的用法示例。


在下文中一共展示了CreatureSpawner.setDelay方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: change

import org.bukkit.block.CreatureSpawner; //導入方法依賴的package包/類
@Override
public void change(Event e, Object[] delta, Changer.ChangeMode mode){
	if (spawner != null) {
		Number delay = (Number)delta[0];
		Number delayNow = ((CreatureSpawner)spawner.getSingle(e).getState()).getDelay();
		CreatureSpawner spawn = ((CreatureSpawner)spawner.getSingle(e).getState());
		if (mode == ChangeMode.SET) {
			spawn.setDelay(delay.intValue());
		} else if (mode == ChangeMode.ADD) {
			spawn.setDelay(delayNow.intValue() + delay.intValue());
		} else if (mode == ChangeMode.REMOVE) {
			spawn.setDelay(delayNow.intValue() - delay.intValue());
		}
		spawn.update();
	}
}
 
開發者ID:TheLimeGlass,項目名稱:Skellett,代碼行數:17,代碼來源:ExprSpawnerDelay.java

示例2: execute

import org.bukkit.block.CreatureSpawner; //導入方法依賴的package包/類
@Override
protected void execute(Event e) {
	if (spawner != null) {
		int delay = ((CreatureSpawner)spawner.getSingle(e)).getDelay();
		CreatureSpawner state = (CreatureSpawner)spawner.getSingle(e).getState();
		state.setDelay(0);
		state.update();
		state.setDelay(delay);
		state.update();
	}
}
 
開發者ID:TheLimeGlass,項目名稱:Skellett,代碼行數:12,代碼來源:EffSpawnerForce.java

示例3: setSpawner

import org.bukkit.block.CreatureSpawner; //導入方法依賴的package包/類
private void setSpawner(Block b, Random random) {
CreatureSpawner spawner = (CreatureSpawner) b.getState();
TreeMap<Integer,EntityType> spawns = WorldStyles.get(b.getWorld().getEnvironment()).getSpawns();
int randKey = random.nextInt(spawns.lastKey());
//Bukkit.getLogger().info("DEBUG: spawner rand key = " + randKey + " out of " + spawns.lastKey());
EntityType type = spawns.ceilingEntry(randKey).getValue();
//Bukkit.getLogger().info("DEBUG: spawner type = " + type);
spawner.setDelay(120);
spawner.setSpawnedType(type);
spawner.update(true);
   }
 
開發者ID:tastybento,項目名稱:askygrid,代碼行數:12,代碼來源:SkyGridPop.java

示例4: pasteNether

import org.bukkit.block.CreatureSpawner; //導入方法依賴的package包/類
public static void pasteNether(File f, final Location loc, boolean log) {
     try {
long start = System.currentTimeMillis();
if (log)
	Bukkit.getLogger().info("Pasting " + f.getAbsolutePath() + "...");

if (!f.exists()) {
	Bukkit.getLogger().info("Schematic doesn't exist, skipping.");
	return;
}

NBTInputStream nbtStream = new NBTInputStream(new GZIPInputStream(new FileInputStream(f)));
CompoundTag nbt = (CompoundTag) nbtStream.readNamedTag().getTag();
if (nbt == null)
	return;

         short width = nbt.getShort("Width");
         short height = nbt.getShort("Height");
         short length = nbt.getShort("Length");

loadChunks(loc.getWorld(), loc.getBlockX(), loc.getBlockZ(), width, length);

         final byte[] blocks = nbt.getByteArray("Blocks");
         final byte[] data = nbt.getByteArray("Data");

for (int x = 0; x < width; x++) {
	for (int y = 0; y < height; y++) {
		for (int z = 0; z < length; z++) {
			final int index = y * width * length + z * width + x;
			final Location l = new Location(loc.getWorld(), x + loc.getX(), y + loc.getY(), z + loc.getZ());
			final int b = blocks[index] & 0xFF;
			final Block block = l.getBlock();
			final Material m = Material.getMaterial(b);

			block.setType(m, false);
			if (m == Material.MOB_SPAWNER) {
				CreatureSpawner spawner = (CreatureSpawner) block.getState();
				spawner.setSpawnedType(EntityType.BLAZE);
				spawner.setDelay(1);
				spawner.update();
			} else {
				block.setData(data[index]);
			}
		}
	}
}

if (log)
	Bukkit.getLogger().info("Pasted successfully in " + (System.currentTimeMillis() - start) + " milliseconds.");
     } catch (Exception e) {
         e.printStackTrace();
     }
 }
 
開發者ID:zyuiop,項目名稱:FastSurvival,代碼行數:54,代碼來源:Schematic.java

示例5: applyTile

import org.bukkit.block.CreatureSpawner; //導入方法依賴的package包/類
private void applyTile(BlockState blockState) {

        boolean requiresUpdate = false;

        // InventoryHolder
        if (blockState instanceof InventoryHolder && _contents != null) {
            InventoryHolder holder = (InventoryHolder)blockState;

            Inventory inventory = holder.getInventory();

            inventory.setContents(_contents);

            requiresUpdate = true;
        }

        // CommandBlock
        if (blockState instanceof CommandBlock) {
            CommandBlock commandBlock = (CommandBlock)blockState;

            if (_commandName != null)
                commandBlock.setName(_commandName);

            if (_command != null)
                commandBlock.setCommand(_command);

            requiresUpdate = true;
        }

        // CreatureSpawner
        if (blockState instanceof CreatureSpawner) {
            CreatureSpawner spawner = (CreatureSpawner)blockState;

            if (_creatureTypeName != null) {
                spawner.setCreatureTypeByName(_creatureTypeName);
                spawner.setDelay(_creatureDelay);
            }

            requiresUpdate = true;
        }

        if (blockState instanceof NoteBlock && _noteTone != null) {
            NoteBlock noteBlock = (NoteBlock)blockState;

            Note note = new Note(_noteOctave, _noteTone, _noteSharped);
            noteBlock.setNote(note);

            requiresUpdate = true;
        }

        if (blockState instanceof Sign && _signLines != null) {
            Sign sign = (Sign)blockState;

            for (int i=0; i < 4; i++)
                sign.setLine(i, _signLines[i]);

            requiresUpdate = true;
        }

        if (blockState instanceof Skull && _skullType != null) {
            Skull skull =  (Skull)blockState;

            skull.setSkullType(_skullType);
            skull.setRotation(_skullRotation);
            skull.setOwner(_skullOwner);

            requiresUpdate = true;
        }

        if (requiresUpdate) {
            blockState.update(true);
        }
    }
 
開發者ID:JCThePants,項目名稱:NucleusFramework,代碼行數:73,代碼來源:SerializableBlockEntity.java

示例6: run

import org.bukkit.block.CreatureSpawner; //導入方法依賴的package包/類
@Override
protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
	if (args.length < 1 || args[0].length() < 2)
	{
		throw new NotEnoughArgumentsException(_("§6Mobs:§r {0}", Util.joinList(LivingEntities.getLivingEntityList())));
	}

	final Location target = LocationUtil.getTarget(user.getPlayer());
	if (target == null || target.getBlock().getType() != Material.MOB_SPAWNER)
	{
		throw new Exception(_("§4Target block must be a mob spawner."));
	}

	try
	{
		String name = args[0];

		EntityType mob = LivingEntities.fromName(name);
		if (mob == null)
		{
			user.sendMessage(_("Invalid mob type."));
			return;
		}
		if (!Permissions.SPAWNER.isAuthorized(user, mob.getName()))
		{
			throw new Exception(_("§4Unable to spawn mob."));
		}
		int delay = 0;
		if (args.length > 1 && Util.isInt(args[1]))
		{
			delay = Integer.parseInt(args[1]);
		}
		final Trade charge = new Trade("spawner-" + mob.getName().toLowerCase(Locale.ENGLISH), ess);
		charge.isAffordableFor(user);

		CreatureSpawner spawner = ((CreatureSpawner)target.getBlock().getState());
		spawner.setSpawnedType(mob);
		spawner.setDelay(delay);

		charge.charge(user);
		user.sendMessage(_("§6Changed spawner type to§c {0}", mob.getName()));
	}
	catch (Exception ex)
	{
		throw new Exception(_("§4Error while changing mob spawner."), ex);
	}
}
 
開發者ID:Curtis3321,項目名稱:Essentials,代碼行數:49,代碼來源:Commandspawner.java


注:本文中的org.bukkit.block.CreatureSpawner.setDelay方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。