2013-03-01 06:52:01 +01:00
|
|
|
package com.gmail.nossr50.util.skills;
|
|
|
|
|
2019-01-15 07:11:58 +01:00
|
|
|
import com.gmail.nossr50.config.Config;
|
|
|
|
import com.gmail.nossr50.mcMMO;
|
|
|
|
import org.bukkit.*;
|
2013-03-01 06:52:01 +01:00
|
|
|
import org.bukkit.FireworkEffect.Type;
|
2013-05-01 14:58:17 +02:00
|
|
|
import org.bukkit.block.Block;
|
2013-03-01 06:52:01 +01:00
|
|
|
import org.bukkit.block.BlockFace;
|
|
|
|
import org.bukkit.entity.EntityType;
|
|
|
|
import org.bukkit.entity.Firework;
|
|
|
|
import org.bukkit.entity.LivingEntity;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.inventory.meta.FireworkMeta;
|
2017-02-22 06:01:39 +01:00
|
|
|
import org.bukkit.metadata.FixedMetadataValue;
|
2013-03-01 06:52:01 +01:00
|
|
|
|
|
|
|
public final class ParticleEffectUtils {
|
|
|
|
|
|
|
|
private ParticleEffectUtils() {};
|
|
|
|
|
|
|
|
public static void playBleedEffect(LivingEntity livingEntity) {
|
|
|
|
if (!Config.getInstance().getBleedEffectEnabled()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
livingEntity.getWorld().playEffect(livingEntity.getEyeLocation(), Effect.STEP_SOUND, Material.REDSTONE_WIRE);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void playDodgeEffect(Player player) {
|
|
|
|
if (!Config.getInstance().getDodgeEffectEnabled()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-09-17 00:55:38 +02:00
|
|
|
playSmokeEffect(player);
|
|
|
|
}
|
|
|
|
|
2014-12-22 16:58:22 +01:00
|
|
|
public static void playFluxEffect(Location location) {
|
|
|
|
if (!Config.getInstance().getFluxEffectEnabled()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
location.getWorld().playEffect(location, Effect.MOBSPAWNER_FLAMES, 1);
|
|
|
|
}
|
|
|
|
|
2013-09-17 00:55:38 +02:00
|
|
|
public static void playSmokeEffect(LivingEntity livingEntity) {
|
|
|
|
Location location = livingEntity.getEyeLocation();
|
|
|
|
World world = livingEntity.getWorld();
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-10-15 14:38:59 +02:00
|
|
|
// Have to do it this way, because not all block directions are valid for smoke
|
|
|
|
world.playEffect(location, Effect.SMOKE, BlockFace.SOUTH_EAST);
|
|
|
|
world.playEffect(location, Effect.SMOKE, BlockFace.SOUTH);
|
|
|
|
world.playEffect(location, Effect.SMOKE, BlockFace.SOUTH_WEST);
|
|
|
|
world.playEffect(location, Effect.SMOKE, BlockFace.EAST);
|
|
|
|
world.playEffect(location, Effect.SMOKE, BlockFace.SELF);
|
|
|
|
world.playEffect(location, Effect.SMOKE, BlockFace.WEST);
|
|
|
|
world.playEffect(location, Effect.SMOKE, BlockFace.NORTH_EAST);
|
|
|
|
world.playEffect(location, Effect.SMOKE, BlockFace.NORTH);
|
|
|
|
world.playEffect(location, Effect.SMOKE, BlockFace.NORTH_WEST);
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static void playGreaterImpactEffect(LivingEntity livingEntity) {
|
|
|
|
if (!Config.getInstance().getGreaterImpactEffectEnabled()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Location location = livingEntity.getEyeLocation();
|
|
|
|
|
|
|
|
livingEntity.getWorld().createExplosion(location.getX(), location.getY(), location.getZ(), 0F, false, false);
|
|
|
|
}
|
|
|
|
|
2013-09-13 01:22:54 +02:00
|
|
|
public static void playCallOfTheWildEffect(LivingEntity livingEntity) {
|
|
|
|
if (!Config.getInstance().getCallOfTheWildEffectEnabled()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
livingEntity.getWorld().playEffect(livingEntity.getEyeLocation(), Effect.MOBSPAWNER_FLAMES, 1);
|
|
|
|
}
|
|
|
|
|
2013-03-01 06:52:01 +01:00
|
|
|
public static void playAbilityEnabledEffect(Player player) {
|
|
|
|
if (!Config.getInstance().getAbilityActivationEffectEnabled()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-05-01 14:58:17 +02:00
|
|
|
if (hasHeadRoom(player)) {
|
|
|
|
fireworkParticleShower(player, Color.GREEN);
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static void playAbilityDisabledEffect(Player player) {
|
|
|
|
if (!Config.getInstance().getAbilityDeactivationEffectEnabled()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-05-01 14:58:17 +02:00
|
|
|
if (hasHeadRoom(player)) {
|
|
|
|
fireworkParticleShower(player, Color.RED);
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
2013-10-28 21:32:40 +01:00
|
|
|
public static void fireworkParticleShower(Player player, Color color) {
|
2013-03-01 06:52:01 +01:00
|
|
|
Location location = player.getLocation();
|
2013-10-18 13:59:21 +02:00
|
|
|
location.setY(location.getY() + (player.isInsideVehicle() ? 1.0 : -1.0));
|
2013-03-01 06:52:01 +01:00
|
|
|
location.setPitch(-90);
|
|
|
|
|
|
|
|
Firework firework = (Firework) player.getWorld().spawnEntity(location, EntityType.FIREWORK);
|
2017-02-22 06:01:39 +01:00
|
|
|
firework.setMetadata(mcMMO.funfettiMetadataKey, new FixedMetadataValue(mcMMO.p, null));
|
2013-03-01 06:52:01 +01:00
|
|
|
FireworkMeta fireworkMeta = firework.getFireworkMeta();
|
2013-05-14 03:17:38 +02:00
|
|
|
FireworkEffect effect = FireworkEffect.builder().flicker(false).withColor(color).with((Config.getInstance().getLargeFireworks() ? Type.BALL_LARGE : Type.BALL)).trail(true).build();
|
2013-03-01 06:52:01 +01:00
|
|
|
fireworkMeta.addEffect(effect);
|
|
|
|
fireworkMeta.addEffect(effect);
|
|
|
|
fireworkMeta.setPower(0);
|
|
|
|
firework.setFireworkMeta(fireworkMeta);
|
|
|
|
}
|
2013-05-01 14:58:17 +02:00
|
|
|
|
|
|
|
private static boolean hasHeadRoom(Player player) {
|
|
|
|
boolean hasHeadRoom = true;
|
|
|
|
Block headBlock = player.getEyeLocation().getBlock();
|
|
|
|
|
|
|
|
for (int i = 0; i < 3; i++) {
|
|
|
|
if (!headBlock.getRelative(BlockFace.UP, i).isEmpty()) {
|
|
|
|
hasHeadRoom = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return hasHeadRoom;
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|