Archiviert
13
0

Improve calling of ProjectileHitEvent. Fixes BUKKIT-3872

Dieser Commit ist enthalten in:
Andre LeBlanc 2013-03-23 12:16:00 -04:00 committet von GJ
Ursprung 45d3e2514d
Commit 08f3df82eb
5 geänderte Dateien mit 10 neuen und 15 gelöschten Zeilen

Datei anzeigen

@ -3,9 +3,7 @@ package net.minecraft.server;
import java.util.List;
// CraftBukkit start
import org.bukkit.entity.Projectile;
import org.bukkit.event.entity.EntityCombustByEntityEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
// CraftBukkit end
@ -209,11 +207,7 @@ public class EntityArrow extends Entity implements IProjectile {
float f3;
if (movingobjectposition != null) {
// CraftBukkit start
Projectile projectile = (Projectile) this.getBukkitEntity();
ProjectileHitEvent phe = new ProjectileHitEvent(projectile);
this.world.getServer().getPluginManager().callEvent(phe);
// CraftBukkit end
org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this); // CraftBukkit - Call event
if (movingobjectposition.entity != null) {
f2 = MathHelper.sqrt(this.motX * this.motX + this.motY * this.motY + this.motZ * this.motZ);

Datei anzeigen

@ -2,8 +2,6 @@ package net.minecraft.server;
import java.util.List;
import org.bukkit.event.entity.ProjectileHitEvent; // CraftBukkit
public abstract class EntityFireball extends Entity {
private int e = -1;
@ -133,8 +131,7 @@ public abstract class EntityFireball extends Entity {
// CraftBukkit start
if (this.dead) {
ProjectileHitEvent phe = new ProjectileHitEvent((org.bukkit.entity.Projectile) this.getBukkitEntity());
this.world.getServer().getPluginManager().callEvent(phe);
org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this);
}
// CraftBukkit end
}

Datei anzeigen

@ -178,6 +178,7 @@ public class EntityFishingHook extends Entity {
}
if (movingobjectposition != null) {
org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this); // Craftbukkit - Call event
if (movingobjectposition.entity != null) {
if (movingobjectposition.entity.damageEntity(DamageSource.projectile(this, this.owner), 0)) {
this.hooked = movingobjectposition.entity;

Datei anzeigen

@ -2,8 +2,6 @@ package net.minecraft.server;
import java.util.List;
import org.bukkit.event.entity.ProjectileHitEvent; // CraftBukkit
public abstract class EntityProjectile extends Entity implements IProjectile {
private int blockX = -1;
@ -158,8 +156,7 @@ public abstract class EntityProjectile extends Entity implements IProjectile {
this.a(movingobjectposition);
// CraftBukkit start
if (this.dead) {
ProjectileHitEvent hitEvent = new ProjectileHitEvent((org.bukkit.entity.Projectile) this.getBukkitEntity());
org.bukkit.Bukkit.getPluginManager().callEvent(hitEvent);
org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this);
}
// CraftBukkit end
}

Datei anzeigen

@ -532,6 +532,12 @@ public class CraftEventFactory {
return event;
}
public static ProjectileHitEvent callProjectileHitEvent(Entity entity) {
ProjectileHitEvent event = new ProjectileHitEvent((Projectile) entity.getBukkitEntity());
entity.world.getServer().getPluginManager().callEvent(event);
return event;
}
public static ExpBottleEvent callExpBottleEvent(Entity entity, int exp) {
ThrownExpBottle bottle = (ThrownExpBottle) entity.getBukkitEntity();
ExpBottleEvent event = new ExpBottleEvent(bottle, exp);