mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2024-05-16 01:41:22 +00:00
787b303c9f
## Additions * Adds a built-in bending board sidebar to visualize bound abilities and cooldowns. * The board respects worlds where bending is disabled. * Players can use the command `/pk board` to toggle the visibility of their board. * Includes an API that community developers can use in BendingBoardManager. * Adds the `"Properties.BendingBoard"` config option to enable or disable the board server. * Adds language file configuration options to control BendingBoard visuals. * `"Board.Title"` * Controls the title at the top of the board. * Supports the standard Minecraft color codes. * `"Board.SelectionPrefix"` * Controls the prefix shown corresponding to your current hot bar slot. * Supports the standard Minecraft color codes. * `"Board.EmptySlot"` * Controls what is shown for empty slots. * Supports the standard Minecraft color codes. * `{slot_number}` can be used as a placeholder for the slot number. * `"Board.MiscSeparator"` * Controls the separation between hot bar binds and temporary cooldowns such as Combos. * Supports the standard Minecraft color codes. * Adds support for KingdomsX version 1.10.19.1 * Adds ability permission check to passive abilities. They should now respect their `bending.ability.<ability name>` permissions. * Adds `AbilityVelocityAffectEntityEvent` * A cancellable event that will fire whenever an ability would alter the velocity of an entity. * Adds the `Abilities.Earth.EarthSmash.Shoot.CollisionRadius` configuration option * Sets the collision radius of shot EarthSmash. ## Fixes * Fixes FireBlast going through liquids. * Fixes duplication involving waterlogged containers. * Fixes being able to not enter the name of a Preset when using the `/pk preset create <name>` command. * Fixes getDayFactor() not being applied correctly and occasionally producing the wrong value. * Fixes a rounding issue with some Fire ability damage configuration options. * Fixes an error when attempting to start EarthGrab. * Fixes PhaseChange error when melting snow. * Fixes a memory/process leak in how cooldowns were removed. * A player's cooldowns could only be removed when they were online. If a player's cooldown expired while they weren't online, their cooldown would attempt to revert every tick until the player rejoined. This has been resolved so cooldowns can revert while a player is offline. * A side effect of this fix is that it is now possible for `PlayerCooldownChangeEvents` to fire while their corresponding Player is offline. * Fixes an issue with `MultiAbilityManager#hasMultiAbilityBound` where it would return true if any MultiAbility is bound, not if the specified MultiAbility was bound. ## Misc Changes * Updates Towny version to 0.96.2.0 * DensityShift sand blocks can now be used as a bendable source. * Changes AvatarState so that its cooldown is applied when the ability ends instead of when it starts. * Changes togglable abilities such as AvatarState, Illumination, and TremorSense to visually show when they are enabled in the BendingBoard and on BendingPreview in the same way as the ChiBlocking Stances. * Updated the text of some ability descriptions and instructions. * Adds new cache to PhaseChange to greatly improve the performance of water/ice updates.
216 lines
7.4 KiB
Java
216 lines
7.4 KiB
Java
package com.projectkorra.projectkorra.ability;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Random;
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
import org.bukkit.ChatColor;
|
|
import org.bukkit.Location;
|
|
import org.bukkit.Material;
|
|
import org.bukkit.Sound;
|
|
import org.bukkit.World;
|
|
import org.bukkit.block.Block;
|
|
import org.bukkit.block.BlockFace;
|
|
import org.bukkit.entity.Player;
|
|
|
|
import com.projectkorra.projectkorra.Element;
|
|
import com.projectkorra.projectkorra.GeneralMethods;
|
|
import com.projectkorra.projectkorra.ProjectKorra;
|
|
import com.projectkorra.projectkorra.Element.SubElement;
|
|
import com.projectkorra.projectkorra.ability.util.Collision;
|
|
import com.projectkorra.projectkorra.configuration.ConfigManager;
|
|
import com.projectkorra.projectkorra.util.ParticleEffect;
|
|
import com.projectkorra.projectkorra.util.TempBlock;
|
|
|
|
public abstract class FireAbility extends ElementalAbility {
|
|
|
|
private static final Map<Block, Player> SOURCE_PLAYERS = new ConcurrentHashMap<>();
|
|
|
|
public FireAbility(final Player player) {
|
|
super(player);
|
|
}
|
|
|
|
@Override
|
|
public boolean isIgniteAbility() {
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public boolean isExplosiveAbility() {
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public Element getElement() {
|
|
return Element.FIRE;
|
|
}
|
|
|
|
@Override
|
|
public void handleCollision(final Collision collision) {
|
|
super.handleCollision(collision);
|
|
if (collision.isRemovingFirst()) {
|
|
ParticleEffect.BLOCK_CRACK.display(collision.getLocationFirst(), 10, 1, 1, 1, 0.1, getFireType().createBlockData());
|
|
}
|
|
}
|
|
/**
|
|
*
|
|
* @return Material based on whether the player is a Blue Firebender, SOUL_FIRE if true, FIRE if false.
|
|
*/
|
|
public Material getFireType() {
|
|
return getBendingPlayer().canUseSubElement(SubElement.BLUE_FIRE) ? Material.SOUL_FIRE : Material.FIRE;
|
|
}
|
|
|
|
/**
|
|
* Returns if fire is allowed to completely replace blocks or if it should
|
|
* place a temp fire block.
|
|
*/
|
|
public static boolean canFireGrief() {
|
|
return getConfig().getBoolean("Properties.Fire.FireGriefing");
|
|
}
|
|
|
|
/**
|
|
* Creates a fire block meant to replace other blocks but reverts when the
|
|
* fire dissipates or is destroyed.
|
|
*/
|
|
public void createTempFire(final Location loc) {
|
|
createTempFire(loc, getConfig().getLong("Properties.Fire.RevertTicks") + (long) ((new Random()).nextDouble() * getConfig().getLong("Properties.Fire.RevertTicks")));
|
|
}
|
|
|
|
public void createTempFire(final Location loc, final long time) {
|
|
if(isIgnitable(loc.getBlock())) {
|
|
new TempBlock(loc.getBlock(), getFireType().createBlockData(), time);
|
|
SOURCE_PLAYERS.put(loc.getBlock(), this.getPlayer());
|
|
}
|
|
}
|
|
|
|
public double getDayFactor(final double value) {
|
|
return (this.player != null && isDay(player.getWorld())) ? value * getDayFactor() : value;
|
|
}
|
|
|
|
public static double getDayFactor() {
|
|
return getConfig().getDouble("Properties.Fire.DayFactor");
|
|
}
|
|
|
|
/**
|
|
* Gets the firebending dayfactor from the config multiplied by a specific
|
|
* value if it is day.
|
|
*
|
|
* @param value The value
|
|
* @param world The world to pass into {@link #isDay(World)}
|
|
* @return value DayFactor multiplied by specified value when
|
|
* {@link #isDay(World)} is true <br />
|
|
* else <br />
|
|
* value The specified value in the parameters
|
|
*/
|
|
public static double getDayFactor(final double value, final World world) {
|
|
if (isDay(world)) {
|
|
return value * getDayFactor();
|
|
}
|
|
return value;
|
|
}
|
|
|
|
public static ChatColor getSubChatColor() {
|
|
return ChatColor.valueOf(ConfigManager.getConfig().getString("Properties.Chat.Colors.FireSub"));
|
|
}
|
|
|
|
public static boolean isIgnitable(final Block block) {
|
|
return (isIgnitable(block.getType()) && Arrays.asList(getTransparentMaterials()).contains(block.getType())) || (GeneralMethods.isSolid(block.getRelative(BlockFace.DOWN)) && isAir(block.getType()));
|
|
}
|
|
|
|
public static boolean isIgnitable(final Material material) {
|
|
return material.isFlammable() || material.isBurnable();
|
|
}
|
|
|
|
/**
|
|
* This method was used for the old collision detection system. Please see
|
|
* {@link Collision} for the new system.
|
|
* <p>
|
|
* Checks whether a location is within a FireShield.
|
|
*
|
|
* @param loc The location to check
|
|
* @return true If the location is inside a FireShield.
|
|
*/
|
|
@Deprecated
|
|
public static boolean isWithinFireShield(final Location loc) {
|
|
final List<String> list = new ArrayList<String>();
|
|
list.add("FireShield");
|
|
return GeneralMethods.blockAbilities(null, list, loc, 0);
|
|
}
|
|
|
|
public static void playCombustionSound(final Location loc) {
|
|
if (getConfig().getBoolean("Properties.Fire.PlaySound")) {
|
|
final float volume = (float) getConfig().getDouble("Properties.Fire.CombustionSound.Volume");
|
|
final float pitch = (float) getConfig().getDouble("Properties.Fire.CombustionSound.Pitch");
|
|
|
|
Sound sound = Sound.ENTITY_FIREWORK_ROCKET_BLAST;
|
|
try {
|
|
sound = Sound.valueOf(getConfig().getString("Properties.Fire.CombustionSound.Sound"));
|
|
} catch (final IllegalArgumentException exception) {
|
|
ProjectKorra.log.warning("Your current value for 'Properties.Fire.CombustionSound.Sound' is not valid.");
|
|
} finally {
|
|
loc.getWorld().playSound(loc, sound, volume, pitch);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void playFirebendingParticles(final Location loc, final int amount, final double xOffset, final double yOffset, final double zOffset) {
|
|
if (this.getBendingPlayer().canUseSubElement(SubElement.BLUE_FIRE)) {
|
|
ParticleEffect.SOUL_FIRE_FLAME.display(loc, amount, xOffset, yOffset, zOffset);
|
|
} else {
|
|
ParticleEffect.FLAME.display(loc, amount, xOffset, yOffset, zOffset);
|
|
}
|
|
}
|
|
|
|
public static void playFirebendingSound(final Location loc) {
|
|
if (getConfig().getBoolean("Properties.Fire.PlaySound")) {
|
|
final float volume = (float) getConfig().getDouble("Properties.Fire.FireSound.Volume");
|
|
final float pitch = (float) getConfig().getDouble("Properties.Fire.FireSound.Pitch");
|
|
|
|
Sound sound = Sound.BLOCK_FIRE_AMBIENT;
|
|
try {
|
|
sound = Sound.valueOf(getConfig().getString("Properties.Fire.FireSound.Sound"));
|
|
} catch (final IllegalArgumentException exception) {
|
|
ProjectKorra.log.warning("Your current value for 'Properties.Fire.FireSound.Sound' is not valid.");
|
|
} finally {
|
|
loc.getWorld().playSound(loc, sound, volume, pitch);
|
|
}
|
|
}
|
|
}
|
|
|
|
public static void playLightningbendingParticle(final Location loc) {
|
|
playLightningbendingParticle(loc, Math.random(), Math.random(), Math.random());
|
|
}
|
|
|
|
public static void playLightningbendingParticle(final Location loc, final double xOffset, final double yOffset, final double zOffset) {
|
|
GeneralMethods.displayColoredParticle("#01E1FF", loc, 1, xOffset, yOffset, zOffset);
|
|
}
|
|
|
|
public static void playLightningbendingSound(final Location loc) {
|
|
if (getConfig().getBoolean("Properties.Fire.PlaySound")) {
|
|
final float volume = (float) getConfig().getDouble("Properties.Fire.LightningSound.Volume");
|
|
final float pitch = (float) getConfig().getDouble("Properties.Fire.LightningSound.Pitch");
|
|
|
|
Sound sound = Sound.ENTITY_CREEPER_HURT;
|
|
try {
|
|
sound = Sound.valueOf(getConfig().getString("Properties.Fire.LightningSound.Sound"));
|
|
} catch (final IllegalArgumentException exception) {
|
|
ProjectKorra.log.warning("Your current value for 'Properties.Fire.LightningSound.Sound' is not valid.");
|
|
} finally {
|
|
loc.getWorld().playSound(loc, sound, volume, pitch);
|
|
}
|
|
}
|
|
}
|
|
|
|
public static void stopBending() {
|
|
SOURCE_PLAYERS.clear();
|
|
}
|
|
|
|
public static Map<Block, Player> getSourcePlayers() {
|
|
return SOURCE_PLAYERS;
|
|
}
|
|
|
|
}
|