本文整理汇总了Java中org.bukkit.potion.Potion.hasExtendedDuration方法的典型用法代码示例。如果您正苦于以下问题:Java Potion.hasExtendedDuration方法的具体用法?Java Potion.hasExtendedDuration怎么用?Java Potion.hasExtendedDuration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.potion.Potion
的用法示例。
在下文中一共展示了Potion.hasExtendedDuration方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testValidity
import org.bukkit.potion.Potion; //导入方法依赖的package包/类
private boolean testValidity(ItemStack[] contents) {
for (ItemStack stack : contents) {
if (stack != null && stack.getType() == Material.POTION && stack.getDurability() != 0) {
Potion potion = Potion.fromItemStack(stack);
// Just to be safe, null check this.
if (potion == null)
continue;
PotionType type = potion.getType();
// Mundane potions etc, can return a null type
if (type == null)
continue;
// is 33s poison, allow
if (type == PotionType.POISON && !potion.hasExtendedDuration() && potion.getLevel() == 1) {
continue;
}
if (potion.getLevel() > getMaxLevel(type)) {
return false;
}
}
}
return true;
}
示例2: isExtendedPotion
import org.bukkit.potion.Potion; //导入方法依赖的package包/类
public static boolean isExtendedPotion(ItemStack itemStack) {
if (itemStack.getItemMeta() instanceof PotionMeta) {
if (Utils.getMajorVersion() >= 9) {
PotionMeta potionMeta = (PotionMeta) itemStack.getItemMeta();
return potionMeta.getBasePotionData().isExtended();
} else {
Potion potion = Potion.fromItemStack(itemStack);
return potion.hasExtendedDuration();
}
}
return false;
}
示例3: fromPotion
import org.bukkit.potion.Potion; //导入方法依赖的package包/类
/**
* This parses an Potion into an instance of PotionLayer. This lets you get the potion type, if the potion is strong, if the potion is long, if the potion is lingering, and if the potion is a
* splash potion.
*
* @param item
* @return {@link PotionLayer}. If it fails to parse, or the item argument is not a valid potion this will return null.
* @throws Exception
*/
@Deprecated
private static PotionLayer fromPotion(Potion potion) throws Exception {
PotionType type = PotionType.match(potion.getType());
if (type == null) {
throw new Exception("no enum for " + potion.getType().name());
}
return new PotionLayer(type, potion.getLevel() > 1, potion.hasExtendedDuration(), false, potion.isSplash());
}