Added Bending Preview Move Display (#525)

This commit is contained in:
OmniCypher 2016-07-28 18:02:25 -07:00 committed by GitHub
parent cc39cc79f9
commit 3c2f26a962
3 changed files with 42 additions and 1 deletions

View file

@ -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)));
}
}
}

View file

@ -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>();

View file

@ -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);