Compare commits
2 Commits
develop
...
develop-ha
Author | SHA1 | Date | |
---|---|---|---|
e6bded1c9e | |||
37a63e10b0 |
@@ -8,6 +8,7 @@ import eu.mhsl.minenet.minigames.instance.game.stateless.types.backrooms.Backroo
|
|||||||
import eu.mhsl.minenet.minigames.instance.game.stateless.types.bedwars.BedwarsFactory;
|
import eu.mhsl.minenet.minigames.instance.game.stateless.types.bedwars.BedwarsFactory;
|
||||||
import eu.mhsl.minenet.minigames.instance.game.stateless.types.acidRain.AcidRainFactory;
|
import eu.mhsl.minenet.minigames.instance.game.stateless.types.acidRain.AcidRainFactory;
|
||||||
import eu.mhsl.minenet.minigames.instance.game.stateless.types.deathcube.DeathcubeFactory;
|
import eu.mhsl.minenet.minigames.instance.game.stateless.types.deathcube.DeathcubeFactory;
|
||||||
|
import eu.mhsl.minenet.minigames.instance.game.stateless.types.fastbridge.FastbridgeFactory;
|
||||||
import eu.mhsl.minenet.minigames.instance.game.stateless.types.highGround.HighGroundFactory;
|
import eu.mhsl.minenet.minigames.instance.game.stateless.types.highGround.HighGroundFactory;
|
||||||
import eu.mhsl.minenet.minigames.instance.game.stateless.types.jumpDive.JumpDiveFactory;
|
import eu.mhsl.minenet.minigames.instance.game.stateless.types.jumpDive.JumpDiveFactory;
|
||||||
import eu.mhsl.minenet.minigames.instance.game.stateless.types.minerun.MinerunFactory;
|
import eu.mhsl.minenet.minigames.instance.game.stateless.types.minerun.MinerunFactory;
|
||||||
@@ -36,7 +37,8 @@ public enum GameList {
|
|||||||
SPLEEF(new SpleefFactory(), GameType.PVP),
|
SPLEEF(new SpleefFactory(), GameType.PVP),
|
||||||
JUMPDIVE(new JumpDiveFactory(), GameType.JUMPNRUN),
|
JUMPDIVE(new JumpDiveFactory(), GameType.JUMPNRUN),
|
||||||
SUMO(new SumoFactory(), GameType.PVP),
|
SUMO(new SumoFactory(), GameType.PVP),
|
||||||
HIGHGROUND(new HighGroundFactory(), GameType.PVP);
|
HIGHGROUND(new HighGroundFactory(), GameType.PVP),
|
||||||
|
FASTBRIDGE(new FastbridgeFactory(), GameType.PROTOTYPE);
|
||||||
|
|
||||||
private final GameFactory factory;
|
private final GameFactory factory;
|
||||||
private final GameType type;
|
private final GameType type;
|
||||||
|
@@ -0,0 +1,64 @@
|
|||||||
|
package eu.mhsl.minenet.minigames.instance.game.stateless.types.fastbridge;
|
||||||
|
|
||||||
|
import eu.mhsl.minenet.minigames.instance.Dimension;
|
||||||
|
import eu.mhsl.minenet.minigames.instance.game.stateless.StatelessGame;
|
||||||
|
import eu.mhsl.minenet.minigames.score.FirstWinsScore;
|
||||||
|
import net.minestom.server.coordinate.Pos;
|
||||||
|
import net.minestom.server.entity.GameMode;
|
||||||
|
import net.minestom.server.entity.Player;
|
||||||
|
import net.minestom.server.event.player.PlayerBlockPlaceEvent;
|
||||||
|
import net.minestom.server.event.player.PlayerMoveEvent;
|
||||||
|
import net.minestom.server.instance.Chunk;
|
||||||
|
import net.minestom.server.inventory.PlayerInventory;
|
||||||
|
import net.minestom.server.item.ItemStack;
|
||||||
|
import net.minestom.server.item.Material;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class Fastbridge extends StatelessGame {
|
||||||
|
private int currentSpawn = 0;
|
||||||
|
|
||||||
|
public Fastbridge() {
|
||||||
|
super(Dimension.OVERWORLD.key, "Fastbridge", new FirstWinsScore());
|
||||||
|
this.setGenerator(new FastbridgeChunkgenerator());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPlayerMove(@NotNull PlayerMoveEvent playerMoveEvent) {
|
||||||
|
Player player = playerMoveEvent.getPlayer();
|
||||||
|
Pos newPos = playerMoveEvent.getNewPosition();
|
||||||
|
if(this.getScore().hasResult(player)) return;
|
||||||
|
if(newPos.y() < -65) {
|
||||||
|
player.teleport(getSpawn());
|
||||||
|
if(!isBeforeBeginning) this.resetPlayer(player);
|
||||||
|
}
|
||||||
|
if(newPos.x() > 53) {
|
||||||
|
this.getScore().insertResult(player);
|
||||||
|
player.setGameMode(GameMode.SPECTATOR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart() {
|
||||||
|
getPlayers().forEach(player -> {
|
||||||
|
player.setGameMode(GameMode.SURVIVAL);
|
||||||
|
resetPlayer(player);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onBlockPlace(@NotNull PlayerBlockPlaceEvent playerBlockPlaceEvent) {
|
||||||
|
if(isBeforeBeginning) playerBlockPlaceEvent.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void resetPlayer(Player player) {
|
||||||
|
if(isBeforeBeginning) return;
|
||||||
|
PlayerInventory inventory = player.getInventory();
|
||||||
|
inventory.clear();
|
||||||
|
inventory.addItemStack(ItemStack.of(Material.WHITE_WOOL, 64));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized Pos getSpawn() {
|
||||||
|
return new Pos(24, -60, currentSpawn++*Chunk.CHUNK_SIZE_Z*2-8, -90, 0);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,23 @@
|
|||||||
|
package eu.mhsl.minenet.minigames.instance.game.stateless.types.fastbridge;
|
||||||
|
|
||||||
|
import net.minestom.server.instance.block.Block;
|
||||||
|
import net.minestom.server.instance.generator.GenerationUnit;
|
||||||
|
import net.minestom.server.instance.generator.Generator;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class FastbridgeChunkgenerator implements Generator {
|
||||||
|
@Override
|
||||||
|
public void generate(@NotNull GenerationUnit unit) {
|
||||||
|
if (unit.absoluteStart().chunkZ() % 2 == 0) {
|
||||||
|
unit.modifier().fill(Block.BARRIER);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (unit.absoluteStart().chunkX() != 1 && unit.absoluteStart().chunkX() != 3) return;
|
||||||
|
for (int x = 5; x <= 10; x++){
|
||||||
|
for (int z = 5; z <= 10; z++){
|
||||||
|
unit.modifier().setRelative(x, 2, z, unit.absoluteStart().chunkX() == 3 ? Block.GOLD_BLOCK : Block.GRASS_BLOCK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,22 @@
|
|||||||
|
package eu.mhsl.minenet.minigames.instance.game.stateless.types.fastbridge;
|
||||||
|
|
||||||
|
import eu.mhsl.minenet.minigames.instance.game.Game;
|
||||||
|
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.room.Room;
|
||||||
|
import eu.mhsl.minenet.minigames.message.component.TranslatedComponent;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class FastbridgeFactory implements GameFactory {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TranslatedComponent name() {
|
||||||
|
return TranslatedComponent.byId("game_Fastbridge#name");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Game manufacture(Room parent, Map<String, Option<?>> configuration) throws Exception {
|
||||||
|
return new Fastbridge().setParent(parent);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user