develop-anvilRun #1
| @@ -27,7 +27,8 @@ public class PrivilegedCommand extends Command { | ||||
|     } | ||||
|  | ||||
|     protected CommandCondition isPrivileged() { | ||||
|         return (sender, commandString) -> sender.hasPermission("admin"); | ||||
| //        return (sender, commandString) -> sender.hasPermission("admin"); | ||||
|         return (sender, commandString) -> true; | ||||
|     } | ||||
|  | ||||
|     protected void addCondition(CommandCondition condition) { | ||||
|   | ||||
| @@ -0,0 +1,63 @@ | ||||
| package eu.mhsl.minenet.minigames.instance.game.stateless.types.anvilRun; | ||||
|  | ||||
| import eu.mhsl.minenet.minigames.instance.game.stateless.StatelessGame; | ||||
| import eu.mhsl.minenet.minigames.score.LastWinsScore; | ||||
| import eu.mhsl.minenet.minigames.instance.Dimension; | ||||
| import eu.mhsl.minenet.minigames.world.generator.terrain.CircularPlateTerrainGenerator; | ||||
| import net.minestom.server.coordinate.Pos; | ||||
| import net.minestom.server.entity.Entity; | ||||
| import net.minestom.server.entity.EntityType; | ||||
| import net.minestom.server.entity.metadata.other.FallingBlockMeta; | ||||
| import net.minestom.server.event.player.PlayerMoveEvent; | ||||
| import net.minestom.server.instance.block.Block; | ||||
| import org.jetbrains.annotations.NotNull; | ||||
|  | ||||
| import java.util.concurrent.CompletableFuture; | ||||
|  | ||||
| class AnvilRun extends StatelessGame { | ||||
|  | ||||
|     final int radius; | ||||
|  | ||||
|     public AnvilRun(int radius, int pvpEnabled) { | ||||
|         super(Dimension.THE_END.key, "Deathcube", new LastWinsScore()); | ||||
|         this.radius = radius; | ||||
|         this.setGenerator(new CircularPlateTerrainGenerator(radius).setPlateHeight(50)); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     protected void onLoad(@NotNull CompletableFuture<Void> callback) { | ||||
|         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; | ||||
|  | ||||
|                 int height = super.rnd.nextInt(100, 500); | ||||
|                 Entity anvil = new Entity(EntityType.FALLING_BLOCK); | ||||
|                 ((FallingBlockMeta) anvil.getEntityMeta()).setBlock(Block.ANVIL); | ||||
|                 anvil.setNoGravity(true); | ||||
|  | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     protected void onStart() { | ||||
|         super.onStart(); | ||||
|  | ||||
|         // Liste mit anvils | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     protected void onPlayerMove(@NotNull PlayerMoveEvent playerMoveEvent) { | ||||
|         super.onPlayerMove(playerMoveEvent); | ||||
|         if(isBeforeBeginning && playerMoveEvent.getNewPosition().y() < 48.5) { | ||||
|             playerMoveEvent.setCancelled(true); | ||||
|             playerMoveEvent.getPlayer().teleport(getSpawn()); | ||||
|         } | ||||
|         if(playerMoveEvent.getNewPosition().y() < 48.5) getScore().insertResult(playerMoveEvent.getPlayer()); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public Pos getSpawn() { | ||||
|         return new Pos(0, 0, 30); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,42 @@ | ||||
| package eu.mhsl.minenet.minigames.instance.game.stateless.types.anvilRun; | ||||
|  | ||||
| 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.game.stateless.config.ConfigManager; | ||||
| import eu.mhsl.minenet.minigames.instance.game.stateless.config.common.NumericOption; | ||||
| import eu.mhsl.minenet.minigames.instance.room.Room; | ||||
| import eu.mhsl.minenet.minigames.message.component.TranslatedComponent; | ||||
| import net.minestom.server.item.Material; | ||||
|  | ||||
| import java.util.Map; | ||||
|  | ||||
| public class AnvilRunFactory implements GameFactory { | ||||
|     @Override | ||||
|     public TranslatedComponent name() { | ||||
|         return TranslatedComponent.byId("game_AnvilRun#name"); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public TranslatedComponent description() { | ||||
|         return TranslatedComponent.byId("game_AnvilRun#description"); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public ConfigManager configuration() { | ||||
|         return new ConfigManager() | ||||
|             .addOption(new NumericOption("radius", Material.HEART_OF_THE_SEA, TranslatedComponent.byId("optionCommon#radius"), 10, 20, 30)) | ||||
|             .addOption(new NumericOption("pvpEnabled", Material.STICK, TranslatedComponent.byId("game_Deathcube#optionPvpEnabled"), 1, 0)); | ||||
|  | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public Game manufacture(Room parent, Map<String, Option<?>> configuration) { | ||||
|         return new AnvilRun(configuration.get("radius").getAsInt(), configuration.get("pvpEnabled").getAsInt()).setParent(parent); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public Material symbol() { | ||||
|         return Material.ANVIL; | ||||
|     } | ||||
| } | ||||
| @@ -6,9 +6,6 @@ import eu.mhsl.minenet.minigames.util.BatchUtil; | ||||
| import eu.mhsl.minenet.minigames.instance.Dimension; | ||||
| import eu.mhsl.minenet.minigames.world.BlockPallet; | ||||
| import eu.mhsl.minenet.minigames.world.generator.terrain.CircularPlateTerrainGenerator; | ||||
| import io.github.togar2.pvp.config.AttackConfig; | ||||
| import io.github.togar2.pvp.config.DamageConfig; | ||||
| import io.github.togar2.pvp.config.PvPConfig; | ||||
| import net.minestom.server.coordinate.Pos; | ||||
| import net.minestom.server.event.player.PlayerMoveEvent; | ||||
| import net.minestom.server.instance.batch.AbsoluteBlockBatch; | ||||
| @@ -27,7 +24,7 @@ class Deathcube extends StatelessGame { | ||||
|         this.radius = radius; | ||||
|         this.height = height + 49; | ||||
|         this.percentage = percentage; | ||||
|         this.setGenerator(new CircularPlateTerrainGenerator(radius+10).setPlateHeight(50)); | ||||
|         this.setGenerator(new CircularPlateTerrainGenerator(radius+10).setPlateHeight(50).setGenerateBorders(true)); | ||||
|  | ||||
| //        if(pvpEnabled == 1) eventNode().addChild( // TODO update | ||||
| //                PvPConfig.emptyBuilder() | ||||
| @@ -66,6 +63,6 @@ class Deathcube extends StatelessGame { | ||||
|  | ||||
|     @Override | ||||
|     public Pos getSpawn() { | ||||
|         return new Pos(0, 50, 30); | ||||
|         return new Pos(0, radius+5, 30); | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user