mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2024-12-23 00:15:05 +00:00
Change AirFlight to use setFlying. Change remove command. (#502)
This commit is contained in:
parent
91bb27882e
commit
913780cb85
3 changed files with 81 additions and 43 deletions
|
@ -1,6 +1,7 @@
|
|||
package com.projectkorra.projectkorra.airbending;
|
||||
|
||||
import com.projectkorra.projectkorra.ability.FlightAbility;
|
||||
import com.projectkorra.projectkorra.object.PlayerFlyData;
|
||||
import com.projectkorra.projectkorra.util.Flight;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
|
@ -14,7 +15,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
public class AirFlight extends FlightAbility {
|
||||
|
||||
private static final ConcurrentHashMap<String, Integer> HITS = new ConcurrentHashMap<>();
|
||||
private static final ConcurrentHashMap<String, Boolean> HOVERING = new ConcurrentHashMap<>();
|
||||
private static final ConcurrentHashMap<String, PlayerFlyData> HOVERING = new ConcurrentHashMap<>();
|
||||
|
||||
private boolean firstProgressIteration;
|
||||
private int maxHitsBeforeRemoval;
|
||||
|
@ -67,11 +68,15 @@ public class AirFlight extends FlightAbility {
|
|||
|
||||
if (bool) {
|
||||
if (!HOVERING.containsKey(playername)) {
|
||||
HOVERING.put(playername, true);
|
||||
HOVERING.put(playername, new PlayerFlyData(player.getAllowFlight(), player.isFlying()));
|
||||
player.setVelocity(new Vector(0, 0, 0));
|
||||
player.setFlying(true);
|
||||
}
|
||||
} else {
|
||||
if (HOVERING.containsKey(playername)) {
|
||||
PlayerFlyData pfd = HOVERING.get(playername);
|
||||
player.setAllowFlight(pfd.canFly());
|
||||
player.setFlying(pfd.isFlying());
|
||||
HOVERING.remove(playername);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,8 +24,8 @@ import java.util.List;
|
|||
public class RemoveCommand extends PKCommand {
|
||||
|
||||
private String succesfullyRemovedElementSelf, wrongElementSelf, invalidElement, playerOffline, wrongElementTarget,
|
||||
succesfullyRemovedElementTarget, succesfullyRemovedElementTargetConfirm, succesfullyRemovedAllElementsTarget,
|
||||
succesfullyRemovedAllElementsTargetConfirm;
|
||||
succesfullyRemovedElementTarget, succesfullyRemovedElementTargetConfirm, succesfullyRemovedAllElementsTarget,
|
||||
succesfullyRemovedAllElementsTargetConfirm;
|
||||
|
||||
public RemoveCommand() {
|
||||
super("remove", "/bending remove <Player> [Element]",
|
||||
|
@ -54,49 +54,54 @@ public class RemoveCommand extends PKCommand {
|
|||
|
||||
Player player = Bukkit.getPlayer(args.get(0));
|
||||
if (player == null) {
|
||||
Element e = Element.fromString(args.get(0));
|
||||
BendingPlayer senderBPlayer = BendingPlayer.getBendingPlayer(sender.getName());
|
||||
if (args.size() == 1) {
|
||||
Element e = Element.fromString(args.get(0));
|
||||
BendingPlayer senderBPlayer = BendingPlayer.getBendingPlayer(sender.getName());
|
||||
|
||||
if (senderBPlayer != null && sender instanceof Player) {
|
||||
if (e != null) {
|
||||
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 PlayerChangeSubElementEvent(sender, player, (SubElement) e,
|
||||
com.projectkorra.projectkorra.event.PlayerChangeSubElementEvent.Result.REMOVE));
|
||||
} else
|
||||
sender.sendMessage(ChatColor.RED + wrongElementSelf);
|
||||
return;
|
||||
} else if (e instanceof Element) {
|
||||
if (senderBPlayer.hasElement(e)) {
|
||||
senderBPlayer.getElements().remove(e);
|
||||
GeneralMethods.saveElements(senderBPlayer);
|
||||
GeneralMethods.removeUnusableAbilities(sender.getName());
|
||||
if (senderBPlayer != null && sender instanceof Player) {
|
||||
if (e != null) {
|
||||
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 PlayerChangeSubElementEvent(sender, player, (SubElement) e,
|
||||
com.projectkorra.projectkorra.event.PlayerChangeSubElementEvent.Result.REMOVE));
|
||||
} else
|
||||
sender.sendMessage(ChatColor.RED + wrongElementSelf);
|
||||
return;
|
||||
} else if (e instanceof Element) {
|
||||
if (senderBPlayer.hasElement(e)) {
|
||||
senderBPlayer.getElements().remove(e);
|
||||
GeneralMethods.saveElements(senderBPlayer);
|
||||
GeneralMethods.removeUnusableAbilities(sender.getName());
|
||||
|
||||
sender.sendMessage(e.getColor() + succesfullyRemovedElementSelf.replace("{element}", e.getName()));
|
||||
Bukkit.getServer().getPluginManager()
|
||||
.callEvent(new PlayerChangeElementEvent(sender, (Player) sender, e, Result.REMOVE));
|
||||
return;
|
||||
} else
|
||||
sender.sendMessage(ChatColor.RED + wrongElementSelf);
|
||||
{
|
||||
return;
|
||||
sender.sendMessage(e.getColor() + succesfullyRemovedElementSelf.replace("{element}", e.getName()));
|
||||
Bukkit.getServer().getPluginManager()
|
||||
.callEvent(new PlayerChangeElementEvent(sender, (Player) sender, e, Result.REMOVE));
|
||||
return;
|
||||
} else
|
||||
sender.sendMessage(ChatColor.RED + wrongElementSelf);
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else
|
||||
sender.sendMessage(ChatColor.RED + invalidElement);
|
||||
{
|
||||
return;
|
||||
}
|
||||
} else
|
||||
sender.sendMessage(ChatColor.RED + invalidElement);
|
||||
{
|
||||
return;
|
||||
}
|
||||
sender.sendMessage(ChatColor.RED + playerOffline);
|
||||
return;
|
||||
} else {
|
||||
help(sender, false);
|
||||
return;
|
||||
}
|
||||
sender.sendMessage(ChatColor.RED + playerOffline);
|
||||
return;
|
||||
}
|
||||
|
||||
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
|
||||
|
@ -122,10 +127,10 @@ public class RemoveCommand extends PKCommand {
|
|||
GeneralMethods.removeUnusableAbilities(player.getName());
|
||||
player.sendMessage(e.getColor()
|
||||
+ this.succesfullyRemovedElementTargetConfirm.replace("{element}", e.getName() + e.getType().getBending())
|
||||
.replace("{sender}", ChatColor.DARK_AQUA + player.getName() + e.getColor()));
|
||||
.replace("{sender}", ChatColor.DARK_AQUA + player.getName() + e.getColor()));
|
||||
sender.sendMessage(e.getColor()
|
||||
+ this.succesfullyRemovedElementTarget.replace("{element}", e.getName() + e.getType().getBending())
|
||||
.replace("{sender}", ChatColor.DARK_AQUA + sender.getName() + e.getColor()));
|
||||
.replace("{sender}", ChatColor.DARK_AQUA + sender.getName() + e.getColor()));
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, player, e, Result.REMOVE));
|
||||
return;
|
||||
}
|
||||
|
|
28
src/com/projectkorra/projectkorra/object/PlayerFlyData.java
Normal file
28
src/com/projectkorra/projectkorra/object/PlayerFlyData.java
Normal file
|
@ -0,0 +1,28 @@
|
|||
package com.projectkorra.projectkorra.object;
|
||||
|
||||
public class PlayerFlyData {
|
||||
|
||||
private boolean canFly;
|
||||
private boolean isFlying;
|
||||
|
||||
public PlayerFlyData(boolean canFly, boolean isFlying) {
|
||||
this.canFly = canFly;
|
||||
this.isFlying = isFlying;
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the player have access to fly mode?
|
||||
* @return
|
||||
*/
|
||||
public boolean canFly() {
|
||||
return canFly;
|
||||
}
|
||||
|
||||
/**
|
||||
* Was the player flying?
|
||||
* @return
|
||||
*/
|
||||
public boolean isFlying() {
|
||||
return isFlying;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue