本文整理匯總了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);
}