started fixing pr comments
This commit is contained in:
parent
e663f3f105
commit
0699206c21
@ -89,5 +89,5 @@ tasks.register('copyJarToServer', Exec) {
|
|||||||
dependsOn shadowJar
|
dependsOn shadowJar
|
||||||
mustRunAfter 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'
|
||||||
}
|
}
|
||||||
|
@ -27,9 +27,7 @@ public class PrivilegedCommand extends Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected CommandCondition isPrivileged() {
|
protected CommandCondition isPrivileged() {
|
||||||
//TODO
|
return (sender, commandString) -> sender.hasPermission("admin");
|
||||||
// return (sender, commandString) -> sender.hasPermission("admin");
|
|
||||||
return (sender, commandString) -> true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addCondition(CommandCondition condition) {
|
protected void addCondition(CommandCondition condition) {
|
||||||
|
@ -100,7 +100,7 @@ public class StatelessGame extends Game {
|
|||||||
countdownUnload();
|
countdownUnload();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void countdownUnload() {
|
private void countdownUnload() {
|
||||||
new TitleMessage(Duration.ofSeconds(1)).appendTranslated("score#done").send(getPlayers());
|
new TitleMessage(Duration.ofSeconds(1)).appendTranslated("score#done").send(getPlayers());
|
||||||
scheduler().scheduleTask(this::unload, TaskSchedule.seconds(5), TaskSchedule.stop());
|
scheduler().scheduleTask(this::unload, TaskSchedule.seconds(5), TaskSchedule.stop());
|
||||||
}
|
}
|
||||||
|
@ -18,12 +18,13 @@ import net.minestom.server.item.ItemStack;
|
|||||||
import net.minestom.server.item.Material;
|
import net.minestom.server.item.Material;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
import java.util.WeakHashMap;
|
||||||
|
|
||||||
class Tetris extends StatelessGame {
|
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 int nextTetrominoesCount;
|
||||||
private final boolean isFast;
|
private final boolean isFast;
|
||||||
private final boolean hasCombat;
|
private final boolean hasCombat;
|
||||||
@ -53,7 +54,7 @@ class Tetris extends StatelessGame {
|
|||||||
.forEach(Entity::remove);
|
.forEach(Entity::remove);
|
||||||
|
|
||||||
if(this.hasCombat) {
|
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());
|
this.tetrisGames.forEach((player, tetrisGame) -> tetrisGame.start());
|
||||||
@ -76,6 +77,8 @@ class Tetris extends StatelessGame {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPlayerMove(@NotNull PlayerMoveEvent event) {
|
protected void onPlayerMove(@NotNull PlayerMoveEvent event) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Pos previousPosition = event.getPlayer().getPosition();
|
Pos previousPosition = event.getPlayer().getPosition();
|
||||||
Pos currentPosition = event.getNewPosition();
|
Pos currentPosition = event.getNewPosition();
|
||||||
@ -103,15 +106,16 @@ class Tetris extends StatelessGame {
|
|||||||
double forwardAmount = movementVector.dot(forward);
|
double forwardAmount = movementVector.dot(forward);
|
||||||
double leftAmount = movementVector.dot(left);
|
double leftAmount = movementVector.dot(left);
|
||||||
|
|
||||||
if (forwardAmount > 0.018) {
|
double buttonPressAmount = 0.018;
|
||||||
|
if (forwardAmount > buttonPressAmount) {
|
||||||
tetrisGame.pressedButton(TetrisGame.Button.W);
|
tetrisGame.pressedButton(TetrisGame.Button.W);
|
||||||
} else if (forwardAmount < -0.018) {
|
} else if (forwardAmount < -buttonPressAmount) {
|
||||||
tetrisGame.pressedButton(TetrisGame.Button.S);
|
tetrisGame.pressedButton(TetrisGame.Button.S);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (leftAmount > 0.018) {
|
if (leftAmount > buttonPressAmount) {
|
||||||
tetrisGame.pressedButton(TetrisGame.Button.D);
|
tetrisGame.pressedButton(TetrisGame.Button.D);
|
||||||
} else if (leftAmount < -0.018) {
|
} else if (leftAmount < -buttonPressAmount) {
|
||||||
tetrisGame.pressedButton(TetrisGame.Button.A);
|
tetrisGame.pressedButton(TetrisGame.Button.A);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user