mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2024-12-23 00:15:05 +00:00
Merge remote-tracking branch 'refs/remotes/ProjectKorra/master'
This commit is contained in:
commit
9d7a03dfd0
2 changed files with 31 additions and 1 deletions
|
@ -1,18 +1,22 @@
|
|||
package com.projectkorra.projectkorra.avatar;
|
||||
|
||||
import com.projectkorra.projectkorra.ProjectKorra;
|
||||
import com.projectkorra.projectkorra.ability.AvatarAbility;
|
||||
import com.projectkorra.projectkorra.util.Flight;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
public class AvatarState extends AvatarAbility {
|
||||
|
||||
private static final HashMap<String, Long> START_TIMES = new HashMap<>();
|
||||
private static final HashMap<UUID, Long> GLOBAL_COOLDOWNS = new HashMap<UUID, Long>();
|
||||
|
||||
private boolean regenEnabled;
|
||||
private boolean speedEnabled;
|
||||
|
@ -35,6 +39,8 @@ public class AvatarState extends AvatarAbility {
|
|||
return;
|
||||
} else if (bPlayer.isOnCooldown(this)) {
|
||||
return;
|
||||
} else if (GLOBAL_COOLDOWNS.containsKey(player.getUniqueId())) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.regenEnabled = getConfig().getBoolean("Abilities.Avatar.AvatarState.PotionEffects.Regeneration.Enabled");
|
||||
|
@ -56,6 +62,14 @@ public class AvatarState extends AvatarAbility {
|
|||
bPlayer.addCooldown(this);
|
||||
if (duration != 0) {
|
||||
START_TIMES.put(player.getName(), System.currentTimeMillis());
|
||||
GLOBAL_COOLDOWNS.put(player.getUniqueId(), System.currentTimeMillis() + cooldown);
|
||||
final UUID id = player.getUniqueId();
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(ProjectKorra.plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
GLOBAL_COOLDOWNS.remove(id);
|
||||
}
|
||||
}, cooldown);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.projectkorra.projectkorra.Element.SubElement;
|
|||
import com.projectkorra.projectkorra.configuration.ConfigManager;
|
||||
import com.projectkorra.projectkorra.event.PlayerChangeElementEvent;
|
||||
import com.projectkorra.projectkorra.event.PlayerChangeElementEvent.Result;
|
||||
import com.projectkorra.rpg.RPGMethods;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
|
@ -50,7 +51,17 @@ public class RemoveCommand extends PKCommand {
|
|||
|
||||
if (senderBPlayer != null && sender instanceof Player) {
|
||||
if (e != null) {
|
||||
if (senderBPlayer.hasElement(e)) {
|
||||
if (e instanceof SubElement) {
|
||||
if (senderBPlayer.hasElement(e)) {
|
||||
senderBPlayer.getSubElements().remove(e);
|
||||
GeneralMethods.saveSubElements(senderBPlayer);
|
||||
GeneralMethods.removeUnusableAbilities(sender.getName());
|
||||
sender.sendMessage(e.getColor() + this.succesfullyRemovedElementSelf.replace("{element}" , e.getName() + e.getType().getBending()).replace("{sender}", ChatColor.DARK_AQUA + sender.getName() + e.getColor()));
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, player, e, Result.REMOVE));
|
||||
} else sender.sendMessage(ChatColor.RED + invalidElement);
|
||||
return;
|
||||
}
|
||||
if (senderBPlayer.hasElement(e)) {
|
||||
senderBPlayer.getElements().remove(e);
|
||||
GeneralMethods.saveElements(senderBPlayer);
|
||||
GeneralMethods.removeUnusableAbilities(sender.getName());
|
||||
|
@ -66,6 +77,10 @@ public class RemoveCommand extends PKCommand {
|
|||
SubElement sub = (SubElement) SubElement.fromString(args.get(0));
|
||||
if (senderBPlayer.hasSubElement(sub)) {
|
||||
senderBPlayer.getSubElements().remove(sub);
|
||||
GeneralMethods.saveSubElements(senderBPlayer);
|
||||
GeneralMethods.removeUnusableAbilities(sender.getName());
|
||||
sender.sendMessage(sub.getColor() + this.succesfullyRemovedElementSelf.replace("{element}" , sub.getName() + sub.getType().getBending()).replace("{sender}", ChatColor.DARK_AQUA + sender.getName() + sub.getColor()));
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, player, e, Result.REMOVE));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + invalidElement);
|
||||
|
@ -106,6 +121,7 @@ public class RemoveCommand extends PKCommand {
|
|||
bPlayer.getElements().clear();
|
||||
GeneralMethods.saveElements(bPlayer);
|
||||
GeneralMethods.removeUnusableAbilities(player.getName());
|
||||
if (GeneralMethods.hasRPG()) RPGMethods.revokeAvatar(bPlayer.getUUID());
|
||||
sender.sendMessage(ChatColor.YELLOW + this.succesfullyRemovedAllElementsTargetConfirm.replace("{target}", ChatColor.DARK_AQUA + player.getName() + ChatColor.YELLOW));
|
||||
player.sendMessage(ChatColor.YELLOW + this.succesfullyRemovedAllElementsTarget.replace("{sender}", ChatColor.DARK_AQUA + sender.getName() + ChatColor.YELLOW));
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, player, null, Result.REMOVE));
|
||||
|
|
Loading…
Reference in a new issue