Skip to content

Commit 5fdd697

Browse files
committed
Simplify common win and lose messages implementation
1 parent 7b8e6b6 commit 5fdd697

File tree

1 file changed

+79
-95
lines changed

1 file changed

+79
-95
lines changed

src/main/java/dev/emortal/minestom/gamesdk/util/GameWinLoseMessages.java

Lines changed: 79 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -2,111 +2,95 @@
22

33
import org.jetbrains.annotations.NotNull;
44

5-
import java.util.ArrayList;
6-
import java.util.Arrays;
75
import java.util.List;
86
import java.util.concurrent.ThreadLocalRandom;
97

108
public final class GameWinLoseMessages {
119

12-
public static final Registry VICTORY = new Registry();
13-
public static final Registry DEFEAT = new Registry();
10+
private static final List<String> VICTORY = List.of(
11+
"pepeD",
12+
"gg ez no re",
13+
"All luck",
14+
"NoHacksJustSkill",
15+
"Were you hacking?",
16+
"Were you teaming?",
17+
"no skill issues here",
18+
"i am better",
19+
"I dropped my popcorn",
20+
"Defeat... but not for you",
21+
"Teamwork makes the dream work",
22+
"vic roy",
23+
"call an ambulance... but not for me",
24+
"What chair do you have?",
25+
"I won? It must have been my chair!",
26+
"No GC this time",
27+
"Moulberry is proud of you",
28+
"tryhard == true",
29+
"touch grass",
30+
"take a shower",
31+
"take a cookie for your efforts",
32+
"[username] never dies!",
33+
"average rust enjoyer",
34+
"average valence enjoyer",
35+
"average minestom enjoyer",
36+
"i wasn't looking, do it again",
37+
"built different",
38+
"carried",
39+
"don't forget to breathe!",
40+
"want a medal?",
41+
"you lost the game",
42+
"BLEHHH"
43+
);
44+
private static final List<String> DEFEAT = List.of(
45+
"I guess you weren't trying",
46+
"no",
47+
"L",
48+
"rip bozo",
49+
"no zaza??",
50+
"what is your excuse?",
51+
"skill issue",
52+
"uffeyman was here",
53+
"Better luck next time!",
54+
"Worse luck next time!",
55+
"Should have used a Minestom client",
56+
"Teamwork... towards defeat",
57+
"No one matches your skill... at losing",
58+
"Victory... but not for you",
59+
"You tried and that's what matters!",
60+
"Zzzzzz",
61+
"Did your cat step on your keyboard?",
62+
"PepeHands",
63+
"At least someone won, too bad it wasn't you",
64+
"cry about it",
65+
"were you afk?",
66+
"smh my head",
67+
"I bet you didn't even say good game",
68+
"You did your best... but it wasn't enough",
69+
"\"i lagged\" said an Australian",
70+
"If I had a dollar every time you won a game, I'd be in crippling debt",
71+
"widepeepoSad",
72+
"try harder",
73+
"You clearly weren't using Graphite",
74+
"I saw the GC spike",
75+
"python user",
76+
"BLEHHH",
77+
"Kotlin user"
78+
);
1479

15-
static {
16-
VICTORY.registerAll(
17-
"pepeD",
18-
"gg ez no re",
19-
"All luck",
20-
"NoHacksJustSkill",
21-
"Were you hacking?",
22-
"Were you teaming?",
23-
"no skill issues here",
24-
"i am better",
25-
"I dropped my popcorn",
26-
"Defeat... but not for you",
27-
"Teamwork makes the dream work",
28-
"vic roy",
29-
"call an ambulance... but not for me",
30-
"What chair do you have?",
31-
"I won? It must have been my chair!",
32-
"No GC this time",
33-
"Moulberry is proud of you",
34-
"tryhard == true",
35-
"touch grass",
36-
"take a shower",
37-
"take a cookie for your efforts",
38-
"[username] never dies!",
39-
"average rust enjoyer",
40-
"average valence enjoyer",
41-
"average minestom enjoyer",
42-
"i wasn't looking, do it again",
43-
"built different",
44-
"carried",
45-
"don't forget to breathe!",
46-
"want a medal?",
47-
"you lost the game",
48-
"BLEHHH"
49-
);
50-
DEFEAT.registerAll(
51-
"I guess you weren't trying",
52-
"no",
53-
"L",
54-
"rip bozo",
55-
"no zaza??",
56-
"what is your excuse?",
57-
"skill issue",
58-
"uffeyman was here",
59-
"Better luck next time!",
60-
"Worse luck next time!",
61-
"Should have used a Minestom client",
62-
"Teamwork... towards defeat",
63-
"No one matches your skill... at losing",
64-
"Victory... but not for you",
65-
"You tried and that's what matters!",
66-
"Zzzzzz",
67-
"Did your cat step on your keyboard?",
68-
"PepeHands",
69-
"At least someone won, too bad it wasn't you",
70-
"cry about it",
71-
"were you afk?",
72-
"smh my head",
73-
"I bet you didn't even say good game",
74-
"You did your best... but it wasn't enough",
75-
"\"i lagged\" said an Australian",
76-
"If I had a dollar every time you won a game, I'd be in crippling debt",
77-
"widepeepoSad",
78-
"try harder",
79-
"You clearly weren't using Graphite",
80-
"I saw the GC spike",
81-
"python user",
82-
"BLEHHH",
83-
"Kotlin user"
84-
);
80+
public static @NotNull String randomVictory() {
81+
return random(VICTORY);
8582
}
8683

87-
private GameWinLoseMessages() {
84+
public static @NotNull String randomDefeat() {
85+
return random(DEFEAT);
8886
}
8987

90-
public static final class Registry {
91-
92-
private final List<String> messages = new ArrayList<>();
93-
94-
public @NotNull String random() {
95-
int length = this.messages.size();
96-
int randomIndex = ThreadLocalRandom.current().nextInt(length);
97-
return this.messages.get(randomIndex);
98-
}
99-
100-
public void register(@NotNull String message) {
101-
this.messages.add(message);
102-
}
103-
104-
public void registerAll(@NotNull String... messages) {
105-
this.messages.addAll(Arrays.asList(messages));
106-
}
88+
private static @NotNull String random(@NotNull List<String> messages) {
89+
int length = messages.size();
90+
int randomIndex = ThreadLocalRandom.current().nextInt(length);
91+
return messages.get(randomIndex);
92+
}
10793

108-
public void reset() {
109-
this.messages.clear();
110-
}
94+
private GameWinLoseMessages() {
11195
}
11296
}

0 commit comments

Comments
 (0)