本文整理汇总了Java中org.bukkit.inventory.meta.PotionMeta.addCustomEffect方法的典型用法代码示例。如果您正苦于以下问题:Java PotionMeta.addCustomEffect方法的具体用法?Java PotionMeta.addCustomEffect怎么用?Java PotionMeta.addCustomEffect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.inventory.meta.PotionMeta
的用法示例。
在下文中一共展示了PotionMeta.addCustomEffect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: LuckyPotion
import org.bukkit.inventory.meta.PotionMeta; //导入方法依赖的package包/类
public void LuckyPotion(BlockBreakEvent event){
Location loc = event.getBlock().getLocation();
World world = loc.getWorld();
ItemStack energyPotion = new ItemStack(Material.POTION, 1);
PotionMeta energyPotionMeta = (PotionMeta) energyPotion.getItemMeta();
energyPotionMeta.setDisplayName("§6Lucky Potion");
List<String> lore = new ArrayList<String>();
lore.add("§6"+ LuckyBlocksMainController.instance.language.getString("POTION_DURATION"));
energyPotionMeta.setLore(lore);
energyPotionMeta.addCustomEffect(new PotionEffect(PotionEffectType.SPEED, 20*60, 1), true);
energyPotionMeta.addCustomEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 20*60, 1), true);
energyPotionMeta.addCustomEffect(new PotionEffect(PotionEffectType.ABSORPTION, 20*60, 1), true);
energyPotionMeta.addCustomEffect(new PotionEffect(PotionEffectType.HEAL, 20*60, 1), true);
energyPotionMeta.addCustomEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST, 20*60, 1), true);
energyPotionMeta.addCustomEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 20*60, 1), true);
energyPotionMeta.addCustomEffect(new PotionEffect(PotionEffectType.JUMP, 20*60, 3), true);
energyPotionMeta.addCustomEffect(new PotionEffect(PotionEffectType.WATER_BREATHING, 20*60, 3), true);
energyPotion.setItemMeta(energyPotionMeta);
Potion po = new Potion((byte) 8258);
po.apply(energyPotion);
world.dropItemNaturally(loc,energyPotion);
}
示例2: toItemStack
import org.bukkit.inventory.meta.PotionMeta; //导入方法依赖的package包/类
public ItemStack toItemStack(int amount) {
ItemStack potion = new ItemStack(Material.POTION, amount, this.getDataValue());
PotionMeta meta = (PotionMeta) potion.getItemMeta();
if (this.getName() != null) {
meta.setDisplayName(this.getName());
}
if (this.getLore() != null && !this.getLore().isEmpty()) {
meta.setLore(this.getLore());
}
if (!this.getEffects().isEmpty()) {
for (PotionEffect effect : this.getEffects()) {
meta.addCustomEffect(effect, true);
}
}
potion.setItemMeta(meta);
return potion;
}
示例3: processMeta
import org.bukkit.inventory.meta.PotionMeta; //导入方法依赖的package包/类
@Override
public void processMeta(Player player, ItemMeta m) {
super.processMeta(player, m);
PotionMeta meta = (PotionMeta) m;
if(type != null)
meta.setBasePotionData(new PotionData(type));
if(customColor != null)
meta.setColor(customColor.resolve(player));
meta.clearCustomEffects();
for(PotionEffect e : customEffects)
meta.addCustomEffect(e, true);
}
示例4: addPotionType
import org.bukkit.inventory.meta.PotionMeta; //导入方法依赖的package包/类
public ItemMaker addPotionType(PotionType type, int time, int amplifier) {
PotionMeta itemMeta = (PotionMeta) this.itemStack.getItemMeta();
itemMeta.setMainEffect(type.getEffectType());
itemMeta.addCustomEffect(new PotionEffect(type.getEffectType(), time * 20, amplifier), true);
this.itemStack.setItemMeta(itemMeta);
return this;
}
示例5: onPlayerDeath
import org.bukkit.inventory.meta.PotionMeta; //导入方法依赖的package包/类
/**
* Drop player's potion effect on his death
*
* @param event Event
*/
@EventHandler
public void onPlayerDeath(PlayerDeathEvent event)
{
for (PotionEffect potionEffect : event.getEntity().getActivePotionEffects())
{
if (this.blacklist.contains(potionEffect.getType()))
continue;
if (PotionType.getByEffect(potionEffect.getType()) == null)
continue;
if(potionEffect.getDuration() > 10000)
continue;
Potion potion = new Potion(PotionType.getByEffect(potionEffect.getType()), potionEffect.getAmplifier() + 1);
ItemStack stack = potion.toItemStack(1);
PotionMeta meta = (PotionMeta) stack.getItemMeta();
meta.clearCustomEffects();
meta.addCustomEffect(new PotionEffect(potionEffect.getType(), potionEffect.getDuration(), potionEffect.getAmplifier()), true);
stack.setItemMeta(meta);
event.getDrops().add(stack);
event.getEntity().removePotionEffect(potionEffect.getType());
}
}
示例6: getResult
import org.bukkit.inventory.meta.PotionMeta; //导入方法依赖的package包/类
public ItemStack getResult() {
ItemStack is = new ItemStack(Material.POTION);
PotionMeta pm = (PotionMeta) is.getItemMeta();
pm.addCustomEffect(new PotionEffect(potionEffectType, maxDuration, maxAmplifier), true);
pm.setMainEffect(potionEffectType);
is.setItemMeta(pm);
return is;
}
示例7: parsePotion
import org.bukkit.inventory.meta.PotionMeta; //导入方法依赖的package包/类
public static PotionMeta parsePotion(Element xml, PotionMeta source) {
for (Element effectElement : xml.getChildren("potion-effect")) {
PotionEffect effect = XMLPotionEffect.parse(effectElement);
if (effect != null) {
source.addCustomEffect(effect, false);
}
}
return source;
}
示例8: CustomPotion
import org.bukkit.inventory.meta.PotionMeta; //导入方法依赖的package包/类
@Deprecated
public CustomPotion(String name, int durability, String[] lore, PotionEffect effect) {
super(Material.POTION, name, (ReflectionUtils.getVersion().startsWith("v1_8_")) ? durability: 0, lore);
PotionMeta meta = (PotionMeta) getItemMeta();
if (ReflectionUtils.getVersion().startsWith("v1_8_")) meta.setMainEffect(PotionEffectType.SATURATION);
else meta.setMainEffect(effect.getType());
meta.addCustomEffect(effect, true);
setItemMeta(meta);
}
示例9: parsePotionEffects
import org.bukkit.inventory.meta.PotionMeta; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void parsePotionEffects() {
PotionMeta customPotionMeta = (PotionMeta) this.finalStack.getItemMeta();
for (Object potionEffect : (List<Object>) this.linkedSection.get("effects")) {
LinkedHashMap<String, Object> potionEffectSection =
(LinkedHashMap<String, Object>) potionEffect;
if (!potionEffectSection.containsKey("type")) {
continue;
}
PotionEffectType potionEffectType = null;
int duration = 1;
int amplifier = 0;
potionEffectType =
PotionEffectType.getByName(potionEffectSection.get("type").toString().toUpperCase());
if (potionEffectSection.containsKey("duration")) {
duration = Integer.parseInt(potionEffectSection.get("duration").toString()) * 20;
}
if (potionEffectSection.containsKey("amplifier")) {
amplifier = Integer.parseInt(potionEffectSection.get("amplifier").toString()) - 1;
}
if (potionEffectType == null) {
continue;
}
customPotionMeta.addCustomEffect(new PotionEffect(potionEffectType, duration, amplifier),
true);
}
this.finalStack.setItemMeta(customPotionMeta);
}
示例10: parsePotionMetaString
import org.bukkit.inventory.meta.PotionMeta; //导入方法依赖的package包/类
private static void parsePotionMetaString(final String string, final PotionMeta meta, final String[] separators) {
final String[] split = StringUtil.splitKeepEmpty(string, separators[1]);
for (final String effectString : split) {
final String[] effectSplit = StringUtil.splitKeepEmpty(effectString, separators[2]);
final PotionEffectType type = PotionEffectType.getByName(effectSplit[0]);
final int duration = Integer.parseInt(effectSplit[1]);
final int amplifier = Integer.parseInt(effectSplit[2]);
meta.addCustomEffect(new PotionEffect(type, duration, amplifier), true);
}
}
示例11: loadPotionMetaFromConfigSection
import org.bukkit.inventory.meta.PotionMeta; //导入方法依赖的package包/类
private static void loadPotionMetaFromConfigSection(final ConfigurationSection metaSection, final PotionMeta meta) {
if (metaSection.isConfigurationSection("potion")) {
final ConfigurationSection potionSection = metaSection.getConfigurationSection("potion");
for (final String key : potionSection.getKeys(false)) {
if (key.startsWith("potionEffect") && potionSection.isConfigurationSection(key)) {
final ConfigurationSection potionEffectSection = potionSection.getConfigurationSection(key);
final PotionEffectType type = PotionEffectType.getByName(potionEffectSection.getString("type"));
final int duration = potionEffectSection.getInt("duration");
final int amplifier = potionEffectSection.getInt("amplifier");
meta.addCustomEffect(new PotionEffect(type, duration, amplifier), true);
}
}
}
}
示例12: change
import org.bukkit.inventory.meta.PotionMeta; //导入方法依赖的package包/类
@Override
public void change(Event e, Object[] delta, @NotNull Changer.ChangeMode mode) {
ItemStack i = item.getSingle(e);
if (i == null) {
return;
}
if (PotionUtils.isPotionItem(i)) {
PotionMeta meta = (PotionMeta) i.getItemMeta();
PotionEffect potionEffect = (meta.getBasePotionData().getType() != PotionType.UNCRAFTABLE)
? PotionUtils.getEffectByEffectType(meta, effectType.getSingle(e))
: PotionUtils.fromPotionData(meta.getBasePotionData());
if (potionEffect == null) {
return;
}
if (meta.getBasePotionData().getType() != PotionType.UNCRAFTABLE) {
meta.removeCustomEffect(effectType.getSingle(e));
} else {
meta.setBasePotionData(PotionUtils.emptyPotionData());
}
Number number = (Number) delta[0];
switch (mode) {
case ADD:
meta.addCustomEffect(new PotionEffect(
potionEffect.getType(),
potionEffect.getDuration(),
potionEffect.getAmplifier() + number.intValue(),
potionEffect.isAmbient(),
potionEffect.hasParticles(),
potionEffect.getColor()
), true);
break;
case SET:
meta.addCustomEffect(new PotionEffect(
potionEffect.getType(),
potionEffect.getDuration(),
number.intValue(),
potionEffect.isAmbient(),
potionEffect.hasParticles(),
potionEffect.getColor()
), true);
break;
case REMOVE:
meta.addCustomEffect(new PotionEffect(
potionEffect.getType(),
potionEffect.getDuration(),
(potionEffect.getAmplifier() - number.intValue() > 0)
? potionEffect.getAmplifier() - number.intValue()
: potionEffect.getAmplifier(),
potionEffect.isAmbient(),
potionEffect.hasParticles(),
potionEffect.getColor()
), true);
break;
}
}
}
示例13: change
import org.bukkit.inventory.meta.PotionMeta; //导入方法依赖的package包/类
@Override
public void change(Event e, Object[] delta, @NotNull Changer.ChangeMode mode) {
ItemStack i = item.getSingle(e);
if (i == null) {
return;
}
if (PotionUtils.isPotionItem(i)) {
PotionMeta meta = (PotionMeta) i.getItemMeta();
PotionEffect potionEffect = (meta.getBasePotionData().getType() != PotionType.UNCRAFTABLE)
? PotionUtils.getEffectByEffectType(meta, effectType.getSingle(e))
: PotionUtils.fromPotionData(meta.getBasePotionData());
if (potionEffect == null) {
return;
}
if (meta.getBasePotionData().getType() != PotionType.UNCRAFTABLE) {
meta.removeCustomEffect(effectType.getSingle(e));
} else {
meta.setBasePotionData(PotionUtils.emptyPotionData());
}
Timespan timespan = (Timespan) delta[0];
switch (mode) {
case ADD:
meta.addCustomEffect(new PotionEffect(
potionEffect.getType(),
potionEffect.getDuration() + Math.toIntExact(timespan.getTicks_i()),
potionEffect.getAmplifier(),
potionEffect.isAmbient(),
potionEffect.hasParticles(),
potionEffect.getColor()
), true);
break;
case SET:
meta.addCustomEffect(new PotionEffect(
potionEffect.getType(),
Math.toIntExact(timespan.getTicks_i()),
potionEffect.getAmplifier(),
potionEffect.isAmbient(),
potionEffect.hasParticles(),
potionEffect.getColor()
), true);
break;
case REMOVE:
meta.addCustomEffect(new PotionEffect(
potionEffect.getType(),
(potionEffect.getDuration() - Math.toIntExact(timespan.getTicks_i()) > 0)
? potionEffect.getDuration() - Math.toIntExact(timespan.getTicks_i())
: potionEffect.getDuration(),
potionEffect.getAmplifier(),
potionEffect.isAmbient(),
potionEffect.hasParticles(),
potionEffect.getColor()
), true);
break;
}
}
}
示例14: createItem
import org.bukkit.inventory.meta.PotionMeta; //导入方法依赖的package包/类
public static ItemStack createItem(LootType type) {
if (type == LootType.RANDOM) type = types.get(CSCoreLib.randomizer().nextInt(types.size()));
if (type == LootType.SLIMEFUN && !Bukkit.getPluginManager().isPluginEnabled("Slimefun")) type = LootType.TREASURE;
ItemStack item = new ItemStack(Material.AIR);
try {
switch(type) {
case BOOK: {
item.setType(Material.ENCHANTED_BOOK);
item = applyTier(item, LootTier.getRandom());
break;
}
case TREASURE: {
item.setType(TREASURE.get(CSCoreLib.randomizer().nextInt(TREASURE.size())));
item.setAmount(CSCoreLib.randomizer().nextInt(max_items - min_items) + min_items);
break;
}
case POTION: {
item.setType(Material.POTION);
item.setDurability(CSCoreLib.randomizer().nextInt(100) > 50 ? (short) 8194: 16386);
String name = COLOR.get(CSCoreLib.randomizer().nextInt(COLOR.size())) + PREFIX.get(CSCoreLib.randomizer().nextInt(PREFIX.size())) + " " + SUFFIX.get(CSCoreLib.randomizer().nextInt(SUFFIX.size()));
PotionMeta meta = (PotionMeta) item.getItemMeta();
meta.setMainEffect(PotionEffectType.HEAL);
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
for (int i = 0; i < CSCoreLib.randomizer().nextInt(max_potions - min_potions) + min_potions; i++) {
PotionEffectType e = POTIONEFFECTS.get(CSCoreLib.randomizer().nextInt(POTIONEFFECTS.size()));
meta.addCustomEffect(new PotionEffect(e, (CSCoreLib.randomizer().nextInt(max_items - min_items) + min_items) * 10 * 20, CSCoreLib.randomizer().nextInt(MagicLoot.getMaxLevel(e) - 1) + 1), true);
}
item.setItemMeta(meta);
break;
}
case TOOL: {
if (CSCoreLib.randomizer().nextInt(100) < 10) item = new ItemStack(Material.ARROW, 4 + CSCoreLib.randomizer().nextInt(20));
else {
item.setType(TOOLS.get(CSCoreLib.randomizer().nextInt(TOOLS.size())));
if (item.getType().getMaxDurability() == 0) break;
item = applyTier(item, LootTier.getRandom());
item.setDurability((short) (CSCoreLib.randomizer().nextInt(item.getType().getMaxDurability() / 4) * 3));
}
break;
}
case SLIMEFUN: {
item = SLIMEFUN.get(CSCoreLib.randomizer().nextInt(SLIMEFUN.size())).clone();
item.setAmount(CSCoreLib.randomizer().nextInt(max_slimefun - min_slimefun) + min_slimefun);
if (!item.getType().equals(Material.SKULL_ITEM) && item.getType().getMaxStackSize() < item.getAmount()) item.setAmount(item.getType().getMaxStackSize());
break;
}
case UNANALIZED: {
item.setType(TOOLS.get(CSCoreLib.randomizer().nextInt(TOOLS.size())));
ItemMeta im = item.getItemMeta();
im.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&7&kMEH WANNA BE EXAMINED"));
List<String> lore = new ArrayList<String>();
lore.add("");
lore.add("�8Tier: �b�d�e�cUnknown");
im.setLore(lore);
item.setItemMeta(im);
if (item.getType().getMaxDurability() > 0) item.setDurability((short) (CSCoreLib.randomizer().nextInt(item.getType().getMaxDurability() / 4) * 3));
break;
}
default:
break;
}
} catch(Exception x) {
x.printStackTrace();
}
return item;
}
示例15: parseItemStack
import org.bukkit.inventory.meta.PotionMeta; //导入方法依赖的package包/类
public static ItemStack parseItemStack(ConfigSection config) {
Material material = parseEnum(Material.class, config.getAsString("item"));
int amount = config.getInt("amount", 1);
short data = (short) config.getInt("data", 0);
String title = config.getString("title", null);
List<String> lore = config.getStringList("lore");
Color color = parseColor(config.getAsString("color"));
Map<Enchantment, Integer> enchantments = parseEnchantments(config.getStringList("enchantments"));
List<PotionEffect> potions = new ArrayList<PotionEffect>();
for (ConfigSection cs : config.getSectionList("potions"))
potions.add(parsePotion(cs));
{
ItemStack itemStack = new ItemStack(material, amount, (short) data);
ItemMeta meta = itemStack.getItemMeta();
if (title != null)
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', title));
meta.setLore(lore);
if (material.name().contains("LEATHER")) {
LeatherArmorMeta armorMeta = (LeatherArmorMeta) meta;
armorMeta.setColor(color);
}
if (material == Material.POTION) {
PotionMeta potionMeta = (PotionMeta) meta;
for (PotionEffect potion : potions)
potionMeta.addCustomEffect(potion, true);
}
itemStack.setItemMeta(meta);
itemStack.addEnchantments(enchantments);
return itemStack;
}
}