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
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);

Datei anzeigen

@ -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();

Datei anzeigen

@ -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();

Datei anzeigen

@ -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();

Datei anzeigen

@ -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();

Datei anzeigen

@ -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;

Datei anzeigen

@ -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()) {

Datei anzeigen

@ -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

Datei anzeigen

@ -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);
}
}

Datei anzeigen

@ -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;

Datei anzeigen

@ -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());

Datei anzeigen

@ -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);