Skip to content

Commit fa22191

Browse files
Merge remote-tracking branch 'ArikSquad/feat/bw' into feat/bw
2 parents 3ae45ed + 64e6ba5 commit fa22191

18 files changed

Lines changed: 2152 additions & 24 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public enum ServerType {
1414
PROTOTYPE_LOBBY(false),
1515
BEDWARS_LOBBY(false),
1616
BEDWARS_GAME(false),
17+
BEDWARS_CONFIGURATOR(false)
1718
;
1819

1920
private final boolean isSkyBlock;

commons/src/main/java/net/swofty/commons/bedwars/map/BedWarsMapsConfig.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,26 @@
22

33
import lombok.Getter;
44
import net.swofty.commons.bedwars.BedwarsGameType;
5+
import lombok.Setter;
56

67
import java.util.List;
78
import java.util.Map;
89

910
@Getter
11+
@Setter
1012
@SuppressWarnings("unused")
1113
public class BedWarsMapsConfig {
1214
private List<MapEntry> maps;
1315

1416
@Getter
17+
@Setter
1518
public static class MapEntry {
1619
private String id;
1720
private String name;
1821
private MapConfiguration configuration;
1922

2023
@Getter
24+
@Setter
2125
public static class MapConfiguration {
2226
private List<BedwarsGameType> types;
2327
private Map<String, TeamGeneratorConfig> generator;
@@ -27,25 +31,29 @@ public static class MapConfiguration {
2731
private Map<String, GlobalGenerator> global_generator;
2832

2933
@Getter
34+
@Setter
3035
public static class MapLocations {
3136
private Position waiting;
3237
private Position spectator;
3338
}
3439

3540
@Getter
41+
@Setter
3642
public static class MapBounds {
3743
private MinMax x;
3844
private MinMax y;
3945
private MinMax z;
4046
}
4147

4248
@Getter
49+
@Setter
4350
public static class TeamGeneratorConfig {
4451
private int delay;
4552
private int amount;
4653
}
4754

4855
@Getter
56+
@Setter
4957
public static class GlobalGenerator {
5058
private int amount;
5159
private int max;
@@ -97,7 +105,24 @@ public String chatColor() {
97105
}
98106
}
99107

108+
public enum GeneratorSpeed {
109+
SLOW(0.7f),
110+
MEDIUM(1.4f),
111+
FAST(2f),
112+
SUPER_FAST(2.2f);
113+
114+
public final float ironSpeed; // per second
115+
// These values are consistent among maps
116+
public final float goldDelay = 8f;
117+
public final int diamondMax = 4;
118+
public final int emeraldMax = 2;
119+
GeneratorSpeed(float speed) {
120+
this.ironSpeed = speed;
121+
}
122+
}
123+
100124
@Getter
125+
@Setter
101126
public static class MapTeam {
102127
private Shops shop;
103128
private PitchYawPosition spawn;

loader/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ dependencies {
3535
implementation(project(":type.prototypelobby"))
3636
implementation(project(":type.bedwarslobby"))
3737
implementation(project(":type.bedwarsgame"))
38+
implementation(project(":type.bedwarsconfigurator"))
3839
implementation(project(":type.generic"))
3940
implementation(project(":commons"))
4041
implementation(project(":proxy.api"))

settings.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ include(":type.hub")
2424
include(":type.dungeonhub")
2525
include(":type.bedwarslobby")
2626
include(":type.bedwarsgame")
27+
include(":type.bedwarsconfigurator")
2728

2829
include(":service.auctionhouse")
2930
include(":service.bazaar")
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
plugins {
2+
java
3+
}
4+
5+
group = "net.swofty"
6+
version = "3.0"
7+
8+
java {
9+
sourceCompatibility = JavaVersion.VERSION_25
10+
targetCompatibility = JavaVersion.VERSION_25
11+
toolchain {
12+
languageVersion.set(JavaLanguageVersion.of(25))
13+
}
14+
}
15+
16+
repositories {
17+
maven("https://jitpack.io")
18+
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/")
19+
maven("https://repo.viaversion.com")
20+
}
21+
22+
dependencies {
23+
implementation(project(":type.generic"))
24+
implementation(project(":commons"))
25+
implementation(project(":proxy.api"))
26+
implementation("org.mongodb:bson:4.11.2")
27+
implementation("net.kyori:adventure-text-minimessage:4.25.0")
28+
compileOnly("net.minestom:minestom:2025.12.20c-1.21.11") {
29+
exclude(group = "org.jboss.shrinkwrap.resolver", module = "shrinkwrap-resolver-depchain")
30+
}
31+
implementation("dev.hollowcube:polar:1.15.0")
32+
implementation("it.unimi.dsi:fastutil:8.5.18")
33+
implementation("org.tinylog:tinylog-api:2.7.0")
34+
implementation("org.tinylog:tinylog-impl:2.7.0")
35+
}
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
package net.swofty.type.bedwarsconfigurator;
2+
3+
import com.google.gson.Gson;
4+
import com.google.gson.GsonBuilder;
5+
import lombok.Getter;
6+
import net.minestom.server.MinecraftServer;
7+
import net.minestom.server.coordinate.Pos;
8+
import net.swofty.commons.CustomWorlds;
9+
import net.swofty.commons.ServerType;
10+
import net.swofty.commons.ServiceType;
11+
import net.swofty.commons.bedwars.map.BedWarsMapsConfig;
12+
import net.swofty.proxyapi.redis.ProxyToClient;
13+
import net.swofty.proxyapi.redis.ServiceToClient;
14+
import net.swofty.type.generic.HypixelGenericLoader;
15+
import net.swofty.type.generic.HypixelTypeLoader;
16+
import net.swofty.type.generic.command.HypixelCommand;
17+
import net.swofty.type.generic.entity.npc.HypixelNPC;
18+
import net.swofty.type.generic.event.HypixelEventClass;
19+
import net.swofty.type.generic.tab.EmptyTabModule;
20+
import net.swofty.type.generic.tab.TablistManager;
21+
import net.swofty.type.generic.tab.TablistModule;
22+
import org.jetbrains.annotations.Nullable;
23+
import org.tinylog.Logger;
24+
25+
import java.io.InputStream;
26+
import java.nio.charset.StandardCharsets;
27+
import java.nio.file.Files;
28+
import java.nio.file.Path;
29+
import java.util.List;
30+
31+
public class TypeBedWarsConfiguratorLoader implements HypixelTypeLoader {
32+
private static Gson gson;
33+
34+
@Getter
35+
private static BedWarsMapsConfig mapsConfig;
36+
37+
@Override
38+
public ServerType getType() {
39+
return ServerType.BEDWARS_CONFIGURATOR;
40+
}
41+
42+
@Override
43+
public void onInitialize(MinecraftServer server) {
44+
gson = new GsonBuilder().create();
45+
loadMapsConfig();
46+
}
47+
48+
private static void loadMapsConfig() {
49+
Path mapsPath = Path.of("./configuration/bedwars/maps.json");
50+
if (!Files.exists(mapsPath)) {
51+
Logger.error("maps.json not found at {}", mapsPath.toAbsolutePath());
52+
return;
53+
}
54+
try (InputStream in = Files.newInputStream(mapsPath)) {
55+
byte[] bytes = in.readAllBytes();
56+
String json = new String(bytes, StandardCharsets.UTF_8);
57+
mapsConfig = gson.fromJson(json, BedWarsMapsConfig.class);
58+
} catch (Exception e) {
59+
Logger.error("Failed to load maps.json", e);
60+
}
61+
}
62+
63+
/**
64+
* Reloads the maps configuration from file
65+
*/
66+
public static void reloadMapsConfig() {
67+
if (gson == null) {
68+
gson = new GsonBuilder().create();
69+
}
70+
loadMapsConfig();
71+
Logger.info("Reloaded maps.json configuration");
72+
}
73+
74+
@Override
75+
public void afterInitialize(MinecraftServer server) {
76+
HypixelGenericLoader.loopThroughPackage("net.swofty.type.bedwarsconfigurator.commands", HypixelCommand.class).forEach(command -> {
77+
try {
78+
MinecraftServer.getCommandManager().register(command.getCommand());
79+
} catch (Exception e) {
80+
Logger.error(e, "Failed to register command " + command.getCommand().getName() + " in class " + command.getClass().getSimpleName());
81+
}
82+
});
83+
}
84+
85+
@Override
86+
public List<ServiceType> getRequiredServices() {
87+
return List.of();
88+
}
89+
90+
@Override
91+
public TablistManager getTablistManager() {
92+
return new TablistManager() {
93+
@Override
94+
public List<TablistModule> getModules() {
95+
return List.of(
96+
new EmptyTabModule(),
97+
new EmptyTabModule(),
98+
new EmptyTabModule(),
99+
new EmptyTabModule()
100+
);
101+
}
102+
};
103+
}
104+
105+
@Override
106+
public LoaderValues getLoaderValues() {
107+
return new LoaderValues(
108+
(type) -> new Pos(0, 100, 0, -90, 0), // Spawn position
109+
false // Announce death messages
110+
);
111+
}
112+
113+
@Override
114+
public List<HypixelEventClass> getTraditionalEvents() {
115+
return HypixelGenericLoader.loopThroughPackage(
116+
"net.swofty.type.bedwarsconfigurator.events",
117+
HypixelEventClass.class
118+
).toList();
119+
}
120+
121+
@Override
122+
public List<HypixelEventClass> getCustomEvents() {
123+
return HypixelGenericLoader.loopThroughPackage(
124+
"net.swofty.type.bedwarsconfigurator.events.custom",
125+
HypixelEventClass.class
126+
).toList();
127+
}
128+
129+
@Override
130+
public List<HypixelNPC> getNPCs() {
131+
return HypixelGenericLoader.loopThroughPackage(
132+
"net.swofty.type.bedwarsconfigurator.npcs",
133+
HypixelNPC.class
134+
).toList();
135+
}
136+
137+
@Override
138+
public List<ServiceToClient> getServiceRedisListeners() {
139+
return HypixelGenericLoader.loopThroughPackage(
140+
"net.swofty.type.bedwarsconfigurator.redis.service",
141+
ServiceToClient.class
142+
).toList();
143+
}
144+
145+
@Override
146+
public List<ProxyToClient> getProxyRedisListeners() {
147+
return List.of();
148+
}
149+
150+
@Override
151+
public @Nullable CustomWorlds getMainInstance() {
152+
return CustomWorlds.BEDWARS_LOBBY;
153+
}
154+
155+
}

0 commit comments

Comments
 (0)