mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2024-12-23 08:25:07 +00:00
add dynamic cooldown feature for airshield, off by default
This commit is contained in:
parent
e4df313132
commit
1c15f9209e
2 changed files with 24 additions and 11 deletions
|
@ -1,9 +1,11 @@
|
|||
package com.projectkorra.projectkorra.airbending;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.ability.AirAbility;
|
||||
import com.projectkorra.projectkorra.ability.util.Collision;
|
||||
import com.projectkorra.projectkorra.attribute.Attribute;
|
||||
import com.projectkorra.projectkorra.avatar.AvatarState;
|
||||
import com.projectkorra.projectkorra.command.Commands;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
|
@ -12,12 +14,9 @@ import org.bukkit.entity.Entity;
|
|||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.ability.AirAbility;
|
||||
import com.projectkorra.projectkorra.ability.util.Collision;
|
||||
import com.projectkorra.projectkorra.attribute.Attribute;
|
||||
import com.projectkorra.projectkorra.avatar.AvatarState;
|
||||
import com.projectkorra.projectkorra.command.Commands;
|
||||
import java.util.HashMap;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
public class AirShield extends AirAbility {
|
||||
|
||||
|
@ -37,6 +36,7 @@ public class AirShield extends AirAbility {
|
|||
private long duration;
|
||||
private Random random;
|
||||
private HashMap<Integer, Integer> angles;
|
||||
private boolean dynamicCooldown;
|
||||
|
||||
public AirShield(final Player player) {
|
||||
super(player);
|
||||
|
@ -50,6 +50,10 @@ public class AirShield extends AirAbility {
|
|||
this.speed = getConfig().getDouble("Abilities.Air.AirShield.Speed");
|
||||
this.streams = getConfig().getInt("Abilities.Air.AirShield.Streams");
|
||||
this.particles = getConfig().getInt("Abilities.Air.AirShield.Particles");
|
||||
this.dynamicCooldown = getConfig().getBoolean("Abilities.Air.AirShield.DynamicCooldown"); //any unused duration from shield is removed from the cooldown
|
||||
if (duration == 0) {
|
||||
this.dynamicCooldown = false;
|
||||
}
|
||||
this.random = new Random();
|
||||
this.angles = new HashMap<>();
|
||||
|
||||
|
@ -95,7 +99,15 @@ public class AirShield extends AirAbility {
|
|||
return;
|
||||
} else if (!this.bPlayer.isAvatarState() || !this.isToggledByAvatarState) {
|
||||
if (!this.player.isSneaking() || !this.bPlayer.canBend(this)) {
|
||||
if (dynamicCooldown) {
|
||||
Long reducedCooldown = cooldown - (duration - (System.currentTimeMillis() - this.getStartTime()));
|
||||
if (reducedCooldown < 0L) {
|
||||
reducedCooldown = 0L;
|
||||
}
|
||||
this.bPlayer.addCooldown(this, reducedCooldown);
|
||||
} else {
|
||||
this.bPlayer.addCooldown(this);
|
||||
}
|
||||
this.remove();
|
||||
return;
|
||||
} else if (this.duration != 0) {
|
||||
|
|
|
@ -833,6 +833,7 @@ public class ConfigManager {
|
|||
config.addDefault("Abilities.Air.AirShield.Streams", 5);
|
||||
config.addDefault("Abilities.Air.AirShield.Speed", 10);
|
||||
config.addDefault("Abilities.Air.AirShield.Particles", 5);
|
||||
config.addDefault("Abilities.Air.AirShield.DynamicCooldown", false);
|
||||
|
||||
config.addDefault("Abilities.Air.AirSpout.Enabled", true);
|
||||
config.addDefault("Abilities.Air.AirSpout.Cooldown", 0);
|
||||
|
|
Loading…
Reference in a new issue