本文整理汇总了Java中org.bukkit.potion.PotionType类的典型用法代码示例。如果您正苦于以下问题:Java PotionType类的具体用法?Java PotionType怎么用?Java PotionType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PotionType类属于org.bukkit.potion包,在下文中一共展示了PotionType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setMainPotionEffect
import org.bukkit.potion.PotionType; //导入依赖的package包/类
public ItemBuilder setMainPotionEffect(PotionType type, boolean extendedDurability, int level, boolean splash) {
if (! (meta instanceof PotionMeta))
return this;
Potion potion = Potion.fromItemStack(stack);
potion.setType(type);
if (! type.isInstant())
potion.setHasExtendedDuration(extendedDurability);
potion.setLevel(level);
potion.setSplash(splash);
potion.apply(stack);
return this;
}
示例2: addPotion
import org.bukkit.potion.PotionType; //导入依赖的package包/类
/**
* Turn an ItemStack with a Material of POTION into a functional potion
* @param typeName PotionType string representing the potion type. (Matches Bukkit PotionType enum.)
* @param upgraded Boolean specifying a level two potion if true
* @param extended Is this an extended duration potion?
*/
public void addPotion(String typeName, boolean upgraded, boolean extended) {
Material mat = this.item.getType();
Set<Material> types = new HashSet<>();
types.add(Material.POTION);
types.add(Material.SPLASH_POTION);
types.add(Material.LINGERING_POTION);
types.add(Material.TIPPED_ARROW);
if (!types.contains(mat)) return;
try {
PotionType type = PotionType.valueOf(typeName.toUpperCase());
PotionData pd = new PotionData(type, extended, upgraded);
PotionMeta meta = (PotionMeta) this.item.getItemMeta();
meta.setBasePotionData(pd);
this.item.setItemMeta(meta);
} catch (Exception ex) {
Bukkit.getLogger().warning(String.format("Kit configuration error: %s", ex.getMessage()));
}
}
示例3: onLoad
import org.bukkit.potion.PotionType; //导入依赖的package包/类
@Override
public void onLoad() {
add(PotionType.UNCRAFTABLE, "Uncraftable", "None", "Default", "Def", "Uncraft", "UC");
add(PotionType.WATER, "Water", "Wat", "WA");
add(PotionType.MUNDANE, "Mundane", "Mun", "MU", "MD");
add(PotionType.THICK, "Thick", "Thi", "TH");
add(PotionType.AWKWARD, "Awkward", "Awk", "AW");
add(PotionType.NIGHT_VISION, "Night Vision", "NV", "NVision", "NightV", "Vision", "Night Vis", "NVis");
add(PotionType.INVISIBILITY, "Invisibility", "Invis", "Inv", "IN");
add(PotionType.JUMP, "Jump", "Jumping", "Leap", "Leaping", "JU", "LE");
add(PotionType.FIRE_RESISTANCE, "Fire Resistance", "FR", "FResistance", "Fire Resist", "Fire Res", "FResist", "FRes", "FireR");
add(PotionType.SPEED, "Speed", "SP");
add(PotionType.SLOWNESS, "Slowness", "SL", "Slow");
add(PotionType.WATER_BREATHING, "Water Breathing", "WBreathing", "WaterBreathing", "Water Breath", "WBreath", "WB");
add(PotionType.INSTANT_HEAL, "Instant Health", "IHealth", "Instant Heal", "IHeal", "Instant HP", "IHP", "IH");
add(PotionType.INSTANT_DAMAGE, "Instant Damage", "IDamage", "Instant Dmg", "IDmg", "Harming", "Harm", "ID");
add(PotionType.POISON, "Poison", "Poi", "Toxic", "PO");
add(PotionType.REGEN, "Regeneration", "Regen", "Reg", "RE");
add(PotionType.STRENGTH, "Strength", "Str", "ST");
add(PotionType.WEAKNESS, "Weakness", "Weak", "WE");
add(PotionType.LUCK, "Luck", "Lucky", "LU");
}
示例4: handlePotions
import org.bukkit.potion.PotionType; //导入依赖的package包/类
/** Handles potions' basic data and counts custom effects */
private void handlePotions(JsonWriter out, PotionMeta meta) throws IOException
{
PotionData base = meta.getBasePotionData();
if (base != null)
{
PotionType type = base.getType();
if (type != null)
out.name("type").value( type.toString() );
out.name("extended").value( base.isExtended() );
out.name("upgraded").value( base.isUpgraded() );
}
if ( meta.hasColor() )
out.name("colorR").value( meta.getColor().getRed() )
.name("colorG").value( meta.getColor().getGreen() )
.name("colorB").value( meta.getColor().getBlue() );
if ( meta.hasCustomEffects() )
out.name("customEffectCount").value( meta.getCustomEffects().size() );
}
示例5: Turret
import org.bukkit.potion.PotionType; //导入依赖的package包/类
public Turret(TurretType turretType, ArrayList<Upgrade> buyableUpgrades, ArrayList<Upgrade> conflicts, Integer fireRate, Double turretDamage, Double turretAccuracy, Double turretCost, Double turretRange, String turretName) {
type = turretType;
speed = fireRate;
damage = turretDamage;
accuracy = turretAccuracy;
cost = turretCost;
name = turretName;
range = turretRange;
unlockedPotionTypes.add(PotionType.POISON);
if(buyableUpgrades != null) {
possibleUpgrades = buyableUpgrades;
}
if(conflicts != null) {
conflictingUpgrades = conflicts;
}
}
示例6: getPotionId
import org.bukkit.potion.PotionType; //导入依赖的package包/类
@Override
public int getPotionId(PotionType type, int level, boolean isSplash, boolean isExtended) {
PreCon.notNull(type);
if (type == PotionType.WATER)
return 0;
int id = type.getDamageValue();
if (level > 1) {
id |= 32;
}
if (isExtended) {
id |= 64;
}
id |= isSplash ? 16384 : 8192;
return id;
}
示例7: removeCustomEffect
import org.bukkit.potion.PotionType; //导入依赖的package包/类
@Override
public boolean removeCustomEffect(PotionEffectType effect) {
int effectId = effect.getId();
MobEffect existing = null;
for (MobEffect mobEffect : getHandle().h) {
if (MobEffectList.getId(mobEffect.getMobEffect()) == effectId) {
existing = mobEffect;
}
}
if (existing == null) {
return false;
}
Validate.isTrue(getBasePotionData().getType() != PotionType.UNCRAFTABLE || getHandle().h.size() != 1, "Tipped Arrows must have at least 1 effect");
getHandle().h.remove(existing);
getHandle().refreshEffects();
return true;
}
示例8: spawnArrow
import org.bukkit.potion.PotionType; //导入依赖的package包/类
public <T extends Arrow> T spawnArrow(Location loc, Vector velocity, float speed, float spread, Class<T> clazz) {
Validate.notNull(loc, "Can not spawn arrow with a null location");
Validate.notNull(velocity, "Can not spawn arrow with a null velocity");
Validate.notNull(clazz, "Can not spawn an arrow with no class");
EntityArrow arrow;
if (TippedArrow.class.isAssignableFrom(clazz)) {
arrow = new EntityTippedArrow(world);
((EntityTippedArrow) arrow).setType(CraftPotionUtil.fromBukkit(new PotionData(PotionType.WATER, false, false)));
} else if (SpectralArrow.class.isAssignableFrom(clazz)) {
arrow = new EntitySpectralArrow(world);
} else {
arrow = new EntityTippedArrow(world);
}
arrow.setPositionRotation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
arrow.shoot(velocity.getX(), velocity.getY(), velocity.getZ(), speed, spread);
world.addEntity(arrow);
return (T) arrow.getBukkitEntity();
}
示例9: toBukkit
import org.bukkit.potion.PotionType; //导入依赖的package包/类
public static PotionData toBukkit(String type) {
if (type == null) {
return new PotionData(PotionType.UNCRAFTABLE, false, false);
}
if (type.startsWith("minecraft:")) {
type = type.substring(10);
}
PotionType potionType = null;
potionType = extendable.inverse().get(type);
if (potionType != null) {
return new PotionData(potionType, true, false);
}
potionType = upgradeable.inverse().get(type);
if (potionType != null) {
return new PotionData(potionType, false, true);
}
potionType = regular.inverse().get(type);
if (potionType != null) {
return new PotionData(potionType, false, false);
}
return new PotionData(PotionType.UNCRAFTABLE, false, false);
}
示例10: splashPotion
import org.bukkit.potion.PotionType; //导入依赖的package包/类
public static ItemStack splashPotion(PotionType type, boolean extended, boolean upgraded, String name, String... lores) {
ItemStack potion = new ItemStack(Material.SPLASH_POTION, 1);
PotionMeta meta = (PotionMeta) potion.getItemMeta();
meta.setBasePotionData(new PotionData(type, extended, upgraded));
potion.setItemMeta(meta);
return potion;
}
示例11: PotionCustomItem
import org.bukkit.potion.PotionType; //导入依赖的package包/类
public PotionCustomItem(Material material, Config config, PlaceholderRegistry placeholders) {
super(material, config, placeholders);
type = config.getEnum("potion-type", PotionType.class);
customColor = PlaceholderValue.colorValue(config.getString("color"));
customEffects = new ArrayList<>();
Collection<Map<String, Object>> rawEffects = (Collection<Map<String, Object>>) config.getCollection("effects");
if(rawEffects != null) {
for (Map<String, Object> e : rawEffects)
customEffects.add(new PotionEffect(e));
}
}
示例12: createPotion
import org.bukkit.potion.PotionType; //导入依赖的package包/类
public static ItemStack createPotion(PotionType potionType, int level, String name) {
Potion potion = new Potion(potionType);
potion.setLevel(level);
ItemStack itemStack = potion.toItemStack(1);
ItemMeta meta = itemStack.getItemMeta();
meta.setDisplayName(name);
itemStack.setItemMeta(meta);
return itemStack;
}
示例13: addPotionType
import org.bukkit.potion.PotionType; //导入依赖的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;
}
示例14: itemWithTypedMetaMatches
import org.bukkit.potion.PotionType; //导入依赖的package包/类
@Test
public void itemWithTypedMetaMatches() throws Throwable {
ImItemStack item = ItemStack.builder(Material.POTION)
.meta(PotionMeta.class, meta -> meta.setBasePotionData(new PotionData(PotionType.LUCK, false, false)))
.immutable();
assertMatches(item, item);
}
示例15: vanillaBrews
import org.bukkit.potion.PotionType; //导入依赖的package包/类
@Test
public void vanillaBrews() throws Exception {
assertEquals(BENEFICIAL, classify(Bukkit.potionRegistry().get(Bukkit.key("healing"))));
assertEquals(BENEFICIAL, classify(new PotionData(PotionType.INSTANT_HEAL, false, false)));
assertEquals(HARMFUL, classify(Bukkit.potionRegistry().get(Bukkit.key("harming"))));
assertEquals(HARMFUL, classify(new PotionData(PotionType.INSTANT_DAMAGE, false, false)));
}