Java 类org.bukkit.material.SpawnEgg 实例源码

项目:uSkyBlock    文件:SpawnEvents.java   
@EventHandler
public void onSpawnEggEvent(PlayerInteractEvent event) {
    Player player = event != null ? event.getPlayer() : null;
    if (player == null || event.isCancelled() || !plugin.isSkyWorld(player.getWorld())) {
        return; // Bail out, we don't care
    }
    if (hasPermission(player, "usb.mod.bypassprotection") || player.isOp()) {
        return;
    }
    ItemStack item = event.getItem();
    if (RIGHT_CLICKS.contains(event.getAction()) && item != null && item.getType() == Material.MONSTER_EGG && item.getData() instanceof SpawnEgg) {
        if (!plugin.playerIsOnIsland(player)) {
            event.setCancelled(true);
            plugin.notifyPlayer(player, tr("\u00a7eYou can only use spawn-eggs on your own island."));
            return;
        }
        SpawnEgg spawnEgg = (SpawnEgg) item.getData();
        checkLimits(event, spawnEgg.getSpawnedType(), player.getLocation());
        if (event.isCancelled()) {
            plugin.notifyPlayer(player, tr("\u00a7cYou have reached your spawn-limit for your island."));
            event.setUseItemInHand(Event.Result.DENY);
            event.setUseInteractedBlock(Event.Result.DENY);
        }
    }
}
项目:TheSurvivalGames    文件:ThrowableSpawnEggs.java   
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
    Player player = event.getPlayer();
    if ((player.hasPermission("tse.use")) && ((event.getAction().equals(Action.RIGHT_CLICK_AIR)) || (event.getAction().equals(Action.RIGHT_CLICK_BLOCK)))) {
        if (event.getItem() == null)
            return;
        ItemStack item = event.getItem();
        if ((!(item.getData() instanceof SpawnEgg)) || (item == null))
            return;
        SpawnEgg segg = (SpawnEgg) item.getData();
        Egg egg = (Egg) event.getPlayer().launchProjectile(Egg.class);
        this.eggs.put(egg, segg.getSpawnedType());
        if (item.getAmount() > 1)
            item.setAmount(item.getAmount() - 1);
        else {
            player.getInventory().remove(item);
        }
        event.setCancelled(true);
    }
}
项目:SonarPet    文件:INMS.java   
default SpawnEggItemData createSpawnEggData(EntityType entityType, ItemMeta meta) {
    if (Versioning.NMS_VERSION.getMajorVersion() >= 9) throw new UnsupportedOperationException("Can't use bukkit API on versions newer than 1.9");
    Preconditions.checkNotNull(meta, "Null meta");
    Preconditions.checkNotNull(entityType, "Null entity type");
    return new SpawnEggItemData(new SpawnEgg(entityType).getData(), meta) {
        @Override
        @SuppressWarnings("depreciation") // Bukkit is okay on versions less than 1.9, and we've already checked above
        public EntityType getSpawnedType() {
            return ((SpawnEgg) getMaterialData()).getSpawnedType();
        }
    };
}
项目:CratesPlus    文件:Version_Util.java   
public ItemStack getSpawnEgg(EntityType entityType, Integer amount) {
    ItemStack egg = new ItemStack(Material.MONSTER_EGG, amount);
    if (entityType != null) {
        SpawnEgg spawnEgg = new SpawnEgg(entityType);
        egg.setData(spawnEgg);
    }
    return egg;
}
项目:NucleusFramework    文件:PreSpawnEggEvent.java   
/**
 * Get the type of entity being spawned.
 */
