Skip to content

Commit 7ded66b

Browse files
feat: test flows
Took 2 hours 57 minutes
1 parent 26b7909 commit 7ded66b

33 files changed

Lines changed: 1523 additions & 54 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
public enum CustomWorlds {
44
ISLANDS_TEMPLATE("hypixel_island_template"),
55
HUB("hypixel_hub"),
6+
DUNGEON_HUB("hypixel_dungeon_hub"),
67
;
78

89
private final String folderName;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
public enum ServerType {
66
ISLAND,
77
HUB,
8+
DUNGEON_HUB,
89
THE_FARMING_ISLANDS;
910

1011
public static boolean isServerType(String type) {
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
package net.swofty.commons;
2+
3+
import lombok.Getter;
4+
import lombok.Setter;
5+
6+
import java.util.List;
7+
8+
public class TestFlow {
9+
@Getter
10+
@Setter
11+
private static String currentTestFlow;
12+
13+
@Getter
14+
@Setter
15+
private static List<String> currentTestPlayers;
16+
17+
/**
18+
* Checks if any test flow is currently active on this server
19+
* @return true if a test flow is active
20+
*/
21+
public static boolean isTestFlowActive() {
22+
return currentTestFlow != null;
23+
}
24+
25+
/**
26+
* Checks if a specific test flow is active
27+
* @param testFlowName the name of the test flow
28+
* @return true if the specified test flow is active
29+
*/
30+
public static boolean isTestFlowActive(String testFlowName) {
31+
return currentTestFlow != null && currentTestFlow.equals(testFlowName);
32+
}
33+
34+
/**
35+
* Gets the current test flow instance
36+
* @return a simple TestFlowInstance or null if no test flow is active
37+
*/
38+
public static TestFlowInstance getTestFlowInstance() {
39+
if (currentTestFlow == null) return null;
40+
return new TestFlowInstance(currentTestFlow, currentTestPlayers);
41+
}
42+
43+
/**
44+
* Sets the current test flow for this server
45+
* @param testFlowName the name of the test flow
46+
* @param players the list of test flow players
47+
*/
48+
public static void setCurrentTestFlow(String testFlowName, List<String> players) {
49+
currentTestFlow = testFlowName;
50+
currentTestPlayers = players;
51+
}
52+
53+
/**
54+
* Clears the current test flow
55+
*/
56+
public static void clearTestFlow() {
57+
currentTestFlow = null;
58+
currentTestPlayers = null;
59+
}
60+
61+
/**
62+
* Simple test flow instance for server-side usage
63+
*/
64+
@Getter
65+
public static class TestFlowInstance {
66+
private final String name;
67+
private final List<String> players;
68+
69+
public TestFlowInstance(String name, List<String> players) {
70+
this.name = name;
71+
this.players = players;
72+
}
73+
74+
/**
75+
* Checks if a player is part of this test flow
76+
* @param playerName the player name to check
77+
* @return true if the player is in this test flow
78+
*/
79+
public boolean hasPlayer(String playerName) {
80+
return players != null && players.contains(playerName);
81+
}
82+
}
83+
}

commons/src/main/java/net/swofty/commons/proxy/ToProxyChannels.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ public enum ToProxyChannels {
1313
REGISTER_SERVER("register-server", new RegisterServerRequirements()),
1414
FINISHED_WITH_PLAYER("finished-with-player", new FinishedWithPlayerRequirements()),
1515
REQUEST_SERVERS("servers", new ServersRequirement()),
16+
REGISTER_TEST_FLOW("register-test-flow", new RegisterTestFlowRequirements()),
17+
TEST_FLOW_SERVER_READY("test-flow-server-ready", new TestFlowServerReadyRequirements()),
1618
;
1719

1820
@Getter
@@ -48,4 +50,4 @@ public static ToProxyChannels getChannelName(String channel) {
4850
}
4951
throw new IllegalArgumentException("Unknown channelName: " + channel);
5052
}
51-
}
53+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package net.swofty.commons.proxy.requirements.to;
2+
3+
import net.swofty.commons.proxy.ProxyChannelRequirements;
4+
5+
import java.util.List;
6+
7+
public class RegisterTestFlowRequirements extends ProxyChannelRequirements {
8+
@Override
9+
public List<RequiredKey> getRequiredKeysForProxy() {
10+
return List.of(
11+
new RequiredKey("test_flow_name"),
12+
new RequiredKey("handler"),
13+
new RequiredKey("players"),
14+
new RequiredKey("server_configs")
15+
);
16+
}
17+
18+
@Override
19+
public List<RequiredKey> getRequiredKeysForServer() {
20+
return List.of(
21+
new RequiredKey("test_flow_name"),
22+
new RequiredKey("handler"),
23+
new RequiredKey("players"),
24+
new RequiredKey("server_configs")
25+
);
26+
}
27+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package net.swofty.commons.proxy.requirements.to;
2+
3+
import net.swofty.commons.proxy.ProxyChannelRequirements;
4+
5+
import java.util.List;
6+
7+
public class TestFlowServerReadyRequirements extends ProxyChannelRequirements {
8+
@Override
9+
public List<RequiredKey> getRequiredKeysForProxy() {
10+
return List.of(
11+
new RequiredKey("test_flow_name"),
12+
new RequiredKey("server_type"),
13+
new RequiredKey("server_index")
14+
);
15+
}
16+
17+
@Override
18+
public List<RequiredKey> getRequiredKeysForServer() {
19+
return List.of(
20+
new RequiredKey("test_flow_name"),
21+
new RequiredKey("server_type"),
22+
new RequiredKey("server_index")
23+
);
24+
}
25+
}

0 commit comments

Comments
 (0)