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


Java CreatureSpawner.update方法代碼示例

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


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

示例1: placeBlock

import org.bukkit.block.CreatureSpawner; //導入方法依賴的package包/類
@Override
public boolean placeBlock(ArmorStand e, Player p) {
	getTexture().placeBlock(e.getLocation().add(0, -0.40, -0.375));
	//p.sendMessage(e.getLocation().getBlock().getLocation().toString());
	
	if (getMaterial().equals(Material.MOB_SPAWNER)) {
		CreatureSpawner cs = (CreatureSpawner) e.getLocation().getBlock().getState();
		cs.setSpawnedType(EntityType.DROPPED_ITEM);
		cs.update();
	}
	setLe(e);
	Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(SuperiorCraft.plugin, new Runnable() {
		public void run() {
			e.getLocation().getBlock().setType(Material.STONE_SLAB2);
			e.getLocation().getBlock().setData((byte) 2);
			e.getLocation().getBlock().getWorld().dropItemNaturally(e.getLocation(), new ItemStack(e.getLocation().add(0, -1, 0).getBlock().getType()));
			e.getLocation().add(0, -1, 0).getBlock().setType(Material.GLOWSTONE);
		}
	}, (1 * 20));
	return true;
}
 
開發者ID:GigaGamma,項目名稱:SuperiorCraft,代碼行數:22,代碼來源:Slab.java

示例2: onBlockPlace

