001    package org.bukkit;
002    
003    import com.google.common.collect.Maps;
004    import java.util.Map;
005    
006    /**
007     * Represents various types of worlds that may exist
008     */
009    public enum WorldType {
010        NORMAL("DEFAULT"),
011        FLAT("FLAT"),
012        VERSION_1_1("DEFAULT_1_1"),
013        LARGE_BIOMES("LARGEBIOMES");
014    
015        private final static Map<String, WorldType> BY_NAME = Maps.newHashMap();
016        private final String name;
017    
018        private WorldType(String name) {
019            this.name = name;
020        }
021    
022        /**
023         * Gets the name of this WorldType
024         *
025         * @return Name of this type
026         */
027        public String getName() {
028            return name;
029        }
030    
031        /**
032         * Gets a Worldtype by its name
033         *
034         * @param name Name of the WorldType to get
035         * @return Requested WorldType, or null if not found
036         */
037        public static WorldType getByName(String name) {
038            return BY_NAME.get(name.toUpperCase());
039        }
040    
041        static {
042            for (WorldType type : values()) {
043                BY_NAME.put(type.name, type);
044            }
045        }
046    }