diff options
author | Andrew Ardill <andrew.ardill@gmail.com> | 2011-12-05 19:13:10 +1100 |
---|---|---|
committer | Andrew Ardill <andrew.ardill@gmail.com> | 2011-12-05 19:23:40 +1100 |
commit | b1a3aa602a8021228e3cdf429cb613c590ceb122 (patch) | |
tree | 8021307349caffcf78fa6e7aefbf0cfe0d33125a /src/main/java | |
parent | 8363eadcabe1ac9277842e75d56a7409ef6e3ced (diff) | |
download | craftbukkit-b1a3aa602a8021228e3cdf429cb613c590ceb122.tar craftbukkit-b1a3aa602a8021228e3cdf429cb613c590ceb122.tar.gz craftbukkit-b1a3aa602a8021228e3cdf429cb613c590ceb122.tar.lz craftbukkit-b1a3aa602a8021228e3cdf429cb613c590ceb122.tar.xz craftbukkit-b1a3aa602a8021228e3cdf429cb613c590ceb122.zip |
Clean-up some events to maintain general style
Diffstat (limited to 'src/main/java')
12 files changed, 40 insertions, 30 deletions
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java index 7851d560..4759b92b 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -1305,7 +1305,7 @@ public abstract class Entity { // CraftBukkit start final org.bukkit.entity.Entity thisBukkitEntity = this.getBukkitEntity(); final org.bukkit.entity.Entity stormBukkitEntity = entityweatherlighting.getBukkitEntity(); - final PluginManager pluginManager = Bukkit.getServer().getPluginManager(); + final PluginManager pluginManager = Bukkit.getPluginManager(); if (thisBukkitEntity instanceof Painting) { PaintingBreakByEntityEvent event = new PaintingBreakByEntityEvent((Painting) thisBukkitEntity, stormBukkitEntity); diff --git a/src/main/java/net/minecraft/server/EntityArrow.java b/src/main/java/net/minecraft/server/EntityArrow.java index 64e71b9d..d4bfa929 100644 --- a/src/main/java/net/minecraft/server/EntityArrow.java +++ b/src/main/java/net/minecraft/server/EntityArrow.java @@ -3,6 +3,7 @@ package net.minecraft.server; import java.util.List; // CraftBukkit start +import org.bukkit.Bukkit; import org.bukkit.entity.Projectile; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; @@ -187,13 +188,12 @@ public class EntityArrow extends Entity { // CraftBukkit start boolean stick; if (entity instanceof EntityLiving) { - org.bukkit.Server server = this.world.getServer(); org.bukkit.entity.Entity damagee = movingobjectposition.entity.getBukkitEntity(); Projectile projectile = (Projectile) this.getBukkitEntity(); EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(projectile, damagee, EntityDamageEvent.DamageCause.PROJECTILE, l); - server.getPluginManager().callEvent(event); + Bukkit.getPluginManager().callEvent(event); if (event.isCancelled()) { stick = !projectile.doesBounce(); diff --git a/src/main/java/net/minecraft/server/EntityEgg.java b/src/main/java/net/minecraft/server/EntityEgg.java index 5211e2e3..9b023156 100644 --- a/src/main/java/net/minecraft/server/EntityEgg.java +++ b/src/main/java/net/minecraft/server/EntityEgg.java @@ -1,5 +1,6 @@ package net.minecraft.server; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Animals; import org.bukkit.entity.CreatureType; @@ -36,7 +37,7 @@ public class EntityEgg extends EntityProjectile { Projectile projectile = (Projectile) this.getBukkitEntity(); EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(projectile, damagee, EntityDamageEvent.DamageCause.PROJECTILE, 0); - this.world.getServer().getPluginManager().callEvent(event); + Bukkit.getPluginManager().callEvent(event); if (event.isCancelled()) { stick = !projectile.doesBounce(); diff --git a/src/main/java/net/minecraft/server/EntityFireball.java b/src/main/java/net/minecraft/server/EntityFireball.java index 6b1e9145..cd0955cb 100644 --- a/src/main/java/net/minecraft/server/EntityFireball.java +++ b/src/main/java/net/minecraft/server/EntityFireball.java @@ -3,6 +3,7 @@ package net.minecraft.server; import java.util.List; // CraftBukkit start +import org.bukkit.Bukkit; import org.bukkit.craftbukkit.entity.CraftEntity; import org.bukkit.craftbukkit.entity.CraftLivingEntity; import org.bukkit.entity.Explosive; @@ -192,7 +193,7 @@ public class EntityFireball extends Entity { Projectile projectile = (Projectile) this.getBukkitEntity(); EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(projectile, damagee, EntityDamageEvent.DamageCause.PROJECTILE, 0); - this.world.getServer().getPluginManager().callEvent(event); + Bukkit.getPluginManager().callEvent(event); if (event.isCancelled()) { stick = !projectile.doesBounce(); diff --git a/src/main/java/net/minecraft/server/EntityFishingHook.java b/src/main/java/net/minecraft/server/EntityFishingHook.java index 5a48641c..5e099849 100644 --- a/src/main/java/net/minecraft/server/EntityFishingHook.java +++ b/src/main/java/net/minecraft/server/EntityFishingHook.java @@ -3,6 +3,7 @@ package net.minecraft.server; import java.util.List; // CraftBukkit start +import org.bukkit.Bukkit; import org.bukkit.entity.Projectile; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; @@ -196,7 +197,7 @@ public class EntityFishingHook extends Entity { Projectile projectile = (Projectile) this.getBukkitEntity(); EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(projectile, damagee, EntityDamageEvent.DamageCause.PROJECTILE, 0); - this.world.getServer().getPluginManager().callEvent(event); + Bukkit.getPluginManager().callEvent(event); if (event.isCancelled()) { stick = !projectile.doesBounce(); diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java index 3a8b7f8f..29297677 100644 --- a/src/main/java/net/minecraft/server/EntityHuman.java +++ b/src/main/java/net/minecraft/server/EntityHuman.java @@ -4,6 +4,7 @@ import java.util.Iterator; import java.util.List; // CraftBukkit start +import org.bukkit.Bukkit; import org.bukkit.craftbukkit.entity.CraftItem; import org.bukkit.craftbukkit.TrigMath; import org.bukkit.entity.Player; @@ -591,7 +592,7 @@ public abstract class EntityHuman extends EntityLiving { org.bukkit.entity.Entity damagee = this.getBukkitEntity(); 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) { return false; @@ -779,7 +780,7 @@ public abstract class EntityHuman extends EntityLiving { org.bukkit.entity.Entity damagee = (entity == null) ? null : entity.getBukkitEntity(); 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) { return; diff --git a/src/main/java/net/minecraft/server/EntityMonster.java b/src/main/java/net/minecraft/server/EntityMonster.java index c425f67c..f1c1a1fa 100644 --- a/src/main/java/net/minecraft/server/EntityMonster.java +++ b/src/main/java/net/minecraft/server/EntityMonster.java @@ -1,6 +1,7 @@ package net.minecraft.server; // CraftBukkit start +import org.bukkit.Bukkit; import org.bukkit.craftbukkit.entity.CraftEntity; import org.bukkit.event.entity.EntityDamageByEntityEvent; 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(); 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.getTarget() == null) { @@ -88,7 +89,7 @@ public abstract class EntityMonster extends EntityCreature implements IMonster { org.bukkit.entity.Entity damagee = (entity == null) ? null : entity.getBukkitEntity(); 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(); if (!event.isCancelled()) { diff --git a/src/main/java/net/minecraft/server/EntitySmallFireball.java b/src/main/java/net/minecraft/server/EntitySmallFireball.java index 426ad87b..f36af592 100644 --- a/src/main/java/net/minecraft/server/EntitySmallFireball.java +++ b/src/main/java/net/minecraft/server/EntitySmallFireball.java @@ -1,6 +1,7 @@ package net.minecraft.server; // CraftBukkit start +import org.bukkit.Bukkit; import org.bukkit.entity.Projectile; import org.bukkit.event.entity.EntityCombustByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent; @@ -25,16 +26,17 @@ public class EntitySmallFireball extends EntityFireball { if (!this.world.isStatic) { // CraftBukkit start - projectile hit event ProjectileHitEvent phe = new ProjectileHitEvent((Projectile) this.getBukkitEntity()); - final PluginManager pluginManager = this.world.getServer().getPluginManager(); + final PluginManager pluginManager = Bukkit.getPluginManager(); pluginManager.callEvent(phe); // CraftBukkit end - if (movingobjectposition.entity != null) { + final Entity movingEntity = movingobjectposition.entity; + if (movingEntity != null) { // 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; - org.bukkit.entity.Entity damagee = movingobjectposition.entity.getBukkitEntity(); + org.bukkit.entity.Entity damagee = movingEntity.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); pluginManager.callEvent(event); @@ -43,10 +45,10 @@ public class EntitySmallFireball extends EntityFireball { stick = !projectile.doesBounce(); } else { // 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 { - stick = movingobjectposition.entity.damageEntity(DamageSource.fireball(this, this.shooter), 5); + stick = movingEntity.damageEntity(DamageSource.fireball(this, this.shooter), 5); } if (stick) { // if the fireball 'sticks', ignite the target @@ -54,7 +56,7 @@ public class EntitySmallFireball extends EntityFireball { pluginManager.callEvent(combustEvent); if (!combustEvent.isCancelled()) { - movingobjectposition.entity.setOnFire(combustEvent.getDuration()); + movingEntity.setOnFire(combustEvent.getDuration()); } } // CraftBukkit end diff --git a/src/main/java/net/minecraft/server/EntitySnowball.java b/src/main/java/net/minecraft/server/EntitySnowball.java index fd82264b..bbacb28f 100644 --- a/src/main/java/net/minecraft/server/EntitySnowball.java +++ b/src/main/java/net/minecraft/server/EntitySnowball.java @@ -1,6 +1,7 @@ package net.minecraft.server; // CraftBukkit start +import org.bukkit.Bukkit; import org.bukkit.craftbukkit.entity.CraftLivingEntity; import org.bukkit.entity.Projectile; import org.bukkit.event.entity.EntityDamageByEntityEvent; @@ -31,16 +32,17 @@ public class EntitySnowball extends EntityProjectile { } // CraftBukkit start 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; - if (movingobjectposition.entity != null) { - if (movingobjectposition.entity instanceof EntityLiving) { - org.bukkit.entity.Entity damagee = movingobjectposition.entity.getBukkitEntity(); + if (movingEntity != null) { + if (movingEntity instanceof EntityLiving) { + org.bukkit.entity.Entity damagee = movingEntity.getBukkitEntity(); Projectile projectile = (Projectile) this.getBukkitEntity(); 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(); b0 = (byte) event.getDamage(); @@ -48,10 +50,10 @@ public class EntitySnowball extends EntityProjectile { stick = !projectile.doesBounce(); } else { // 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 { - stick = movingobjectposition.entity.damageEntity(DamageSource.projectile(this, this.shooter), b0); + stick = movingEntity.damageEntity(DamageSource.projectile(this, this.shooter), b0); } } diff --git a/src/main/java/net/minecraft/server/EntityWolf.java b/src/main/java/net/minecraft/server/EntityWolf.java index cd6d7a0c..879501ba 100644 --- a/src/main/java/net/minecraft/server/EntityWolf.java +++ b/src/main/java/net/minecraft/server/EntityWolf.java @@ -4,6 +4,7 @@ import java.util.Iterator; import java.util.List; // CraftBukkit start +import org.bukkit.Bukkit; import org.bukkit.craftbukkit.entity.CraftEntity; import org.bukkit.craftbukkit.event.CraftEventFactory; 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(); EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK, b0); - this.world.getServer().getPluginManager().callEvent(event); + Bukkit.getPluginManager().callEvent(event); if (event.isCancelled()) { return; diff --git a/src/main/java/net/minecraft/server/Explosion.java b/src/main/java/net/minecraft/server/Explosion.java index 1d67dccf..739f1f49 100644 --- a/src/main/java/net/minecraft/server/Explosion.java +++ b/src/main/java/net/minecraft/server/Explosion.java @@ -7,6 +7,7 @@ import java.util.Random; import java.util.Set; // CraftBukkit start +import org.bukkit.Bukkit; import org.bukkit.entity.TNTPrimed; import org.bukkit.event.entity.EntityDamageByBlockEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent; @@ -117,7 +118,6 @@ public class Explosion { double d10 = (1.0D - d7) * d9; // CraftBukkit start - explosion damage hook - org.bukkit.Server server = this.world.getServer(); 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); @@ -127,7 +127,7 @@ public class Explosion { // TODO: get the x/y/z of the tnt block? // does this even get called ever? @see EntityTNTPrimed - not BlockTNT or whatever EntityDamageByBlockEvent event = new EntityDamageByBlockEvent(null, damagee, EntityDamageEvent.DamageCause.BLOCK_EXPLOSION, damageDone); - server.getPluginManager().callEvent(event); + Bukkit.getPluginManager().callEvent(event); if (!event.isCancelled()) { entity.damageEntity(DamageSource.EXPLOSION, event.getDamage()); @@ -144,7 +144,7 @@ public class Explosion { damageCause = EntityDamageEvent.DamageCause.ENTITY_EXPLOSION; } EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(damager, damagee, damageCause, damageDone); - server.getPluginManager().callEvent(event); + Bukkit.getPluginManager().callEvent(event); if (!event.isCancelled()) { entity.damageEntity(DamageSource.EXPLOSION, event.getDamage()); diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index cfa0ec88..17438f7c 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -299,7 +299,7 @@ public class CraftEventFactory { } 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()); org.bukkit.World world = entity.getWorld(); Bukkit.getServer().getPluginManager().callEvent(event); |