本文整理汇总了Java中org.bukkit.inventory.meta.FireworkEffectMeta类的典型用法代码示例。如果您正苦于以下问题:Java FireworkEffectMeta类的具体用法?Java FireworkEffectMeta怎么用?Java FireworkEffectMeta使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FireworkEffectMeta类属于org.bukkit.inventory.meta包,在下文中一共展示了FireworkEffectMeta类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parse
import org.bukkit.inventory.meta.FireworkEffectMeta; //导入依赖的package包/类
public static ItemMeta parse(Element xml, ItemMeta source) {
if (source instanceof BannerMeta) {
return parseBanner(xml, (BannerMeta) source);
} else if (source instanceof BookMeta) {
return parseBook(xml, (BookMeta) source);
} else if (source instanceof EnchantmentStorageMeta) {
return parseEnchantmentStorage(xml, (EnchantmentStorageMeta) source);
} else if (source instanceof FireworkMeta) {
return parseFirework(xml, (FireworkMeta) source);
} else if (source instanceof FireworkEffectMeta) {
return parseFireworkEffect(xml, (FireworkEffectMeta) source);
} else if (source instanceof LeatherArmorMeta) {
return parseLeatherArmor(xml, (LeatherArmorMeta) source);
} else if (source instanceof MapMeta) {
return parseMap(xml, (MapMeta) source);
} else if (source instanceof PotionMeta) {
return parsePotion(xml, (PotionMeta) source);
} else if (source instanceof SkullMeta) {
return parseSkull(xml, (SkullMeta) source);
} else if (source instanceof SpawnEggMeta) {
return parseSpawnEgg(xml, (SpawnEggMeta) source);
}
return source;
}
示例2: apply
import org.bukkit.inventory.meta.FireworkEffectMeta; //导入依赖的package包/类
@Override
public boolean apply(@Nullable ItemStack item1, @Nullable ItemStack item2) {
Boolean b = precondition(item1, item2, true);
if (b != null) {
return b;
}
if (item1.getItemMeta() instanceof FireworkMeta
&& item2.getItemMeta() instanceof FireworkMeta) {
return ((FireworkMeta) item1.getItemMeta()).getEffects()
.equals(((FireworkMeta) item2.getItemMeta()).getEffects());
} else if (item1.getItemMeta() instanceof FireworkEffectMeta
&& item2.getItemMeta() instanceof FireworkEffectMeta) {
return ((FireworkEffectMeta) item1.getItemMeta()).getEffect()
.equals(((FireworkEffectMeta) item2.getItemMeta()).getEffect());
}
return false;
}
示例3: fireworkRemove
import org.bukkit.inventory.meta.FireworkEffectMeta; //导入依赖的package包/类
/**
* Removes a {@link FireworkEffect} by index from this item, assuming it is a firework. If it is
* a
* firework charge, its one and only effect is removed, disregarding the index given.
* <p />
* <b>UNSAFE</b>
*
* @param index index of the firework to remove
*
* @return this item builder instance, for chaining
*/
public ItemBuilder fireworkRemove(int index) {
boolean b = isFireworkEffectMeta();
if (b || isFireworkMeta()) {
try {
if (b) {
((FireworkEffectMeta) this.itemMeta).setEffect(null);
} else {
((FireworkMeta) this.itemMeta).removeEffect(index);
}
} catch (Exception e) {
if (!this.failSilently) {
e.printStackTrace();
}
}
}
return this;
}
示例4: fireworkClear
import org.bukkit.inventory.meta.FireworkEffectMeta; //导入依赖的package包/类
/**
* Clears all {@link FireworkEffect}s on this item, assuming it is a firework or firework charge.
* <p />
* <b>UNSAFE</b>
*
* @return this item builder instance, for chaining
*/
public ItemBuilder fireworkClear() {
boolean b = isFireworkEffectMeta();
if (b || isFireworkMeta()) {
try {
if (b) {
((FireworkEffectMeta) this.itemMeta).setEffect(null);
} else {
((FireworkMeta) this.itemMeta).clearEffects();
}
} catch (Exception e) {
if (!this.failSilently) {
e.printStackTrace();
}
}
}
return this;
}
示例5: initialize
import org.bukkit.inventory.meta.FireworkEffectMeta; //导入依赖的package包/类
@Override
public SerialItemData initialize(ItemStack stack) {
ItemMeta meta = stack.getItemMeta();
if(meta instanceof FireworkEffectMeta) {
valid = true;
FireworkEffectMeta fireworkEffectMeta = (FireworkEffectMeta)meta;
if(fireworkEffectMeta.hasEffect()) {
hasEffect = true;
colors = fireworkEffectMeta.getEffect().getColors();
fadeColors = fireworkEffectMeta.getEffect().getFadeColors();
type = fireworkEffectMeta.getEffect().getType().name();
trail = fireworkEffectMeta.getEffect().hasTrail();
flicker = fireworkEffectMeta.getEffect().hasFlicker();
}
}
return this;
}
示例6: getSpecialMetaString
import org.bukkit.inventory.meta.FireworkEffectMeta; //导入依赖的package包/类
/**
* Gets a String representing all special meta of this ItemStack, if any.
*
* @param is the ItemStack
* @param separators the separators
*
* @return a String representing this ItemStack's special meta or an empty String
*
* @throws InventoryUtilException if something goes wrong
*/
public static String getSpecialMetaString(final ItemStack is, final String[] separators) throws InventoryUtilException {
final ItemMeta meta = is.getItemMeta();
if (meta instanceof BookMeta) {
return getBookMetaString((BookMeta)meta);
} else if (meta instanceof EnchantmentStorageMeta) {
return getEnchantmentStorageMetaString((EnchantmentStorageMeta)meta, separators);
} else if (meta instanceof FireworkEffectMeta) {
return getFireworkEffectMetaString((FireworkEffectMeta)meta);
} else if (meta instanceof FireworkMeta) {
return getFireworkMetaString((FireworkMeta)meta, separators);
} else if (meta instanceof LeatherArmorMeta) {
return getLeatherArmorMetaString((LeatherArmorMeta)meta);
} else if (meta instanceof MapMeta) {
return getMapMetaString((MapMeta)meta);
} else if (meta instanceof PotionMeta) {
return getPotionMetaString((PotionMeta)meta, separators);
} else if (meta instanceof SkullMeta) {
return getSkullMetaString((SkullMeta)meta);
} else {
throw new InventoryUtilException("Unknown Meta type '" + meta.getClass().getName() + "', please report this to the author (Ribesg)!");
}
}
示例7: setTo
import org.bukkit.inventory.meta.FireworkEffectMeta; //导入依赖的package包/类
@Override
public void setTo(ItemMeta meta) {
if(meta instanceof FireworkEffectMeta){
FireworkEffectMeta fire = (FireworkEffectMeta) meta;
FireworkEffect ef = (FireworkEffect) me.getOriginal();
if(ef != null)
fire.setEffect(ef);
}
}
示例8: setFrom
import org.bukkit.inventory.meta.FireworkEffectMeta; //导入依赖的package包/类
@Override
public SubMeta setFrom(ItemMeta meta) {
if(meta instanceof FireworkEffectMeta){
FireworkEffectMeta fire = (FireworkEffectMeta) meta;
me = new FireworkEffects(fire.getEffect());
}
return this;
}
示例9: fireworkAdd
import org.bukkit.inventory.meta.FireworkEffectMeta; //导入依赖的package包/类
/**
* Adds {@link FireworkEffect}s to this item, assuming it is a firework or firework charge.
* <p />
* <b>UNSAFE</b>
*
* @param effects effects to add
*
* @return this item builder instance, for chaining
*/
public ItemBuilder fireworkAdd(@Nonnull FireworkEffect... effects) {
if (effects == null) {
if (!this.failSilently) {
throw new IllegalArgumentException("effects cannot be null.");
}
return this;
}
boolean b = false;
try {
b = isFireworkEffectMeta();
} catch (IllegalStateException ignored) {
}
if (b || isFireworkMeta()) {
try {
if (b) {
((FireworkEffectMeta) this.itemMeta).setEffect(effects[0]);
} else {
((FireworkMeta) this.itemMeta).addEffects(effects);
}
} catch (Exception e) {
if (!this.failSilently) {
e.printStackTrace();
}
}
}
return this;
}
示例10: isFireworkEffectMeta
import org.bukkit.inventory.meta.FireworkEffectMeta; //导入依赖的package包/类
private boolean isFireworkEffectMeta() {
if (!(this.itemMeta instanceof FireworkEffectMeta)) {
if (!this.failSilently) {
throw new IllegalStateException("ItemMeta is not of FireworkEffectMeta.");
}
return false;
}
return true;
}
示例11: CardboardMetaFireworkEffect
import org.bukkit.inventory.meta.FireworkEffectMeta; //导入依赖的package包/类
@SuppressWarnings("deprecation")
public CardboardMetaFireworkEffect(ItemStack firework) {
this.id = firework.getTypeId();
FireworkEffectMeta meta = (FireworkEffectMeta) firework.getItemMeta();
this.effect = new CardboardFireworkEffect(meta.getEffect());
}
示例12: unbox
import org.bukkit.inventory.meta.FireworkEffectMeta; //导入依赖的package包/类
@SuppressWarnings("deprecation")
public ItemMeta unbox() {
FireworkEffectMeta meta = (FireworkEffectMeta) new ItemStack(this.id).getItemMeta();
meta.setEffect(this.effect.unbox());
return meta;
}
示例13: build
import org.bukkit.inventory.meta.FireworkEffectMeta; //导入依赖的package包/类
@Override
public ItemStack build(ItemStack stack) {
if(valid && hasEffect) {
FireworkEffectMeta meta = (FireworkEffectMeta)stack.getItemMeta();
FireworkEffect effect = FireworkEffect.builder().flicker(flicker)
.trail(trail).withColor(colors).withFade(fadeColors)
.with(FireworkEffect.Type.valueOf(type)).build();
meta.setEffect(effect);
stack.setItemMeta(meta);
}
return stack;
}
示例14: fromString
import org.bukkit.inventory.meta.FireworkEffectMeta; //导入依赖的package包/类
/**
* Parses 3 strings into an ItemMeta.
*
* @param meta the ItemMeta to complete
* @param nameString the DisplayName String
* @param loreString the Lore String representation
* @param specialMetaString the Special Meta part String representation
*
* @return the same ItemMeta, completed
*/
public static ItemMeta fromString(final ItemMeta meta, final String nameString, final String loreString, final String specialMetaString, final String[] separators) throws InventoryUtilException {
if (meta instanceof BookMeta) {
parseBookMetaString(specialMetaString, (BookMeta)meta);
} else if (meta instanceof EnchantmentStorageMeta) {
parseEnchantmentStorageMetaString(specialMetaString, (EnchantmentStorageMeta)meta, separators);
} else if (meta instanceof FireworkEffectMeta) {
parseFireworkEffectMetaString(specialMetaString, (FireworkEffectMeta)meta);
} else if (meta instanceof FireworkMeta) {
parseFireworkMetaString(specialMetaString, (FireworkMeta)meta, separators);
} else if (meta instanceof LeatherArmorMeta) {
parseLeatherArmorMetaString(specialMetaString, (LeatherArmorMeta)meta);
} else if (meta instanceof MapMeta) {
parseMapMetaString(specialMetaString, (MapMeta)meta);
} else if (meta instanceof PotionMeta) {
parsePotionMetaString(specialMetaString, (PotionMeta)meta, separators);
} else if (meta instanceof SkullMeta) {
parseSkullMetaString(specialMetaString, (SkullMeta)meta);
}
if (!nameString.isEmpty()) {
meta.setDisplayName(nameString);
}
if (loreString.length() > 1) {
final List<String> lore = new ArrayList<>();
final String separator = loreString.substring(0, 2);
Collections.addAll(lore, StringUtil.splitKeepEmpty(loreString.substring(2), separator));
meta.setLore(lore);
}
return meta;
}
示例15: saveToConfigSection
import org.bukkit.inventory.meta.FireworkEffectMeta; //导入依赖的package包/类
/**
* Saves an ItemMeta to a ConfigurationSection
*
* @param itemSection the parent section of the to-be-created meta section
* @param is the ItemStack
*/
public static void saveToConfigSection(final ConfigurationSection itemSection, final ItemStack is) {
final ItemMeta meta = is.getItemMeta();
if (meta instanceof BookMeta) {
saveBookMetaToConfigSection(createAndGetSection(itemSection, "meta"), (BookMeta)meta);
} else if (meta instanceof EnchantmentStorageMeta) {
saveEnchantmentStorageMetaToConfigSection(createAndGetSection(itemSection, "meta"), (EnchantmentStorageMeta)meta);
} else if (meta instanceof FireworkEffectMeta) {
saveFireworkEffectMetaToConfigSection(createAndGetSection(itemSection, "meta"), (FireworkEffectMeta)meta);
} else if (meta instanceof FireworkMeta) {
saveFireworkMetaToConfigSection(createAndGetSection(itemSection, "meta"), (FireworkMeta)meta);
} else if (meta instanceof LeatherArmorMeta) {
saveLeatherArmorMetaToConfigSection(createAndGetSection(itemSection, "meta"), (LeatherArmorMeta)meta);
} else if (meta instanceof MapMeta) {
saveMapMetaToConfigSection(createAndGetSection(itemSection, "meta"), (MapMeta)meta);
} else if (meta instanceof PotionMeta) {
savePotionMetaToConfigSection(createAndGetSection(itemSection, "meta"), (PotionMeta)meta);
} else if (meta instanceof SkullMeta) {
saveSkullMetaToConfigSection(createAndGetSection(itemSection, "meta"), (SkullMeta)meta);
}
if (meta.hasDisplayName()) {
createAndGetSection(itemSection, "meta").set("name", ColorUtil.decolorize(meta.getDisplayName()));
}
if (meta.hasLore()) {
createAndGetSection(itemSection, "meta").set("lore", ColorUtil.decolorize(meta.getLore()));
}
}