Make Avatar State less broken

Avatar State is now highly configurable:
You can now turn potion effects on / off as well as configure the power
of the effect (the potion level).
This commit is contained in:
MistPhizzle 2014-07-07 22:52:33 -04:00
parent 0b75442710
commit 1909e0e764
3 changed files with 66 additions and 11 deletions

View file

@ -1,18 +1,34 @@
package com.projectkorra.ProjectKorra.Ability;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import com.projectkorra.ProjectKorra.Flight;
import com.projectkorra.ProjectKorra.Methods;
import com.projectkorra.ProjectKorra.ProjectKorra;
public class AvatarState {
public static ConcurrentHashMap<Player, AvatarState> instances = new ConcurrentHashMap<Player, AvatarState>();
public static Map<String, Long> cooldowns = new HashMap<String, Long>();
public static FileConfiguration config = ProjectKorra.plugin.getConfig();
private static final long cooldown = ProjectKorra.plugin.getConfig().getLong("Abilities.AvatarState.Cooldown");
private static boolean regenEnabled = config.getBoolean("Abilities.AvatarState.PotionEffects.Regeneration.Enabled");
private static int regenPower = config.getInt("Abilities.AvatarState.PotionEffects.Regeneration.Power") - 1;
private static boolean speedEnabled = config.getBoolean("Abilities.AvatarState.PotionEffects.Speed..Enabled");
private static int speedPower = config.getInt("Abilities.AvatarState.Potioneffects.Speed.Power") - 1;
private static boolean resistanceEnabled = config.getBoolean("Abilities.AvatarState.PotionEffects.DamageResistance.Enabled");
private static int resistancePower = config.getInt("Abilities.AvatarState.PotionEffects.DamageResistance.Power") - 1;
private static boolean fireResistanceEnabled = config.getBoolean("Abilities.AvatarState.PotionEffects.FireResistance.Enabled");
private static int fireResistancePower = config.getInt("Abilities.AvatarState.PotionEffects.FireResistance.Power") - 1;
private static final double factor = 5;
@ -24,9 +40,19 @@ public class AvatarState {
this.player = player;
if (instances.containsKey(player)) {
instances.remove(player);
} else {
new Flight(player);
instances.put(player, this);
return;
}
if (cooldowns.containsKey(player.getName())) {
if (cooldowns.get(player.getName()) + cooldown >= System.currentTimeMillis()) {
return;
} else {
cooldowns.remove(player.getName());
}
}
new Flight(player);
instances.put(player, this);
if (cooldown != 0) {
cooldowns.put(player.getName(), System.currentTimeMillis());
}
}
@ -51,14 +77,22 @@ public class AvatarState {
private void addPotionEffects() {
int duration = 70;
player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION,
duration, 3));
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,
duration, 2));
player.addPotionEffect(new PotionEffect(
PotionEffectType.DAMAGE_RESISTANCE, duration, 2));
player.addPotionEffect(new PotionEffect(
PotionEffectType.FIRE_RESISTANCE, duration, 2));
if (regenEnabled) {
player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION,
duration, regenPower));
}
if (speedEnabled) {
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,
duration, speedPower));
}
if (resistanceEnabled) {
player.addPotionEffect(new PotionEffect(
PotionEffectType.DAMAGE_RESISTANCE, duration, resistancePower));
}
if (fireResistanceEnabled) {
player.addPotionEffect(new PotionEffect(
PotionEffectType.FIRE_RESISTANCE, duration, fireResistancePower));
}
}
public static boolean isAvatarState(Player player) {

View file

@ -80,6 +80,13 @@ public class ConfigManager {
+ "are incredibly amplified in this state. Additionally, AirShield and FireJet become toggle-able "
+ "abilities and last until you deactivate them or the Avatar State. Click again with the Avatar "
+ "State selected to deactivate it.");
config.addDefault("Abilities.AvatarState.PotionEffects.Regeneration.Enabled", true);
config.addDefault("Abilities.AvatarState.PotionEffects.Regeneration.Power", 3);
config.addDefault("Abilities.AvatarState.PotionEffects.Speed.Enabled", true);
config.addDefault("Abilities.AvatarState.PotionEffects.Speed.Power", 3);
config.addDefault("Abilities.AvatarState.PotionEffects.DamageResistance.Enabled", true);
config.addDefault("Abilities.AvatarState.PotionEffects.FireResistance.Enabled", true);
config.addDefault("Abilities.AvatarState.PotionEffects.FireResistance.Power", 3);
plugin.getConfig().addDefault("Abilities.Air.Passive.Factor", 0.3);
plugin.getConfig().addDefault("Abilities.Air.Passive.Speed", 2);

View file

@ -58,6 +58,20 @@ Abilities:
AvatarState:
Enabled: true
Description: "The signature ability of the Avatar, this is a toggle. Click to activate to become nearly unstoppable. While in the Avatar State, the user takes severely reduced damage from all sources, regenreates health rapidly, and is granted extreme speed. Nearly all abilities are incredibly amplified in this state. Additionally, AirShield and FireJet become toggle-able abilities and last until you deactivate them or the Avatar State. Click again with the Avatar State selected to deactivate it."
Cooldown: 720000
PotionEffects:
Regeneration:
Enabled: true
Power: 3
Speed:
Enabled: true
Power: 3
DamageResistance:
Enabled: true
Power: 3
FireResistance:
Enabled: true
Power: 3
Air:
Passive:
Factor: 0.3