Added PlayerFish event.

This commit is contained in:
EvilSeph committed 2011-07-03 03:01:38 -04:00
1 parent aacb95e275
commit 3789f61c7e
2 files changed
+75

No files matched your search

@@ -6,6 +6,7 @@ import java.util.List;
import org.bukkit.entity.Projectile;
import org.bukkit.event.entity.EntityDamageByProjectileEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.player.PlayerFishEvent;
// CraftBukkit end
public class EntityFish extends Entity {
@@ -336,6 +337,16 @@ public class EntityFish extends Entity {
byte b0 = 0;
if (this.c != null) {
// CraftBukkit start
PlayerFishEvent playerFishEvent = new PlayerFishEvent((org.bukkit.entity.Player) this.owner.getBukkitEntity(), this.c.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_ENTITY);
this.world.getServer().getPluginManager().callEvent(playerFishEvent);
if (playerFishEvent.isCancelled()) {
this.die();
this.owner.hookedFish = null;
return 0;
}
// CraftBukkit end
double d0 = this.owner.locX - this.locX;
double d1 = this.owner.locY - this.locY;
double d2 = this.owner.locZ - this.locZ;
@@ -348,6 +359,16 @@ public class EntityFish extends Entity {
b0 = 3;
} else if (this.k > 0) {
EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY, this.locZ, new ItemStack(Item.RAW_FISH));
// CraftBukkit start
PlayerFishEvent playerFishEvent = new PlayerFishEvent((org.bukkit.entity.Player) this.owner.getBukkitEntity(), entityitem.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_FISH);
this.world.getServer().getPluginManager().callEvent(playerFishEvent);
if (playerFishEvent.isCancelled()) {
this.die();
this.owner.hookedFish = null;
return 0;
}
// CraftBukkit end
double d5 = this.owner.locX - this.locX;
double d6 = this.owner.locY - this.locY;
double d7 = this.owner.locZ - this.locZ;
@@ -363,9 +384,25 @@ public class EntityFish extends Entity {
}
if (this.h) {
// CraftBukkit start
PlayerFishEvent playerFishEvent = new PlayerFishEvent((org.bukkit.entity.Player) this.owner.getBukkitEntity(), null, PlayerFishEvent.State.IN_GROUND);
this.world.getServer().getPluginManager().callEvent(playerFishEvent);
if (playerFishEvent.isCancelled()) {
this.die();
this.owner.hookedFish = null;
return 0;
}
// CraftBukkit end
b0 = 2;
}
// CraftBukkit start
if (b0 == 0) {
PlayerFishEvent playerFishEvent = new PlayerFishEvent((org.bukkit.entity.Player) this.owner.getBukkitEntity(), null, PlayerFishEvent.State.FAILED_ATTEMPT);
this.world.getServer().getPluginManager().callEvent(playerFishEvent);
}
// CraftBukkit end
this.die();
this.owner.hookedFish = null;
return b0;