From 402fcfe26c26420e2ebaa411e4ba1c341e36dedb Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 24 Apr 2021 10:43:10 -0400 Subject: [PATCH] Lute custom particles now work will all lute attack effects --- .../untargeted/lute/BruteLuteAttack.java | 22 ++++++++++++++- .../untargeted/lute/CircularLuteAttack.java | 28 +++++++++++++++++-- .../untargeted/lute/SimpleLuteAttack.java | 22 ++++++++++++++- .../untargeted/lute/SlashLuteAttack.java | 22 ++++++++++++++- .../untargeted/lute/WaveLuteAttack.java | 27 ++++++++++++++++-- 5 files changed, 114 insertions(+), 7 deletions(-) diff --git a/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/lute/BruteLuteAttack.java b/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/lute/BruteLuteAttack.java index a7eb02e8..d7b9d001 100644 --- a/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/lute/BruteLuteAttack.java +++ b/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/lute/BruteLuteAttack.java @@ -1,5 +1,7 @@ package net.Indyuce.mmoitems.api.interaction.weapon.untargeted.lute; +import com.google.gson.JsonObject; +import io.lumine.mythic.lib.MythicLib; import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.api.ItemAttackResult; @@ -7,6 +9,7 @@ import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats; import net.Indyuce.mmoitems.api.util.SoundReader; import io.lumine.mythic.lib.api.DamageType; import io.lumine.mythic.lib.api.item.NBTItem; +import net.Indyuce.mmoitems.stat.data.ProjectileParticlesData; import org.bukkit.Location; import org.bukkit.Particle; import org.bukkit.entity.Entity; @@ -36,7 +39,24 @@ public class BruteLuteAttack implements LuteAttackHandler { break; } - loc.getWorld().spawnParticle(Particle.NOTE, loc, 2, .1, .1, .1, 0); + if (nbt.hasTag("MMOITEMS_PROJECTILE_PARTICLES")) { + JsonObject obj = MythicLib.plugin.getJson().parse(nbt.getString("MMOITEMS_PROJECTILE_PARTICLES"), JsonObject.class); + Particle particle = Particle.valueOf(obj.get("Particle").getAsString()); + // If the selected particle is colored, use the provided color + if (ProjectileParticlesData.isColorable(particle)) { + double red = Double.parseDouble(String.valueOf(obj.get("Red"))); + double green = Double.parseDouble(String.valueOf(obj.get("Green"))); + double blue = Double.parseDouble(String.valueOf(obj.get("Blue"))); + ProjectileParticlesData.shootParticle(stats.getPlayer(), particle, loc, red, green, blue); + // If it's not colored, just shoot the particle + } else { + ProjectileParticlesData.shootParticle(stats.getPlayer(), particle, loc, 0, 0, 0); + } + // If no particle has been provided via projectile particle attribute, default to this particle + } else { + loc.getWorld().spawnParticle(Particle.NOTE, loc, 2, .1, .1, .1, 0); + } + if (j == 0) sound.play(loc, 2, (float) (.5 + (double) ti / range)); for (Entity target : entities) diff --git a/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/lute/CircularLuteAttack.java b/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/lute/CircularLuteAttack.java index a5fd3539..cfe0df7e 100644 --- a/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/lute/CircularLuteAttack.java +++ b/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/lute/CircularLuteAttack.java @@ -1,5 +1,7 @@ package net.Indyuce.mmoitems.api.interaction.weapon.untargeted.lute; +import com.google.gson.JsonObject; +import io.lumine.mythic.lib.MythicLib; import io.lumine.mythic.lib.api.DamageType; import io.lumine.mythic.lib.api.item.NBTItem; import net.Indyuce.mmoitems.MMOItems; @@ -7,6 +9,7 @@ import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.api.ItemAttackResult; import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats; import net.Indyuce.mmoitems.api.util.SoundReader; +import net.Indyuce.mmoitems.stat.data.ProjectileParticlesData; import org.bukkit.Location; import org.bukkit.Particle; import org.bukkit.entity.Entity; @@ -38,8 +41,29 @@ public class CircularLuteAttack implements LuteAttackHandler { double a = (double) ti / 3; Vector vec = MMOUtils.rotateFunc(new Vector(Math.cos(a), Math.sin(a), 0).multiply(.3), loc); - loc.getWorld().spawnParticle(Particle.NOTE, loc.clone().add(vec), 0); - loc.getWorld().spawnParticle(Particle.NOTE, loc.clone().add(vec.multiply(-1)), 0); + + + if (nbt.hasTag("MMOITEMS_PROJECTILE_PARTICLES")) { + JsonObject obj = MythicLib.plugin.getJson().parse(nbt.getString("MMOITEMS_PROJECTILE_PARTICLES"), JsonObject.class); + Particle particle = Particle.valueOf(obj.get("Particle").getAsString()); + // If the selected particle is colored, use the provided color + if (ProjectileParticlesData.isColorable(particle)) { + double red = Double.parseDouble(String.valueOf(obj.get("Red"))); + double green = Double.parseDouble(String.valueOf(obj.get("Green"))); + double blue = Double.parseDouble(String.valueOf(obj.get("Blue"))); + ProjectileParticlesData.shootParticle(stats.getPlayer(), particle, loc.clone().add(vec), red, green, blue); + ProjectileParticlesData.shootParticle(stats.getPlayer(), particle, loc.clone().add(vec.multiply(-1)), red, green, blue); + // If it's not colored, just shoot the particle + } else { + ProjectileParticlesData.shootParticle(stats.getPlayer(), particle, loc.clone().add(vec), 0, 0, 0); + ProjectileParticlesData.shootParticle(stats.getPlayer(), particle, loc.clone().add(vec.multiply(-1)), 0, 0, 0); + } + // If no particle has been provided via projectile particle attribute, default to this particle + } else { + loc.getWorld().spawnParticle(Particle.NOTE, loc.clone().add(vec), 0); + loc.getWorld().spawnParticle(Particle.NOTE, loc.clone().add(vec.multiply(-1)), 0); + } + if (j == 0) sound.play(loc, 2, (float) (.5 + (double) ti / range)); for (Entity target : entities) diff --git a/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/lute/SimpleLuteAttack.java b/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/lute/SimpleLuteAttack.java index 3de696a6..2efee7fd 100644 --- a/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/lute/SimpleLuteAttack.java +++ b/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/lute/SimpleLuteAttack.java @@ -1,5 +1,7 @@ package net.Indyuce.mmoitems.api.interaction.weapon.untargeted.lute; +import com.google.gson.JsonObject; +import io.lumine.mythic.lib.MythicLib; import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.api.ItemAttackResult; @@ -7,6 +9,7 @@ import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats; import net.Indyuce.mmoitems.api.util.SoundReader; import io.lumine.mythic.lib.api.DamageType; import io.lumine.mythic.lib.api.item.NBTItem; +import net.Indyuce.mmoitems.stat.data.ProjectileParticlesData; import org.bukkit.Location; import org.bukkit.Particle; import org.bukkit.entity.Entity; @@ -36,7 +39,24 @@ public class SimpleLuteAttack implements LuteAttackHandler { break; } - loc.getWorld().spawnParticle(Particle.NOTE, loc, 0); + if (nbt.hasTag("MMOITEMS_PROJECTILE_PARTICLES")) { + JsonObject obj = MythicLib.plugin.getJson().parse(nbt.getString("MMOITEMS_PROJECTILE_PARTICLES"), JsonObject.class); + Particle particle = Particle.valueOf(obj.get("Particle").getAsString()); + // If the selected particle is colored, use the provided color + if (ProjectileParticlesData.isColorable(particle)) { + double red = Double.parseDouble(String.valueOf(obj.get("Red"))); + double green = Double.parseDouble(String.valueOf(obj.get("Green"))); + double blue = Double.parseDouble(String.valueOf(obj.get("Blue"))); + ProjectileParticlesData.shootParticle(stats.getPlayer(), particle, loc, red, green, blue); + // If it's not colored, just shoot the particle + } else { + ProjectileParticlesData.shootParticle(stats.getPlayer(), particle, loc, 0, 0, 0); + } + // If no particle has been provided via projectile particle attribute, default to this particle + } else { + loc.getWorld().spawnParticle(Particle.NOTE, loc, 0); + } + if (j == 0) sound.play(loc, 2, (float) (.5 + (double) ti / range)); for (Entity target : entities) diff --git a/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/lute/SlashLuteAttack.java b/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/lute/SlashLuteAttack.java index 865e7531..3a8da868 100644 --- a/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/lute/SlashLuteAttack.java +++ b/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/lute/SlashLuteAttack.java @@ -1,5 +1,7 @@ package net.Indyuce.mmoitems.api.interaction.weapon.untargeted.lute; +import com.google.gson.JsonObject; +import io.lumine.mythic.lib.MythicLib; import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.api.ItemAttackResult; @@ -7,6 +9,7 @@ import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats; import net.Indyuce.mmoitems.api.util.SoundReader; import io.lumine.mythic.lib.api.DamageType; import io.lumine.mythic.lib.api.item.NBTItem; +import net.Indyuce.mmoitems.stat.data.ProjectileParticlesData; import org.bukkit.Location; import org.bukkit.Particle; import org.bukkit.entity.Entity; @@ -32,7 +35,24 @@ public class SlashLuteAttack implements LuteAttackHandler { loc.setDirection(vec); loc.setYaw(loc.getYaw() + k); loc.setPitch(stats.getPlayer().getEyeLocation().getPitch()); - loc.getWorld().spawnParticle(Particle.NOTE, loc.clone().add(loc.getDirection().multiply(1.5 * ti)), 0); + + if (nbt.hasTag("MMOITEMS_PROJECTILE_PARTICLES")) { + JsonObject obj = MythicLib.plugin.getJson().parse(nbt.getString("MMOITEMS_PROJECTILE_PARTICLES"), JsonObject.class); + Particle particle = Particle.valueOf(obj.get("Particle").getAsString()); + // If the selected particle is colored, use the provided color + if (ProjectileParticlesData.isColorable(particle)) { + double red = Double.parseDouble(String.valueOf(obj.get("Red"))); + double green = Double.parseDouble(String.valueOf(obj.get("Green"))); + double blue = Double.parseDouble(String.valueOf(obj.get("Blue"))); + ProjectileParticlesData.shootParticle(stats.getPlayer(), particle, loc.clone().add(loc.getDirection().multiply(1.5 * ti)), red, green, blue); + // If it's not colored, just shoot the particle + } else { + ProjectileParticlesData.shootParticle(stats.getPlayer(), particle, loc.clone().add(loc.getDirection().multiply(1.5 * ti)), 0, 0, 0); + } + // If no particle has been provided via projectile particle attribute, default to this particle + } else { + loc.getWorld().spawnParticle(Particle.NOTE, loc.clone().add(loc.getDirection().multiply(1.5 * ti)), 0); + } } } }.runTaskTimer(MMOItems.plugin, 0, 1); diff --git a/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/lute/WaveLuteAttack.java b/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/lute/WaveLuteAttack.java index 189046e2..a1b2b1d5 100644 --- a/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/lute/WaveLuteAttack.java +++ b/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/lute/WaveLuteAttack.java @@ -1,5 +1,7 @@ package net.Indyuce.mmoitems.api.interaction.weapon.untargeted.lute; +import com.google.gson.JsonObject; +import io.lumine.mythic.lib.MythicLib; import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.api.ItemAttackResult; @@ -7,6 +9,7 @@ import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats; import net.Indyuce.mmoitems.api.util.SoundReader; import io.lumine.mythic.lib.api.DamageType; import io.lumine.mythic.lib.api.item.NBTItem; +import net.Indyuce.mmoitems.stat.data.ProjectileParticlesData; import org.bukkit.Location; import org.bukkit.Particle; import org.bukkit.entity.Entity; @@ -37,8 +40,28 @@ public class WaveLuteAttack implements LuteAttackHandler { } Vector vec = MMOUtils.rotateFunc(new Vector(.5, 0, 0), loc); - loc.getWorld().spawnParticle(Particle.NOTE, loc.clone().add(vec.multiply(Math.sin((double) ti / 2))), 0); - loc.getWorld().spawnParticle(Particle.NOTE, loc.clone().add(vec.multiply(-1)), 0); + + if (nbt.hasTag("MMOITEMS_PROJECTILE_PARTICLES")) { + JsonObject obj = MythicLib.plugin.getJson().parse(nbt.getString("MMOITEMS_PROJECTILE_PARTICLES"), JsonObject.class); + Particle particle = Particle.valueOf(obj.get("Particle").getAsString()); + // If the selected particle is colored, use the provided color + if (ProjectileParticlesData.isColorable(particle)) { + double red = Double.parseDouble(String.valueOf(obj.get("Red"))); + double green = Double.parseDouble(String.valueOf(obj.get("Green"))); + double blue = Double.parseDouble(String.valueOf(obj.get("Blue"))); + ProjectileParticlesData.shootParticle(stats.getPlayer(), particle, loc.clone().add(vec.multiply(Math.sin((double) ti / 2))), red, green, blue); + ProjectileParticlesData.shootParticle(stats.getPlayer(), particle, loc.clone().add(vec.multiply(-1)), red, green, blue); + // If it's not colored, just shoot the particle + } else { + ProjectileParticlesData.shootParticle(stats.getPlayer(), particle, loc.clone().add(vec.multiply(Math.sin((double) ti / 2))), 0, 0, 0); + ProjectileParticlesData.shootParticle(stats.getPlayer(), particle, loc.clone().add(vec.multiply(-1)), 0, 0, 0); + } + // If no particle has been provided via projectile particle attribute, default to this particle + } else { + loc.getWorld().spawnParticle(Particle.NOTE, loc.clone().add(vec.multiply(Math.sin((double) ti / 2))), 0); + loc.getWorld().spawnParticle(Particle.NOTE, loc.clone().add(vec.multiply(-1)), 0); + } + if (j == 0) sound.play(loc, 2, (float) (.5 + (double) ti / range)); for (Entity target : entities)