execute(CommandContext)   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
package de.pewpewproject.lasertag.command.lasertag.game;
2
3
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
4
import com.mojang.brigadier.context.CommandContext;
5
import de.pewpewproject.lasertag.command.CommandFeedback;
6
import de.pewpewproject.lasertag.command.ServerFeedbackCommand;
7
import net.minecraft.server.command.ServerCommandSource;
8
9
import java.util.Optional;
10
11
import static net.minecraft.server.command.CommandManager.literal;
12
13
/**
14
 * The stop lasertag game command
15
 *
16
 * @author Étienne Muser
17
 */
18
public class StopLasertagGameCommand extends ServerFeedbackCommand {
19
    protected Optional<CommandFeedback> execute(CommandContext<ServerCommandSource> context) {
20
21
        // Get the game managers
22
        var gameManager = context.getSource().getWorld().getServerLasertagManager();
23
24
        gameManager.stopLasertagGame();
25
26
        return Optional.empty();
27
    }
28
29
    static void register(LiteralArgumentBuilder<ServerCommandSource> lab) {
30
        lab.then(literal("stopLasertagGame")
31
                .requires(s -> s.hasPermissionLevel(1))
32
                .executes(new StopLasertagGameCommand()));
33
    }
34
}
35