mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-27 13:06:02 +01:00
Entity audit. Adds checks for null entities, and adds conformity.
This commit is contained in:
parent
1dad7de4f3
commit
1cbde901ba
@ -1,11 +1,6 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
// CraftBukkit start
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
import org.bukkit.craftbukkit.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.entity.CraftLivingEntity;
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.event.entity.EntityDamageByBlockEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
@ -102,7 +97,7 @@ public class BlockCactus extends Block {
|
||||
if(entity instanceof EntityLiving) {
|
||||
CraftServer server = ((WorldServer) world).getServer();
|
||||
org.bukkit.block.Block damager = ((WorldServer) world).getWorld().getBlockAt(i, j, k);
|
||||
org.bukkit.entity.Entity damagee = entity.getBukkitEntity();
|
||||
org.bukkit.entity.Entity damagee = (entity == null)?null:entity.getBukkitEntity();
|
||||
DamageCause damageType = EntityDamageEvent.DamageCause.CONTACT;
|
||||
int damageDone = 1;
|
||||
|
||||
|
@ -9,6 +9,7 @@ import org.bukkit.craftbukkit.entity.CraftBoat;
|
||||
import org.bukkit.craftbukkit.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.CraftMappable;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
import org.bukkit.event.Event.Type;
|
||||
import org.bukkit.event.vehicle.VehicleCreateEvent;
|
||||
@ -86,7 +87,9 @@ public class EntityBoat extends Entity implements CraftMappable { // CraftBukkit
|
||||
// CraftBukkit start
|
||||
private void handleCreation(World world) {
|
||||
CraftServer server = ((WorldServer) world).getServer();
|
||||
VehicleCreateEvent event = new VehicleCreateEvent( Type.VEHICLE_CREATE, (Vehicle) this.getBukkitEntity());
|
||||
Type eventType = Type.VEHICLE_CREATE;
|
||||
Vehicle vehicle = (Vehicle) this.getBukkitEntity();
|
||||
VehicleCreateEvent event = new VehicleCreateEvent(eventType, vehicle);
|
||||
server.getPluginManager().callEvent(event);
|
||||
}
|
||||
// CraftBukkit end
|
||||
@ -97,7 +100,12 @@ public class EntityBoat extends Entity implements CraftMappable { // CraftBukkit
|
||||
|
||||
public boolean a(Entity entity, int i) {
|
||||
// CraftBukkit start
|
||||
VehicleDamageEvent event = new VehicleDamageEvent( Type.VEHICLE_DAMAGE, (Vehicle) this.getBukkitEntity(), entity.getBukkitEntity(), i);
|
||||
Type eventType = Type.VEHICLE_DAMAGE;
|
||||
Vehicle vehicle = (Vehicle) this.getBukkitEntity();
|
||||
org.bukkit.entity.Entity attacker = (entity == null)?null:entity.getBukkitEntity();
|
||||
int damage = i;
|
||||
|
||||
VehicleDamageEvent event = new VehicleDamageEvent(eventType, vehicle, attacker, damage);
|
||||
((WorldServer) l).getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
@ -290,7 +298,13 @@ public class EntityBoat extends Entity implements CraftMappable { // CraftBukkit
|
||||
|
||||
// CraftBukkit start
|
||||
CraftServer server = ((WorldServer)l).getServer();
|
||||
VehicleMoveEvent event = new VehicleMoveEvent(Type.VEHICLE_MOVE, (Vehicle) this.getBukkitEntity(), new Location(((WorldServer)l).getWorld(), prevX, prevY, prevZ, prevYaw, prevPitch), new Location(((WorldServer)l).getWorld(), p, q, r, v, w));
|
||||
CraftWorld world = ((WorldServer)l).getWorld();
|
||||
Type eventType = Type.VEHICLE_MOVE;
|
||||
Vehicle vehicle = (Vehicle) this.getBukkitEntity();
|
||||
Location from = new Location(world, prevX, prevY, prevZ, prevYaw, prevPitch);
|
||||
Location to = new Location(world, p, q, r, v, w);
|
||||
|
||||
VehicleMoveEvent event = new VehicleMoveEvent(eventType, vehicle, from, to);
|
||||
server.getPluginManager().callEvent(event);
|
||||
// CraftBukkit end
|
||||
|
||||
@ -325,7 +339,11 @@ public class EntityBoat extends Entity implements CraftMappable { // CraftBukkit
|
||||
// CraftBukkit start
|
||||
public void c(Entity entity) {
|
||||
CraftServer server = ((WorldServer)l).getServer();
|
||||
VehicleEntityCollisionEvent collsionEvent = new VehicleEntityCollisionEvent( Type.VEHICLE_COLLISION_ENTITY, (Vehicle) this.getBukkitEntity(), entity.getBukkitEntity());
|
||||
Type eventType = Type.VEHICLE_COLLISION_ENTITY;
|
||||
Vehicle vehicle = (Vehicle) this.getBukkitEntity();
|
||||
org.bukkit.entity.Entity hitEntity = (entity == null)?null:entity.getBukkitEntity();
|
||||
|
||||
VehicleEntityCollisionEvent collsionEvent = new VehicleEntityCollisionEvent(eventType, vehicle, hitEntity);
|
||||
server.getPluginManager().callEvent(collsionEvent);
|
||||
|
||||
if (collsionEvent.isCancelled()) {
|
||||
@ -347,7 +365,11 @@ public class EntityBoat extends Entity implements CraftMappable { // CraftBukkit
|
||||
if (!l.z) {
|
||||
// CraftBukkit start
|
||||
CraftServer server = ((WorldServer)l).getServer();
|
||||
VehicleEnterEvent event = new VehicleEnterEvent( Type.VEHICLE_ENTER, (Vehicle) this.getBukkitEntity(), entityplayer.getBukkitEntity());
|
||||
Type eventType = Type.VEHICLE_ENTER;
|
||||
Vehicle vehicle = (Vehicle) this.getBukkitEntity();
|
||||
org.bukkit.entity.Entity player = entityplayer.getBukkitEntity();
|
||||
|
||||
VehicleEnterEvent event = new VehicleEnterEvent(eventType, vehicle, player);
|
||||
server.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
|
@ -196,7 +196,7 @@ public class EntityEgg extends Entity {
|
||||
}
|
||||
}
|
||||
|
||||
// Craftbukkit start
|
||||
// CraftBukkit start
|
||||
boolean hatching = !this.l.z && W.nextInt(8) == 0;
|
||||
byte numHatching = (hatching && W.nextInt(32) == 0) ? (byte) 4 : (byte) 1;
|
||||
if (!hatching) {
|
||||
@ -207,7 +207,7 @@ public class EntityEgg extends Entity {
|
||||
if (ak instanceof EntityPlayerMP) {
|
||||
CraftServer server = ((WorldServer) l).getServer();
|
||||
Type eventType = Type.PLAYER_EGG_THROW;
|
||||
Player player = (Player) ak.getBukkitEntity();
|
||||
Player player = (ak == null)?null:(Player) ak.getBukkitEntity();
|
||||
|
||||
PlayerEggThrowEvent event = new PlayerEggThrowEvent(eventType, player, hatching, numHatching, hatchingType);
|
||||
server.getPluginManager().callEvent(event);
|
||||
|
@ -13,11 +13,16 @@ public class EntityFallingSand extends Entity {
|
||||
public EntityFallingSand(World world) {
|
||||
super(world);
|
||||
b = 0;
|
||||
// CraftBukkit start
|
||||
CraftServer server = ((WorldServer) this.l).getServer();
|
||||
this.bukkitEntity = new CraftFallingSand(server, this);
|
||||
// CraftBukkit end
|
||||
}
|
||||
|
||||
public EntityFallingSand(World world, double d, double d1, double d2, int i) {
|
||||
super(world);
|
||||
b = 0;
|
||||
// CraftBukkit start
|
||||
this(world);
|
||||
// CraftBukkit end
|
||||
a = i;
|
||||
this.i = true;
|
||||
a(0.98F, 0.98F);
|
||||
@ -30,10 +35,6 @@ public class EntityFallingSand extends Entity {
|
||||
m = d;
|
||||
n = d1;
|
||||
o = d2;
|
||||
//CraftBukkit start
|
||||
CraftServer server = ((WorldServer) this.l).getServer();
|
||||
this.bukkitEntity = new CraftFallingSand(server, this);
|
||||
//CraftBukkit end
|
||||
}
|
||||
|
||||
protected void a() {}
|
||||
|
@ -17,12 +17,9 @@ public class EntityItem extends Entity {
|
||||
public float d;
|
||||
|
||||
public EntityItem(World world, double d1, double d2, double d3, ItemStack itemstack) {
|
||||
super(world);
|
||||
b = 0;
|
||||
f = 5;
|
||||
d = (float) (Math.random() * 3.1415926535897931D * 2D);
|
||||
a(0.25F, 0.25F);
|
||||
H = J / 2.0F;
|
||||
// CraftBukkit start
|
||||
this(world);
|
||||
// CraftBukkit end
|
||||
a(d1, d2, d3);
|
||||
a = itemstack;
|
||||
v = (float) (Math.random() * 360D);
|
||||
@ -30,10 +27,7 @@ public class EntityItem extends Entity {
|
||||
t = 0.20000000298023224D;
|
||||
u = (float) (Math.random() * 0.20000000298023224D - 0.10000000149011612D);
|
||||
M = false;
|
||||
//CraftBukkit start
|
||||
CraftServer server = ((WorldServer) this.l).getServer();
|
||||
this.bukkitEntity = new CraftItem(server, this);
|
||||
//CraftBukkit end
|
||||
|
||||
}
|
||||
|
||||
public EntityItem(World world) {
|
||||
@ -43,6 +37,10 @@ public class EntityItem extends Entity {
|
||||
d = (float) (Math.random() * 3.1415926535897931D * 2D);
|
||||
a(0.25F, 0.25F);
|
||||
H = J / 2.0F;
|
||||
// CraftBukkit start
|
||||
CraftServer server = ((WorldServer) this.l).getServer();
|
||||
this.bukkitEntity = new CraftItem(server, this);
|
||||
// CraftBukkit end
|
||||
}
|
||||
|
||||
protected void a() {}
|
||||
|
@ -6,10 +6,9 @@ import java.util.Random;
|
||||
// CraftBukkit start
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.entity.CraftLivingEntity;
|
||||
//CraftBukkit end
|
||||
import org.bukkit.event.entity.EntityDamageByBlockEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
// CraftBukkit end
|
||||
|
||||
public abstract class EntityLiving extends Entity {
|
||||
|
||||
|
@ -9,6 +9,7 @@ import org.bukkit.craftbukkit.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.entity.CraftPoweredMinecart;
|
||||
import org.bukkit.craftbukkit.entity.CraftStorageMinecart;
|
||||
import org.bukkit.craftbukkit.CraftMappable;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.entity.CraftMinecart;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
@ -172,7 +173,10 @@ public class EntityMinecart extends Entity implements IInventory, CraftMappable
|
||||
// CraftBukkit start
|
||||
private void handleCreation(World world) {
|
||||
CraftServer server = ((WorldServer) world).getServer();
|
||||
VehicleCreateEvent event = new VehicleCreateEvent(Type.VEHICLE_CREATE, (Vehicle) this.getBukkitEntity());
|
||||
Type eventType = Type.VEHICLE_CREATE;
|
||||
Vehicle vehicle = (Vehicle) this.getBukkitEntity();
|
||||
|
||||
VehicleCreateEvent event = new VehicleCreateEvent(eventType, vehicle);
|
||||
server.getPluginManager().callEvent(event);
|
||||
}
|
||||
// CraftBukkit end
|
||||
@ -183,11 +187,12 @@ public class EntityMinecart extends Entity implements IInventory, CraftMappable
|
||||
|
||||
public boolean a(Entity entity, int i) {
|
||||
// CraftBukkit start
|
||||
org.bukkit.entity.Entity passenger = null;
|
||||
if ((EntityLiving)entity != null) {
|
||||
passenger = entity.getBukkitEntity();
|
||||
}
|
||||
VehicleDamageEvent event = new VehicleDamageEvent(Type.VEHICLE_DAMAGE, (Vehicle) this.getBukkitEntity(), passenger, i);
|
||||
Type eventType = Type.VEHICLE_DAMAGE;
|
||||
Vehicle vehicle = (Vehicle) this.getBukkitEntity();
|
||||
org.bukkit.entity.Entity passenger = (entity == null)?null:entity.getBukkitEntity();
|
||||
int damage = i;
|
||||
|
||||
VehicleDamageEvent event = new VehicleDamageEvent(eventType, vehicle, passenger, damage);
|
||||
((WorldServer)l).getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
@ -510,7 +515,13 @@ public class EntityMinecart extends Entity implements IInventory, CraftMappable
|
||||
|
||||
// CraftBukkit start
|
||||
CraftServer server = ((WorldServer)this.l).getServer();
|
||||
VehicleMoveEvent event = new VehicleMoveEvent(Type.VEHICLE_MOVE, (Vehicle) this.getBukkitEntity(), new Location(((WorldServer)this.l).getWorld(), prevX, prevY, prevZ, prevYaw, prevPitch), new Location(((WorldServer)this.l).getWorld(), p, q, r, v, w));
|
||||
CraftWorld world = ((WorldServer)this.l).getWorld();
|
||||
Type eventType = Type.VEHICLE_MOVE;
|
||||
Vehicle vehicle = (Vehicle) this.getBukkitEntity();
|
||||
Location from = new Location(world, prevX, prevY, prevZ, prevYaw, prevPitch);
|
||||
Location to = new Location(world, p, q, r, v, w);
|
||||
|
||||
VehicleMoveEvent event = new VehicleMoveEvent(eventType , vehicle , from, to);
|
||||
server.getPluginManager().callEvent(event);
|
||||
// CraftBukkit end
|
||||
|
||||
@ -646,7 +657,11 @@ public class EntityMinecart extends Entity implements IInventory, CraftMappable
|
||||
|
||||
// CraftBukkit start
|
||||
CraftServer server = ((WorldServer)l).getServer();
|
||||
VehicleEntityCollisionEvent collsionEvent = new VehicleEntityCollisionEvent(Type.VEHICLE_COLLISION_ENTITY, (Vehicle) this.getBukkitEntity(), entity.getBukkitEntity());
|
||||
Type eventType = Type.VEHICLE_COLLISION_ENTITY;
|
||||
Vehicle vehicle = (Vehicle) this.getBukkitEntity();
|
||||
org.bukkit.entity.Entity hitEntity = (entity == null)?null:entity.getBukkitEntity();
|
||||
|
||||
VehicleEntityCollisionEvent collsionEvent = new VehicleEntityCollisionEvent(eventType, vehicle, hitEntity);
|
||||
server.getPluginManager().callEvent(collsionEvent);
|
||||
|
||||
if (collsionEvent.isCancelled()) {
|
||||
@ -655,7 +670,9 @@ public class EntityMinecart extends Entity implements IInventory, CraftMappable
|
||||
|
||||
if ((entity instanceof EntityLiving) && !(entity instanceof EntityPlayer) && d == 0 && s * s + u * u > 0.01D && j == null && entity.k == null) {
|
||||
if (!collsionEvent.isPickupCancelled()) {
|
||||
VehicleEnterEvent enterEvent = new VehicleEnterEvent(Type.VEHICLE_ENTER, (Vehicle) this.getBukkitEntity(), entity.getBukkitEntity());
|
||||
eventType = Type.VEHICLE_ENTER;
|
||||
|
||||
VehicleEnterEvent enterEvent = new VehicleEnterEvent(eventType, vehicle, hitEntity);
|
||||
server.getPluginManager().callEvent(enterEvent);
|
||||
|
||||
if (!enterEvent.isCancelled()) {
|
||||
@ -772,7 +789,11 @@ public class EntityMinecart extends Entity implements IInventory, CraftMappable
|
||||
if (!l.z) {
|
||||
// CraftBukkit start
|
||||
CraftServer server = ((WorldServer) l).getServer();
|
||||
VehicleEnterEvent event = new VehicleEnterEvent(Type.VEHICLE_ENTER, (Vehicle) this.getBukkitEntity(), entityplayer.getBukkitEntity());
|
||||
Type eventType = Type.VEHICLE_ENTER;
|
||||
Vehicle vehicle = (Vehicle) this.getBukkitEntity();
|
||||
org.bukkit.entity.Entity player = (entityplayer == null)?null:entityplayer.getBukkitEntity();
|
||||
|
||||
VehicleEnterEvent event = new VehicleEnterEvent(eventType, vehicle, player);
|
||||
server.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
|
@ -72,7 +72,7 @@ public class EntityMobs extends EntityCreature implements IMobs {
|
||||
if(entity instanceof EntityLiving) {
|
||||
CraftServer server = ((WorldServer) l).getServer();
|
||||
org.bukkit.entity.Entity damager = this.getBukkitEntity();
|
||||
org.bukkit.entity.Entity damagee = entity.getBukkitEntity();
|
||||
org.bukkit.entity.Entity damagee = (entity == null)?null:entity.getBukkitEntity();
|
||||
DamageCause damageType = EntityDamageEvent.DamageCause.ENTITY_ATTACK;
|
||||
int damageDone = c;
|
||||
|
||||
|
@ -343,7 +343,7 @@ public abstract class EntityPlayer extends EntityLiving {
|
||||
if(entity instanceof EntityLiving) {
|
||||
CraftServer server = ((WorldServer) l).getServer();
|
||||
org.bukkit.entity.Entity damager = this.getBukkitEntity();
|
||||
org.bukkit.entity.Entity damagee = entity.getBukkitEntity();
|
||||
org.bukkit.entity.Entity damagee = (entity == null)?null:entity.getBukkitEntity();
|
||||
DamageCause damageType = EntityDamageEvent.DamageCause.ENTITY_ATTACK;
|
||||
int damageDone = i;
|
||||
|
||||
|
@ -41,7 +41,9 @@ public class EntitySkeleton extends EntityMobs {
|
||||
if (f1 > 0.5F && l.i(MathHelper.b(p), MathHelper.b(q), MathHelper.b(r)) && W.nextFloat() * 30F < (f1 - 0.4F) * 2.0F) {
|
||||
// CraftBukkit start
|
||||
CraftServer server = ((WorldServer) l).getServer();
|
||||
EntityCombustEvent event = new EntityCombustEvent(Type.ENTITY_COMBUST, this.getBukkitEntity());
|
||||
Type eventType = Type.ENTITY_COMBUST;
|
||||
org.bukkit.entity.Entity entity = this.getBukkitEntity();
|
||||
EntityCombustEvent event = new EntityCombustEvent(eventType, entity);
|
||||
server.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
Z = 300;
|
||||
|
@ -8,8 +8,8 @@ import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.entity.CraftSnowball;
|
||||
import org.bukkit.event.entity.EntityDamageByProjectileEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
//CraftBukkit end
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
// CraftBukkit end
|
||||
|
||||
public class EntitySnowball extends Entity {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user