当前位置: 首页>>代码示例>>Java>>正文


Java PotionMeta.setMainEffect方法代码示例

本文整理汇总了Java中org.bukkit.inventory.meta.PotionMeta.setMainEffect方法的典型用法代码示例。如果您正苦于以下问题:Java PotionMeta.setMainEffect方法的具体用法?Java PotionMeta.setMainEffect怎么用?Java PotionMeta.setMainEffect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.inventory.meta.PotionMeta的用法示例。


在下文中一共展示了PotionMeta.setMainEffect方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: potionMain

import org.bukkit.inventory.meta.PotionMeta; //导入方法依赖的package包/类
/**
 * Sets this item's main effect, assuming it is a potion.
 * <p />
 * <b>UNSAFE</b>
 *
 * @param effectType effect type to set
 *
 * @return this item builder instance, for chaining
 * @see ItemBuilder#potionMain(PotionData) 
 */
@Deprecated
public ItemBuilder potionMain(PotionEffectType effectType) {
  if (isPotionMeta()) {
    try {
      PotionMeta potionMeta = (PotionMeta) this.itemMeta;
      if (potionMeta.setMainEffect(effectType) == false) {
        potionMeta.setBasePotionData(new PotionData(potionTypeFromLegacy(effectType), false, false));
      }
    } catch (Exception e) {
      if (!this.failSilently) {
        e.printStackTrace();
      }
    }
  }
  return this;
}
 
开发者ID:SupaHam,项目名称:SupaCommons,代码行数:27,代码来源:ItemBuilder.java

示例2: 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;
}
 
开发者ID:cadox8,项目名称:WC,代码行数:10,代码来源:ItemMaker.java

示例3: 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;
}
 
开发者ID:crazyhorse961,项目名称:NationZ,代码行数:9,代码来源:BrewingRecipe.java

示例4: 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);
}
 
开发者ID:TheBusyBiscuit,项目名称:CS-CoreLib,代码行数:10,代码来源:CustomPotion.java

示例5: 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;
}
 
开发者ID:TheBusyBiscuit,项目名称:MagicLoot3,代码行数:69,代码来源:ItemManager.java


注:本文中的org.bukkit.inventory.meta.PotionMeta.setMainEffect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。