3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-17 05:20:05 +01:00

Clean-up some events to maintain general style

Dieser Commit ist enthalten in:
Andrew Ardill 2011-12-05 19:13:10 +11:00
Ursprung 8363eadcab
Commit b1a3aa602a
12 geänderte Dateien mit 40 neuen und 30 gelöschten Zeilen

Datei anzeigen

@ -1305,7 +1305,7 @@ public abstract class Entity {
// CraftBukkit start // CraftBukkit start
final org.bukkit.entity.Entity thisBukkitEntity = this.getBukkitEntity(); final org.bukkit.entity.Entity thisBukkitEntity = this.getBukkitEntity();
final org.bukkit.entity.Entity stormBukkitEntity = entityweatherlighting.getBukkitEntity(); final org.bukkit.entity.Entity stormBukkitEntity = entityweatherlighting.getBukkitEntity();
final PluginManager pluginManager = Bukkit.getServer().getPluginManager(); final PluginManager pluginManager = Bukkit.getPluginManager();
if (thisBukkitEntity instanceof Painting) { if (thisBukkitEntity instanceof Painting) {
PaintingBreakByEntityEvent event = new PaintingBreakByEntityEvent((Painting) thisBukkitEntity, stormBukkitEntity); PaintingBreakByEntityEvent event = new PaintingBreakByEntityEvent((Painting) thisBukkitEntity, stormBukkitEntity);

Datei anzeigen

@ -3,6 +3,7 @@ package net.minecraft.server;
import java.util.List; import java.util.List;
// CraftBukkit start // CraftBukkit start
import org.bukkit.Bukkit;
import org.bukkit.entity.Projectile; import org.bukkit.entity.Projectile;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
@ -187,13 +188,12 @@ public class EntityArrow extends Entity {
// CraftBukkit start // CraftBukkit start
boolean stick; boolean stick;
if (entity instanceof EntityLiving) { if (entity instanceof EntityLiving) {
org.bukkit.Server server = this.world.getServer();
org.bukkit.entity.Entity damagee = movingobjectposition.entity.getBukkitEntity(); org.bukkit.entity.Entity damagee = movingobjectposition.entity.getBukkitEntity();
Projectile projectile = (Projectile) this.getBukkitEntity(); Projectile projectile = (Projectile) this.getBukkitEntity();
EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(projectile, damagee, EntityDamageEvent.DamageCause.PROJECTILE, l); EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(projectile, damagee, EntityDamageEvent.DamageCause.PROJECTILE, l);
server.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
stick = !projectile.doesBounce(); stick = !projectile.doesBounce();

Datei anzeigen

@ -1,5 +1,6 @@
package net.minecraft.server; package net.minecraft.server;
import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Animals; import org.bukkit.entity.Animals;
import org.bukkit.entity.CreatureType; import org.bukkit.entity.CreatureType;
@ -36,7 +37,7 @@ public class EntityEgg extends EntityProjectile {
Projectile projectile = (Projectile) this.getBukkitEntity(); Projectile projectile = (Projectile) this.getBukkitEntity();
EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(projectile, damagee, EntityDamageEvent.DamageCause.PROJECTILE, 0); EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(projectile, damagee, EntityDamageEvent.DamageCause.PROJECTILE, 0);
this.world.getServer().getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
stick = !projectile.doesBounce(); stick = !projectile.doesBounce();

Datei anzeigen

@ -3,6 +3,7 @@ package net.minecraft.server;
import java.util.List; import java.util.List;
// CraftBukkit start // CraftBukkit start
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.entity.CraftEntity; import org.bukkit.craftbukkit.entity.CraftEntity;
import org.bukkit.craftbukkit.entity.CraftLivingEntity; import org.bukkit.craftbukkit.entity.CraftLivingEntity;
import org.bukkit.entity.Explosive; import org.bukkit.entity.Explosive;
@ -192,7 +193,7 @@ public class EntityFireball extends Entity {
Projectile projectile = (Projectile) this.getBukkitEntity(); Projectile projectile = (Projectile) this.getBukkitEntity();
EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(projectile, damagee, EntityDamageEvent.DamageCause.PROJECTILE, 0); EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(projectile, damagee, EntityDamageEvent.DamageCause.PROJECTILE, 0);
this.world.getServer().getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
stick = !projectile.doesBounce(); stick = !projectile.doesBounce();

Datei anzeigen

@ -3,6 +3,7 @@ package net.minecraft.server;
import java.util.List; import java.util.List;
// CraftBukkit start // CraftBukkit start
import org.bukkit.Bukkit;
import org.bukkit.entity.Projectile; import org.bukkit.entity.Projectile;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
@ -196,7 +197,7 @@ public class EntityFishingHook extends Entity {
Projectile projectile = (Projectile) this.getBukkitEntity(); Projectile projectile = (Projectile) this.getBukkitEntity();
EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(projectile, damagee, EntityDamageEvent.DamageCause.PROJECTILE, 0); EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(projectile, damagee, EntityDamageEvent.DamageCause.PROJECTILE, 0);
this.world.getServer().getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
stick = !projectile.doesBounce(); stick = !projectile.doesBounce();

Datei anzeigen

@ -4,6 +4,7 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
// CraftBukkit start // CraftBukkit start
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.entity.CraftItem; import org.bukkit.craftbukkit.entity.CraftItem;
import org.bukkit.craftbukkit.TrigMath; import org.bukkit.craftbukkit.TrigMath;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -591,7 +592,7 @@ public abstract class EntityHuman extends EntityLiving {
org.bukkit.entity.Entity damagee = this.getBukkitEntity(); org.bukkit.entity.Entity damagee = this.getBukkitEntity();
EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK, i); EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK, i);
this.world.getServer().getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled() || event.getDamage() == 0) { if (event.isCancelled() || event.getDamage() == 0) {
return false; return false;
@ -779,7 +780,7 @@ public abstract class EntityHuman extends EntityLiving {
org.bukkit.entity.Entity damagee = (entity == null) ? null : entity.getBukkitEntity(); org.bukkit.entity.Entity damagee = (entity == null) ? null : entity.getBukkitEntity();
EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK, i); EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK, i);
this.world.getServer().getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled() || event.getDamage() == 0) { if (event.isCancelled() || event.getDamage() == 0) {
return; return;

Datei anzeigen

@ -1,6 +1,7 @@
package net.minecraft.server; package net.minecraft.server;
// CraftBukkit start // CraftBukkit start
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.entity.CraftEntity; import org.bukkit.craftbukkit.entity.CraftEntity;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
@ -49,7 +50,7 @@ public abstract class EntityMonster extends EntityCreature implements IMonster {
org.bukkit.entity.Entity bukkitTarget = entity == null ? null : entity.getBukkitEntity(); org.bukkit.entity.Entity bukkitTarget = entity == null ? null : entity.getBukkitEntity();
EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), bukkitTarget, EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY); EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), bukkitTarget, EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY);
this.world.getServer().getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) { if (!event.isCancelled()) {
if (event.getTarget() == null) { if (event.getTarget() == null) {
@ -88,7 +89,7 @@ public abstract class EntityMonster extends EntityCreature implements IMonster {
org.bukkit.entity.Entity damagee = (entity == null) ? null : entity.getBukkitEntity(); org.bukkit.entity.Entity damagee = (entity == null) ? null : entity.getBukkitEntity();
EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(this.getBukkitEntity(), damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK, this.damage); EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(this.getBukkitEntity(), damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK, this.damage);
this.world.getServer().getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
i = event.getDamage(); i = event.getDamage();
if (!event.isCancelled()) { if (!event.isCancelled()) {

Datei anzeigen

@ -1,6 +1,7 @@
package net.minecraft.server; package net.minecraft.server;
// CraftBukkit start // CraftBukkit start
import org.bukkit.Bukkit;
import org.bukkit.entity.Projectile; import org.bukkit.entity.Projectile;
import org.bukkit.event.entity.EntityCombustByEntityEvent; import org.bukkit.event.entity.EntityCombustByEntityEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
@ -25,16 +26,17 @@ public class EntitySmallFireball extends EntityFireball {
if (!this.world.isStatic) { if (!this.world.isStatic) {
// CraftBukkit start - projectile hit event // CraftBukkit start - projectile hit event
ProjectileHitEvent phe = new ProjectileHitEvent((Projectile) this.getBukkitEntity()); ProjectileHitEvent phe = new ProjectileHitEvent((Projectile) this.getBukkitEntity());
final PluginManager pluginManager = this.world.getServer().getPluginManager(); final PluginManager pluginManager = Bukkit.getPluginManager();
pluginManager.callEvent(phe); pluginManager.callEvent(phe);
// CraftBukkit end // CraftBukkit end
if (movingobjectposition.entity != null) { final Entity movingEntity = movingobjectposition.entity;
if (movingEntity != null) {
// CraftBukkit start - entity damage by entity event + combust event // CraftBukkit start - entity damage by entity event + combust event
if (!movingobjectposition.entity.isFireproof()) { // check if not fireproof if (!movingEntity.isFireproof()) { // check if not fireproof
boolean stick; boolean stick;
org.bukkit.entity.Entity damagee = movingobjectposition.entity.getBukkitEntity(); org.bukkit.entity.Entity damagee = movingEntity.getBukkitEntity();
Projectile projectile = (Projectile) this.getBukkitEntity(); Projectile projectile = (Projectile) this.getBukkitEntity();
if (movingobjectposition.entity instanceof EntityLiving) { if (movingEntity instanceof EntityLiving) {
EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(projectile, damagee, EntityDamageEvent.DamageCause.PROJECTILE, 5); EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(projectile, damagee, EntityDamageEvent.DamageCause.PROJECTILE, 5);
pluginManager.callEvent(event); pluginManager.callEvent(event);
@ -43,10 +45,10 @@ public class EntitySmallFireball extends EntityFireball {
stick = !projectile.doesBounce(); stick = !projectile.doesBounce();
} else { } else {
// this function returns if the fireball should stick in or not, i.e. !bounce // this function returns if the fireball should stick in or not, i.e. !bounce
stick = movingobjectposition.entity.damageEntity(DamageSource.fireball(this, this.shooter), event.getDamage()); stick = movingEntity.damageEntity(DamageSource.fireball(this, this.shooter), event.getDamage());
} }
} else { } else {
stick = movingobjectposition.entity.damageEntity(DamageSource.fireball(this, this.shooter), 5); stick = movingEntity.damageEntity(DamageSource.fireball(this, this.shooter), 5);
} }
if (stick) { if (stick) {
// if the fireball 'sticks', ignite the target // if the fireball 'sticks', ignite the target
@ -54,7 +56,7 @@ public class EntitySmallFireball extends EntityFireball {
pluginManager.callEvent(combustEvent); pluginManager.callEvent(combustEvent);
if (!combustEvent.isCancelled()) { if (!combustEvent.isCancelled()) {
movingobjectposition.entity.setOnFire(combustEvent.getDuration()); movingEntity.setOnFire(combustEvent.getDuration());
} }
} }
// CraftBukkit end // CraftBukkit end

Datei anzeigen

@ -1,6 +1,7 @@
package net.minecraft.server; package net.minecraft.server;
// CraftBukkit start // CraftBukkit start
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.entity.CraftLivingEntity; import org.bukkit.craftbukkit.entity.CraftLivingEntity;
import org.bukkit.entity.Projectile; import org.bukkit.entity.Projectile;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
@ -31,16 +32,17 @@ public class EntitySnowball extends EntityProjectile {
} }
// CraftBukkit start // CraftBukkit start
ProjectileHitEvent hitEvent = new ProjectileHitEvent((Projectile) this.getBukkitEntity()); ProjectileHitEvent hitEvent = new ProjectileHitEvent((Projectile) this.getBukkitEntity());
this.world.getServer().getPluginManager().callEvent(hitEvent); Bukkit.getPluginManager().callEvent(hitEvent);
final Entity movingEntity = movingobjectposition.entity;
boolean stick = false; boolean stick = false;
if (movingobjectposition.entity != null) { if (movingEntity != null) {
if (movingobjectposition.entity instanceof EntityLiving) { if (movingEntity instanceof EntityLiving) {
org.bukkit.entity.Entity damagee = movingobjectposition.entity.getBukkitEntity(); org.bukkit.entity.Entity damagee = movingEntity.getBukkitEntity();
Projectile projectile = (Projectile) this.getBukkitEntity(); Projectile projectile = (Projectile) this.getBukkitEntity();
EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(projectile, damagee, EntityDamageEvent.DamageCause.PROJECTILE, b0); EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(projectile, damagee, EntityDamageEvent.DamageCause.PROJECTILE, b0);
this.world.getServer().getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
this.shooter = (projectile.getShooter() == null) ? null : ((CraftLivingEntity) projectile.getShooter()).getHandle(); this.shooter = (projectile.getShooter() == null) ? null : ((CraftLivingEntity) projectile.getShooter()).getHandle();
b0 = (byte) event.getDamage(); b0 = (byte) event.getDamage();
@ -48,10 +50,10 @@ public class EntitySnowball extends EntityProjectile {
stick = !projectile.doesBounce(); stick = !projectile.doesBounce();
} else { } else {
// this function returns if the snowball should stick in or not, i.e. !bounce // this function returns if the snowball should stick in or not, i.e. !bounce
stick = movingobjectposition.entity.damageEntity(DamageSource.projectile(this, this.shooter), b0); stick = movingEntity.damageEntity(DamageSource.projectile(this, this.shooter), b0);
} }
} else { } else {
stick = movingobjectposition.entity.damageEntity(DamageSource.projectile(this, this.shooter), b0); stick = movingEntity.damageEntity(DamageSource.projectile(this, this.shooter), b0);
} }
} }

Datei anzeigen

@ -4,6 +4,7 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
// CraftBukkit start // CraftBukkit start
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.entity.CraftEntity; import org.bukkit.craftbukkit.entity.CraftEntity;
import org.bukkit.craftbukkit.event.CraftEventFactory; import org.bukkit.craftbukkit.event.CraftEventFactory;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
@ -341,7 +342,7 @@ public class EntityWolf extends EntityAnimal {
org.bukkit.entity.Entity damagee = entity == null ? null : entity.getBukkitEntity(); org.bukkit.entity.Entity damagee = entity == null ? null : entity.getBukkitEntity();
EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK, b0); EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK, b0);
this.world.getServer().getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
return; return;

Datei anzeigen

@ -7,6 +7,7 @@ import java.util.Random;
import java.util.Set; import java.util.Set;
// CraftBukkit start // CraftBukkit start
import org.bukkit.Bukkit;
import org.bukkit.entity.TNTPrimed; import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.entity.EntityDamageByBlockEvent; import org.bukkit.event.entity.EntityDamageByBlockEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
@ -117,7 +118,6 @@ public class Explosion {
double d10 = (1.0D - d7) * d9; double d10 = (1.0D - d7) * d9;
// CraftBukkit start - explosion damage hook // CraftBukkit start - explosion damage hook
org.bukkit.Server server = this.world.getServer();
org.bukkit.entity.Entity damagee = (entity == null) ? null : entity.getBukkitEntity(); org.bukkit.entity.Entity damagee = (entity == null) ? null : entity.getBukkitEntity();
int damageDone = (int) ((d10 * d10 + d10) / 2.0D * 8.0D * (double) this.size + 1.0D); int damageDone = (int) ((d10 * d10 + d10) / 2.0D * 8.0D * (double) this.size + 1.0D);
@ -127,7 +127,7 @@ public class Explosion {
// TODO: get the x/y/z of the tnt block? // TODO: get the x/y/z of the tnt block?
// does this even get called ever? @see EntityTNTPrimed - not BlockTNT or whatever // does this even get called ever? @see EntityTNTPrimed - not BlockTNT or whatever
EntityDamageByBlockEvent event = new EntityDamageByBlockEvent(null, damagee, EntityDamageEvent.DamageCause.BLOCK_EXPLOSION, damageDone); EntityDamageByBlockEvent event = new EntityDamageByBlockEvent(null, damagee, EntityDamageEvent.DamageCause.BLOCK_EXPLOSION, damageDone);
server.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) { if (!event.isCancelled()) {
entity.damageEntity(DamageSource.EXPLOSION, event.getDamage()); entity.damageEntity(DamageSource.EXPLOSION, event.getDamage());
@ -144,7 +144,7 @@ public class Explosion {
damageCause = EntityDamageEvent.DamageCause.ENTITY_EXPLOSION; damageCause = EntityDamageEvent.DamageCause.ENTITY_EXPLOSION;
} }
EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(damager, damagee, damageCause, damageDone); EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(damager, damagee, damageCause, damageDone);
server.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) { if (!event.isCancelled()) {
entity.damageEntity(DamageSource.EXPLOSION, event.getDamage()); entity.damageEntity(DamageSource.EXPLOSION, event.getDamage());

Datei anzeigen

@ -299,7 +299,7 @@ public class CraftEventFactory {
} }
public static EntityDeathEvent callEntityDeathEvent(EntityLiving victim, List<org.bukkit.inventory.ItemStack> drops) { public static EntityDeathEvent callEntityDeathEvent(EntityLiving victim, List<org.bukkit.inventory.ItemStack> drops) {
CraftLivingEntity entity = (CraftLivingEntity)victim.getBukkitEntity(); CraftLivingEntity entity = (CraftLivingEntity) victim.getBukkitEntity();
EntityDeathEvent event = new EntityDeathEvent(entity, drops, victim.getExpReward()); EntityDeathEvent event = new EntityDeathEvent(entity, drops, victim.getExpReward());
org.bukkit.World world = entity.getWorld(); org.bukkit.World world = entity.getWorld();
Bukkit.getServer().getPluginManager().callEvent(event); Bukkit.getServer().getPluginManager().callEvent(event);