Archiviert
13
0

Added PlayerFish event.

Dieser Commit ist enthalten in:
EvilSeph 2011-07-03 00:28:29 -04:00
Ursprung aacb95e275
Commit 3789f61c7e
2 geänderte Dateien mit 75 neuen und 0 gelöschten Zeilen

Datei anzeigen

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

Datei anzeigen

@ -0,0 +1,38 @@
package net.minecraft.server;
import org.bukkit.event.player.PlayerFishEvent; // CraftBukkit
public class ItemFishingRod extends Item {
public ItemFishingRod(int i) {
super(i);
this.d(64);
this.c(1);
}
public ItemStack a(ItemStack itemstack, World world, EntityHuman entityhuman) {
if (entityhuman.hookedFish != null) {
int i = entityhuman.hookedFish.h();
itemstack.damage(i, entityhuman);
entityhuman.w();
} else {
// CraftBukkit start
PlayerFishEvent playerFishEvent = new PlayerFishEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), null,PlayerFishEvent.State.FISHING);
world.getServer().getPluginManager().callEvent(playerFishEvent);
if (playerFishEvent.isCancelled()) {
return itemstack;
}
// CraftBukkit end
world.makeSound(entityhuman, "random.bow", 0.5F, 0.4F / (b.nextFloat() * 0.4F + 0.8F));
if (!world.isStatic) {
world.addEntity(new EntityFish(world, entityhuman));
}
entityhuman.w();
}
return itemstack;
}
}