Added /mode command, and improved redfort world.
This commit is contained in:
parent
53b8718a06
commit
3e26a33f5a
|
@ -47,7 +47,7 @@ public class PlayerManager {
|
||||||
joinMessage = username + " joined the game.";
|
joinMessage = username + " joined the game.";
|
||||||
}
|
}
|
||||||
player.setPosition(getBestSpawnPoint(player));
|
player.setPosition(getBestSpawnPoint(player));
|
||||||
player.setMode(PlayerMode.CREATIVE);
|
player.setMode(PlayerMode.NORMAL);
|
||||||
// Tell all other players that this one has joined.
|
// Tell all other players that this one has joined.
|
||||||
broadcastTcpMessageToAllBut(new PlayerJoinMessage(
|
broadcastTcpMessageToAllBut(new PlayerJoinMessage(
|
||||||
player.getId(), player.getUsername(), player.getTeam() == null ? -1 : player.getTeam().getId(),
|
player.getId(), player.getUsername(), player.getTeam() == null ? -1 : player.getTeam().getId(),
|
||||||
|
|
|
@ -4,6 +4,7 @@ import nl.andrewl.aos2_server.ClientCommunicationHandler;
|
||||||
import nl.andrewl.aos2_server.Server;
|
import nl.andrewl.aos2_server.Server;
|
||||||
import nl.andrewl.aos2_server.cli.ingame.commands.KillCommand;
|
import nl.andrewl.aos2_server.cli.ingame.commands.KillCommand;
|
||||||
import nl.andrewl.aos2_server.cli.ingame.commands.KillDeathRatioCommand;
|
import nl.andrewl.aos2_server.cli.ingame.commands.KillDeathRatioCommand;
|
||||||
|
import nl.andrewl.aos2_server.cli.ingame.commands.PlayerModeCommand;
|
||||||
import nl.andrewl.aos2_server.model.ServerPlayer;
|
import nl.andrewl.aos2_server.model.ServerPlayer;
|
||||||
import nl.andrewl.aos_core.net.client.ChatMessage;
|
import nl.andrewl.aos_core.net.client.ChatMessage;
|
||||||
|
|
||||||
|
@ -25,6 +26,7 @@ public class PlayerCommandHandler {
|
||||||
commands = new HashMap<>();
|
commands = new HashMap<>();
|
||||||
commands.put("kd", new KillDeathRatioCommand());
|
commands.put("kd", new KillDeathRatioCommand());
|
||||||
commands.put("kill", new KillCommand());
|
commands.put("kill", new KillCommand());
|
||||||
|
commands.put("mode", new PlayerModeCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handle(String rawCommand, ServerPlayer player, ClientCommunicationHandler handler) {
|
public void handle(String rawCommand, ServerPlayer player, ClientCommunicationHandler handler) {
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
package nl.andrewl.aos2_server.cli.ingame.commands;
|
||||||
|
|
||||||
|
import nl.andrewl.aos2_server.ClientCommunicationHandler;
|
||||||
|
import nl.andrewl.aos2_server.Server;
|
||||||
|
import nl.andrewl.aos2_server.cli.ingame.PlayerCommand;
|
||||||
|
import nl.andrewl.aos2_server.model.ServerPlayer;
|
||||||
|
import nl.andrewl.aos_core.model.PlayerMode;
|
||||||
|
import nl.andrewl.aos_core.net.client.ChatMessage;
|
||||||
|
|
||||||
|
public class PlayerModeCommand implements PlayerCommand {
|
||||||
|
@Override
|
||||||
|
public void handle(String[] args, ServerPlayer player, ClientCommunicationHandler handler, Server server) {
|
||||||
|
if (args.length < 1) {
|
||||||
|
handler.sendTcpMessage(ChatMessage.privateMessage("Missing required mode argument."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String modeText = args[0].trim().toUpperCase();
|
||||||
|
try {
|
||||||
|
PlayerMode mode = PlayerMode.valueOf(modeText);
|
||||||
|
player.setMode(mode);
|
||||||
|
server.getPlayerManager().broadcastUdpMessage(player.getUpdateMessage(System.currentTimeMillis()));
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
handler.sendTcpMessage(ChatMessage.privateMessage("Invalid mode. Should be NORMAL, CREATIVE, or SPECTATOR."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -100,8 +100,7 @@ public class PlayerActionManager {
|
||||||
|
|
||||||
updated = switch (player.getMode()) {
|
updated = switch (player.getMode()) {
|
||||||
case NORMAL -> normalMovementController.tickMovement(dt, player, input, server, world, server.getConfig().physics);
|
case NORMAL -> normalMovementController.tickMovement(dt, player, input, server, world, server.getConfig().physics);
|
||||||
case CREATIVE -> creativeMovementController.tickMovement(dt, player, input, server, world, server.getConfig().physics);
|
case CREATIVE, SPECTATOR -> creativeMovementController.tickMovement(dt, player, input, server, world, server.getConfig().physics);
|
||||||
case SPECTATOR -> false;
|
|
||||||
} || updated;
|
} || updated;
|
||||||
input.reset(); // Reset our input state after processing this tick's player input.
|
input.reset(); // Reset our input state after processing this tick's player input.
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue