Refactored User room to be optional

This commit is contained in:
2023-10-03 10:40:32 +02:00
parent 4b82b81d63
commit 16cf29a590
8 changed files with 46 additions and 29 deletions

View File

@@ -52,7 +52,7 @@ public abstract class Game extends MineNetInstance implements Spawnable {
try {
Game game = factory.manufacture(options);
Room.getRoom(owner).moveMembersToGame(game);
Room.getRoom(owner).orElseThrow().moveMembersToGame(game);
game.load();
} catch (Exception e) {

View File

@@ -11,13 +11,13 @@ import eu.mhsl.minenet.minigames.instance.game.stateless.types.towerdefense.Towe
import eu.mhsl.minenet.minigames.instance.game.stateless.types.trafficlightrace.TrafficLightRaceFactory;
public enum GameList {
DEATHCUBE(new DeathcubeFactory(), GameType.OTHER),
DEATHCUBE(new DeathcubeFactory(), GameType.JUMPNRUN),
STICKFIGHT(new StickFightFactory(), GameType.PVP),
MINERUN(new MinerunFactory(), GameType.PVE),
MINERUN(new MinerunFactory(), GameType.JUMPNRUN),
TRAFFICLIGHTRACE(new TrafficLightRaceFactory(), GameType.OTHER),
TOWERDEFENSE(new TowerdefenseFactory(), GameType.PVE),
BEDWARS(new BedwarsFactory(), GameType.PVP),
BACKROOMS(new BackroomsFactory(), GameType.PVE),
TOWERDEFENSE(new TowerdefenseFactory(), GameType.PROTOTYPE),
BEDWARS(new BedwarsFactory(), GameType.PROTOTYPE),
BACKROOMS(new BackroomsFactory(), GameType.PROTOTYPE),
SPLEEF(new SpleefFactory(), GameType.PVP);
private final GameFactory factory;

View File

@@ -6,7 +6,9 @@ import net.minestom.server.item.Material;
public enum GameType {
OTHER(Material.GRASS_BLOCK, TranslatedComponent.byId("GameType#other"), TranslatedComponent.byId("GameType#other_description")),
PVP(Material.DIAMOND_SWORD, TranslatedComponent.byId("GameType#pvp"), TranslatedComponent.byId("GameType#pvp_description")),
PVE(Material.DIAMOND_PICKAXE, TranslatedComponent.byId("GameType#pve"), TranslatedComponent.byId("GameType#pve_description"));
PVE(Material.DIAMOND_PICKAXE, TranslatedComponent.byId("GameType#pve"), TranslatedComponent.byId("GameType#pve_description")),
JUMPNRUN(Material.DIAMOND_BOOTS, TranslatedComponent.byId("GameType#jumpnrun"), TranslatedComponent.byId("GameType#jumpnrun_description")),
PROTOTYPE(Material.COMMAND_BLOCK, TranslatedComponent.byId("GameType#prototype"), TranslatedComponent.byId("GameType#prototype_description"));
final Material icon;

View File

@@ -4,6 +4,7 @@ import eu.mhsl.minenet.minigames.instance.game.stateless.StatelessGame;
import eu.mhsl.minenet.minigames.score.FirstWinsScore;
import eu.mhsl.minenet.minigames.util.BatchUtil;
import eu.mhsl.minenet.minigames.instance.Dimension;
import net.minestom.server.coordinate.Pos;
import net.minestom.server.coordinate.Vec;
import net.minestom.server.event.player.PlayerMoveEvent;
import net.minestom.server.instance.batch.AbsoluteBlockBatch;
@@ -26,7 +27,7 @@ class TrafficLightRace extends StatelessGame {
protected void onLoad(@NotNull CompletableFuture<Void> callback) {
AbsoluteBlockBatch batch = new AbsoluteBlockBatch();
for (int x = -10; x <= 10; x++) {
for (int z = 5; z <= 100; z++) {
for (int z = 0; z <= 100; z++) {
batch.setBlock(x, 5, z, super.rnd.nextInt(0, 100) > 90 ? Block.SOUL_SAND : Block.BLACK_CONCRETE_POWDER);
}
}
@@ -67,4 +68,8 @@ class TrafficLightRace extends StatelessGame {
}
}
@Override
public Pos getSpawn() {
return new Pos(0, 6, 10);
}
}