mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2025-03-12 13:19:23 +01:00
Switch Arrow input class to AbstractArrow, which implements both the Arrow and Spectral Arrow classes, fixing potion effects not appearing onto SpectralArrows. Tipped arrows also work, prior to this update, and still work after, which will close any open issues related to tipped_arrows, as the particles and potion effects work for tipped_arrows.
This commit is contained in:
parent
99e893801d
commit
441de831fc
@ -4,14 +4,14 @@ import io.lumine.mythic.lib.api.item.NBTItem;
|
||||
import io.lumine.mythic.lib.gson.JsonParser;
|
||||
import io.lumine.mythic.lib.player.particle.ParticleInformation;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.AbstractArrow;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class ArrowParticles extends BukkitRunnable {
|
||||
private final Arrow arrow;
|
||||
private final AbstractArrow arrow;
|
||||
private final ParticleInformation particleInfo;
|
||||
|
||||
public ArrowParticles(Arrow arrow, NBTItem item) {
|
||||
public ArrowParticles(AbstractArrow arrow, NBTItem item) {
|
||||
this.arrow = arrow;
|
||||
this.particleInfo = new ParticleInformation(JsonParser.parseString(item.getString("MMOITEMS_ARROW_PARTICLES")).getAsJsonObject());
|
||||
|
||||
|
@ -24,7 +24,7 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.AbstractArrow;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
@ -272,7 +272,7 @@ public class ItemUse implements Listener {
|
||||
*/
|
||||
@EventHandler
|
||||
public void handleCustomBows(EntityShootBowEvent event) {
|
||||
if (!(event.getProjectile() instanceof Arrow) || !(event.getEntity() instanceof Player))
|
||||
if (!(event.getProjectile() instanceof AbstractArrow) || !(event.getEntity() instanceof Player))
|
||||
return;
|
||||
|
||||
final NBTItem item = NBTItem.get(event.getBow());
|
||||
@ -291,7 +291,7 @@ public class ItemUse implements Listener {
|
||||
final EquipmentSlot bowSlot = itemInMainHand.isSimilar(event.getBow()) ? EquipmentSlot.MAIN_HAND : EquipmentSlot.OFF_HAND;
|
||||
MMOItems.plugin.getEntities().registerCustomProjectile(item, playerData.getStats().newTemporary(bowSlot), event.getProjectile(), event.getForce());
|
||||
|
||||
final Arrow arrow = (Arrow) event.getProjectile();
|
||||
final AbstractArrow arrow = (AbstractArrow) event.getProjectile();
|
||||
if (item.getStat("ARROW_VELOCITY") > 0)
|
||||
arrow.setVelocity(arrow.getVelocity().multiply(item.getStat("ARROW_VELOCITY")));
|
||||
}
|
||||
|
@ -10,10 +10,7 @@ import net.Indyuce.mmoitems.api.interaction.projectile.EntityData;
|
||||
import net.Indyuce.mmoitems.api.interaction.projectile.ProjectileData;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -62,8 +59,8 @@ public class EntityManager implements Listener {
|
||||
* arrow particles. Currently projectiles are only arrows so there is no
|
||||
* problem with other projectiles like snowballs etc.
|
||||
*/
|
||||
if (entity instanceof Arrow && sourceItem.hasTag("MMOITEMS_ARROW_PARTICLES"))
|
||||
new ArrowParticles((Arrow) entity, sourceItem);
|
||||
if (entity instanceof AbstractArrow && sourceItem.hasTag("MMOITEMS_ARROW_PARTICLES"))
|
||||
new ArrowParticles((AbstractArrow) entity, sourceItem);
|
||||
|
||||
projectiles.put(entity.getEntityId(), projectileData);
|
||||
}
|
||||
@ -109,7 +106,7 @@ public class EntityManager implements Listener {
|
||||
return;
|
||||
|
||||
final Projectile projectile = (Projectile) event.getDamager();
|
||||
final ProjectileData data = projectiles.get(projectile.getEntityId());
|
||||
final ProjectileData data = getProjectileData(projectile);
|
||||
if (data == null)
|
||||
return;
|
||||
|
||||
@ -130,7 +127,7 @@ public class EntityManager implements Listener {
|
||||
return;
|
||||
|
||||
final ProjectileAttackMetadata projAttack = (ProjectileAttackMetadata) event.getAttack();
|
||||
final ProjectileData data = projectiles.get(projAttack.getProjectile().getEntityId());
|
||||
final ProjectileData data = getProjectileData(projAttack.getProjectile());
|
||||
if (data == null)
|
||||
return;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user