Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperErnD committed Dec 17, 2024
1 parent 2d1831c commit ead9cf6
Showing 1 changed file with 8 additions and 2 deletions.
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);
}
}



0 comments on commit ead9cf6

Please sign in to comment.