001 package org.bukkit;
002
003 import java.util.HashMap;
004
005 import org.apache.commons.lang.Validate;
006
007 import com.google.common.collect.Maps;
008
009 /**
010 * Represents the art on a painting
011 */
012 public enum Art {
013 KEBAB(0, 1, 1),
014 AZTEC(1, 1, 1),
015 ALBAN(2, 1, 1),
016 AZTEC2(3, 1, 1),
017 BOMB(4, 1, 1),
018 PLANT(5, 1, 1),
019 WASTELAND(6, 1, 1),
020 POOL(7, 2, 1),
021 COURBET(8, 2, 1),
022 SEA(9, 2, 1),
023 SUNSET(10, 2, 1),
024 CREEBET(11, 2, 1),
025 WANDERER(12, 1, 2),
026 GRAHAM(13, 1, 2),
027 MATCH(14, 2, 2),
028 BUST(15, 2, 2),
029 STAGE(16, 2, 2),
030 VOID(17, 2, 2),
031 SKULL_AND_ROSES(18, 2, 2),
032 WITHER(19, 2, 2),
033 FIGHTERS(20, 4, 2),
034 POINTER(21, 4, 4),
035 PIGSCENE(22, 4, 4),
036 BURNINGSKULL(23, 4, 4),
037 SKELETON(24, 4, 3),
038 DONKEYKONG(25, 4, 3);
039
040 private int id, width, height;
041 private static final HashMap<String, Art> BY_NAME = Maps.newHashMap();
042 private static final HashMap<Integer, Art> BY_ID = Maps.newHashMap();
043
044 private Art(int id, int width, int height) {
045 this.id = id;
046 this.width = width;
047 this.height = height;
048 }
049
050 /**
051 * Gets the width of the painting, in blocks
052 *
053 * @return The width of the painting, in blocks
054 */
055 public int getBlockWidth() {
056 return width;
057 }
058
059 /**
060 * Gets the height of the painting, in blocks
061 *
062 * @return The height of the painting, in blocks
063 */
064 public int getBlockHeight() {
065 return height;
066 }
067
068 /**
069 * Get the ID of this painting.
070 *
071 * @return The ID of this painting
072 * @deprecated Magic value
073 */
074 @Deprecated
075 public int getId() {
076 return id;
077 }
078
079 /**
080 * Get a painting by its numeric ID
081 *
082 * @param id The ID
083 * @return The painting
084 * @deprecated Magic value
085 */
086 @Deprecated
087 public static Art getById(int id) {
088 return BY_ID.get(id);
089 }
090
091 /**
092 * Get a painting by its unique name
093 * <p>
094 * This ignores underscores and capitalization
095 *
096 * @param name The name
097 * @return The painting
098 */
099 public static Art getByName(String name) {
100 Validate.notNull(name, "Name cannot be null");
101
102 return BY_NAME.get(name.toLowerCase().replaceAll("_", ""));
103 }
104
105 static {
106 for (Art art : values()) {
107 BY_ID.put(art.id, art);
108 BY_NAME.put(art.toString().toLowerCase().replaceAll("_", ""), art);
109 }
110 }
111 }