1.16.1 details

* Add nonstatic createTempFire methods and use those in fire abilities
* Move isIgnitable from BlazeArc to FireAbility
* Update GeneralMethods#isLightEmitting(Material)
* Update ParticleEffect to include new Particle enums
    * Deprecate DRIP_LAVA and DRIP_WATER in favor of making them more consistent with DRIPPING particles
    * ParticleEffect for Particle SOUL_FIRE_FLAME is called SOUL_FLAME to remove unnecessary redundancy
This commit is contained in:
Simp 2020-06-27 12:54:30 -04:00
parent 448a5f7292
commit 4b848f1513
9 changed files with 161 additions and 112 deletions

View file

@ -31,37 +31,6 @@ import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import com.bekvon.bukkit.residence.Residence;
import com.bekvon.bukkit.residence.api.ResidenceInterface;
import com.bekvon.bukkit.residence.protection.ClaimedResidence;
import com.bekvon.bukkit.residence.protection.ResidencePermissions;
import com.google.common.reflect.ClassPath;
import com.griefcraft.lwc.LWC;
import com.griefcraft.lwc.LWCPlugin;
import com.griefcraft.model.Protection;
import com.palmergames.bukkit.towny.Towny;
import com.palmergames.bukkit.towny.TownyMessaging;
import com.palmergames.bukkit.towny.TownySettings;
import com.palmergames.bukkit.towny.object.Coord;
import com.palmergames.bukkit.towny.object.PlayerCache;
import com.palmergames.bukkit.towny.object.PlayerCache.TownBlockStatus;
import com.palmergames.bukkit.towny.object.TownyPermission;
import com.palmergames.bukkit.towny.object.TownyUniverse;
import com.palmergames.bukkit.towny.object.TownyWorld;
import com.palmergames.bukkit.towny.object.WorldCoord;
import com.palmergames.bukkit.towny.utils.PlayerCacheUtil;
import com.palmergames.bukkit.towny.war.flagwar.TownyWar;
import com.palmergames.bukkit.towny.war.flagwar.TownyWarConfig;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.flags.Flags;
import com.sk89q.worldguard.protection.flags.StateFlag;
import com.songoda.kingdoms.constants.land.Land;
import com.songoda.kingdoms.constants.land.SimpleChunkLocation;
import com.songoda.kingdoms.constants.player.KingdomPlayer;
import com.songoda.kingdoms.manager.game.GameManagement;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Color;
@ -88,13 +57,33 @@ import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import com.bekvon.bukkit.residence.Residence;
import com.bekvon.bukkit.residence.api.ResidenceInterface;
import com.bekvon.bukkit.residence.protection.ClaimedResidence;
import com.bekvon.bukkit.residence.protection.ResidencePermissions;
import com.google.common.reflect.ClassPath;
import com.griefcraft.lwc.LWC;
import com.griefcraft.lwc.LWCPlugin;
import com.griefcraft.model.Protection;
import com.palmergames.bukkit.towny.Towny;
import com.palmergames.bukkit.towny.TownyMessaging;
import com.palmergames.bukkit.towny.TownySettings;
import com.palmergames.bukkit.towny.object.Coord;
import com.palmergames.bukkit.towny.object.PlayerCache;
import com.palmergames.bukkit.towny.object.PlayerCache.TownBlockStatus;
import com.palmergames.bukkit.towny.object.TownyPermission;
import com.palmergames.bukkit.towny.object.TownyUniverse;
import com.palmergames.bukkit.towny.object.TownyWorld;
import com.palmergames.bukkit.towny.object.WorldCoord;
import com.palmergames.bukkit.towny.utils.PlayerCacheUtil;
import com.palmergames.bukkit.towny.war.flagwar.TownyWar;
import com.palmergames.bukkit.towny.war.flagwar.TownyWarConfig;
import com.projectkorra.projectkorra.Element.SubElement;
import com.projectkorra.projectkorra.ability.Ability;
import com.projectkorra.projectkorra.ability.AddonAbility;
import com.projectkorra.projectkorra.ability.CoreAbility;
import com.projectkorra.projectkorra.ability.EarthAbility;
import com.projectkorra.projectkorra.ability.ElementalAbility;
import com.projectkorra.projectkorra.ability.FireAbility;
import com.projectkorra.projectkorra.ability.PassiveAbility;
import com.projectkorra.projectkorra.ability.WaterAbility;
import com.projectkorra.projectkorra.ability.util.Collision;
@ -133,6 +122,15 @@ import com.projectkorra.projectkorra.util.TempArmorStand;
import com.projectkorra.projectkorra.util.TempBlock;
import com.projectkorra.projectkorra.waterbending.WaterManipulation;
import com.projectkorra.projectkorra.waterbending.WaterSpout;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.flags.Flags;
import com.sk89q.worldguard.protection.flags.StateFlag;
import com.songoda.kingdoms.constants.land.Land;
import com.songoda.kingdoms.constants.land.SimpleChunkLocation;
import com.songoda.kingdoms.constants.player.KingdomPlayer;
import com.songoda.kingdoms.manager.game.GameManagement;
import br.net.fabiozumbi12.RedProtect.Bukkit.RedProtect;
import br.net.fabiozumbi12.RedProtect.Bukkit.Region;
@ -2361,6 +2359,22 @@ public class GeneralMethods {
case LAVA:
case JACK_O_LANTERN:
case END_ROD:
case DRAGON_EGG:
case END_PORTAL_FRAME:
case BROWN_MUSHROOM:
case SEA_PICKLE:
case SOUL_FIRE:
case SOUL_TORCH:
case SOUL_CAMPFIRE:
case SOUL_LANTERN:
case RESPAWN_ANCHOR:
case FIRE:
case SHROOMLIGHT:
case CAMPFIRE:
case LANTERN:
case END_GATEWAY:
case END_PORTAL:
case CRYING_OBSIDIAN:
return true;
default:
return false;

View file

@ -143,7 +143,7 @@ public abstract class AirAbility extends ElementalAbility {
double x = loc.getX() + 2 * xOffset * (Math.random() - 0.5);
double y = loc.getY() + 2 * yOffset * (Math.random() - 0.5);
double z = loc.getZ() + 2 * zOffset * (Math.random() - 0.5);
loc.getWorld().spawnParticle(Particle.SPELL_MOB_AMBIENT, x, y, z, 0, 98 / 255D, 188 / 255D, 192 / 255D, 1);
loc.getWorld().spawnParticle(Particle.SPELL_MOB, x, y, z, 0, 98 / 255D, 188 / 255D, 192 / 255D, 1);
}
} else {
getAirbendingParticles().display(loc, amount, xOffset, yOffset, zOffset);

View file

@ -9,6 +9,7 @@ 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.BendingPlayer;
@ -17,7 +18,6 @@ import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.ability.util.Collision;
import com.projectkorra.projectkorra.configuration.ConfigManager;
import com.projectkorra.projectkorra.firebending.BlazeArc;
import com.projectkorra.projectkorra.util.ParticleEffect;
import com.projectkorra.projectkorra.util.TempBlock;
@ -58,6 +58,12 @@ public abstract class FireAbility extends ElementalAbility {
return getConfig().getBoolean("Properties.Fire.FireGriefing");
}
/**
* Creates a fire TempBlock at the given location with a duration
* @param loc
* @param bPlayer
* @return created TempBlock
*/
public static TempBlock createTempFire(Location loc, BendingPlayer bPlayer) {
TempBlock tb = new TempBlock(loc.getBlock(), getFireColor(bPlayer));
tb.setRevertTime(ConfigManager.getConfig().getLong("Properties.Fire.RevertTicks"));
@ -69,6 +75,18 @@ public abstract class FireAbility extends ElementalAbility {
tb.setRevertTime(ConfigManager.getConfig().getLong("Properties.Fire.RevertTicks"));
return tb;
}
public TempBlock createTempFire(Location loc) {
TempBlock tb = new TempBlock(loc.getBlock(), getFireColor(bPlayer));
tb.setRevertTime(ConfigManager.getConfig().getLong("Properties.Fire.RevertTicks"));
return tb;
}
public TempBlock createTempFire(Block block) {
TempBlock tb = new TempBlock(block, getFireColor(bPlayer));
tb.setRevertTime(ConfigManager.getConfig().getLong("Properties.Fire.RevertTicks"));
return tb;
}
public double getDayFactor(final double value) {
return this.player != null ? value * getDayFactor() : 1;
@ -96,52 +114,96 @@ public abstract class FireAbility extends ElementalAbility {
return value;
}
/**
* Get the Material based on the color of the given BendingPlayer's firebending
* @param bPlayer checked BendingPlayer
* @return blue fire if they have blue fire subelement, otherwise normal fire
*/
public static Material getFireColor(final BendingPlayer bPlayer) {
if (bPlayer.hasSubElement(Element.BLUE_FIRE)) {
return Material.SOUL_FIRE;
} else {
if (bPlayer == null) {
return Material.FIRE;
}
}
return bPlayer.hasSubElement(Element.BLUE_FIRE) ? Material.SOUL_FIRE : Material.FIRE;
}
/**
* Get the Material based on the color of the ability's BendingPlayer's firebending
* @return blue fire if they have blue fire subelement, otherwise normal fire
*/
public Material getFireColor() {
if (bPlayer.hasSubElement(Element.BLUE_FIRE)) {
return Material.SOUL_FIRE;
} else {
if (bPlayer == null) {
return Material.FIRE;
}
return bPlayer.hasSubElement(Element.BLUE_FIRE) ? Material.SOUL_FIRE : Material.FIRE;
}
/**
* Get the ParticleEffect based on the color of the ability's BendingPlayer's firebending
* @param bPlayer checked BendingPlayer
* @return blue fire if they have blue fire subelement, otherwise normal fire
*/
public static ParticleEffect getFireParticle(final BendingPlayer bPlayer) {
if (bPlayer.hasSubElement(Element.BLUE_FIRE)) {
return ParticleEffect.SOUL_FLAME;
} else {
if (bPlayer == null) {
return ParticleEffect.FLAME;
}
return bPlayer.hasSubElement(Element.BLUE_FIRE) ? ParticleEffect.SOUL_FLAME : ParticleEffect.FLAME;
}
/**
* Get the ParticleEffect based on the color of the ability's BendingPlayer's firebending
* @return blue fire if they have blue fire subelement, otherwise normal fire
*/
public ParticleEffect getFireParticle() {
if (bPlayer.hasSubElement(Element.BLUE_FIRE)) {
return ParticleEffect.SOUL_FLAME;
} else {
if (bPlayer == null) {
return ParticleEffect.FLAME;
}
return bPlayer.hasSubElement(Element.BLUE_FIRE) ? ParticleEffect.SOUL_FLAME : ParticleEffect.FLAME;
}
public static ChatColor getSubChatColor() {
return ChatColor.valueOf(ConfigManager.getConfig().getString("Properties.Chat.Colors.FireSub"));
}
/**
* Gets the topmost ignitable block within the specified range from the given block
* @param block checked block and center of range
* @param range y-axis range from given block to check within
* @return null if no ignitable block found in the range
*/
public static Block getIgnitable(final Block block, final int range) {
Block top = GeneralMethods.getTopBlock(block.getLocation(), range).getRelative(BlockFace.UP);
if (isIgnitable(top)) {
return top;
}
return null;
}
/**
* Checks if the block is a type of fire
* @param block checked block
* @return true if fire type
*/
public static boolean isFire(final Block block) {
return block.getType() == Material.FIRE || block.getType() == Material.SOUL_FIRE;
}
/**
* Checks if the given block can be ignited
* @param block checked block
* @return true if fire can be placed in a mostly vanilla fashion at the block
*/
public static boolean isIgnitable(final Block block) {
return block != null ? isIgnitable(block.getType()) : false;
}
public static boolean isIgnitable(final Material material) {
return material.isFlammable() || material.isBurnable();
if (block == null) {
return false;
}
return block.isPassable() && !block.isLiquid() && GeneralMethods.isSolid(block.getRelative(BlockFace.DOWN));
}
/**

View file

@ -1,14 +1,11 @@
package com.projectkorra.projectkorra.firebending;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import com.projectkorra.projectkorra.BendingPlayer;
import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ability.FireAbility;
import com.projectkorra.projectkorra.attribute.Attribute;
@ -37,9 +34,7 @@ public class BlazeArc extends FireAbility {
this.origin = location.clone();
this.location = this.origin.clone();
this.direction = direction.clone();
this.direction.setY(0);
this.direction = this.direction.clone().normalize();
this.direction = direction.clone().setY(0).normalize();
this.location = this.location.clone().add(this.direction);
this.time = System.currentTimeMillis();
@ -68,7 +63,7 @@ public class BlazeArc extends FireAbility {
this.remove();
return;
} else if (System.currentTimeMillis() - this.time >= this.interval) {
this.location = this.location.clone().add(this.direction);
this.location.add(this.direction);
this.time = System.currentTimeMillis();
final Block block = this.location.getBlock();
@ -83,51 +78,13 @@ public class BlazeArc extends FireAbility {
return;
}
final Block ignitable = getIgnitable(block);
final Block ignitable = getIgnitable(block, 1);
if (ignitable != null) {
this.ignite(ignitable);
}
}
}
public static Block getIgnitable(final Block block) {
Block top = GeneralMethods.isSolid(block) ? block.getRelative(BlockFace.UP) : block;
for (int i = 0; i < 2; i++) {
if (GeneralMethods.isSolid(top.getRelative(BlockFace.DOWN))) {
break;
}
top = top.getRelative(BlockFace.DOWN);
}
if (top.getType() == Material.FIRE) {
return top;
} else if (top.getType().isBurnable()) {
return top;
} else if (isAir(top.getType())) {
return top;
} else {
return null;
}
}
public static boolean isIgnitable(final Player player, final Block block) {
if (!BendingPlayer.getBendingPlayer(player).hasElement(Element.FIRE)) {
return false;
} else if (!GeneralMethods.isSolid(block.getRelative(BlockFace.DOWN))) {
return false;
} else if (block.getType() == Material.FIRE) {
return true;
} else if (block.getType().isBurnable()) {
return true;
} else if (isAir(block.getType())) {
return true;
} else {
return false;
}
}
public static void removeAroundPoint(final Location location, final double radius) {
for (final BlazeArc stream : getAbilities(BlazeArc.class)) {
if (stream.location.getWorld().equals(location.getWorld())) {

View file

@ -155,14 +155,14 @@ public class FireBlast extends FireAbility {
private void ignite(final Location location) {
for (final Block block : GeneralMethods.getBlocksAroundPoint(location, 1 + this.collisionRadius)) {
if (BlazeArc.isIgnitable(this.player, block) && !this.safeBlocks.contains(block) && !GeneralMethods.isRegionProtectedFromBuild(this, block.getLocation())) {
if (isIgnitable(block) && !this.safeBlocks.contains(block) && !GeneralMethods.isRegionProtectedFromBuild(this, block.getLocation())) {
if (canFireGrief()) {
if (isPlant(block) || isSnow(block)) {
new PlantRegrowth(this.player, block);
}
block.setType(getFireColor(bPlayer));
block.setType(getFireColor());
} else {
createTempFire(block, bPlayer);
createTempFire(block);
}
}
}
@ -190,7 +190,7 @@ public class FireBlast extends FireAbility {
furnace.setBurnTime((short) 800);
furnace.setCookTime((short) 800);
furnace.update();
} else if (BlazeArc.isIgnitable(this.player, block.getRelative(BlockFace.UP))) {
} else if (isIgnitable(block.getRelative(BlockFace.UP))) {
if ((this.isFireBurst && this.fireBurstIgnite) || !this.isFireBurst) {
this.ignite(this.location);
}

View file

@ -230,8 +230,8 @@ public class FireBlastCharged extends FireAbility {
private void ignite(final Location location) {
for (final Block block : GeneralMethods.getBlocksAroundPoint(location, this.collisionRadius)) {
if (BlazeArc.isIgnitable(this.player, block)) {
createTempFire(block, bPlayer);
if (isIgnitable(block)) {
createTempFire(block);
}
}
}

View file

@ -31,6 +31,7 @@ public class FireJet extends FireAbility {
private Random random;
private Boolean previousGlidingState;
private Boolean showGliding;
private VelocityBuilder velocity;
public FireJet(final Player player) {
super(player);
@ -54,17 +55,17 @@ public class FireJet extends FireAbility {
this.cooldown = getConfig().getLong("Abilities.Fire.FireJet.Cooldown");
this.showGliding = getConfig().getBoolean("Abilities.Fire.FireJet.ShowGliding");
this.random = new Random();
this.velocity = new VelocityBuilder();
this.speed = this.getDayFactor(this.speed);
final Block block = player.getLocation().getBlock();
if (BlazeArc.isIgnitable(player, block) || ElementalAbility.isAir(block.getType()) || block.getType() == Material.STONE_SLAB || block.getType() == Material.ACACIA_SLAB || block.getType() == Material.BIRCH_SLAB || block.getType() == Material.DARK_OAK_SLAB || block.getType() == Material.JUNGLE_SLAB || block.getType() == Material.OAK_SLAB || block.getType() == Material.SPRUCE_SLAB || isIlluminationTorch(block) || this.bPlayer.isAvatarState()) {
if (isIgnitable(block) || ElementalAbility.isAir(block.getType()) || block.getType() == Material.STONE_SLAB || block.getType() == Material.ACACIA_SLAB || block.getType() == Material.BIRCH_SLAB || block.getType() == Material.DARK_OAK_SLAB || block.getType() == Material.JUNGLE_SLAB || block.getType() == Material.OAK_SLAB || block.getType() == Material.SPRUCE_SLAB || isIlluminationTorch(block) || this.bPlayer.isAvatarState()) {
player.setVelocity(player.getEyeLocation().getDirection().clone().normalize().multiply(this.speed));
if (!canFireGrief()) {
if (ElementalAbility.isAir(block.getType()) && GeneralMethods.isSolid(block.getRelative(BlockFace.DOWN))) {
createTempFire(block, bPlayer);
createTempFire(block);
}
} else if (ElementalAbility.isAir(block.getType())) {
block.setType(getFireColor());
}
@ -103,7 +104,7 @@ public class FireJet extends FireAbility {
timefactor = 1 - (System.currentTimeMillis() - this.time) / (2.0 * this.duration);
}
new VelocityBuilder(player.getEyeLocation().getDirection()).knockback(this.speed * timefactor).apply(player, this);
velocity.direction(player.getEyeLocation().getDirection()).knockback(this.speed * timefactor).apply(player, this);
this.player.setFallDistance(0);
}
}

View file

@ -112,7 +112,7 @@ public class Illumination extends FireAbility {
final Block standingBlock = this.player.getLocation().getBlock();
final Block standBlock = standingBlock.getRelative(BlockFace.DOWN);
if (!BlazeArc.isIgnitable(this.player, standingBlock)) {
if (isIgnitable(standingBlock)) {
return;
} else if (!GeneralMethods.isSolid(standBlock)) {
return;

View file

@ -21,14 +21,18 @@ public enum ParticleEffect {
BUBBLE_COLUMN_UP (Particle.BUBBLE_COLUMN_UP),
BUBBLE_POP (Particle.BUBBLE_POP),
CLOUD (Particle.CLOUD),
COMPOSTER (Particle.COMPOSTER),
CRIMSON_SPORE (Particle.CRIMSON_SPORE),
CRIT (Particle.CRIT),
CRIT_MAGIC (Particle.CRIT_MAGIC),
CURRENT_DOWN (Particle.CURRENT_DOWN),
DAMAGE_INDICATOR (Particle.DAMAGE_INDICATOR),
DOLPHIN (Particle.DOLPHIN),
DRAGON_BREATH (Particle.DRAGON_BREATH),
DRIP_LAVA (Particle.DRIP_LAVA),
DRIP_WATER (Particle.DRIP_WATER),
DRIPPING_HONEY (Particle.DRIPPING_HONEY),
DRIPPING_LAVA (Particle.DRIP_LAVA), @Deprecated DRIP_LAVA (Particle.DRIP_LAVA),
DRIPPING_OBSIDIAN_TEAR (Particle.DRIPPING_OBSIDIAN_TEAR),
DRIPPING_WATER (Particle.DRIP_WATER), @Deprecated DRIP_WATER (Particle.DRIP_WATER),
ENCHANTMENT_TABLE (Particle.ENCHANTMENT_TABLE),
END_ROD (Particle.END_ROD),
EXPLOSION_HUGE (Particle.EXPLOSION_HUGE),
@ -39,6 +43,11 @@ public enum ParticleEffect {
* Applicable data: {@link BlockData}
*/
FALLING_DUST (Particle.FALLING_DUST),
FALLING_HONEY (Particle.FALLING_HONEY),
FALLING_LAVA (Particle.FALLING_LAVA),
FALLING_NECTAR (Particle.FALLING_NECTAR),
FALLING_OBSIDIAN_TEAR (Particle.FALLING_OBSIDIAN_TEAR),
FALLING_WATER (Particle.FALLING_WATER),
FIREWORKS_SPARK (Particle.FIREWORKS_SPARK),
FLAME (Particle.FLAME),
HEART (Particle.HEART),
@ -47,6 +56,9 @@ public enum ParticleEffect {
* Applicable data: {@link ItemStack}
*/
ITEM_CRACK (Particle.ITEM_CRACK),
LANDING_HONEY (Particle.LANDING_HONEY),
LANDING_LAVA (Particle.LANDING_LAVA),
LANDING_OBSIDIAN_TEAR (Particle.LANDING_OBSIDIAN_TEAR),
LAVA (Particle.LAVA),
MOB_APPEARANCE (Particle.MOB_APPEARANCE),
NAUTILUS (Particle.NAUTILUS),
@ -57,6 +69,7 @@ public enum ParticleEffect {
* Applicable data: {@link DustOptions}
*/
REDSTONE (Particle.REDSTONE),
REVERSE_PORTAL (Particle.REVERSE_PORTAL),
SLIME (Particle.SLIME),
SMOKE_NORMAL (Particle.SMOKE_NORMAL),
SMOKE_LARGE (Particle.SMOKE_LARGE),
@ -78,10 +91,12 @@ public enum ParticleEffect {
TOWN_AURA (Particle.TOWN_AURA),
VILLAGER_ANGRY (Particle.VILLAGER_ANGRY),
VILLAGER_HAPPY (Particle.VILLAGER_HAPPY),
WARPED_SPORE (Particle.WARPED_SPORE),
WATER_BUBBLE (Particle.WATER_BUBBLE),
WATER_DROP (Particle.WATER_DROP),
WATER_SPLASH (Particle.WATER_SPLASH),
WATER_WAKE (Particle.WATER_WAKE);
WATER_WAKE (Particle.WATER_WAKE),
WHITE_ASH (Particle.WHITE_ASH);
Particle particle;
Class<?> dataClass;