de.pewpewproject.lasertag.command.lasertag.game.StopLasertagGameCommand   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 15
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute(CommandContext) 0 8 1
A register(LiteralArgumentBuilder) 0 4 1
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