aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/moe/ymc/acron/common/WorldKey.java
blob: fa10d547a09c935b9689d99ab7daaa60788e0e90 (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
package moe.ymc.acron.common;

import com.google.gson.annotations.SerializedName;
import net.minecraft.util.Identifier;
import net.minecraft.world.dimension.DimensionType;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public enum WorldKey {
    @SerializedName("overworld")
    OVERWORLD,
    @SerializedName("nether")
    NETHER,
    @SerializedName("end")
    END;

    private static final Logger LOGGER = LogManager.getLogger();

    public static @Nullable WorldKey create(@NotNull Identifier identifier) {
        if (identifier.equals(DimensionType.OVERWORLD_ID)) {
            return OVERWORLD;
        } else if (identifier.equals(DimensionType.THE_NETHER_ID)) {
            return NETHER;
        } else if (identifier.equals(DimensionType.THE_END_ID)) {
            return END;
        } else {
            LOGGER.warn("Unknown world {}:{}. Returning NULL to the client.",
                    identifier.getNamespace(),
                    identifier.getPath());
            return null;
        }
    }
}