diff options
author | Tahg <tahgtahv@gmail.com> | 2011-10-12 14:12:53 -0400 |
---|---|---|
committer | Tahg <tahgtahv@gmail.com> | 2011-10-12 14:13:11 -0400 |
commit | 8c02599256e39bcd1b177af6a1759680a870cedd (patch) | |
tree | 2df297e3e06f6e883cd717fd9b75d2437dbc58e1 /src | |
parent | 7d153a9f5856e5ad9ac7ba734a166529c9aad4b6 (diff) | |
download | craftbukkit-8c02599256e39bcd1b177af6a1759680a870cedd.tar craftbukkit-8c02599256e39bcd1b177af6a1759680a870cedd.tar.gz craftbukkit-8c02599256e39bcd1b177af6a1759680a870cedd.tar.lz craftbukkit-8c02599256e39bcd1b177af6a1759680a870cedd.tar.xz craftbukkit-8c02599256e39bcd1b177af6a1759680a870cedd.zip |
fixed mapping of Art <-> EnumArt in Paintings
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/CraftArt.java | 74 | ||||
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java | 6 |
2 files changed, 77 insertions, 3 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftArt.java b/src/main/java/org/bukkit/craftbukkit/CraftArt.java new file mode 100644 index 00000000..7773a55a --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/CraftArt.java @@ -0,0 +1,74 @@ +package org.bukkit.craftbukkit; + +import net.minecraft.server.EnumArt; +import org.bukkit.Art; + +// Safety class, will break if either side changes +public class CraftArt { + public static Art NotchToBukkit(EnumArt art) { + switch (art) { + case KEBAB: return Art.KEBAB; + case AZTEC: return Art.AZTEC; + case ALBAN: return Art.ALBAN; + case AZTEC2: return Art.AZTEC2; + case BOMB: return Art.BOMB; + case PLANT: return Art.PLANT; + case WASTELAND: return Art.WASTELAND; + case POOL: return Art.POOL; + case COURBET: return Art.COURBET; + case SEA: return Art.SEA; + case SUNSET: return Art.SUNSET; + case CREEBET: return Art.CREEBET; + case WANDERER: return Art.WANDERER; + case GRAHAM: return Art.GRAHAM; + case MATCH: return Art.MATCH; + case BUST: return Art.BUST; + case STAGE: return Art.STAGE; + case VOID: return Art.VOID; + case SKULL_AND_ROSES: return Art.SKULL_AND_ROSES; + case FIGHTERS: return Art.FIGHTERS; + case POINTER: return Art.POINTER; + case PIGSCENE: return Art.PIGSCENE; + case BURNINGSKULL: return Art.BURNINGSKULL; + case SKELETON: return Art.SKELETON; + case DONKEYKONG: return Art.DONKEYKONG; + } + return null; + } + + public static EnumArt BukkitToNotch(Art art) { + switch (art) { + case KEBAB: return EnumArt.KEBAB; + case AZTEC: return EnumArt.AZTEC; + case ALBAN: return EnumArt.ALBAN; + case AZTEC2: return EnumArt.AZTEC2; + case BOMB: return EnumArt.BOMB; + case PLANT: return EnumArt.PLANT; + case WASTELAND: return EnumArt.WASTELAND; + case POOL: return EnumArt.POOL; + case COURBET: return EnumArt.COURBET; + case SEA: return EnumArt.SEA; + case SUNSET: return EnumArt.SUNSET; + case CREEBET: return EnumArt.CREEBET; + case WANDERER: return EnumArt.WANDERER; + case GRAHAM: return EnumArt.GRAHAM; + case MATCH: return EnumArt.MATCH; + case BUST: return EnumArt.BUST; + case STAGE: return EnumArt.STAGE; + case VOID: return EnumArt.VOID; + case SKULL_AND_ROSES: return EnumArt.SKULL_AND_ROSES; + case FIGHTERS: return EnumArt.FIGHTERS; + case POINTER: return EnumArt.POINTER; + case PIGSCENE: return EnumArt.PIGSCENE; + case BURNINGSKULL: return EnumArt.BURNINGSKULL; + case SKELETON: return EnumArt.SKELETON; + case DONKEYKONG: return EnumArt.DONKEYKONG; + } + return null; + } + + { + assert (EnumArt.values().length == 25); + assert (Art.values().length == 25); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java index 69647d7b..763a284f 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java @@ -9,6 +9,7 @@ import net.minecraft.server.WorldServer; import org.bukkit.Art; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.craftbukkit.CraftArt; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.entity.Painting; @@ -31,8 +32,7 @@ public class CraftPainting extends CraftEntity implements Painting { public Art getArt() { EnumArt art = getHandle().e; - // Since both EnumArt and Art have exactly the same enum constants, this works - return Art.getByName(art.toString()); + return CraftArt.NotchToBukkit(art); } public boolean setArt(Art art) { @@ -42,7 +42,7 @@ public class CraftPainting extends CraftEntity implements Painting { public boolean setArt(Art art, boolean force) { EntityPainting painting = getHandle(); EnumArt oldArt = painting.e; - EnumArt newArt = EnumArt.valueOf(art.toString()); + EnumArt newArt = CraftArt.BukkitToNotch(art); painting.e = newArt; painting.b(painting.a); if(!force && !painting.i()) { |