diff options
author | Wesley Wolfe <weswolf@aol.com> | 2013-03-15 23:09:04 -0500 |
---|---|---|
committer | Wesley Wolfe <weswolf@aol.com> | 2013-03-16 02:15:51 -0500 |
commit | 2cb9cbf05cc7cefdf646f0d2b4bc4c2d94afd28d (patch) | |
tree | f36fcdacb9c8064026dd7c07caec440497d4d60c /src | |
parent | b2c72b968e708012ad9770ab5d8919948a267470 (diff) | |
download | craftbukkit-2cb9cbf05cc7cefdf646f0d2b4bc4c2d94afd28d.tar craftbukkit-2cb9cbf05cc7cefdf646f0d2b4bc4c2d94afd28d.tar.gz craftbukkit-2cb9cbf05cc7cefdf646f0d2b4bc4c2d94afd28d.tar.lz craftbukkit-2cb9cbf05cc7cefdf646f0d2b4bc4c2d94afd28d.tar.xz craftbukkit-2cb9cbf05cc7cefdf646f0d2b4bc4c2d94afd28d.zip |
Handle the newly refactored minecarts.
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/CraftWorld.java | 65 | ||||
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java | 8 | ||||
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java | 13 | ||||
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartChest.java (renamed from src/main/java/org/bukkit/craftbukkit/entity/CraftStorageMinecart.java) | 7 | ||||
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartFurnace.java (renamed from src/main/java/org/bukkit/craftbukkit/entity/CraftPoweredMinecart.java) | 9 | ||||
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartHopper.java | 10 | ||||
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartMobSpawner.java | 10 | ||||
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartRideable.java | 22 | ||||
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartTNT.java | 15 |
9 files changed, 99 insertions, 60 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 9218f074..adb2bba3 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -1,52 +1,54 @@ package org.bukkit.craftbukkit; import java.io.File; -import java.util.Iterator; -import java.util.Set; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; +import java.util.Iterator; import java.util.List; import java.util.Random; +import java.util.Set; import java.util.UUID; -import org.apache.commons.lang.Validate; - -import org.bukkit.craftbukkit.entity.*; -import org.bukkit.craftbukkit.metadata.BlockMetadataStore; -import org.bukkit.entity.*; -import org.bukkit.entity.Entity; import net.minecraft.server.*; -import org.bukkit.entity.Arrow; -import org.bukkit.Effect; -import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; -import org.bukkit.event.weather.WeatherChangeEvent; -import org.bukkit.event.weather.ThunderChangeEvent; -import org.bukkit.event.world.SpawnChangeEvent; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.entity.Boat; -import org.bukkit.Chunk; -import org.bukkit.inventory.ItemStack; -import org.bukkit.metadata.MetadataValue; -import org.bukkit.plugin.Plugin; -import org.bukkit.util.Vector; +import org.apache.commons.lang.Validate; import org.bukkit.BlockChangeDelegate; import org.bukkit.Bukkit; -import org.bukkit.generator.ChunkGenerator; +import org.bukkit.Chunk; import org.bukkit.ChunkSnapshot; +import org.bukkit.Difficulty; +import org.bukkit.Effect; import org.bukkit.Location; +import org.bukkit.Sound; import org.bukkit.TreeType; import org.bukkit.World; import org.bukkit.block.Biome; -import org.bukkit.generator.BlockPopulator; -import org.bukkit.Difficulty; -import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; import org.bukkit.craftbukkit.block.CraftBlock; +import org.bukkit.craftbukkit.entity.*; import org.bukkit.craftbukkit.inventory.CraftItemStack; -import org.bukkit.plugin.messaging.StandardMessenger; +import org.bukkit.craftbukkit.metadata.BlockMetadataStore; import org.bukkit.craftbukkit.util.LongHash; +import org.bukkit.entity.*; +import org.bukkit.entity.Entity; +import org.bukkit.entity.minecart.ExplosiveMinecart; +import org.bukkit.entity.minecart.HopperMinecart; +import org.bukkit.entity.minecart.PoweredMinecart; +import org.bukkit.entity.minecart.SpawnerMinecart; +import org.bukkit.entity.minecart.StorageMinecart; +import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; +import org.bukkit.event.weather.ThunderChangeEvent; +import org.bukkit.event.weather.WeatherChangeEvent; +import org.bukkit.event.world.SpawnChangeEvent; +import org.bukkit.generator.BlockPopulator; +import org.bukkit.generator.ChunkGenerator; +import org.bukkit.inventory.ItemStack; +import org.bukkit.metadata.MetadataValue; +import org.bukkit.plugin.Plugin; +import org.bukkit.plugin.messaging.StandardMessenger; +import org.bukkit.util.Vector; public class CraftWorld implements World { public static final int CUSTOM_DIMENSION_OFFSET = 10; @@ -252,7 +254,6 @@ public class CraftWorld implements World { return chunk != null; } - @SuppressWarnings("unchecked") private void chunkLoadPostProcess(net.minecraft.server.Chunk chunk, int x, int z) { if (chunk != null) { world.chunkProviderServer.chunks.put(LongHash.toLong(x, z), chunk); @@ -864,13 +865,13 @@ public class CraftWorld implements World { entity = new EntityMinecartFurnace(world, x, y, z); } else if (StorageMinecart.class.isAssignableFrom(clazz)) { entity = new EntityMinecartChest(world, x, y, z); - } else if (MinecartTNT.class.isAssignableFrom(clazz)) { + } else if (ExplosiveMinecart.class.isAssignableFrom(clazz)) { entity = new EntityMinecartTNT(world, x, y, z); - } else if (MinecartHopper.class.isAssignableFrom(clazz)) { + } else if (HopperMinecart.class.isAssignableFrom(clazz)) { entity = new EntityMinecartHopper(world, x, y, z); - } else if (MinecartMobSpawner.class.isAssignableFrom(clazz)) { + } else if (SpawnerMinecart.class.isAssignableFrom(clazz)) { entity = new EntityMinecartMobSpawner(world, x, y, z); - } else { + } else { // Default to rideable minecart for pre-rideable compatibility entity = new EntityMinecartRideable(world, x, y, z); } } else if (EnderSignal.class.isAssignableFrom(clazz)) { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java index f88092e1..0edf2d95 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -137,12 +137,12 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { else { return new CraftWeather(server, (EntityWeather) entity); } } else if (entity instanceof EntityMinecartAbstract) { - if (entity instanceof EntityMinecartFurnace) { return new CraftPoweredMinecart(server, (EntityMinecartFurnace) entity); } - else if (entity instanceof EntityMinecartChest) { return new CraftStorageMinecart(server, (EntityMinecartChest) entity); } + if (entity instanceof EntityMinecartFurnace) { return new CraftMinecartFurnace(server, (EntityMinecartFurnace) entity); } + else if (entity instanceof EntityMinecartChest) { return new CraftMinecartChest(server, (EntityMinecartChest) entity); } else if (entity instanceof EntityMinecartTNT) { return new CraftMinecartTNT(server, (EntityMinecartTNT) entity); } else if (entity instanceof EntityMinecartHopper) { return new CraftMinecartHopper(server, (EntityMinecartHopper) entity); } else if (entity instanceof EntityMinecartMobSpawner) { return new CraftMinecartMobSpawner(server, (EntityMinecartMobSpawner) entity); } - else { return new CraftMinecart(server, (EntityMinecartRideable) entity); } + else if (entity instanceof EntityMinecartRideable) { return new CraftMinecartRideable(server, (EntityMinecartRideable) entity); } } else if (entity instanceof EntityHanging) { if (entity instanceof EntityPainting) { return new CraftPainting(server, (EntityPainting) entity); } else if (entity instanceof EntityItemFrame) { return new CraftItemFrame(server, (EntityItemFrame) entity); } @@ -151,7 +151,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { else if (entity instanceof EntityTNTPrimed) { return new CraftTNTPrimed(server, (EntityTNTPrimed) entity); } else if (entity instanceof EntityFireworks) { return new CraftFirework(server, (EntityFireworks) entity); } - throw new IllegalArgumentException("Unknown entity"); + throw new AssertionError("Unknown entity " + entity == null ? null : entity.getClass()); } public Location getLocation() { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java index 73e807e1..acbad192 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java @@ -1,12 +1,12 @@ package org.bukkit.craftbukkit.entity; import net.minecraft.server.EntityMinecartAbstract; + import org.bukkit.craftbukkit.CraftServer; -import org.bukkit.entity.EntityType; import org.bukkit.entity.Minecart; import org.bukkit.util.Vector; -public class CraftMinecart extends CraftVehicle implements Minecart { +public abstract class CraftMinecart extends CraftVehicle implements Minecart { public CraftMinecart(CraftServer server, EntityMinecartAbstract entity) { super(server, entity); } @@ -57,13 +57,4 @@ public class CraftMinecart extends CraftVehicle implements Minecart { public EntityMinecartAbstract getHandle() { return (EntityMinecartAbstract) entity; } - - @Override - public String toString() { - return "CraftMinecart"; - } - - public EntityType getType() { - return EntityType.MINECART; - } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftStorageMinecart.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartChest.java index ef86e413..f5a18757 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftStorageMinecart.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartChest.java @@ -8,10 +8,11 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.StorageMinecart; import org.bukkit.inventory.Inventory; -public class CraftStorageMinecart extends CraftMinecart implements StorageMinecart { +@SuppressWarnings("deprecation") +public class CraftMinecartChest extends CraftMinecart implements StorageMinecart { private final CraftInventory inventory; - public CraftStorageMinecart(CraftServer server, EntityMinecartChest entity) { + public CraftMinecartChest(CraftServer server, EntityMinecartChest entity) { super(server, entity); inventory = new CraftInventory(entity); } @@ -22,7 +23,7 @@ public class CraftStorageMinecart extends CraftMinecart implements StorageMineca @Override public String toString() { - return "CraftStorageMinecart{" + "inventory=" + inventory + '}'; + return "CraftMinecartChest{" + "inventory=" + inventory + '}'; } public EntityType getType() { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPoweredMinecart.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartFurnace.java index a07829e2..463b4cee 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPoweredMinecart.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartFurnace.java @@ -1,19 +1,20 @@ package org.bukkit.craftbukkit.entity; -import org.bukkit.craftbukkit.entity.CraftMinecart; import net.minecraft.server.EntityMinecartFurnace; + import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.EntityType; import org.bukkit.entity.PoweredMinecart; -public class CraftPoweredMinecart extends CraftMinecart implements PoweredMinecart { - public CraftPoweredMinecart(CraftServer server, EntityMinecartFurnace entity) { +@SuppressWarnings("deprecation") +public class CraftMinecartFurnace extends CraftMinecart implements PoweredMinecart { + public CraftMinecartFurnace(CraftServer server, EntityMinecartFurnace entity) { super(server, entity); } @Override public String toString() { - return "CraftPoweredMinecart"; + return "CraftMinecartFurnace"; } public EntityType getType() { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartHopper.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartHopper.java index 67fcbb47..e34d082d 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartHopper.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartHopper.java @@ -1,15 +1,21 @@ package org.bukkit.craftbukkit.entity; import net.minecraft.server.EntityMinecartHopper; + import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.EntityType; -import org.bukkit.entity.MinecartHopper; +import org.bukkit.entity.minecart.HopperMinecart; -final class CraftMinecartHopper extends CraftMinecart implements MinecartHopper { +final class CraftMinecartHopper extends CraftMinecart implements HopperMinecart { CraftMinecartHopper(CraftServer server, EntityMinecartHopper entity) { super(server, entity); } + @Override + public String toString() { + return "CraftMinecartHopper"; + } + public EntityType getType() { return EntityType.MINECART_HOPPER; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartMobSpawner.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartMobSpawner.java index 83be050b..a78d8169 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartMobSpawner.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartMobSpawner.java @@ -1,15 +1,21 @@ package org.bukkit.craftbukkit.entity; import net.minecraft.server.EntityMinecartMobSpawner; + import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.EntityType; -import org.bukkit.entity.MinecartMobSpawner; +import org.bukkit.entity.minecart.SpawnerMinecart; -final class CraftMinecartMobSpawner extends CraftMinecart implements MinecartMobSpawner { +final class CraftMinecartMobSpawner extends CraftMinecart implements SpawnerMinecart { CraftMinecartMobSpawner(CraftServer server, EntityMinecartMobSpawner entity) { super(server, entity); } + @Override + public String toString() { + return "CraftMinecartMobSpawner"; + } + public EntityType getType() { return EntityType.MINECART_MOB_SPAWNER; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartRideable.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartRideable.java new file mode 100644 index 00000000..9305d884 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartRideable.java @@ -0,0 +1,22 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.server.EntityMinecartAbstract; + +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.minecart.RideableMinecart; + +public class CraftMinecartRideable extends CraftMinecart implements RideableMinecart { + public CraftMinecartRideable(CraftServer server, EntityMinecartAbstract entity) { + super(server, entity); + } + + @Override + public String toString() { + return "CraftMinecartRideable"; + } + + public EntityType getType() { + return EntityType.MINECART; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartTNT.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartTNT.java index 861b01fe..0c8109bb 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartTNT.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartTNT.java @@ -1,11 +1,22 @@ package org.bukkit.craftbukkit.entity; import net.minecraft.server.EntityMinecartTNT; + import org.bukkit.craftbukkit.CraftServer; -import org.bukkit.entity.MinecartTNT; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.minecart.ExplosiveMinecart; -final class CraftMinecartTNT extends CraftMinecart implements MinecartTNT { +final class CraftMinecartTNT extends CraftMinecart implements ExplosiveMinecart { CraftMinecartTNT(CraftServer server, EntityMinecartTNT entity) { super(server, entity); } + + @Override + public String toString() { + return "CraftMinecartTNT"; + } + + public EntityType getType() { + return EntityType.MINECART_TNT; + } } |