import org.bukkit.block.CreatureSpawner; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onBlockPlace(BlockPlaceEvent event) {
    Block block = event.getBlockPlaced();
    ItemStack stack = event.getItemInHand();
    Player player = event.getPlayer();
    if (block.getState() instanceof CreatureSpawner && stack.hasItemMeta()) {
        ItemMeta meta = stack.getItemMeta();

        if (meta.hasLore() && meta.hasDisplayName()) {
            CreatureSpawner spawner = (CreatureSpawner) block.getState();
            List<String> lore = meta.getLore();
            if (!lore.isEmpty()) {
                String spawnerName = ChatColor.stripColor(lore.get(0).toUpperCase());
                Optional<EntityType> entityTypeOptional = GuavaCompat.getIfPresent(EntityType.class, spawnerName);
                if (entityTypeOptional.isPresent()) {
                    spawner.setSpawnedType(entityTypeOptional.get());
                    spawner.update(true, true);
                    player.sendMessage(ChatColor.AQUA + "Placed a " + ChatColor.BLUE + spawnerName + ChatColor.AQUA + " spawner.");
                }
            }
        }
    }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:24,代碼來源:CrowbarListener.java

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

示例4: placeBlock

import org.bukkit.block.CreatureSpawner; //導入方法依賴的package包/類
@Override
public boolean placeBlock(ArmorStand e, Player p) {
	getTexture().placeBlock(e.getLocation().add(0, 0.125, -0.375));
	e.getLocation().getBlock().setType(getMaterial());
	if (getMaterial().equals(Material.MOB_SPAWNER)) {
		CreatureSpawner cs = (CreatureSpawner) e.getLocation().getBlock().getState();
		cs.setSpawnedType(EntityType.DROPPED_ITEM);
		cs.update();
	}
	setLe(e);
	return true;
}
 
開發者ID:GigaGamma,項目名稱:SuperiorCraft,代碼行數:13,代碼來源:CustomTexturedBlock.java

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

示例6: change

import org.bukkit.block.CreatureSpawner; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
@Override
public void change(Event e, Object[] delta, Changer.ChangeMode mode){
	if (spawner != null) {
		CreatureSpawner spawn = ((CreatureSpawner)spawner.getSingle(e).getState());
		if (mode == ChangeMode.SET) {
			spawn.setCreatureTypeByName((String)delta[0]);
		}
		spawn.update();
	}
}
 
開發者ID:TheLimeGlass,項目名稱:Skellett,代碼行數:12,代碼來源:ExprSpawnerType.java

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

示例8: commandUse

import org.bukkit.block.CreatureSpawner; //導入方法依賴的package包/類
public boolean commandUse(CommandSender sender, String[] args) {
    Variables var = Necessities.getVar();
    if (sender instanceof Player) {
        Player p = (Player) sender;
        User u = Necessities.getUM().getUser(p.getUniqueId());
        Location l = u.getLookingAt();
        if (l == null) {
            p.sendMessage(var.getEr() + "Error: " + var.getErMsg() + "Block out of range.");
            return true;
        }
        if (l.getBlock().getState() instanceof CreatureSpawner) {
            CreatureSpawner spawner = (CreatureSpawner) l.getBlock().getState();
            if (args.length == 0) {
                p.sendMessage(var.getMessages() + "Spawner type is " + spawner.getSpawnedType().toString().replaceAll("_", " ").toLowerCase() + '.');
                return true;
            }
            EntityType spawnerType = getType(args[0]);
            if (spawnerType == null) {
                p.sendMessage(var.getEr() + "Error: " + var.getErMsg() + "Invalid mob type.");
                p.sendMessage(var.getMessages() + "Valid mob types: " + ChatColor.WHITE + validTypes());
                return true;
            }
            spawner.setSpawnedType(spawnerType);
            spawner.update();
            p.sendMessage(var.getMessages() + "Spawner type set to " + var.getObj() + spawner.getSpawnedType().toString().replaceAll("_", " ").toLowerCase() + var.getMessages() + '.');
            return true;
        }
        sender.sendMessage(var.getEr() + "Error: " + var.getErMsg() + "That block is not a spawner.");
        return true;
    } else
        sender.sendMessage(var.getEr() + "Error: " + var.getErMsg() + "You cannot change the type of spawner because you cannot look at the spawner.");
    return true;
}
 
開發者ID:pupnewfster,項目名稱:Necessities,代碼行數:34,代碼來源:CmdSpawner.java

示例9: onBlockPlace

import org.bukkit.block.CreatureSpawner; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR)
public void onBlockPlace(BlockPlaceEvent e) {
    Block block = e.getBlockPlaced();
    ItemStack spawner = e.getItemInHand();
    if (spawner.getType().equals(Material.MOB_SPAWNER) && !e.isCancelled()) {
        if (spawner.getItemMeta().hasLore()) {
            if (spawner.getItemMeta().getLore().toString().contains("Spawner")) {
                CreatureSpawner placedSpawner = (CreatureSpawner) block.getState();
                if (spawner.getItemMeta().getLore().toString().contains("Pig")) {
                    placedSpawner.setSpawnedType(EntityType.PIG);
                } else if (spawner.getItemMeta().getLore().toString().contains("Skeleton")) {
                    placedSpawner.setSpawnedType(EntityType.SKELETON);
                } else if (spawner.getItemMeta().getLore().toString().contains("Spider")) {
                    placedSpawner.setSpawnedType(EntityType.SPIDER);
                } else if (spawner.getItemMeta().getLore().toString().contains("Zombie")) {
                    placedSpawner.setSpawnedType(EntityType.ZOMBIE);
                } else if (spawner.getItemMeta().getLore().toString().contains("Cave Spider")) {
                    placedSpawner.setSpawnedType(EntityType.CAVE_SPIDER);
                } else if (spawner.getItemMeta().getLore().toString().contains("Blaze")) {
                    placedSpawner.setSpawnedType(EntityType.BLAZE);
                } else if (spawner.getItemMeta().getLore().toString().contains("SilverFish")) {
                    placedSpawner.setSpawnedType(EntityType.SILVERFISH);
                }
                placedSpawner.update();
            }
        }
    }
}
 
開發者ID:janie177,項目名稱:MausWasHere,代碼行數:29,代碼來源:BlockListener.java

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

示例11: paste

import org.bukkit.block.CreatureSpawner; //導入方法依賴的package包/類
/**
 * Paste this block at blockLoc
 * @param nms
 * @param blockLoc
 */
