From 4a3c54648b2d7dc9128ff142efc403d7f26a0837 Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Thu, 17 Feb 2011 14:47:33 +1100 Subject: [PATCH] Updated to use CreatureType and CreatureSpawner Nothing will break as a result of the refactoring of MobType due to deprecated code being left in. These will be removed after 1 week, enough time for plugin devs time to migrate. By: Andrew Ardill --- .../bukkit/craftbukkit/block/CraftBlock.java | 2 +- ...Spawner.java => CraftCreatureSpawner.java} | 55 +++++++++++++++---- 2 files changed, 46 insertions(+), 11 deletions(-) rename paper-server/src/main/java/org/bukkit/craftbukkit/block/{CraftMobSpawner.java => CraftCreatureSpawner.java} (52%) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java index 55f8422fa2..f1ff00f302 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -278,7 +278,7 @@ public class CraftBlock implements Block { case DISPENSER: return new CraftDispenser(this); case MOB_SPAWNER: - return new CraftMobSpawner(this); + return new CraftCreatureSpawner(this); case NOTE_BLOCK: return new CraftNoteBlock(this); default: diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftMobSpawner.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java similarity index 52% rename from paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftMobSpawner.java rename to paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java index 9cc283ec87..660400d649 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftMobSpawner.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java @@ -2,41 +2,42 @@ package org.bukkit.craftbukkit.block; import net.minecraft.server.TileEntityMobSpawner; import org.bukkit.block.Block; +import org.bukkit.block.CreatureSpawner; import org.bukkit.block.MobSpawner; import org.bukkit.craftbukkit.CraftWorld; +import org.bukkit.entity.CreatureType; import org.bukkit.entity.MobType; -public class CraftMobSpawner extends CraftBlockState implements MobSpawner { +public class CraftCreatureSpawner extends CraftBlockState implements CreatureSpawner, MobSpawner { private final CraftWorld world; private final TileEntityMobSpawner spawner; - public CraftMobSpawner(final Block block) { + public CraftCreatureSpawner(final Block block) { super(block); world = (CraftWorld)block.getWorld(); spawner = (TileEntityMobSpawner)world.getTileEntityAt(getX(), getY(), getZ()); } - public MobType getMobType() { - return MobType.fromName(spawner.h); + public CreatureType getCreatureType() { + return CreatureType.fromName(spawner.h); } - public void setMobType(MobType mobType) { - spawner.h = mobType.getName(); + public void setCreatureType(CreatureType creatureType) { + spawner.h = creatureType.getName(); } - public String getMobTypeId() { + public String getCreatureTypeId() { return spawner.h; } - public void setMobTypeId(String mobType) { + public void setCreatureTypeId(String creatureType) { // Verify input - MobType type = MobType.fromName(mobType); + CreatureType type = CreatureType.fromName(creatureType); if (type == null) { return; } spawner.h = type.getName(); - } public int getDelay() { @@ -46,4 +47,38 @@ public class CraftMobSpawner extends CraftBlockState implements MobSpawner { public void setDelay(int delay) { spawner.e = delay; } + + /** + * @deprecated + */ + public MobType getMobType() { + return MobType.fromName(spawner.h); + } + + /** + * @deprecated + */ + public void setMobType(MobType mobType) { + spawner.h = mobType.getName(); + + } + + /** + * @deprecated + */ + public String getMobTypeId() { + return spawner.h; + } + + /** + * @deprecated + */ + public void setMobTypeId(String mobType) { + // Verify input + MobType type = MobType.fromName(mobType); + if (type == null) { + return; + } + spawner.h = type.getName(); + } }