13
0
geforkt von Mirrors/Paper

Clean vehicle code.

Dieser Commit ist enthalten in:
Erik Broes 2011-02-01 23:52:36 +01:00
Ursprung 1dac92a766
Commit 001a45804e
4 geänderte Dateien mit 17 neuen und 85 gelöschten Zeilen

Datei anzeigen

@ -4,8 +4,6 @@ import java.util.List;
// CraftBukkit start
import org.bukkit.Location;
import org.bukkit.craftbukkit.entity.CraftBoat;
import org.bukkit.craftbukkit.entity.CraftEntity;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.entity.Vehicle;
@ -31,14 +29,6 @@ public class EntityBoat extends Entity {
private double am;
// CraftBukkit start
private void handleCreation(World world) {
CraftServer server = ((WorldServer) world).getServer();
Type eventType = Type.VEHICLE_CREATE;
Vehicle vehicle = (Vehicle) this.getBukkitEntity();
VehicleCreateEvent event = new VehicleCreateEvent(eventType, vehicle);
server.getPluginManager().callEvent(event);
}
public void c(Entity entity) {
CraftServer server = ((WorldServer) this.world).getServer();
Type eventType = Type.VEHICLE_COLLISION_ENTITY;
@ -91,7 +81,13 @@ public class EntityBoat extends Entity {
this.lastY = d1;
this.lastZ = d2;
handleCreation(world); // CraftBukkit
// CraftBukkit start
CraftServer server = ((WorldServer) world).getServer();
Type eventType = Type.VEHICLE_CREATE;
Vehicle vehicle = (Vehicle) this.getBukkitEntity();
VehicleCreateEvent event = new VehicleCreateEvent(eventType, vehicle);
server.getPluginManager().callEvent(event);
// CraftBukkit end
}
public double k() {

Datei anzeigen

@ -4,12 +4,7 @@ import java.util.List;
// CraftBukkit start
import org.bukkit.Location;
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;
import org.bukkit.event.Event.Type;
@ -50,26 +45,6 @@ public class EntityMinecart extends Entity implements IInventory {
public ItemStack[] getContents() {
return this.al;
}
private void handleCreation(World world) {
CraftServer server = ((WorldServer) world).getServer();
Type eventType = Type.VEHICLE_CREATE;
Vehicle vehicle = (Vehicle) this.getBukkitEntity();
VehicleCreateEvent event = new VehicleCreateEvent(eventType, vehicle);
server.getPluginManager().callEvent(event);
}
@Override
public org.bukkit.entity.Entity getBukkitEntity(){
if (this.d == CraftMinecart.Type.StorageMinecart.getId()) {
return this.bukkitStorageMinecart;
} else if (this.d == CraftMinecart.Type.PoweredMinecart.getId()) {
return this.bukkitPoweredMinecart;
} else {
return this.bukkitEntity;
}
}
// CraftBukkit end
public EntityMinecart(World world) {
@ -86,10 +61,11 @@ public class EntityMinecart extends Entity implements IInventory {
// CraftBukkit start
CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftMinecart(server, this);
this.bukkitPoweredMinecart = new CraftPoweredMinecart(server, this);
this.bukkitStorageMinecart = new CraftStorageMinecart(server, this);
handleCreation(world);
Type eventType = Type.VEHICLE_CREATE;
Vehicle vehicle = (Vehicle) this.getBukkitEntity();
VehicleCreateEvent event = new VehicleCreateEvent(eventType, vehicle);
server.getPluginManager().callEvent(event);
// CraftBukkit end
}

Datei anzeigen

@ -1,19 +0,0 @@
package org.bukkit.craftbukkit;
import org.bukkit.craftbukkit.entity.CraftEntity;
/**
* Indicates that an object has a method to get its CraftBukkit-equivalent
* CraftEntity object from its Minecraft net.minecraft.server.Entity object.
*
* @author sk89q
*/
/**@deprecated*/
public interface CraftMappable {
/**
* Gets the CraftEntity version.
*
* @return
*/
public CraftEntity getCraftEntity();
}

Datei anzeigen

@ -6,7 +6,7 @@ import org.bukkit.entity.Minecart;
/**
* A minecart.
*
*
* @author sk89q
*/
public class CraftMinecart extends CraftVehicle implements Minecart {
@ -18,18 +18,18 @@ public class CraftMinecart extends CraftVehicle implements Minecart {
Minecart(0),
StorageMinecart(1),
PoweredMinecart(2);
private final int id;
private Type(int id) {
this.id = id;
}
public int getId() {
return id;
}
}
protected EntityMinecart minecart;
public CraftMinecart(CraftServer server, EntityMinecart entity) {
@ -44,27 +44,6 @@ public class CraftMinecart extends CraftVehicle implements Minecart {
public int getDamage() {
return minecart.a;
}
/**
* Internal function to convert an MC entity to an appropriate CraftBukkit
* entity.
*
* @param server
* @param minecart
* @return
*
* @deprecated
*/
public static CraftMinecart getCraftMinecart(CraftServer server,
EntityMinecart minecart) {
if (minecart.d == Type.StorageMinecart.getId()) {
return new CraftStorageMinecart(server, minecart);
} else if (minecart.d == Type.PoweredMinecart.getId()) {
return new CraftPoweredMinecart(server, minecart);
} else {
return new CraftMinecart(server, minecart);
}
}
@Override
public String toString() {