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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
package de.hysky.skyblocker.utils;
import com.mojang.serialization.Codec;
import net.minecraft.util.StringIdentifiable;
import org.apache.commons.text.WordUtils;
import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
import java.util.EnumSet;
/**
* All Skyblock locations
*/
public enum Location implements StringIdentifiable {
PRIVATE_ISLAND("dynamic"),
GARDEN("garden"),
HUB("hub"),
THE_FARMING_ISLAND("farming_1"),
THE_PARK("foraging_1"),
SPIDERS_DEN("combat_1", "Spider's Den"),
BLAZING_FORTRESS("combat_2"),
THE_END("combat_3"),
CRIMSON_ISLE("crimson_isle"),
GOLD_MINE("mining_1"),
DEEP_CAVERNS("mining_2"),
DWARVEN_MINES("mining_3"),
BACKWATER_BAYOU("fishing_1"),
DUNGEON_HUB("dungeon_hub"),
WINTER_ISLAND("winter", "Jerry's Workshop"),
THE_RIFT("rift"),
DARK_AUCTION("dark_auction"),
CRYSTAL_HOLLOWS("crystal_hollows"),
DUNGEON("dungeon", "Dungeons"),
KUUDRAS_HOLLOW("kuudra", "Kuudra's Hollow"),
/**
* The freezing cold Glacite Mineshafts! *brr... so cold... :(*
*/
GLACITE_MINESHAFT("mineshaft"),
/**
* <p>Goodbye 1.8 hello 1.21 (and foraging 50 for all)!</p>
*/
GALATEA("foraging_2"),
/**
* Unknown Skyblock location
*/
UNKNOWN("unknown");
public static final Codec<Location> CODEC = StringIdentifiable.createCodec(Location::values);
public static final Codec<EnumSet<Location>> SET_CODEC = CodecUtils.enumSetCodec(CODEC, Location.class);
/**
* location id from <a href="https://api.hypixel.net/v2/resources/games">Hypixel API</a>
*/
@NotNull
private final String id;
/**
* friendly name from <a href="https://api.hypixel.net/v2/resources/games">Hypixel API</a>
*/
@NotNull
private final String friendlyName;
/**
* @param id location id from <a href="https://api.hypixel.net/v2/resources/games">Hypixel API</a>
* @param friendlyName friendly name from <a href="https://api.hypixel.net/v2/resources/games">Hypixel API</a>
*/
Location(@NotNull String id, @NotNull String friendlyName) {
this.id = id;
this.friendlyName = friendlyName;
}
/**
* Alternative constructor to avoid replicating simple friendlyNames that can be obtained with manipulating the enum's name.
*
* @param id location id from <a href="https://api.hypixel.net/v2/resources/games">Hypixel API</a>
*/
Location(@NotNull String id) {
this.id = id;
this.friendlyName = WordUtils.capitalizeFully(name().replace('_', ' '));
}
/**
* @return location id
*/
@NotNull
public String id() {
return this.id;
}
@Override
public String asString() {
return id();
}
/**
* @param id location id from <a href="https://api.hypixel.net/v2/resources/games">Hypixel API</a>
* @return The {@link Location} with this id, or {@link #UNKNOWN} if not found
*/
@NotNull
public static Location from(String id) {
return Arrays.stream(Location.values())
.filter(loc -> loc.id.equals(id))
.findFirst()
.orElse(UNKNOWN);
}
/**
* @param friendlyName friendly name from <a href="https://api.hypixel.net/v2/resources/games">Hypixel API</a>
* @return The {@link Location} with this friendly name or {@link #UNKNOWN} if not found
*/
@NotNull
public static Location fromFriendlyName(String friendlyName) {
return Arrays.stream(Location.values())
.filter(loc -> loc.friendlyName.equals(friendlyName))
.findFirst()
.orElse(UNKNOWN);
}
@Override
public String toString() {
return friendlyName;
}
}
|