//@SuppressWarnings("deprecation")
@SuppressWarnings("deprecation")
public void paste(NMSAbstraction nms, Location blockLoc, boolean usePhysics, Biome biome) {
    // Only paste air if it is below the sea level and in the overworld
    Block block = new Location(blockLoc.getWorld(), x, y, z).add(blockLoc).getBlock();
    block.setBiome(biome);
    nms.setBlockSuperFast(block, typeId, data, usePhysics);
    if (signText != null) {
        if (block.getTypeId() != typeId) {
            block.setTypeId(typeId);
        }
        // Sign
        Sign sign = (Sign) block.getState();
        int index = 0;
        for (String line : signText) {
            sign.setLine(index++, line);
        }
        sign.update(true, false);
    } else if (banner != null) {
        banner.set(block);
    } else if (skull != null){
        skull.set(block);
    } else if (pot != null){
        pot.set(nms, block);
    } else if (spawnerBlockType != null) {
        if (block.getTypeId() != typeId) {
            block.setTypeId(typeId);
        }
        CreatureSpawner cs = (CreatureSpawner)block.getState();
        cs.setSpawnedType(spawnerBlockType);
        //Bukkit.getLogger().info("DEBUG: setting spawner");
        cs.update(true, false);
    } else if (!chestContents.isEmpty()) {
        if (block.getTypeId() != typeId) {
            block.setTypeId(typeId);
        }
        //Bukkit.getLogger().info("DEBUG: inventory holder "+ block.getType());
        // Check if this is a double chest
        
        InventoryHolder chestBlock = (InventoryHolder) block.getState();
        //InventoryHolder iH = chestBlock.getInventory().getHolder();
        if (chestBlock instanceof DoubleChest) {
            //Bukkit.getLogger().info("DEBUG: double chest");
            DoubleChest doubleChest = (DoubleChest) chestBlock;
            for (ItemStack chestItem: chestContents.values()) {
                doubleChest.getInventory().addItem(chestItem);
            }
        } else {
            // Single chest
            for (Entry<Byte, ItemStack> en : chestContents.entrySet()) {
                //Bukkit.getLogger().info("DEBUG: " + en.getKey() + ","  + en.getValue());
                chestBlock.getInventory().setItem(en.getKey(), en.getValue());
            }
        }
    }
}
 
開發者ID:tastybento,項目名稱:acidisland,代碼行數:62,代碼來源:IslandBlock.java

示例12: modify

import org.bukkit.block.CreatureSpawner; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
public void modify(Block block, boolean applyPhysics) {
    if (!isValid) return;

    try {
        BlockState blockState = block.getState();
        // Clear chests so they don't dump their contents.
        if (blockState instanceof InventoryHolder) {
            NMSUtils.clearItems(block.getLocation());
        }

        if (material != null) {
            byte blockData = data != null ? (byte)(short)data : block.getData();
            block.setTypeIdAndData(material.getId(), blockData, applyPhysics);
            blockState = block.getState();
        }

        // Set tile entity data first
        // Command blocks still prefer internal data for parameterized commands
        if (blockState != null && blockState instanceof CommandBlock && extraData != null && extraData instanceof BlockCommand) {
            CommandBlock command = (CommandBlock)blockState;
            BlockCommand commandData = (BlockCommand)extraData;
            command.setCommand(commandData.command);
            if (commandData.customName != null) {
                command.setName(commandData.customName);
            }
            command.update();
        } else if (extraData != null && extraData instanceof BlockTileEntity) {
            // Tile entity data overrides everything else, and may replace all of this in the future.
            NMSUtils.setTileEntityData(block.getLocation(), ((BlockTileEntity) extraData).data);
        } else if (blockState != null && (material == Material.STANDING_BANNER || material == Material.WALL_BANNER) && extraData != null && extraData instanceof BlockBanner) {
            if (blockState != null && blockState instanceof Banner) {
                BlockBanner bannerData = (BlockBanner)extraData;
                Banner banner = (Banner)blockState;
                if (bannerData.patterns != null)
                {
                    banner.setPatterns(bannerData.patterns);
                }
                if (bannerData.baseColor != null)
                {
                    banner.setBaseColor(bannerData.baseColor);
                }
            }
            blockState.update(true, false);
        } else if (blockState != null && blockState instanceof Skull && extraData != null && extraData instanceof BlockSkull) {
            Skull skull = (Skull)blockState;
            BlockSkull skullData = (BlockSkull)extraData;
            if (skullData.skullType != null) {
                skull.setSkullType(skullData.skullType);
            }
            if (skullData.rotation != null) {
                skull.setRotation(skullData.rotation);
            }
            if (skullData.profile != null) {
                CompatibilityUtils.setSkullProfile(skull, skullData.profile);
            }
            skull.update(true, false);
        } else if (blockState != null && blockState instanceof CreatureSpawner && extraData != null && extraData instanceof BlockMobSpawner) {
            BlockMobSpawner spawnerData = (BlockMobSpawner)extraData;
            if (spawnerData.mobName != null && !spawnerData.mobName.isEmpty())
            {
                CreatureSpawner spawner = (CreatureSpawner)blockState;
                spawner.setCreatureTypeByName(spawnerData.mobName);
                spawner.update();
            }
        }
    } catch (Exception ex) {
        Bukkit.getLogger().warning("Error updating block state: " + ex.getMessage());
    }
}
 
開發者ID:elBukkit,項目名稱:MagicLib,代碼行數:71,代碼來源:MaterialAndData.java


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