mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2024-12-22 16:05:01 +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);
|
||||
if (!event.isCancelled()) {
|
||||
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);
|
||||
if (!event.isCancelled()) {
|
||||
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.object.Preset;
|
||||
import com.projectkorra.projectkorra.storage.DBConnection;
|
||||
import com.projectkorra.projectkorra.util.ActionBar;
|
||||
import com.projectkorra.projectkorra.util.BlockCacheElement;
|
||||
import com.projectkorra.projectkorra.util.Flight;
|
||||
import com.projectkorra.projectkorra.util.ParticleEffect;
|
||||
|
@ -557,6 +558,23 @@ public class GeneralMethods {
|
|||
block.getWorld().dropItem(block.getLocation(), item);
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
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.PlayerChangeElementEvent;
|
||||
import com.projectkorra.projectkorra.event.PlayerChangeElementEvent.Result;
|
||||
import com.projectkorra.projectkorra.event.PlayerCooldownChangeEvent;
|
||||
import com.projectkorra.projectkorra.event.PlayerJumpEvent;
|
||||
import com.projectkorra.projectkorra.firebending.Blaze;
|
||||
import com.projectkorra.projectkorra.firebending.BlazeArc;
|
||||
|
@ -1386,7 +1387,11 @@ public class PKListener implements Listener {
|
|||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onPlayerSlotChange(PlayerItemHeldEvent event) {
|
||||
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);
|
||||
if (waterArms != null) {
|
||||
waterArms.displayBoundMsg(event.getNewSlot() + 1);
|
||||
|
|
Loading…
Reference in a new issue