Get the shooter of AreaEffectClouds as liable damagers
This commit is contained in:
parent
ed93c837bb
commit
0f924843b0
@ -51,6 +51,7 @@ import com.massivecraft.massivecore.engine.EngineMassiveCoreSponsor;
|
||||
import com.massivecraft.massivecore.engine.EngineMassiveCoreTeleportMixinCause;
|
||||
import com.massivecraft.massivecore.engine.EngineMassiveCoreVariable;
|
||||
import com.massivecraft.massivecore.engine.EngineMassiveCoreWorldNameSet;
|
||||
import com.massivecraft.massivecore.integration.liability.IntegrationLiabilityAreaEffectCloud;
|
||||
import com.massivecraft.massivecore.integration.vault.IntegrationVault;
|
||||
import com.massivecraft.massivecore.item.DataBannerPattern;
|
||||
import com.massivecraft.massivecore.item.WriterItemStack;
|
||||
@ -321,6 +322,7 @@ public class MassiveCore extends MassivePlugin
|
||||
|
||||
// Integration
|
||||
IntegrationVault.class,
|
||||
IntegrationLiabilityAreaEffectCloud.class,
|
||||
|
||||
// Command
|
||||
CmdMassiveCore.class,
|
||||
|
@ -0,0 +1,33 @@
|
||||
package com.massivecraft.massivecore.integration.liability;
|
||||
|
||||
import com.massivecraft.massivecore.Integration;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
public class IntegrationLiabilityAreaEffectCloud extends Integration
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static IntegrationLiabilityAreaEffectCloud i = new IntegrationLiabilityAreaEffectCloud();
|
||||
public static IntegrationLiabilityAreaEffectCloud get() { return i; }
|
||||
|
||||
public IntegrationLiabilityAreaEffectCloud()
|
||||
{
|
||||
this.setClassName("org.bukkit.entity.AreaEffectCloud");
|
||||
}
|
||||
|
||||
// Don't need to specify an engine here since the only methods we want to protect are static
|
||||
|
||||
// -------------------------------------------- //
|
||||
// LIABILITY CALCULATION
|
||||
// -------------------------------------------- //
|
||||
|
||||
public Entity getLiableDamager(EntityDamageByEntityEvent event)
|
||||
{
|
||||
if (!this.isIntegrationActive()) return null;
|
||||
return LiabilityCalculatorAreaEffectCloud.liability(event);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.massivecraft.massivecore.integration.liability;
|
||||
|
||||
import org.bukkit.entity.AreaEffectCloud;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.projectiles.ProjectileSource;
|
||||
|
||||
public class LiabilityCalculatorAreaEffectCloud
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// LIABILITY CALCULATION
|
||||
// -------------------------------------------- //
|
||||
|
||||
public static Entity liability(EntityDamageByEntityEvent event)
|
||||
{
|
||||
Entity liable = event.getDamager();
|
||||
if (!(liable instanceof AreaEffectCloud)) return null;
|
||||
|
||||
AreaEffectCloud cloud = (AreaEffectCloud) liable;
|
||||
ProjectileSource source = cloud.getSource();
|
||||
return source instanceof Entity ? (Entity) source : null;
|
||||
}
|
||||
|
||||
}
|
@ -9,6 +9,7 @@ import com.massivecraft.massivecore.comparator.ComparatorCaseInsensitive;
|
||||
import com.massivecraft.massivecore.engine.EngineMassiveCoreDatabase;
|
||||
import com.massivecraft.massivecore.engine.EngineMassiveCoreMain;
|
||||
import com.massivecraft.massivecore.engine.EngineMassiveCoreWorldNameSet;
|
||||
import com.massivecraft.massivecore.integration.liability.IntegrationLiabilityAreaEffectCloud;
|
||||
import com.massivecraft.massivecore.mixin.MixinMessage;
|
||||
import com.massivecraft.massivecore.nms.NmsEntityGet;
|
||||
import com.massivecraft.massivecore.predicate.Predicate;
|
||||
@ -1353,18 +1354,19 @@ public class MUtil
|
||||
|
||||
public static Entity getLiableDamager(EntityDamageEvent event)
|
||||
{
|
||||
if ( ! (event instanceof EntityDamageByEntityEvent)) return null;
|
||||
if (!(event instanceof EntityDamageByEntityEvent)) return null;
|
||||
EntityDamageByEntityEvent edbeEvent = (EntityDamageByEntityEvent)event;
|
||||
Entity ret = edbeEvent.getDamager();
|
||||
if (ret instanceof Projectile)
|
||||
{
|
||||
Projectile projectile = (Projectile)ret;
|
||||
ProjectileSource projectileSource = projectile.getShooter();
|
||||
if (projectileSource instanceof Entity)
|
||||
{
|
||||
ret = (Entity)projectileSource;
|
||||
}
|
||||
if (projectileSource instanceof Entity) ret = (Entity)projectileSource;
|
||||
}
|
||||
|
||||
Entity cloudBasedDamager = IntegrationLiabilityAreaEffectCloud.get().getLiableDamager(edbeEvent);
|
||||
if (cloudBasedDamager != null) ret = cloudBasedDamager;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user