本文整理汇总了Java中org.bukkit.potion.PotionEffectType.getByName方法的典型用法代码示例。如果您正苦于以下问题:Java PotionEffectType.getByName方法的具体用法?Java PotionEffectType.getByName怎么用?Java PotionEffectType.getByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.potion.PotionEffectType
的用法示例。
在下文中一共展示了PotionEffectType.getByName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: craftPotionEffect
import org.bukkit.potion.PotionEffectType; //导入方法依赖的package包/类
public static PotionEffect craftPotionEffect(String name, ConfigurationSection section) {
if(section == null){
Error.MISSING.add();
return null;
}
PotionEffectType effect = PotionEffectType.getByName(name);
if( effect == null ) {
ErrorLogger.addError(name + " is not a valid potion effect type !");
return null;
}
int duration = section.getInt(Node.DURATION.get(), 120)*20;
int amplifier = section.getInt(Node.LEVEL.get(), 1) - 1;
boolean ambient = section.getBoolean(Node.AMBIANT.get(), true);
boolean particles = section.getBoolean(Node.PARTICLE.get(), true);
return new PotionEffect(effect, duration, amplifier, ambient, particles);
}
示例2: parsePotionEffect
import org.bukkit.potion.PotionEffectType; //导入方法依赖的package包/类
private PotionEffect parsePotionEffect(JsonObject jsonObject) {
PotionEffectType type = PotionEffectType.getByName(Strings.getTechnicalName(jsonObject.get("type").getAsString()));
int duration = 30;
int amplifier = 0;
boolean ambient = true;
boolean particles = true;
//Color color = null;
if (jsonObject.has("duration")) { // Ticks
duration = jsonObject.get("duration").getAsInt();
}
if (jsonObject.has("amplifier")) {
amplifier = jsonObject.get("amplifier").getAsInt();
}
if (jsonObject.has("ambient")) {
ambient = jsonObject.get("ambient").getAsBoolean();
}
if (jsonObject.has("particles")) {
particles = jsonObject.get("particles").getAsBoolean();
}
//if (jsonObject.has("color")) color = Color.jsonObject.get("color")
return new PotionEffect(type, duration, amplifier, ambient, particles, null);
}
示例3: parsePotionEffectType
import org.bukkit.potion.PotionEffectType; //导入方法依赖的package包/类
public static PotionEffectType parsePotionEffectType(Node node, String text) throws InvalidXMLException {
PotionEffectType type = PotionEffectType.getByName(text.toUpperCase().replace(" ", "_"));
if(type == null) type = Bukkit.potionEffectRegistry().get(parseKey(node, text));
if(type == null) {
throw new InvalidXMLException("Unknown potion effect '" + node.getValue() + "'", node);
}
return type;
}
示例4: deserializePotionEffect
import org.bukkit.potion.PotionEffectType; //导入方法依赖的package包/类
public static PotionEffect deserializePotionEffect(String raw) {
String[] arr = raw.split(",");
PotionEffectType type = PotionEffectType.getByName(arr[0].toUpperCase());
int level = Integer.parseInt(arr[1]);
int duration = 2147483647;
if (arr.length > 2)
duration = Integer.parseInt(arr[2]);
return new PotionEffect(type, duration, level - 1);
}
示例5: getPotionEffects
import org.bukkit.potion.PotionEffectType; //导入方法依赖的package包/类
public static List<PotionEffect> getPotionEffects(int food) {
List<PotionEffect> effects = new ArrayList<PotionEffect>();
String[] e;
PotionEffectType eft;
int duration;
int amplifier;
for(String eff : config.getStringList(String.valueOf(food) + ".effects")){
e = eff.split(", ");
eft = PotionEffectType.getByName(e[0]);
duration = Integer.parseInt(e[1]) * 20;
amplifier = Integer.parseInt(e[2]) - 1;
effects.add(new PotionEffect(eft, duration, amplifier));
}
return effects;
}
示例6: getPotionEffect
import org.bukkit.potion.PotionEffectType; //导入方法依赖的package包/类
public PotionEffect getPotionEffect() {
return new PotionEffect(PotionEffectType.getByName(type), duration, amplifier);
}