Skip to content

Commit 1a6b1bb

Browse files
committed
2 parents 81fd805 + daacb62 commit 1a6b1bb

237 files changed

Lines changed: 29508 additions & 144 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Hypixel SkyBlock
22

3-
[<img src="https://discordapp.com/assets/e4923594e694a21542a489471ecffa50.svg" alt="Discord" height="55" />](https://discord.gg/ZaGW5wzUJ3)
3+
[<img src="https://discordapp.com/assets/e4923594e694a21542a489471ecffa50.svg" alt="Discord" height="55" />](https://discord.swofty.net)
44

55
A 1.21.11 Minestom-based recreation of Hypixel SkyBlock with a properly abstracted, scalable microservices architecture.
66

@@ -22,7 +22,7 @@ Full documentation is available at **[opensource.swofty.net](https://opensource.
2222

2323
- [Releases](https://github.com/Swofty-Developments/HypixelSkyBlock/releases)
2424
- [Javadocs](https://swofty-developments.github.io/HypixelSkyBlock/)
25-
- [Discord](https://discord.gg/ZaGW5wzUJ3)
25+
- [Discord](https://discord.swofty.net)
2626
- [Video Guide](https://www.youtube.com/watch?v=pxzJbjjQL-M)
2727

2828
## Features

commons/src/main/java/net/swofty/commons/CustomWorlds.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public enum CustomWorlds {
1717
PROTOTYPE_LOBBY("hypixel_prototype_lobby"),
1818
BEDWARS_LOBBY("hypixel_bedwars_lobby"),
1919
MURDER_MYSTERY_LOBBY("hypixel_murder_mystery_lobby"),
20+
SKYWARS_LOBBY("hypixel_skywars_lobby"),
2021
;
2122

2223
private final String folderName;

commons/src/main/java/net/swofty/commons/ServerType.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ public enum ServerType {
2424
BEDWARS_CONFIGURATOR(false),
2525
MURDER_MYSTERY_LOBBY(false),
2626
MURDER_MYSTERY_GAME(false),
27-
MURDER_MYSTERY_CONFIGURATOR(false)
27+
MURDER_MYSTERY_CONFIGURATOR(false),
28+
SKYWARS_LOBBY(false),
29+
SKYWARS_GAME(false),
30+
SKYWARS_CONFIGURATOR(false)
2831
;
2932

3033
private final boolean isSkyBlock;
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
package net.swofty.commons.skywars;
2+
3+
import lombok.Getter;
4+
import org.jetbrains.annotations.Nullable;
5+
6+
@Getter
7+
public enum SkywarsGameType {
8+
SOLO_NORMAL(0, "Solo Normal", 1, 12, false),
9+
SOLO_INSANE(1, "Solo Insane", 1, 12, true),
10+
DOUBLES_NORMAL(2, "Doubles", 2, 12, false),
11+
SOLO_LUCKY_BLOCK(3, "Lucky Block", 1, 12, false),
12+
;
13+
14+
private final int id;
15+
private final String displayName;
16+
private final int teamSize;
17+
private final int maxTeams;
18+
private final boolean insane;
19+
20+
SkywarsGameType(int id, String displayName, int teamSize, int maxTeams, boolean insane) {
21+
this.id = id;
22+
this.displayName = displayName;
23+
this.teamSize = teamSize;
24+
this.maxTeams = maxTeams;
25+
this.insane = insane;
26+
}
27+
28+
public int maxPlayers() {
29+
return teamSize * maxTeams;
30+
}
31+
32+
public int getMaxPlayers() {
33+
return maxPlayers();
34+
}
35+
36+
public int getMinPlayers() {
37+
// Minimum is 2 players for solo, or 2 teams for team modes
38+
return teamSize == 1 ? 2 : teamSize * 2;
39+
}
40+
41+
public boolean isSolo() {
42+
return teamSize == 1;
43+
}
44+
45+
/**
46+
* Returns the mode string for this game type.
47+
* @return "INSANE" for insane modes, "NORMAL" otherwise
48+
*/
49+
public String getModeString() {
50+
return insane ? "INSANE" : "NORMAL";
51+
}
52+
53+
@Nullable
54+
public static SkywarsGameType from(String field) {
55+
for (SkywarsGameType type : values()) {
56+
if (type.name().equalsIgnoreCase(field)) {
57+
return type;
58+
}
59+
}
60+
return null;
61+
}
62+
63+
@Nullable
64+
public static SkywarsGameType fromDisplayName(String displayName) {
65+
for (SkywarsGameType type : values()) {
66+
if (type.displayName.equalsIgnoreCase(displayName)) {
67+
return type;
68+
}
69+
}
70+
return null;
71+
}
72+
73+
@Nullable
74+
public static SkywarsGameType fromId(int id) {
75+
for (SkywarsGameType type : values()) {
76+
if (type.id == id) {
77+
return type;
78+
}
79+
}
80+
return null;
81+
}
82+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package net.swofty.commons.skywars;
2+
3+
import lombok.Getter;
4+
5+
import java.util.Arrays;
6+
import java.util.List;
7+
8+
@Getter
9+
public enum SkywarsLeaderboardMode {
10+
ALL("all", "All Modes"),
11+
SOLO_NORMAL("solo_normal", "Solo Normal"),
12+
SOLO_INSANE("solo_insane", "Solo Insane"),
13+
DOUBLES("doubles", "Doubles");
14+
15+
private final String key;
16+
private final String displayName;
17+
18+
SkywarsLeaderboardMode(String key, String displayName) {
19+
this.key = key;
20+
this.displayName = displayName;
21+
}
22+
23+
private static final List<SkywarsGameType> ACTIVE_MODES = Arrays.asList(
24+
SkywarsGameType.SOLO_NORMAL,
25+
SkywarsGameType.SOLO_INSANE,
26+
SkywarsGameType.DOUBLES_NORMAL
27+
);
28+
29+
public boolean includes(SkywarsGameType gameType) {
30+
return switch (this) {
31+
case ALL -> ACTIVE_MODES.contains(gameType);
32+
case SOLO_NORMAL -> gameType == SkywarsGameType.SOLO_NORMAL;
33+
case SOLO_INSANE -> gameType == SkywarsGameType.SOLO_INSANE;
34+
case DOUBLES -> gameType == SkywarsGameType.DOUBLES_NORMAL;
35+
};
36+
}
37+
38+
public SkywarsLeaderboardMode next() {
39+
SkywarsLeaderboardMode[] values = values();
40+
int nextOrdinal = (this.ordinal() + 1) % values.length;
41+
return values[nextOrdinal];
42+
}
43+
44+
public SkywarsLeaderboardMode previous() {
45+
SkywarsLeaderboardMode[] values = values();
46+
int prevOrdinal = (this.ordinal() - 1 + values.length) % values.length;
47+
return values[prevOrdinal];
48+
}
49+
50+
public static SkywarsLeaderboardMode fromKey(String key) {
51+
for (SkywarsLeaderboardMode mode : values()) {
52+
if (mode.key.equalsIgnoreCase(key)) {
53+
return mode;
54+
}
55+
}
56+
return ALL;
57+
}
58+
59+
public static SkywarsLeaderboardMode fromGameType(SkywarsGameType gameType) {
60+
return switch (gameType) {
61+
case SOLO_NORMAL -> SOLO_NORMAL;
62+
case SOLO_INSANE -> SOLO_INSANE;
63+
case DOUBLES_NORMAL -> DOUBLES;
64+
default -> ALL;
65+
};
66+
}
67+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package net.swofty.commons.skywars;
2+
3+
import lombok.Getter;
4+
5+
@Getter
6+
public enum SkywarsLeaderboardPeriod {
7+
DAILY("daily", "Daily", 1),
8+
WEEKLY("weekly", "Weekly", 7),
9+
MONTHLY("monthly", "Monthly", 30),
10+
LIFETIME("lifetime", "Lifetime", -1);
11+
12+
private final String key;
13+
private final String displayName;
14+
private final int days;
15+
16+
SkywarsLeaderboardPeriod(String key, String displayName, int days) {
17+
this.key = key;
18+
this.displayName = displayName;
19+
this.days = days;
20+
}
21+
22+
public SkywarsLeaderboardPeriod next() {
23+
SkywarsLeaderboardPeriod[] values = values();
24+
int nextOrdinal = (this.ordinal() + 1) % values.length;
25+
return values[nextOrdinal];
26+
}
27+
28+
public SkywarsLeaderboardPeriod previous() {
29+
SkywarsLeaderboardPeriod[] values = values();
30+
int prevOrdinal = (this.ordinal() - 1 + values.length) % values.length;
31+
return values[prevOrdinal];
32+
}
33+
34+
public static SkywarsLeaderboardPeriod fromKey(String key) {
35+
for (SkywarsLeaderboardPeriod period : values()) {
36+
if (period.key.equalsIgnoreCase(key)) {
37+
return period;
38+
}
39+
}
40+
return LIFETIME;
41+
}
42+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package net.swofty.commons.skywars;
2+
3+
public record SkywarsLeaderboardPreferences(
4+
SkywarsLeaderboardPeriod period,
5+
SkywarsLeaderboardMode mode,
6+
SkywarsLeaderboardView view,
7+
SkywarsTextAlignment textAlignment
8+
) {
9+
public static SkywarsLeaderboardPreferences defaults() {
10+
return new SkywarsLeaderboardPreferences(
11+
SkywarsLeaderboardPeriod.WEEKLY,
12+
SkywarsLeaderboardMode.ALL,
13+
SkywarsLeaderboardView.TOP_10,
14+
SkywarsTextAlignment.CENTER
15+
);
16+
}
17+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package net.swofty.commons.skywars;
2+
3+
import lombok.Getter;
4+
5+
@Getter
6+
public enum SkywarsLeaderboardView {
7+
TOP_10("top_10", "Top 10"),
8+
PLAYERS_AROUND_YOU("around_you", "Players Around You");
9+
10+
private final String key;
11+
private final String displayName;
12+
13+
SkywarsLeaderboardView(String key, String displayName) {
14+
this.key = key;
15+
this.displayName = displayName;
16+
}
17+
18+
public SkywarsLeaderboardView next() {
19+
SkywarsLeaderboardView[] values = values();
20+
int nextOrdinal = (this.ordinal() + 1) % values.length;
21+
return values[nextOrdinal];
22+
}
23+
24+
public SkywarsLeaderboardView previous() {
25+
SkywarsLeaderboardView[] values = values();
26+
int prevOrdinal = (this.ordinal() - 1 + values.length) % values.length;
27+
return values[prevOrdinal];
28+
}
29+
30+
public static SkywarsLeaderboardView fromKey(String key) {
31+
for (SkywarsLeaderboardView view : values()) {
32+
if (view.key.equalsIgnoreCase(key)) {
33+
return view;
34+
}
35+
}
36+
return TOP_10;
37+
}
38+
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
package net.swofty.commons.skywars;
2+
3+
import lombok.Getter;
4+
5+
@Getter
6+
public enum SkywarsLevelColor {
7+
NONE(0, "7", "⋆"),
8+
IRON(5, "f", "✦"),
9+
GOLD(10, "6", "✦"),
10+
DIAMOND(15, "b", "✦"),
11+
EMERALD(20, "a", "✦"),
12+
SAPPHIRE(25, "3", "✦"),
13+
RUBY(30, "c", "✦"),
14+
CRYSTAL(35, "d", "✦"),
15+
OPAL(40, "8", "✦"),
16+
AMETHYST(45, "5", "✦"),
17+
RAINBOW(50, "f", "✦");
18+
19+
private final int minimumLevel;
20+
private final String colorCode;
21+
private final String symbol;
22+
23+
SkywarsLevelColor(int minimumLevel, String colorCode, String symbol) {
24+
this.minimumLevel = minimumLevel;
25+
this.colorCode = colorCode;
26+
this.symbol = symbol;
27+
}
28+
29+
public static SkywarsLevelColor fromLevel(int level) {
30+
SkywarsLevelColor result = NONE;
31+
for (SkywarsLevelColor color : values()) {
32+
if (level >= color.minimumLevel) {
33+
result = color;
34+
}
35+
}
36+
return result;
37+
}
38+
39+
public String constructLevelBrackets(int level) {
40+
if (this == RAINBOW) {
41+
return constructRainbowBrackets(level);
42+
}
43+
return "§" + colorCode + "[" + level + symbol + "]";
44+
}
45+
46+
public String constructLevelString(int level) {
47+
if (this == RAINBOW) {
48+
return constructRainbowString(level);
49+
}
50+
return "§" + colorCode + level + symbol;
51+
}
52+
53+
private String constructRainbowBrackets(int level) {
54+
String levelStr = String.valueOf(level);
55+
String[] colors = {"c", "6", "e", "a", "b", "d"};
56+
StringBuilder result = new StringBuilder("§" + colors[0] + "[");
57+
58+
for (int i = 0; i < levelStr.length(); i++) {
59+
result.append("§").append(colors[(i + 1) % colors.length]).append(levelStr.charAt(i));
60+
}
61+
62+
result.append("§f").append(symbol).append("§" + colors[0] + "]");
63+
return result.toString();
64+
}
65+
66+
private String constructRainbowString(int level) {
67+
String levelStr = String.valueOf(level);
68+
String[] colors = {"c", "6", "e", "a", "b", "d"};
69+
StringBuilder result = new StringBuilder();
70+
71+
for (int i = 0; i < levelStr.length(); i++) {
72+
result.append("§").append(colors[i % colors.length]).append(levelStr.charAt(i));
73+
}
74+
75+
result.append("§f").append(symbol);
76+
return result.toString();
77+
}
78+
79+
public static String getLevelDisplay(int level) {
80+
SkywarsLevelColor color = fromLevel(level);
81+
return color.constructLevelBrackets(level);
82+
}
83+
}

0 commit comments

Comments
 (0)