use of org.bukkit.potion.PotionEffectType in project Essentials by drtshock.
the class Commandpotion method run.
@Override
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
final ItemStack stack = user.getItemInHand();
if (args.length == 0) {
final Set<String> potionslist = new TreeSet<>();
for (Map.Entry<String, PotionEffectType> entry : Potions.entrySet()) {
final String potionName = entry.getValue().getName().toLowerCase(Locale.ENGLISH);
if (potionslist.contains(potionName) || (user.isAuthorized("essentials.potion." + potionName))) {
potionslist.add(entry.getKey());
}
}
throw new NotEnoughArgumentsException(tl("potions", StringUtil.joinList(potionslist.toArray())));
}
boolean holdingPotion = stack.getType() == Material.POTION;
if (!holdingPotion && ReflUtil.getNmsVersionObject().isHigherThanOrEqualTo(ReflUtil.V1_9_R1)) {
holdingPotion = stack.getType() == Material.SPLASH_POTION || stack.getType() == Material.LINGERING_POTION;
}
if (holdingPotion) {
PotionMeta pmeta = (PotionMeta) stack.getItemMeta();
if (args.length > 0) {
if (args[0].equalsIgnoreCase("clear")) {
pmeta.clearCustomEffects();
stack.setItemMeta(pmeta);
} else if (args[0].equalsIgnoreCase("apply") && user.isAuthorized("essentials.potion.apply")) {
for (PotionEffect effect : pmeta.getCustomEffects()) {
effect.apply(user.getBase());
}
} else if (args.length < 3) {
throw new NotEnoughArgumentsException();
} else {
final MetaItemStack mStack = new MetaItemStack(stack);
for (String arg : args) {
mStack.addPotionMeta(user.getSource(), true, arg, ess);
}
if (mStack.completePotion()) {
pmeta = (PotionMeta) mStack.getItemStack().getItemMeta();
stack.setItemMeta(pmeta);
} else {
user.sendMessage(tl("invalidPotion"));
throw new NotEnoughArgumentsException();
}
}
}
} else {
throw new Exception(tl("holdPotion"));
}
}
use of org.bukkit.potion.PotionEffectType in project xAuth by CypherX.
the class PlayerDataHandler method buildPotFx.
private Collection<PotionEffect> buildPotFx(String str) {
String[] effectSplit = str.split(";");
String[] type = effectSplit[0].split(",");
String[] duration = effectSplit[1].split(",");
String[] amplifier = effectSplit[2].split(",");
Collection<PotionEffect> effects = new ArrayList<PotionEffect>();
for (int i = 0; i < type.length; i++) {
PotionEffectType potFxType = PotionEffectType.getById(Integer.parseInt(type[i]));
int potFxDur = Integer.parseInt(duration[i]);
int potFxAmp = Integer.parseInt(amplifier[i]);
effects.add(new PotionEffect(potFxType, potFxDur, potFxAmp));
}
return effects;
}
use of org.bukkit.potion.PotionEffectType in project Arcade2 by ShootGame.
the class GamePlayer method reset.
public void reset() {
if (!this.isOnline()) {
return;
}
Player bukkit = this.getBukkit();
this.refresh();
bukkit.closeInventory();
this.getPlayer().clearInventory(true);
this.resetHealth();
this.setLevel(PlayerLevel.getDefaultLevel());
bukkit.setAbsorption(AbsorptionContent.Config.DEFAULT_ABSORPTION);
bukkit.setAllowFlight(CanFlyContent.Config.DEFAULT_CAN_FLY);
bukkit.setArrowsStuck(RemoveArrowsContent.FINAL_COUNT);
bukkit.setExhaustion(ExhaustionContent.Config.DEFAULT_LEVEL);
bukkit.setExp((float) ExperienceContent.Config.DEFAULT_EXPERIENCE.getValue());
bukkit.setFallDistance(FallDistanceContent.Config.DEFAULT_DISTANCE);
bukkit.setFireTicks(TimeUtils.toTicksInt(BurnContent.Config.DEFAULT_TIME));
bukkit.setFlying(FlyContent.Config.DEFAULT_FLY);
bukkit.setFlySpeed(FlySpeedContent.Config.DEFAULT_SPEED);
bukkit.setFoodLevel(HungerContent.Config.DEFAULT_LEVEL);
bukkit.setGameMode(GameModeContent.Config.DEFAULT_GAME_MODE);
bukkit.setGlowing(GlowContent.Config.DEFAULT_GLOW);
bukkit.setGravity(GravityContent.Config.DEFAULT_GRAVITY);
bukkit.setKnockbackReduction(KnockbackContent.Config.DEFAULT_KNOCKBACK);
bukkit.setSaturation(SaturationContent.Config.DEFAULT_SATURATION);
bukkit.setSilent(SilentContent.Config.DEFAULT_SILENT);
bukkit.setSneaking(false);
bukkit.setSprinting(false);
bukkit.setVelocity(VelocityContent.Config.DEFAULT_VELOCITY);
bukkit.setWalkSpeed(WalkSpeedContent.Config.DEFAULT_SPEED);
bukkit.resetPlayerTime();
bukkit.resetPlayerWeather();
bukkit.resetTitle();
for (PotionEffectType effect : PotionEffectType.values()) {
bukkit.removePotionEffect(effect);
}
if (this.attributeMap != null) {
for (AttributeKey key : this.attributeMap.getTracking()) {
Attribute attribute = this.attributeMap.getAttribute(key);
if (attribute != null) {
attribute.removeAllModifers();
}
}
this.attributeMap.unsubscribeAll();
}
this.getMojang().reset();
}
use of org.bukkit.potion.PotionEffectType in project TriggerReactor by wysohn.
the class CommonFunctions method makePotionEffect.
@Override
public PotionEffect makePotionEffect(String EffectType, int duration, int amplifier, boolean ambient, boolean particles) {
PotionEffectType type = null;
type = PotionEffectType.getByName(EffectType);
if (type != null) {
return new PotionEffect(type, duration, amplifier, ambient, particles);
} else {
return null;
}
}
Aggregations