Represents various map environment types that a world may be
| 4636 | * Represents various map environment types that a world may be |
| 4637 | */ |
| 4638 | public enum Environment { |
| 4639 | |
| 4640 | /** |
| 4641 | * Represents the "normal"/"surface world" map |
| 4642 | */ |
| 4643 | NORMAL(0), |
| 4644 | /** |
| 4645 | * Represents a nether based map ("hell") |
| 4646 | */ |
| 4647 | NETHER(-1), |
| 4648 | /** |
| 4649 | * Represents the "end" map |
| 4650 | */ |
| 4651 | THE_END(1), |
| 4652 | /** |
| 4653 | * Represents a custom dimension |
| 4654 | */ |
| 4655 | CUSTOM(-999); |
| 4656 | |
| 4657 | private final int id; |
| 4658 | private static final Map<Integer, Environment> lookup = new HashMap<Integer, Environment>(); |
| 4659 | |
| 4660 | private Environment(int id) { |
| 4661 | this.id = id; |
| 4662 | } |
| 4663 | |
| 4664 | /** |
| 4665 | * Gets the dimension ID of this environment |
| 4666 | * |
| 4667 | * @return dimension ID |
| 4668 | * @apiNote Internal Use Only |
| 4669 | */ |
| 4670 | @org.jetbrains.annotations.ApiStatus.Internal // Paper |
| 4671 | public int getId() { |
| 4672 | return id; |
| 4673 | } |
| 4674 | |
| 4675 | /** |
| 4676 | * Get an environment by ID |
| 4677 | * |
| 4678 | * @param id The ID of the environment |
| 4679 | * @return The environment |
| 4680 | * @apiNote Internal Use Only |
| 4681 | */ |
| 4682 | @org.jetbrains.annotations.ApiStatus.Internal // Paper |
| 4683 | @Nullable |
| 4684 | public static Environment getEnvironment(int id) { |
| 4685 | return lookup.get(id); |
| 4686 | } |
| 4687 | |
| 4688 | static { |
| 4689 | for (Environment env : values()) { |
| 4690 | lookup.put(env.getId(), env); |
| 4691 | } |
| 4692 | } |
| 4693 | } |
| 4694 | } |