summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/bukkit/WorldType.java
blob: 36ad85ef13d56b36448b2cdd517783354ac5b16c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package org.bukkit;

import java.util.HashMap;
import java.util.Map;

/**
 * Represents various types of worlds that may exist
 */
public enum WorldType {
    NORMAL("DEFAULT"),
    FLAT("FLAT");

    private final static Map<String, WorldType> lookup = new HashMap<String, WorldType>();
    private final String name;

    static {
        for (WorldType type : values()) {
            lookup.put(type.name, type);
        }
    }

    private WorldType(String name) {
        this.name = name;
    }

    /**
     * Gets the name of this WorldType
     *
     * @return Name of this type
     */
    public String getName() {
        return name;
    }

    /**
     * Gets a Worldtype by its name
     *
     * @param name Name of the WorldType to get
     * @return Requested WorldType, or null if not found
     */
    public static WorldType getByName(String name) {
        return lookup.get(name.toUpperCase());
    }
}