Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.minecraft.text.Text;
import net.minecraft.util.math.random.Random;
import net.minecraft.registry.entry.RegistryEntry;
import xyz.nucleoid.plasmid.api.game.GameOpenContext;
import xyz.nucleoid.plasmid.api.game.GameOpenException;
import xyz.nucleoid.plasmid.api.game.GameOpenProcedure;
Expand All @@ -11,11 +12,16 @@ public final class RandomGame {
public static GameOpenProcedure open(GameOpenContext<RandomGameConfig> context) {
var config = context.config();

var game = config.selectGame(Random.createLocal());
if (game == null) {
if(config.isEmpty()) {
throw new GameOpenException(Text.translatable("text.plasmid.random.empty_composite_game_config"));
}

RegistryEntry<GameConfig<?>> game = null;
while(game == null) game = config.selectGame(Random.createLocal());

return GameOpenProcedure.withOverride(GameConfig.openProcedure(context.server(), game), game);
}
}