mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2025-01-05 06:57:37 +01:00
Fixed an issue with default skill 'Ambers' in 1.20.5+
This commit is contained in:
parent
7cabb2398a
commit
c84e52a963
@ -9,8 +9,10 @@ import io.lumine.mythic.lib.skill.SkillMetadata;
|
|||||||
import io.lumine.mythic.lib.skill.handler.SkillHandler;
|
import io.lumine.mythic.lib.skill.handler.SkillHandler;
|
||||||
import io.lumine.mythic.lib.skill.result.def.SimpleSkillResult;
|
import io.lumine.mythic.lib.skill.result.def.SimpleSkillResult;
|
||||||
import io.lumine.mythic.lib.skill.trigger.TriggerMetadata;
|
import io.lumine.mythic.lib.skill.trigger.TriggerMetadata;
|
||||||
|
import io.lumine.mythic.lib.skill.trigger.TriggerType;
|
||||||
import io.lumine.mythic.lib.util.EntityLocationType;
|
import io.lumine.mythic.lib.util.EntityLocationType;
|
||||||
import io.lumine.mythic.lib.util.ParabolicProjectile;
|
import io.lumine.mythic.lib.util.ParabolicProjectile;
|
||||||
|
import io.lumine.mythic.lib.util.annotation.BackwardsCompatibility;
|
||||||
import io.lumine.mythic.lib.version.VParticle;
|
import io.lumine.mythic.lib.version.VParticle;
|
||||||
import net.Indyuce.mmocore.api.event.PlayerResourceUpdateEvent;
|
import net.Indyuce.mmocore.api.event.PlayerResourceUpdateEvent;
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
@ -22,17 +24,25 @@ import org.bukkit.entity.LivingEntity;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class Ambers extends SkillHandler<SimpleSkillResult> implements Listener {
|
public class Ambers extends SkillHandler<SimpleSkillResult> implements Listener {
|
||||||
|
|
||||||
|
@BackwardsCompatibility(version = "1.20.5")
|
||||||
|
private final boolean legacyParticles = MythicLib.plugin.getVersion().isUnder(1, 20, 5);
|
||||||
|
|
||||||
public Ambers() {
|
public Ambers() {
|
||||||
super(false);
|
super(false);
|
||||||
|
|
||||||
registerModifiers("percent");
|
registerModifiers("percent");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public SimpleSkillResult getResult(SkillMetadata meta) {
|
public SimpleSkillResult getResult(SkillMetadata meta) {
|
||||||
return new SimpleSkillResult(meta.hasAttackBound() && meta.hasTargetEntity() && meta.getTargetEntityOrNull() instanceof LivingEntity);
|
return new SimpleSkillResult(meta.hasAttackSource()
|
||||||
|
&& meta.hasTargetEntity()
|
||||||
|
&& meta.getTargetEntityOrNull() instanceof LivingEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -47,23 +57,23 @@ public class Ambers extends SkillHandler<SimpleSkillResult> implements Listener
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void spawnAmber(PlayerAttackEvent event) {
|
public void spawnAmber(PlayerAttackEvent event) {
|
||||||
MMOPlayerData data = event.getAttacker().getData();
|
MMOPlayerData data = event.getAttacker().getData();
|
||||||
if (!event.getAttack().getDamage().hasType(DamageType.SKILL))
|
if (!event.getAttack().getDamage().hasType(DamageType.SKILL)) return;
|
||||||
return;
|
|
||||||
|
|
||||||
PassiveSkill passive = data.getPassiveSkillMap().getSkill(this);
|
PassiveSkill passive = data.getPassiveSkillMap().getSkill(this);
|
||||||
if (passive == null)
|
if (passive == null) return;
|
||||||
return;
|
|
||||||
|
|
||||||
passive.getTriggeredSkill().cast(new TriggerMetadata(event));
|
passive.getTriggeredSkill().cast(new TriggerMetadata(event, TriggerType.API));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Amber extends BukkitRunnable {
|
class Amber extends BukkitRunnable {
|
||||||
private final Location loc;
|
private final Location loc;
|
||||||
private final MMOPlayerData data;
|
private final MMOPlayerData data;
|
||||||
private final double percent;
|
private final double percent;
|
||||||
|
|
||||||
private int j;
|
private int j;
|
||||||
|
|
||||||
|
private static final double RADIUS_SQUARED = 3;
|
||||||
|
|
||||||
private Amber(MMOPlayerData data, Location source, Location loc, double percent) {
|
private Amber(MMOPlayerData data, Location source, Location loc, double percent) {
|
||||||
this.loc = loc;
|
this.loc = loc;
|
||||||
this.data = data;
|
this.data = data;
|
||||||
@ -80,10 +90,9 @@ public class Ambers extends SkillHandler<SimpleSkillResult> implements Listener
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.getPlayer().getLocation().distanceSquared(loc) < 2) {
|
if (data.getPlayer().getLocation().add(0, 1, 0).distanceSquared(loc) < RADIUS_SQUARED) {
|
||||||
|
|
||||||
data.getPlayer().playSound(data.getPlayer().getLocation(), Sound.BLOCK_END_PORTAL_FRAME_FILL, 1, 1);
|
data.getPlayer().playSound(data.getPlayer().getLocation(), Sound.BLOCK_END_PORTAL_FRAME_FILL, 1, 1);
|
||||||
// data.getSkillData().ambers++;
|
|
||||||
|
|
||||||
// Give mana back
|
// Give mana back
|
||||||
PlayerData playerData = PlayerData.get(data);
|
PlayerData playerData = PlayerData.get(data);
|
||||||
@ -95,7 +104,11 @@ public class Ambers extends SkillHandler<SimpleSkillResult> implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int j = 0; j < 5; j++)
|
for (int j = 0; j < 5; j++)
|
||||||
loc.getWorld().spawnParticle(VParticle.ENTITY_EFFECT.get(), loc, 0, 1, 0.647, 0, 1);
|
if (legacyParticles)
|
||||||
|
loc.getWorld().spawnParticle(VParticle.ENTITY_EFFECT.get(), loc, 0, 1, 0.647, 0, 1);
|
||||||
|
else
|
||||||
|
loc.getWorld().spawnParticle(VParticle.ENTITY_EFFECT.get(), loc, 0, 1, 0.647, 0, 1, Color.ORANGE);
|
||||||
|
|
||||||
loc.getWorld().spawnParticle(VParticle.REDSTONE.get(), loc, 1, new Particle.DustOptions(Color.ORANGE, 1.3f));
|
loc.getWorld().spawnParticle(VParticle.REDSTONE.get(), loc, 1, new Particle.DustOptions(Color.ORANGE, 1.3f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user