| Total Complexity | 2 |
| Total Lines | 26 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | package de.pewpewproject.lasertag.command.lasertag.game; |
||
| 19 | public class LeaveLasertagTeamCommand extends ServerFeedbackCommand { |
||
| 20 | protected Optional<CommandFeedback> execute(CommandContext<ServerCommandSource> context) { |
||
| 21 | |||
| 22 | // Get the game managers |
||
| 23 | var gameManager = context.getSource().getWorld().getServerLasertagManager(); |
||
| 24 | var teamsManager = gameManager.getTeamsManager(); |
||
| 25 | |||
| 26 | // Get the server |
||
| 27 | var server = context.getSource().getServer(); |
||
| 28 | |||
| 29 | // Get executing player |
||
| 30 | var player = context.getSource().getPlayer(); |
||
| 31 | |||
| 32 | // Leave team |
||
| 33 | teamsManager.playerLeaveHisTeam(player); |
||
| 34 | |||
| 35 | // Clear inventory |
||
| 36 | player.getInventory().clear(); |
||
| 37 | |||
| 38 | // Notify player in chat |
||
| 39 | return Optional.of(new CommandFeedback(Text.literal("You left your team"), true, false)); |
||
| 40 | } |
||
| 41 | |||
| 42 | static void register(LiteralArgumentBuilder<ServerCommandSource> lab) { |
||
| 43 | lab.then(literal("leaveTeam") |
||
| 44 | .executes(new LeaveLasertagTeamCommand())); |
||
| 45 | } |
||
| 47 |