Added configuration options to spleef game
This commit is contained in:
parent
61448e77f2
commit
91069b76c6
Binary file not shown.
@ -18,13 +18,11 @@ public class PlayerLoginHandler implements EventListener<PlayerLoginEvent> {
|
||||
|
||||
@Override
|
||||
public @NotNull Result run(@NotNull PlayerLoginEvent event) {
|
||||
|
||||
Player p = event.getPlayer();
|
||||
|
||||
p.setRespawnPoint(Hub.INSTANCE.getSpawn());
|
||||
p.sendMessage(p.getUuid().toString());
|
||||
event.setSpawningInstance(Hub.INSTANCE);
|
||||
//SkinCache.applySkin(p);
|
||||
SkinCache.applySkin(p);
|
||||
|
||||
|
||||
if(p.getUsername().equalsIgnoreCase("minetec"))
|
||||
|
@ -19,15 +19,18 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class Spleef extends StatelessGame {
|
||||
int size = 30;
|
||||
int stackCount = 3;
|
||||
int radius;
|
||||
int stackCount;
|
||||
|
||||
final int heightPerLevel = 20;
|
||||
final int totalElevation = 50;
|
||||
|
||||
public Spleef() {
|
||||
public Spleef(int radius, int stackCount) {
|
||||
super(Dimension.OVERWORLD.DIMENSION, "Spleef", new LastWinsScore(1));
|
||||
|
||||
this.radius = radius;
|
||||
this.stackCount = stackCount;
|
||||
|
||||
setGenerator(new CircularTerrainGenerator(50, false));
|
||||
|
||||
eventNode().addListener(PlayerStartDiggingEvent.class, this::destroyBlock);
|
||||
@ -38,9 +41,9 @@ public class Spleef extends StatelessGame {
|
||||
AbsoluteBlockBatch circle = new AbsoluteBlockBatch();
|
||||
|
||||
for (int level = 0; level < stackCount; level++) {
|
||||
for(int x = -size; x <= size; x++) {
|
||||
for(int z = -size; z <= size; z++) {
|
||||
if(new Pos(x, 0, z).distance(new Pos(0, 0, 0)) > size) continue;
|
||||
for(int x = -radius; x <= radius; x++) {
|
||||
for(int z = -radius; z <= radius; z++) {
|
||||
if(new Pos(x, 0, z).distance(new Pos(0, 0, 0)) > radius) continue;
|
||||
|
||||
circle.setBlock(x, totalElevation + (level * heightPerLevel), z, BlockPallet.WINTER.rnd());
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import eu.mhsl.minenet.minigames.instance.game.stateless.StatelessGame;
|
||||
import eu.mhsl.minenet.minigames.instance.game.stateless.config.ConfigManager;
|
||||
import eu.mhsl.minenet.minigames.instance.game.stateless.config.GameFactory;
|
||||
import eu.mhsl.minenet.minigames.instance.game.stateless.config.Option;
|
||||
import eu.mhsl.minenet.minigames.instance.game.stateless.config.common.NumericOption;
|
||||
import eu.mhsl.minenet.minigames.instance.game.stateless.config.restriction.RestrictionHandler;
|
||||
import eu.mhsl.minenet.minigames.instance.game.stateless.config.restriction.common.MinimalPlayeramountGameRestriction;
|
||||
import eu.mhsl.minenet.minigames.message.component.TranslatedComponent;
|
||||
@ -18,17 +19,24 @@ public class SpleefFactory implements GameFactory {
|
||||
return TranslatedComponent.byId("game_Spleef#name");
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public RestrictionHandler globalRestrictions() {
|
||||
// return new RestrictionHandler()
|
||||
// .addRestriction(new MinimalPlayeramountGameRestriction(2));
|
||||
// }
|
||||
@Override
|
||||
public RestrictionHandler globalRestrictions() {
|
||||
return new RestrictionHandler()
|
||||
.addRestriction(new MinimalPlayeramountGameRestriction(2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material symbol() {
|
||||
return Material.DIAMOND_SHOVEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigManager configuration() {
|
||||
return new ConfigManager()
|
||||
.addOption(new NumericOption("radius", Material.HEART_OF_THE_SEA, TranslatedComponent.byId("game_Spleef#radius"), 10, 20, 30))
|
||||
.addOption(new NumericOption("stackCount", Material.SCAFFOLDING, TranslatedComponent.byId("game_Spleef#stackCount"), 1, 2, 3, 4, 5));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TranslatedComponent description() {
|
||||
return TranslatedComponent.byId("game_Spleef#description");
|
||||
@ -36,6 +44,6 @@ public class SpleefFactory implements GameFactory {
|
||||
|
||||
@Override
|
||||
public StatelessGame manufacture(Map<String, Option<?>> configuration) throws Exception {
|
||||
return new Spleef();
|
||||
return new Spleef(configuration.get("radius").getAsInt(), configuration.get("stackCount").getAsInt());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user