public EntityType getEntityType() {
    ItemMeta meta = _spawnEgg.getItemMeta();
    if (meta instanceof SpawnEgg) {
        return ((SpawnEgg) meta).getSpawnedType();
    }
    return EntityType.UNKNOWN;
}
项目:DisableMobs    文件:SpawnListener.java   
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
    ItemStack itemStack = event.getItem();
    if (itemStack != null && itemStack.getData() instanceof SpawnEgg) {
        SpawnEgg data = (SpawnEgg) event.getItem().getData();
        EntityType type = data.getSpawnedType();
        MobPermission permission = plugin.getMobPermission(type);

        if (permission == MobPermission.DISABLED) {
            event.getPlayer().sendMessage(
                  plugin.getDescription().getName() + " prevented " + EntityHelper.getEntityName(type) + " to be spawned.");
            event.setCancelled(true);
        }
    }
}
项目:MazePlugin    文件:Abstract2DMaze.java   
public BlockMeta setChest_Concurrent(int x,int y,int z)
{
    ArrayList<Map<String,Object>> Inventory = new ArrayList<Map<String,Object>>();
    Random random = new Random();
    int maxsize = 27;
    for(int i = 0; i < maxsize;i++)
    {
        Inventory.add(i,null);
    }
    for(int j = 0; j < try_count_takaramono; j++) {
        for (int i = 0; i < gen_count_takaramono; i++) {
            int invnumber = random.nextInt(maxsize);

            ItemStack item;
            if(Inventory.get(i) != null)
            {
                item = ItemStack.deserialize(Inventory.get(i));
            }
            else
            {
                item = null;
            }
            Material m;
            if (item == null) {
                if (random.nextFloat() < chance_takaramono_rare)
                {
                    m = BonusItems_rare.get(random.nextInt(BonusItems_rare.size()));
                }
                else
                {
                    m = BonusItems.get(random.nextInt(BonusItems.size()));
                }
                if(m.toString().matches("(SWORD|CHESTPLATE|HELMET|BOOTS|LEGGINGS|PICKAXE|BOW|BOOK)"))
                {
                    item = new ItemStack(m);
                    for (int k = 0; k < random.nextInt(4); k++) {
                        try {
                            item.addEnchantment(Enchantments.get(random.nextInt(Enchantments.size())), random.nextInt(5));
                        } catch (IllegalArgumentException e)
                        {

                        }
                    }
                }
                else if(m == Material.MONSTER_EGG)
                {

                    item = new SpawnEgg(Monsters.get(random.nextInt(Monsters.size()))).toItemStack();
                }
                else
                {
                    item = new ItemStack(m);
                }
                int amount = 1 + random.nextInt(3);
                if(amount > item.getMaxStackSize())
                {
                    amount = 1;
                }
                item.setAmount(amount);
            }
            Inventory.add(invnumber,item.serialize());
        }
    }
    return new BlockMeta(Material.CHEST,x,y,z,Inventory);
}
项目:MazePlugin    文件:Abstract3DMaze.java   
public BlockMeta setChest_Concurrent(int x,int y,int z)
{
    ArrayList<Map<String,Object>> Inventory = new ArrayList<Map<String,Object>>();
    Random random = new Random();
    int maxsize = 27;
    for(int i = 0; i < maxsize;i++)
    {
        Inventory.add(i,null);
    }
    for(int j = 0; j < try_count_takaramono; j++) {
        for (int i = 0; i < gen_count_takaramono; i++) {
            int invnumber = random.nextInt(maxsize);

            ItemStack item;
            if(Inventory.get(i) != null)
            {
                item = ItemStack.deserialize(Inventory.get(i));
            }
            else
            {
                item = null;
            }
            Material m;
            if (item == null) {
                if (random.nextFloat() < chance_takaramono_rare)
                {
                    m = BonusItems_rare.get(random.nextInt(BonusItems_rare.size()));
                }
                else
                {
                    m = BonusItems.get(random.nextInt(BonusItems.size()));
                }
                if(m.toString().matches("(SWORD|CHESTPLATE|HELMET|BOOTS|LEGGINGS|PICKAXE|BOW|BOOK)"))
                {
                    item = new ItemStack(m);
                    for (int k = 0; k < random.nextInt(4); k++) {
                        try {
                            item.addEnchantment(Enchantments.get(random.nextInt(Enchantments.size())), random.nextInt(5));
                        } catch (IllegalArgumentException e)
                        {

                        }
                    }
                }
                else if(m == Material.MONSTER_EGG)
                {

                    item = new SpawnEgg(Monsters.get(random.nextInt(Monsters.size()))).toItemStack();
                }
                else if(m == Material.SAND || m == Material.COBBLESTONE)
                {
                    item = new ItemStack(m,64);
                    Inventory.add(invnumber,item.serialize());
                    continue;
                }
                else
                {
                    item = new ItemStack(m);
                }
                int amount = 1 + random.nextInt(3);
                if(amount > item.getMaxStackSize())
                {
                    amount = 1;
                }
                item.setAmount(amount);
            }
            Inventory.add(invnumber,item.serialize());
        }
    }
    return new BlockMeta(Material.CHEST,x,y,z,Inventory);
}
项目:SonarPet    文件:INMS.java   
default SpawnEggItemData createSpawnEggData(byte rawData, ItemMeta meta) {
    EntityType entityType = new SpawnEgg(rawData).getSpawnedType();
    if (entityType == null) entityType = SpawnEggItemData.DEFAULT_TYPE;
    return createSpawnEggData(entityType, meta); // Convert raw data to entity type
}
项目:SonarPet    文件:NMSImpl.java   
@Override
public SpawnEggItemData createSpawnEggData(EntityType entityType, ItemMeta meta) {
    checkNotNull(entityType, "Null entity type");
    checkNotNull(meta, "Null item meta");
    return new NMSSpawnEggItemData(new SpawnEgg(entityType).getData(), meta, entityType); // Pretend we use metadata to make the code happy
}
项目:SonarPet    文件:NMSImpl.java   
@Override
public SpawnEggItemData createSpawnEggData(EntityType entityType, ItemMeta meta) {
    checkNotNull(entityType, "Null entity type");
    checkNotNull(meta, "Null item meta");
    return new NMSSpawnEggItemData(new SpawnEgg(entityType).getData(), meta, entityType); // Pretend we use metadata to make the code happy
}
项目:SonarPet    文件:NMSImpl.java   
@Override
public SpawnEggItemData createSpawnEggData(EntityType entityType, ItemMeta meta) {
    checkNotNull(entityType, "Null entity type");
    checkNotNull(meta, "Null item meta");
    return new NMSSpawnEggItemData(new SpawnEgg(entityType).getData(), meta, entityType); // Pretend we use metadata to make the code happy
}
项目:SonarPet    文件:NMSImpl.java   
@Override
public SpawnEggItemData createSpawnEggData(EntityType entityType, ItemMeta meta) {
    checkNotNull(entityType, "Null entity type");
    checkNotNull(meta, "Null item meta");
    return new NMSSpawnEggItemData(new SpawnEgg(entityType).getData(), meta, entityType); // Pretend we use metadata to make the code happy
}
项目:SonarPet    文件:NMSImpl.java   
@Override
public SpawnEggItemData createSpawnEggData(EntityType entityType, ItemMeta meta) {
    checkNotNull(entityType, "Null entity type");
    checkNotNull(meta, "Null item meta");
    return new NMSSpawnEggItemData(new SpawnEgg(entityType).getData(), meta, entityType); // Pretend we use metadata to make the code happy
}
项目:CratesPlus    文件:Version_Util.java   
public EntityType getEntityTypeFromItemStack(ItemStack itemStack) {
    SpawnEgg spawnEgg = (SpawnEgg) itemStack.getData();
    return spawnEgg.getSpawnedType();
}
项目:acidisland    文件:NMSHandler.java   
@Override
public ItemStack getSpawnEgg(EntityType type, int amount) {
    SpawnEgg egg = new SpawnEgg(type);
    return egg.toItemStack(amount);
}
项目:acidisland    文件:NMSHandler.java   
@Override
public ItemStack getSpawnEgg(EntityType type, int amount) {
    SpawnEgg egg = new SpawnEgg(type);
    return egg.toItemStack(amount);
}
项目:acidisland    文件:NMSHandler.java   
@Override
public ItemStack getSpawnEgg(EntityType type, int amount) {
    SpawnEgg egg = new SpawnEgg(type);
    return egg.toItemStack(amount);
}
项目:acidisland    文件:NMSHandler.java   
@Override
public ItemStack getSpawnEgg(EntityType type, int amount) {
    SpawnEgg egg = new SpawnEgg(type);
    return egg.toItemStack(amount);
}
项目:acidisland    文件:NMSHandler.java   
@Override
public ItemStack getSpawnEgg(EntityType type, int amount) {
    SpawnEgg egg = new SpawnEgg(type);
    return egg.toItemStack(amount);
}
项目:acidisland    文件:NMSHandler.java   
@Override
public ItemStack getSpawnEgg(EntityType type, int amount) {
    SpawnEgg egg = new SpawnEgg(type);
    return egg.toItemStack(amount);
}
项目:askyblock    文件:NMSHandler.java   
@Override
public ItemStack getSpawnEgg(EntityType type, int amount) {
    SpawnEgg egg = new SpawnEgg(type);
    return egg.toItemStack(amount);
}
项目:askyblock    文件:NMSHandler.java   
@Override
public ItemStack getSpawnEgg(EntityType type, int amount) {
    SpawnEgg egg = new SpawnEgg(type);
    return egg.toItemStack(amount);
}
项目:askyblock    文件:NMSHandler.java   
@Override
public ItemStack getSpawnEgg(EntityType type, int amount) {
    SpawnEgg egg = new SpawnEgg(type);
    return egg.toItemStack(amount);
}
项目:askyblock    文件:NMSHandler.java   
@Override
public ItemStack getSpawnEgg(EntityType type, int amount) {
    SpawnEgg egg = new SpawnEgg(type);
    return egg.toItemStack(amount);
}
项目:askyblock    文件:NMSHandler.java   
@Override
public ItemStack getSpawnEgg(EntityType type, int amount) {
    SpawnEgg egg = new SpawnEgg(type);
    return egg.toItemStack(amount);
}
项目:askyblock    文件:NMSHandler.java   
@Override
public ItemStack getSpawnEgg(EntityType type, int amount) {
    SpawnEgg egg = new SpawnEgg(type);
    return egg.toItemStack(amount);
}
项目:BedrockAPI    文件:SpawnEgg.java   
public SpawnEgg() {
}
项目:BedrockAPI    文件:SpawnEgg.java   
@Deprecated public SpawnEgg(int type, byte data) {
}
项目:BedrockAPI    文件:SpawnEgg.java   
@Deprecated public SpawnEgg(byte data) {
}
项目:BedrockAPI    文件:SpawnEgg.java   
public SpawnEgg(EntityType type) {
}
项目:BedrockAPI    文件:SpawnEgg.java   
public SpawnEgg clone() {
    return null;
}
项目:CraftFX    文件:MaterialDataUtil.java   
public static MaterialData getMaterialData(String identifier) {
    final String[] split = identifier.replaceAll("\\s+", "_").split("\\W");
    // TODO: Add additional material/name database like essentials/worldedit have
    Material material = matchMaterial(split[0]);

    if (material == null) {
        // try worldedit
        material = getWEMaterial(split[0]);
        if (material == null) return null;
    }

    if (split.length == 1) {
        return new MaterialData(material);
    }

    try {
        final byte rawData = Byte.parseByte(split[1]);
        return new MaterialData(material, rawData);
    } catch (NumberFormatException e) {
        // ignore
    }

    switch (material) {
        case LEAVES:
            return getMaterialData(material, Leaves::new, TreeSpecies.class, split[1]);
        case COAL:
            return getMaterialData(material, Coal::new, CoalType.class, split[1]);
        case LONG_GRASS:
            return getMaterialData(material, LongGrass::new, GrassSpecies.class, split[1]);
        case SANDSTONE:
            return getMaterialData(material, Sandstone::new, SandstoneType.class, split[1]);
        case MONSTER_EGG:
            return getMaterialData(material, SpawnEgg::new, EntityType.class, split[1]);
        case LOG:
            return getMaterialData(material, Tree::new, TreeSpecies.class, split[1]);
        case WOOD_STEP:
            return getMaterialData(material, WoodenStep::new, TreeSpecies.class, split[1]);
        case WOOL:
            return getMaterialData(material, Wool::new, DyeColor.class, split[1]);
        // TODO: Add Dye here when Spigot finally accepts my PR to match other MaterialData types
        default:
            // Couldn't find additional data for this material
            return new MaterialData(material);
    }
}