mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2024-12-23 00:15:05 +00:00
Added Bending Preview Move Display (#525)
This commit is contained in:
parent
cc39cc79f9
commit
3c2f26a962
3 changed files with 42 additions and 1 deletions
|
@ -110,6 +110,15 @@ public class BendingPlayer {
|
||||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||||
if (!event.isCancelled()) {
|
if (!event.isCancelled()) {
|
||||||
this.cooldowns.put(ability, cooldown + System.currentTimeMillis());
|
this.cooldowns.put(ability, cooldown + System.currentTimeMillis());
|
||||||
|
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
int slot = player.getInventory().getHeldItemSlot() + 1;
|
||||||
|
String abilityName = event.getAbility();
|
||||||
|
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
|
||||||
|
|
||||||
|
if (bPlayer.getBoundAbility()!= null && bPlayer.getBoundAbility().equals(CoreAbility.getAbility(abilityName))) {
|
||||||
|
GeneralMethods.displayMovePreview(player, CoreAbility.getAbility(bPlayer.getAbilities().get(slot)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -613,6 +622,15 @@ public class BendingPlayer {
|
||||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||||
if (!event.isCancelled()) {
|
if (!event.isCancelled()) {
|
||||||
this.cooldowns.remove(ability);
|
this.cooldowns.remove(ability);
|
||||||
|
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
int slot = player.getInventory().getHeldItemSlot() + 1;
|
||||||
|
String abilityName = event.getAbility();
|
||||||
|
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
|
||||||
|
|
||||||
|
if (bPlayer.getBoundAbility()!= null && bPlayer.getBoundAbility().equals(CoreAbility.getAbility(abilityName))) {
|
||||||
|
GeneralMethods.displayMovePreview(player, CoreAbility.getAbility(bPlayer.getAbilities().get(slot)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,7 @@ import com.projectkorra.projectkorra.firebending.FireCombo;
|
||||||
import com.projectkorra.projectkorra.firebending.FireShield;
|
import com.projectkorra.projectkorra.firebending.FireShield;
|
||||||
import com.projectkorra.projectkorra.object.Preset;
|
import com.projectkorra.projectkorra.object.Preset;
|
||||||
import com.projectkorra.projectkorra.storage.DBConnection;
|
import com.projectkorra.projectkorra.storage.DBConnection;
|
||||||
|
import com.projectkorra.projectkorra.util.ActionBar;
|
||||||
import com.projectkorra.projectkorra.util.BlockCacheElement;
|
import com.projectkorra.projectkorra.util.BlockCacheElement;
|
||||||
import com.projectkorra.projectkorra.util.Flight;
|
import com.projectkorra.projectkorra.util.Flight;
|
||||||
import com.projectkorra.projectkorra.util.ParticleEffect;
|
import com.projectkorra.projectkorra.util.ParticleEffect;
|
||||||
|
@ -558,6 +559,23 @@ public class GeneralMethods {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void displayMovePreview(Player player, CoreAbility ability) {
|
||||||
|
String displayedMessage = null;
|
||||||
|
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
|
||||||
|
|
||||||
|
if (ability != null) {
|
||||||
|
if (bPlayer.isOnCooldown(ability)) {
|
||||||
|
displayedMessage = ability.getElement().getColor() + "" + ChatColor.STRIKETHROUGH + ability.getName();
|
||||||
|
} else {
|
||||||
|
displayedMessage = ability.getElement().getColor() + ability.getName();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
displayedMessage = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
ActionBar.sendActionBar(displayedMessage, player);
|
||||||
|
}
|
||||||
|
|
||||||
public static List<Block> getBlocksAlongLine(Location ploc, Location tloc, World w) {
|
public static List<Block> getBlocksAlongLine(Location ploc, Location tloc, World w) {
|
||||||
List<Block> blocks = new ArrayList<Block>();
|
List<Block> blocks = new ArrayList<Block>();
|
||||||
|
|
||||||
|
|
|
@ -123,6 +123,7 @@ import com.projectkorra.projectkorra.event.EntityBendingDeathEvent;
|
||||||
import com.projectkorra.projectkorra.event.HorizontalVelocityChangeEvent;
|
import com.projectkorra.projectkorra.event.HorizontalVelocityChangeEvent;
|
||||||
import com.projectkorra.projectkorra.event.PlayerChangeElementEvent;
|
import com.projectkorra.projectkorra.event.PlayerChangeElementEvent;
|
||||||
import com.projectkorra.projectkorra.event.PlayerChangeElementEvent.Result;
|
import com.projectkorra.projectkorra.event.PlayerChangeElementEvent.Result;
|
||||||
|
import com.projectkorra.projectkorra.event.PlayerCooldownChangeEvent;
|
||||||
import com.projectkorra.projectkorra.event.PlayerJumpEvent;
|
import com.projectkorra.projectkorra.event.PlayerJumpEvent;
|
||||||
import com.projectkorra.projectkorra.firebending.Blaze;
|
import com.projectkorra.projectkorra.firebending.Blaze;
|
||||||
import com.projectkorra.projectkorra.firebending.BlazeArc;
|
import com.projectkorra.projectkorra.firebending.BlazeArc;
|
||||||
|
@ -1386,6 +1387,10 @@ public class PKListener implements Listener {
|
||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
public void onPlayerSlotChange(PlayerItemHeldEvent event) {
|
public void onPlayerSlotChange(PlayerItemHeldEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
|
||||||
|
int slot = event.getNewSlot() + 1;
|
||||||
|
|
||||||
|
GeneralMethods.displayMovePreview(player, CoreAbility.getAbility(bPlayer.getAbilities().get(slot)));
|
||||||
|
|
||||||
WaterArms waterArms = CoreAbility.getAbility(player, WaterArms.class);
|
WaterArms waterArms = CoreAbility.getAbility(player, WaterArms.class);
|
||||||
if (waterArms != null) {
|
if (waterArms != null) {
|
||||||
|
|
Loading…
Reference in a new issue