SPIGOT-1904: AreaEffectCloud events and additional API
By: t00thpick1 <t00thpick1dirko@gmail.com>
This commit is contained in:
@@ -2,6 +2,7 @@ package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import java.util.List;
|
||||
import net.minecraft.server.EntityAreaEffectCloud;
|
||||
import net.minecraft.server.EntityLiving;
|
||||
import net.minecraft.server.MobEffect;
|
||||
import net.minecraft.server.MobEffectList;
|
||||
|
||||
@@ -15,6 +16,7 @@ import org.bukkit.entity.AreaEffectCloud;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.projectiles.ProjectileSource;
|
||||
import org.bukkit.potion.PotionData;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@@ -202,4 +204,17 @@ public class CraftAreaEffectCloud extends CraftEntity implements AreaEffectCloud
|
||||
public PotionData getBasePotionData() {
|
||||
return CraftPotionUtil.toBukkit(getHandle().getType());
|
||||
}
|
||||
|
||||
public ProjectileSource getSource() {
|
||||
return getHandle().projectileSource;
|
||||
}
|
||||
|
||||
public void setSource(ProjectileSource shooter) {
|
||||
if (shooter instanceof CraftLivingEntity) {
|
||||
getHandle().a((EntityLiving) ((CraftLivingEntity) shooter).getHandle()); // PAIL rename setSource
|
||||
} else {
|
||||
getHandle().a((EntityLiving) null);
|
||||
}
|
||||
getHandle().projectileSource = shooter;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,10 @@ import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LingeringPotion;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class CraftLingeringPotion extends CraftThrownPotion {
|
||||
public class CraftLingeringPotion extends CraftThrownPotion implements LingeringPotion {
|
||||
|
||||
public CraftLingeringPotion(CraftServer server, EntityPotion entity) {
|
||||
super(server, entity);
|
||||
|
||||
@@ -6,9 +6,10 @@ import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.SplashPotion;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class CraftSplashPotion extends CraftThrownPotion {
|
||||
public class CraftSplashPotion extends CraftThrownPotion implements SplashPotion {
|
||||
|
||||
public CraftSplashPotion(CraftServer server, EntityPotion entity) {
|
||||
super(server, entity);
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.inventory.CraftMetaBook;
|
||||
import org.bukkit.craftbukkit.util.CraftDamageSource;
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
import org.bukkit.entity.AreaEffectCloud;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Creeper;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@@ -344,6 +345,15 @@ public class CraftEventFactory {
|
||||
return event;
|
||||
}
|
||||
|
||||
public static LingeringPotionSplashEvent callLingeringPotionSplashEvent(EntityPotion potion, EntityAreaEffectCloud cloud) {
|
||||
ThrownPotion thrownPotion = (ThrownPotion) potion.getBukkitEntity();
|
||||
AreaEffectCloud effectCloud = (AreaEffectCloud) cloud.getBukkitEntity();
|
||||
|
||||
LingeringPotionSplashEvent event = new LingeringPotionSplashEvent(thrownPotion, effectCloud);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
return event;
|
||||
}
|
||||
|
||||
/**
|
||||
* BlockFadeEvent
|
||||
*/
|
||||
@@ -993,4 +1003,10 @@ public class CraftEventFactory {
|
||||
entity.world.getServer().getPluginManager().callEvent(event);
|
||||
return event;
|
||||
}
|
||||
|
||||
public static AreaEffectCloudApplyEvent callAreaEffectCloudApplyEvent(EntityAreaEffectCloud cloud, List<LivingEntity> entities) {
|
||||
AreaEffectCloudApplyEvent event = new AreaEffectCloudApplyEvent((AreaEffectCloud) cloud.getBukkitEntity(), entities);
|
||||
cloud.world.getServer().getPluginManager().callEvent(event);
|
||||
return event;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user