geforkt von Mirrors/Paper
[Bleeding] Implemented PotionSplashEvent. Closes BUKKIT-307
Dieser Commit ist enthalten in:
Ursprung
74ead3abd1
Commit
872dad5540
@ -3,6 +3,16 @@ package net.minecraft.server;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
// CraftBukkit start
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import org.bukkit.craftbukkit.entity.CraftLivingEntity;
|
||||||
|
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.event.entity.PotionSplashEvent;
|
||||||
|
// CraftBukkit end
|
||||||
|
|
||||||
public class EntityPotion extends EntityProjectile {
|
public class EntityPotion extends EntityProjectile {
|
||||||
|
|
||||||
private int d;
|
private int d;
|
||||||
@ -48,6 +58,9 @@ public class EntityPotion extends EntityProjectile {
|
|||||||
if (list1 != null && !list1.isEmpty()) {
|
if (list1 != null && !list1.isEmpty()) {
|
||||||
Iterator iterator = list1.iterator();
|
Iterator iterator = list1.iterator();
|
||||||
|
|
||||||
|
// CraftBukkit
|
||||||
|
HashMap<LivingEntity, Double> affected = new HashMap<LivingEntity, Double>();
|
||||||
|
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
Entity entity = (Entity) iterator.next();
|
Entity entity = (Entity) iterator.next();
|
||||||
double d0 = this.i(entity);
|
double d0 = this.i(entity);
|
||||||
@ -59,6 +72,21 @@ public class EntityPotion extends EntityProjectile {
|
|||||||
d1 = 1.0D;
|
d1 = 1.0D;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CraftBukkit start
|
||||||
|
affected.put((LivingEntity) entity.getBukkitEntity(), d1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PotionSplashEvent event = CraftEventFactory.callPotionSplashEvent(this, affected);
|
||||||
|
if (!event.isCancelled()) {
|
||||||
|
for (LivingEntity victim : event.getAffectedEntities()) {
|
||||||
|
if (!(victim instanceof CraftLivingEntity)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
EntityLiving entity = ((CraftLivingEntity) victim).getHandle();
|
||||||
|
double d1 = event.getIntensity(victim);
|
||||||
|
// CraftBukkit end
|
||||||
|
|
||||||
Iterator iterator1 = list.iterator();
|
Iterator iterator1 = list.iterator();
|
||||||
|
|
||||||
while (iterator1.hasNext()) {
|
while (iterator1.hasNext()) {
|
||||||
|
@ -2,6 +2,7 @@ package org.bukkit.craftbukkit.event;
|
|||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import net.minecraft.server.ChunkCoordinates;
|
import net.minecraft.server.ChunkCoordinates;
|
||||||
import net.minecraft.server.Entity;
|
import net.minecraft.server.Entity;
|
||||||
@ -24,6 +25,7 @@ import net.minecraft.server.EntityMushroomCow;
|
|||||||
import net.minecraft.server.EntityPig;
|
import net.minecraft.server.EntityPig;
|
||||||
import net.minecraft.server.EntityPigZombie;
|
import net.minecraft.server.EntityPigZombie;
|
||||||
import net.minecraft.server.EntityPlayer;
|
import net.minecraft.server.EntityPlayer;
|
||||||
|
import net.minecraft.server.EntityPotion;
|
||||||
import net.minecraft.server.EntitySheep;
|
import net.minecraft.server.EntitySheep;
|
||||||
import net.minecraft.server.EntitySilverfish;
|
import net.minecraft.server.EntitySilverfish;
|
||||||
import net.minecraft.server.EntitySkeleton;
|
import net.minecraft.server.EntitySkeleton;
|
||||||
@ -56,6 +58,7 @@ import org.bukkit.entity.Arrow;
|
|||||||
import org.bukkit.entity.CreatureType;
|
import org.bukkit.entity.CreatureType;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.entity.ThrownPotion;
|
||||||
import org.bukkit.event.Event.Type;
|
import org.bukkit.event.Event.Type;
|
||||||
import org.bukkit.event.block.*;
|
import org.bukkit.event.block.*;
|
||||||
import org.bukkit.event.entity.*;
|
import org.bukkit.event.entity.*;
|
||||||
@ -65,6 +68,7 @@ import org.bukkit.event.player.*;
|
|||||||
import org.bukkit.event.server.ServerListPingEvent;
|
import org.bukkit.event.server.ServerListPingEvent;
|
||||||
|
|
||||||
public class CraftEventFactory {
|
public class CraftEventFactory {
|
||||||
|
// helper methods
|
||||||
private static boolean canBuild(CraftWorld world, Player player, int x, int z) {
|
private static boolean canBuild(CraftWorld world, Player player, int x, int z) {
|
||||||
WorldServer worldServer = world.getHandle();
|
WorldServer worldServer = world.getHandle();
|
||||||
int spawnSize = Bukkit.getServer().getSpawnRadius();
|
int spawnSize = Bukkit.getServer().getSpawnRadius();
|
||||||
@ -321,6 +325,17 @@ public class CraftEventFactory {
|
|||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PotionSplashEvent
|
||||||
|
*/
|
||||||
|
public static PotionSplashEvent callPotionSplashEvent(EntityPotion potion, Map<LivingEntity, Double> affectedEntities) {
|
||||||
|
ThrownPotion thrownPotion = (ThrownPotion) potion.getBukkitEntity();
|
||||||
|
|
||||||
|
PotionSplashEvent event = new PotionSplashEvent(thrownPotion, affectedEntities);
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BlockFadeEvent
|
* BlockFadeEvent
|
||||||
*/
|
*/
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren