started fixing pr comments

This commit is contained in:
Lars Neuhaus 2024-11-23 14:26:19 +01:00
parent e663f3f105
commit 0699206c21
4 changed files with 14 additions and 12 deletions

View File

@ -89,5 +89,5 @@ tasks.register('copyJarToServer', Exec) {
dependsOn shadowJar
mustRunAfter shadowJar
commandLine 'scp', 'build/libs/Minigames-1.0-SNAPSHOT.jar', '/home/lars/Documents/Minecraft Server/minigames'
commandLine 'scp', 'build/libs/Minigames-1.0-SNAPSHOT.jar', 'root@10.20.6.5:/root/minigames'
}

View File

@ -27,9 +27,7 @@ public class PrivilegedCommand extends Command {
}
protected CommandCondition isPrivileged() {
//TODO
// return (sender, commandString) -> sender.hasPermission("admin");
return (sender, commandString) -> true;
return (sender, commandString) -> sender.hasPermission("admin");
}
protected void addCondition(CommandCondition condition) {

View File

@ -100,7 +100,7 @@ public class StatelessGame extends Game {
countdownUnload();
}
protected void countdownUnload() {
private void countdownUnload() {
new TitleMessage(Duration.ofSeconds(1)).appendTranslated("score#done").send(getPlayers());
scheduler().scheduleTask(this::unload, TaskSchedule.seconds(5), TaskSchedule.stop());
}

View File

@ -18,12 +18,13 @@ import net.minestom.server.item.ItemStack;
import net.minestom.server.item.Material;
import org.jetbrains.annotations.NotNull;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.WeakHashMap;
class Tetris extends StatelessGame {
private final Map<Player, TetrisGame> tetrisGames = new HashMap<>();
private final Map<Player, TetrisGame> tetrisGames = new WeakHashMap<>();
private final int nextTetrominoesCount;
private final boolean isFast;
private final boolean hasCombat;
@ -53,7 +54,7 @@ class Tetris extends StatelessGame {
.forEach(Entity::remove);
if(this.hasCombat) {
this.tetrisGames.forEach((player, tetrisGame) -> tetrisGame.updateOtherTetrisGames(this.tetrisGames.values().stream().toList()));
this.tetrisGames.values().forEach(tetrisGame -> tetrisGame.updateOtherTetrisGames((List<TetrisGame>) this.tetrisGames.values()));
}
this.tetrisGames.forEach((player, tetrisGame) -> tetrisGame.start());
@ -76,6 +77,8 @@ class Tetris extends StatelessGame {
@Override
protected void onPlayerMove(@NotNull PlayerMoveEvent event) {
event.setCancelled(true);
Player player = event.getPlayer();
Pos previousPosition = event.getPlayer().getPosition();
Pos currentPosition = event.getNewPosition();
@ -103,15 +106,16 @@ class Tetris extends StatelessGame {
double forwardAmount = movementVector.dot(forward);
double leftAmount = movementVector.dot(left);
if (forwardAmount > 0.018) {
double buttonPressAmount = 0.018;
if (forwardAmount > buttonPressAmount) {
tetrisGame.pressedButton(TetrisGame.Button.W);
} else if (forwardAmount < -0.018) {
} else if (forwardAmount < -buttonPressAmount) {
tetrisGame.pressedButton(TetrisGame.Button.S);
}
if (leftAmount > 0.018) {
if (leftAmount > buttonPressAmount) {
tetrisGame.pressedButton(TetrisGame.Button.D);
} else if (leftAmount < -0.018) {
} else if (leftAmount < -buttonPressAmount) {
tetrisGame.pressedButton(TetrisGame.Button.A);
}