Added more events for Wolves. Thanks Deaygo!
Added events for when wolf owner attacks an entity, or is attacked. Also added event for when a non-tame wolf targets a sheep.
Dieser Commit ist enthalten in:
Ursprung
155874eec9
Commit
b292a9dfbc
@ -10,7 +10,9 @@ import org.bukkit.craftbukkit.TrigMath;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityTargetEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
|
||||
import org.bukkit.event.player.PlayerBedEnterEvent;
|
||||
import org.bukkit.event.player.PlayerBedLeaveEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
@ -463,8 +465,25 @@ public abstract class EntityHuman extends EntityLiving {
|
||||
EntityWolf entitywolf1 = (EntityWolf) entity;
|
||||
|
||||
if (entitywolf1.A() && entitywolf1.E() == null && this.name.equals(entitywolf1.x()) && (!flag || !entitywolf1.isSitting())) {
|
||||
entitywolf1.setSitting(false);
|
||||
entitywolf1.c(entityliving);
|
||||
// CraftBukkit start
|
||||
CraftServer server = this.world.getServer();
|
||||
org.bukkit.entity.Entity bukkitTarget = null;
|
||||
if (entity != null) {
|
||||
bukkitTarget = entityliving.getBukkitEntity();
|
||||
}
|
||||
EntityTargetEvent event;
|
||||
if (flag) {
|
||||
event = new EntityTargetEvent(entitywolf1.getBukkitEntity(), bukkitTarget, TargetReason.OWNER_ATTACKED_TARGET);
|
||||
} else {
|
||||
event = new EntityTargetEvent(entitywolf1.getBukkitEntity(), bukkitTarget, TargetReason.TARGET_ATTACKED_OWNER);
|
||||
}
|
||||
server.getPluginManager().callEvent(event);
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
entitywolf1.setSitting(false);
|
||||
entitywolf1.c(entityliving);
|
||||
}
|
||||
// CraftBukkit end
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -109,7 +109,22 @@ public class EntityWolf extends EntityAnimal {
|
||||
List list = this.world.a(EntitySheep.class, AxisAlignedBB.b(this.locX, this.locY, this.locZ, this.locX + 1.0D, this.locY + 1.0D, this.locZ + 1.0D).b(16.0D, 4.0D, 16.0D));
|
||||
|
||||
if (!list.isEmpty()) {
|
||||
this.c((Entity) list.get(this.world.random.nextInt(list.size())));
|
||||
// CraftBukkit start
|
||||
Entity entity = (Entity) list.get(this.world.random.nextInt(list.size()));
|
||||
|
||||
CraftServer server = this.world.getServer();
|
||||
org.bukkit.entity.Entity bukkitTarget = null;
|
||||
if (entity != null) {
|
||||
bukkitTarget = entity.getBukkitEntity();
|
||||
}
|
||||
|
||||
EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), bukkitTarget, TargetReason.RANDOM_TARGET);
|
||||
server.getPluginManager().callEvent(event);
|
||||
|
||||
if (!event.isCancelled() || event.getTarget() != null ) {
|
||||
this.c(entity);
|
||||
}
|
||||
// CraftBukkit end
|
||||
}
|
||||
}
|
||||
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren