use of org.bukkit.potion.PotionEffectType in project TotalFreedomMod by TotalFreedom.
the class Command_potion method run.
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
if (args.length == 1 || args.length == 2) {
if (args[0].equalsIgnoreCase("list")) {
List<String> potionEffectTypeNames = new ArrayList<>();
for (PotionEffectType potion_effect_type : PotionEffectType.values()) {
if (potion_effect_type != null) {
potionEffectTypeNames.add(potion_effect_type.getName());
}
}
msg("Potion effect types: " + StringUtils.join(potionEffectTypeNames, ", "), ChatColor.AQUA);
} else if (args[0].equalsIgnoreCase("clearall")) {
if (!(plugin.al.isAdmin(sender) || senderIsConsole)) {
noPerms();
return true;
}
FUtil.adminAction(sender.getName(), "Cleared all potion effects from all players", true);
for (Player target : server.getOnlinePlayers()) {
for (PotionEffect potion_effect : target.getActivePotionEffects()) {
target.removePotionEffect(potion_effect.getType());
}
}
} else if (args[0].equalsIgnoreCase("clear")) {
Player target = playerSender;
if (args.length == 2) {
target = getPlayer(args[1]);
if (target == null) {
msg(FreedomCommand.PLAYER_NOT_FOUND, ChatColor.RED);
return true;
}
}
if (!target.equals(playerSender)) {
if (!plugin.al.isAdmin(sender)) {
msg("Only superadmins can clear potion effects from other players.");
return true;
}
} else if (senderIsConsole) {
msg("You must specify a target player when using this command from the console.");
return true;
}
for (PotionEffect potion_effect : target.getActivePotionEffects()) {
target.removePotionEffect(potion_effect.getType());
}
msg("Cleared all active potion effects " + (!target.equals(playerSender) ? "from player " + target.getName() + "." : "from yourself."), ChatColor.AQUA);
} else {
return false;
}
} else if (args.length == 4 || args.length == 5) {
if (args[0].equalsIgnoreCase("add")) {
Player target = playerSender;
if (args.length == 5) {
target = getPlayer(args[4]);
if (target == null) {
msg(FreedomCommand.PLAYER_NOT_FOUND, ChatColor.RED);
return true;
}
}
if (!target.equals(playerSender)) {
if (!plugin.al.isAdmin(sender)) {
sender.sendMessage("Only superadmins can apply potion effects to other players.");
return true;
}
} else if (senderIsConsole) {
sender.sendMessage("You must specify a target player when using this command from the console.");
return true;
}
PotionEffectType potion_effect_type = PotionEffectType.getByName(args[1]);
if (potion_effect_type == null) {
sender.sendMessage(ChatColor.AQUA + "Invalid potion effect type.");
return true;
}
int duration;
try {
duration = Integer.parseInt(args[2]);
duration = Math.min(duration, 100000);
} catch (NumberFormatException ex) {
msg("Invalid potion duration.", ChatColor.RED);
return true;
}
int amplifier;
try {
amplifier = Integer.parseInt(args[3]);
amplifier = Math.min(amplifier, 100000);
} catch (NumberFormatException ex) {
msg("Invalid potion amplifier.", ChatColor.RED);
return true;
}
PotionEffect new_effect = potion_effect_type.createEffect(duration, amplifier);
target.addPotionEffect(new_effect, true);
msg("Added potion effect: " + new_effect.getType().getName() + ", Duration: " + new_effect.getDuration() + ", Amplifier: " + new_effect.getAmplifier() + (!target.equals(playerSender) ? " to player " + target.getName() + "." : " to yourself."), ChatColor.AQUA);
return true;
} else {
return false;
}
} else {
return false;
}
return true;
}
use of org.bukkit.potion.PotionEffectType in project Denizen-For-Bukkit by DenizenScript.
the class CastCommand method execute.
@SuppressWarnings("unchecked")
@Override
public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
// Fetch objects
List<dEntity> entities = (List<dEntity>) scriptEntry.getObject("entities");
PotionEffectType effect = (PotionEffectType) scriptEntry.getObject("effect");
int amplifier = scriptEntry.getElement("amplifier").asInt();
Duration duration = (Duration) scriptEntry.getObject("duration");
boolean remove = scriptEntry.getElement("remove").asBoolean();
Element showParticles = scriptEntry.getElement("show_particles");
Element ambient = scriptEntry.getElement("ambient");
// Report to dB
dB.report(scriptEntry, getName(), aH.debugObj("Target(s)", entities.toString()) + aH.debugObj("Effect", effect.getName()) + aH.debugObj("Amplifier", amplifier) + duration.debug() + ambient.debug() + showParticles.debug());
boolean amb = ambient.asBoolean();
boolean showP = showParticles.asBoolean();
// Apply the PotionEffect to the targets!
for (dEntity entity : entities) {
if (entity.getLivingEntity().hasPotionEffect(effect)) {
entity.getLivingEntity().removePotionEffect(effect);
}
if (remove) {
continue;
}
PotionEffect potion = new PotionEffect(effect, duration.getTicksAsInt(), amplifier, amb, showP);
if (!potion.apply(entity.getLivingEntity())) {
dB.echoError(scriptEntry.getResidingQueue(), "Bukkit was unable to apply '" + potion.getType().getName() + "' to '" + entity.toString() + "'.");
}
}
}
use of org.bukkit.potion.PotionEffectType in project Denizen-For-Bukkit by DenizenScript.
the class dEntity method getAttribute.
@Override
public String getAttribute(Attribute attribute) {
if (attribute == null) {
return null;
}
if (entity == null && entity_type == null) {
if (npc != null) {
return new Element(identify()).getAttribute(attribute);
}
dB.echoError("dEntity has returned null.");
return null;
}
// -->
if (attribute.startsWith("debug.log")) {
dB.log(debug());
return new Element(Boolean.TRUE.toString()).getAttribute(attribute.fulfill(2));
}
// -->
if (attribute.startsWith("debug.no_color")) {
return new Element(ChatColor.stripColor(debug())).getAttribute(attribute.fulfill(2));
}
// -->
if (attribute.startsWith("debug")) {
return new Element(debug()).getAttribute(attribute.fulfill(1));
}
// -->
if (attribute.startsWith("prefix")) {
return new Element(prefix).getAttribute(attribute.fulfill(1));
}
// -->
if (attribute.startsWith("type")) {
return new Element("Entity").getAttribute(attribute.fulfill(1));
}
// -->
if (attribute.startsWith("entity_type")) {
return new Element(entity_type.getName()).getAttribute(attribute.fulfill(1));
}
// -->
if (attribute.startsWith("is_spawned")) {
return new Element(isSpawned()).getAttribute(attribute.fulfill(1));
}
// -->
if (attribute.startsWith("eid")) {
return new Element(entity.getEntityId()).getAttribute(attribute.fulfill(1));
}
// -->
if (attribute.startsWith("uuid")) {
return new Element(getUUID().toString()).getAttribute(attribute.fulfill(1));
}
// -->
if (attribute.startsWith("script")) {
// TODO: Maybe return legit null?
return new Element(entityScript == null ? "null" : entityScript).getAttribute(attribute.fulfill(1));
}
// -->
if (attribute.startsWith("has_flag")) {
String flag_name;
if (attribute.hasContext(1)) {
flag_name = attribute.getContext(1);
} else {
return null;
}
if (isPlayer() || isCitizensNPC()) {
dB.echoError("Reading flag for PLAYER or NPC as if it were an ENTITY!");
return null;
}
return new Element(FlagManager.entityHasFlag(this, flag_name)).getAttribute(attribute.fulfill(1));
}
// -->
if (attribute.startsWith("flag")) {
String flag_name;
if (attribute.hasContext(1)) {
flag_name = attribute.getContext(1);
} else {
return null;
}
if (isPlayer() || isCitizensNPC()) {
dB.echoError("Reading flag for PLAYER or NPC as if it were an ENTITY!");
return null;
}
if (attribute.getAttribute(2).equalsIgnoreCase("is_expired") || attribute.startsWith("isexpired")) {
return new Element(!FlagManager.entityHasFlag(this, flag_name)).getAttribute(attribute.fulfill(2));
}
if (attribute.getAttribute(2).equalsIgnoreCase("size") && !FlagManager.entityHasFlag(this, flag_name)) {
return new Element(0).getAttribute(attribute.fulfill(2));
}
if (FlagManager.entityHasFlag(this, flag_name)) {
FlagManager.Flag flag = DenizenAPI.getCurrentInstance().flagManager().getEntityFlag(this, flag_name);
return new dList(flag.toString(), true, flag.values()).getAttribute(attribute.fulfill(1));
}
return new Element(identify()).getAttribute(attribute);
}
// -->
if (attribute.startsWith("list_flags")) {
dList allFlags = new dList(DenizenAPI.getCurrentInstance().flagManager().listEntityFlags(this));
dList searchFlags = null;
if (!allFlags.isEmpty() && attribute.hasContext(1)) {
searchFlags = new dList();
String search = attribute.getContext(1);
if (search.startsWith("regex:")) {
try {
Pattern pattern = Pattern.compile(search.substring(6), Pattern.CASE_INSENSITIVE);
for (String flag : allFlags) {
if (pattern.matcher(flag).matches()) {
searchFlags.add(flag);
}
}
} catch (Exception e) {
dB.echoError(e);
}
} else {
search = CoreUtilities.toLowerCase(search);
for (String flag : allFlags) {
if (CoreUtilities.toLowerCase(flag).contains(search)) {
searchFlags.add(flag);
}
}
}
}
return searchFlags == null ? allFlags.getAttribute(attribute.fulfill(1)) : searchFlags.getAttribute(attribute.fulfill(1));
}
if (entity == null) {
return new Element(identify()).getAttribute(attribute);
}
// -->
if (attribute.startsWith("custom_id")) {
if (CustomNBT.hasCustomNBT(getLivingEntity(), "denizen-script-id")) {
return new dScript(CustomNBT.getCustomNBT(getLivingEntity(), "denizen-script-id")).getAttribute(attribute.fulfill(1));
} else {
return new Element(entity.getType().name()).getAttribute(attribute.fulfill(1));
}
}
// -->
if (attribute.startsWith("name")) {
return new Element(getName()).getAttribute(attribute.fulfill(1));
}
// -->
if (attribute.startsWith("saddle")) {
if (getLivingEntity().getType() == EntityType.HORSE) {
return new dItem(((Horse) getLivingEntity()).getInventory().getSaddle()).getAttribute(attribute.fulfill(1));
} else if (getLivingEntity().getType() == EntityType.PIG) {
return new dItem(((Pig) getLivingEntity()).hasSaddle() ? Material.SADDLE : Material.AIR).getAttribute(attribute.fulfill(1));
}
}
// -->
if (attribute.startsWith("horse_armor") || attribute.startsWith("horse_armour")) {
if (getLivingEntity().getType() == EntityType.HORSE) {
return new dItem(((Horse) getLivingEntity()).getInventory().getArmor()).getAttribute(attribute.fulfill(1));
}
}
// -->
if (attribute.startsWith("has_saddle")) {
if (getLivingEntity().getType() == EntityType.HORSE) {
return new Element(((Horse) getLivingEntity()).getInventory().getSaddle().getType() == Material.SADDLE).getAttribute(attribute.fulfill(1));
} else if (getLivingEntity().getType() == EntityType.PIG) {
return new Element(((Pig) getLivingEntity()).hasSaddle()).getAttribute(attribute.fulfill(1));
}
}
// -->
if (attribute.startsWith("item_in_hand") || attribute.startsWith("iteminhand")) {
return new dItem(NMSHandler.getInstance().getEntityHelper().getItemInHand(getLivingEntity())).getAttribute(attribute.fulfill(1));
}
// -->
if (attribute.startsWith("item_in_offhand") || attribute.startsWith("iteminoffhand")) {
return new dItem(NMSHandler.getInstance().getEntityHelper().getItemInOffHand(getLivingEntity())).getAttribute(attribute.fulfill(1));
}
// -->
if (attribute.startsWith("map_trace")) {
EntityHelper.MapTraceResult mtr = NMSHandler.getInstance().getEntityHelper().mapTrace(getLivingEntity(), 200);
if (mtr != null) {
double x = 0;
double y = 0;
double basex = mtr.hitLocation.getX() - Math.floor(mtr.hitLocation.getX());
double basey = mtr.hitLocation.getY() - Math.floor(mtr.hitLocation.getY());
double basez = mtr.hitLocation.getZ() - Math.floor(mtr.hitLocation.getZ());
if (mtr.angle == BlockFace.NORTH) {
x = 128f - (basex * 128f);
} else if (mtr.angle == BlockFace.SOUTH) {
x = basex * 128f;
} else if (mtr.angle == BlockFace.WEST) {
x = basez * 128f;
} else if (mtr.angle == BlockFace.EAST) {
x = 128f - (basez * 128f);
}
y = 128f - (basey * 128f);
return new dLocation(null, Math.round(x), Math.round(y)).getAttribute(attribute.fulfill(1));
}
}
// -->
if (attribute.startsWith("can_see")) {
if (isLivingEntity() && attribute.hasContext(1) && dEntity.matches(attribute.getContext(1))) {
dEntity toEntity = dEntity.valueOf(attribute.getContext(1));
if (toEntity != null && toEntity.isSpawned()) {
return new Element(getLivingEntity().hasLineOfSight(toEntity.getBukkitEntity())).getAttribute(attribute.fulfill(1));
}
}
}
// -->
if (attribute.startsWith("eye_location")) {
return new dLocation(getEyeLocation()).getAttribute(attribute.fulfill(1));
}
// -->
if (attribute.startsWith("eye_height")) {
if (isLivingEntity()) {
return new Element(getLivingEntity().getEyeHeight()).getAttribute(attribute.fulfill(1));
}
}
// -->
if (attribute.startsWith("location.cursor_on")) {
int range = attribute.getIntContext(2);
if (range < 1) {
range = 50;
}
Set<Material> set = new HashSet<Material>();
set.add(Material.AIR);
attribute = attribute.fulfill(2);
if (attribute.startsWith("ignore") && attribute.hasContext(1)) {
List<dMaterial> ignoreList = dList.valueOf(attribute.getContext(1)).filter(dMaterial.class);
for (dMaterial material : ignoreList) {
set.add(material.getMaterial());
}
attribute = attribute.fulfill(1);
}
return new dLocation(getLivingEntity().getTargetBlock(set, range).getLocation()).getAttribute(attribute);
}
// -->
if (attribute.startsWith("location.standing_on")) {
return new dLocation(entity.getLocation().clone().add(0, -0.5f, 0)).getAttribute(attribute.fulfill(2));
}
// -->
if (attribute.startsWith("location")) {
return new dLocation(entity.getLocation()).getAttribute(attribute.fulfill(1));
}
// -->
if (attribute.startsWith("velocity")) {
return new dLocation(entity.getVelocity().toLocation(entity.getWorld())).getAttribute(attribute.fulfill(1));
}
// -->
if (attribute.startsWith("world")) {
return new dWorld(entity.getWorld()).getAttribute(attribute.fulfill(1));
}
// -->
if (attribute.startsWith("can_pickup_items")) {
if (isLivingEntity()) {
return new Element(getLivingEntity().getCanPickupItems()).getAttribute(attribute.fulfill(1));
}
}
// -->
if (attribute.startsWith("fallingblock_material")) {
return dMaterial.getMaterialFrom(((FallingBlock) entity).getMaterial()).getAttribute(attribute.fulfill(1));
}
// -->
if (attribute.startsWith("fall_distance")) {
return new Element(entity.getFallDistance()).getAttribute(attribute.fulfill(1));
}
// -->
if (attribute.startsWith("fire_time")) {
return new Duration(entity.getFireTicks() / 20).getAttribute(attribute.fulfill(1));
}
// -->
if (attribute.startsWith("on_fire")) {
return new Element(entity.getFireTicks() > 0).getAttribute(attribute.fulfill(1));
}
// -->
if (attribute.startsWith("leash_holder") || attribute.startsWith("get_leash_holder")) {
if (isLivingEntity() && getLivingEntity().isLeashed()) {
return new dEntity(getLivingEntity().getLeashHolder()).getAttribute(attribute.fulfill(1));
}
}
// -->
if (attribute.startsWith("passenger") || attribute.startsWith("get_passenger")) {
if (!entity.isEmpty()) {
return new dEntity(entity.getPassenger()).getAttribute(attribute.fulfill(1));
}
}
// -->
if (attribute.startsWith("shooter") || attribute.startsWith("get_shooter")) {
if (isProjectile() && hasShooter()) {
return getShooter().getAttribute(attribute.fulfill(1));
}
}
// -->
if (attribute.startsWith("vehicle") || attribute.startsWith("get_vehicle")) {
if (entity.isInsideVehicle()) {
return new dEntity(entity.getVehicle()).getAttribute(attribute.fulfill(1));
}
}
// -->
if (attribute.startsWith("has_effect")) {
boolean returnElement = false;
if (attribute.hasContext(1)) {
PotionEffectType effectType = PotionEffectType.getByName(attribute.getContext(1));
for (org.bukkit.potion.PotionEffect effect : getLivingEntity().getActivePotionEffects()) {
if (effect.getType().equals(effectType)) {
returnElement = true;
}
}
} else if (!getLivingEntity().getActivePotionEffects().isEmpty()) {
returnElement = true;
}
return new Element(returnElement).getAttribute(attribute.fulfill(1));
}
// -->
if (attribute.startsWith("can_breed")) {
return new Element(((Ageable) getLivingEntity()).canBreed()).getAttribute(attribute.fulfill(1));
}
// -->
if (attribute.startsWith("breeding") || attribute.startsWith("is_breeding")) {
return new Element(NMSHandler.getInstance().getEntityHelper().isBreeding((Animals) getLivingEntity())).getAttribute(attribute.fulfill(1));
}
// -->
if (attribute.startsWith("has_passenger")) {
return new Element(!entity.isEmpty()).getAttribute(attribute.fulfill(1));
}
// -->
if (attribute.startsWith("empty") || attribute.startsWith("is_empty")) {
return new Element(entity.isEmpty()).getAttribute(attribute.fulfill(1));
}
// -->
if (attribute.startsWith("inside_vehicle") || attribute.startsWith("is_inside_vehicle")) {
return new Element(entity.isInsideVehicle()).getAttribute(attribute.fulfill(1));
}
// -->
if (attribute.startsWith("leashed") || attribute.startsWith("is_leashed")) {
if (isLivingEntity()) {
return new Element(getLivingEntity().isLeashed()).getAttribute(attribute.fulfill(1));
} else {
return Element.FALSE.getAttribute(attribute.fulfill(1));
}
}
// -->
if (attribute.startsWith("on_ground") || attribute.startsWith("is_on_ground")) {
return new Element(entity.isOnGround()).getAttribute(attribute.fulfill(1));
}
// -->
if (attribute.startsWith("persistent") || attribute.startsWith("is_persistent")) {
if (isLivingEntity()) {
return new Element(!getLivingEntity().getRemoveWhenFarAway()).getAttribute(attribute.fulfill(1));
} else {
return Element.FALSE.getAttribute(attribute.fulfill(1));
}
}
// -->
if (attribute.startsWith("killer")) {
return getPlayerFrom(getLivingEntity().getKiller()).getAttribute(attribute.fulfill(1));
}
// -->
if (attribute.startsWith("last_damage.amount")) {
return new Element(getLivingEntity().getLastDamage()).getAttribute(attribute.fulfill(2));
}
// -->
if (attribute.startsWith("last_damage.cause") && entity.getLastDamageCause() != null) {
return new Element(entity.getLastDamageCause().getCause().name()).getAttribute(attribute.fulfill(2));
}
// -->
if (attribute.startsWith("last_damage.duration")) {
return new Duration((long) getLivingEntity().getNoDamageTicks()).getAttribute(attribute.fulfill(2));
}
// -->
if (attribute.startsWith("oxygen.max")) {
return new Duration((long) getLivingEntity().getMaximumAir()).getAttribute(attribute.fulfill(1));
}
// -->
if (attribute.startsWith("oxygen")) {
return new Duration((long) getLivingEntity().getRemainingAir()).getAttribute(attribute.fulfill(1));
}
// -->
if (attribute.startsWith("remove_when_far")) {
return new Element(getLivingEntity().getRemoveWhenFarAway()).getAttribute(attribute.fulfill(1));
}
// -->
if (attribute.startsWith("target")) {
if (getBukkitEntity() instanceof Creature) {
Entity target = ((Creature) getLivingEntity()).getTarget();
if (target != null) {
return new dEntity(target).getAttribute(attribute.fulfill(1));
}
}
return null;
}
// -->
if (attribute.startsWith("time_lived")) {
return new Duration(entity.getTicksLived() / 20).getAttribute(attribute.fulfill(1));
}
// -->
if ((attribute.startsWith("pickup_delay") || attribute.startsWith("pickupdelay")) && getBukkitEntity() instanceof Item) {
return new Duration(((Item) getBukkitEntity()).getPickupDelay() * 20).getAttribute(attribute.fulfill(1));
}
// -->
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_9_R2) && attribute.startsWith("gliding")) {
return new Element(getLivingEntity().isGliding()).getAttribute(attribute.fulfill(1));
}
// -->
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_9_R2) && attribute.startsWith("glowing")) {
return new Element(getLivingEntity().isGlowing()).getAttribute(attribute.fulfill(1));
}
// -->
if (attribute.startsWith("is_living")) {
return new Element(isLivingEntity()).getAttribute(attribute.fulfill(1));
}
// -->
if (attribute.startsWith("is_mob")) {
if (!isPlayer() && !isNPC()) {
return Element.TRUE.getAttribute(attribute.fulfill(1));
} else {
return Element.FALSE.getAttribute(attribute.fulfill(1));
}
}
// -->
if (attribute.startsWith("is_npc")) {
return new Element(isCitizensNPC()).getAttribute(attribute.fulfill(1));
}
// -->
if (attribute.startsWith("is_player")) {
return new Element(isPlayer()).getAttribute(attribute.fulfill(1));
}
// -->
if (attribute.startsWith("is_projectile")) {
return new Element(isProjectile()).getAttribute(attribute.fulfill(1));
}
// -->
if (attribute.startsWith("tameable") || attribute.startsWith("is_tameable")) {
return new Element(EntityTame.describes(this)).getAttribute(attribute.fulfill(1));
}
// -->
if (attribute.startsWith("ageable") || attribute.startsWith("is_ageable")) {
return new Element(EntityAge.describes(this)).getAttribute(attribute.fulfill(1));
}
// -->
if (attribute.startsWith("colorable") || attribute.startsWith("is_colorable")) {
return new Element(EntityColor.describes(this)).getAttribute(attribute.fulfill(1));
}
// -->
if (attribute.startsWith("experience") && getBukkitEntity() instanceof ExperienceOrb) {
return new Element(((ExperienceOrb) getBukkitEntity()).getExperience()).getAttribute(attribute.fulfill(1));
}
// -->
if (attribute.startsWith("dragon_phase") && getBukkitEntity() instanceof EnderDragon) {
return new Element(((EnderDragon) getLivingEntity()).getPhase().name()).getAttribute(attribute.fulfill(1));
}
// -->
if (attribute.startsWith("describe")) {
String escript = getEntityScript();
return new Element("e@" + (escript != null && escript.length() > 0 ? escript : getEntityType().getLowercaseName()) + PropertyParser.getPropertiesString(this)).getAttribute(attribute.fulfill(1));
}
// Iterate through this object's properties' attributes
for (Property property : PropertyParser.getProperties(this)) {
String returned = property.getAttribute(attribute);
if (returned != null) {
return returned;
}
}
return new Element(identify()).getAttribute(attribute);
}
use of org.bukkit.potion.PotionEffectType in project Glowstone by GlowstoneMC.
the class GlowMetaPotion method fromNBT.
public static PotionEffect fromNBT(CompoundTag tag) {
PotionEffectType type = PotionEffectType.getById(tag.getByte("Id"));
int duration = tag.getInt("Duration");
int amplifier = tag.getByte("Amplifier");
boolean ambient = tag.isByte("Ambient") && tag.getBool("Ambient");
boolean particles = !tag.isByte("ShowParticles") || tag.getBool("ShowParticles");
return new PotionEffect(type, duration, amplifier, ambient, particles);
}
use of org.bukkit.potion.PotionEffectType in project MagicPlugin by elBukkit.
the class Mage method updatePassiveEffects.
protected void updatePassiveEffects() {
protection.clear();
strength.clear();
weakness.clear();
attributes.clear();
spMultiplier = 1;
cooldownReduction = 0;
costReduction = 0;
consumeReduction = 0;
List<PotionEffectType> currentEffects = new ArrayList<>(effectivePotionEffects.keySet());
LivingEntity entity = getLivingEntity();
effectivePotionEffects.clear();
addPassiveEffects(properties, true);
if (activeClass != null) {
addPassiveEffects(activeClass, true);
spMultiplier = (float) (spMultiplier * activeClass.getDouble("sp_multiplier", 1.0));
}
if (activeWand != null && !activeWand.isPassive()) {
addPassiveEffects(activeWand, false);
effectivePotionEffects.putAll(activeWand.getPotionEffects());
}
// Don't add these together so things stay balanced!
if (offhandWand != null && !offhandWand.isPassive()) {
addPassiveEffects(offhandWand, false);
effectivePotionEffects.putAll(offhandWand.getPotionEffects());
spMultiplier *= offhandWand.getSPMultiplier();
}
for (Wand armorWand : activeArmor.values()) {
if (armorWand != null) {
addPassiveEffects(armorWand, false);
effectivePotionEffects.putAll(armorWand.getPotionEffects());
}
}
if (entity != null) {
for (PotionEffectType effectType : currentEffects) {
if (!effectivePotionEffects.containsKey(effectType)) {
entity.removePotionEffect(effectType);
}
}
for (Map.Entry<PotionEffectType, Integer> effects : effectivePotionEffects.entrySet()) {
PotionEffect effect = new PotionEffect(effects.getKey(), Integer.MAX_VALUE, effects.getValue(), true, false);
CompatibilityUtils.applyPotionEffect(entity, effect);
}
}
}
Aggregations