• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

CyclopsMC / IntegratedDynamics / 22181546457

19 Feb 2026 12:20PM UTC coverage: 46.183% (+0.8%) from 45.359%
22181546457

push

github

rubensworks
Merge branch 'feature/performance-tracking' into master-1.21-lts

2841 of 8850 branches covered (32.1%)

Branch coverage included in aggregate %.

12409 of 24171 relevant lines covered (51.34%)

2.44 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

48.72
/src/main/java/org/cyclops/integrateddynamics/command/CommandNetworkDiagnostics.java
1
package org.cyclops.integrateddynamics.command;
2

3
import com.mojang.brigadier.Command;
4
import com.mojang.brigadier.arguments.IntegerArgumentType;
5
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
6
import com.mojang.brigadier.context.CommandContext;
7
import com.mojang.brigadier.exceptions.CommandSyntaxException;
8
import net.minecraft.commands.CommandSourceStack;
9
import net.minecraft.commands.Commands;
10
import org.cyclops.cyclopscore.command.argument.ArgumentTypeEnum;
11
import org.cyclops.integrateddynamics.GeneralConfig;
12
import org.cyclops.integrateddynamics.IntegratedDynamics;
13
import org.cyclops.integrateddynamics.core.network.diagnostics.NetworkDiagnostics;
14
import org.cyclops.integrateddynamics.network.packet.NetworkDiagnosticsTriggerClient;
15

16
/**
17
 * Command for opening the network diagnostics gui.
18
 * @author rubensworks
19
 *
20
 */
21
public class CommandNetworkDiagnostics implements Command<CommandSourceStack> {
22

23
    private final boolean operationArg;
24
    private final boolean portArg;
25

26
    public CommandNetworkDiagnostics(boolean operationArg, boolean portArg) {
2✔
27
        this.operationArg = operationArg;
3✔
28
        this.portArg = portArg;
3✔
29
    }
1✔
30

31
    @Override
32
    public int run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
33
        StartStop operation = this.operationArg ? ArgumentTypeEnum.getValue(context, "operation", StartStop.class) : StartStop.START;
×
34
        int port = this.portArg ? IntegerArgumentType.getInteger(context, "port") : GeneralConfig.diagnosticsWebServerPort;
×
35
        IntegratedDynamics._instance.getPacketHandler().sendToPlayer
×
36
                (new NetworkDiagnosticsTriggerClient(operation == StartStop.START, port),
×
37
                context.getSource().getPlayerOrException()
×
38
        );
39
        return 0;
×
40
    }
41

42
    public static LiteralArgumentBuilder<CommandSourceStack> make() {
43
        LiteralArgumentBuilder<CommandSourceStack> builder = Commands.literal("networkdiagnostics")
3✔
44
                .requires((commandSource) -> commandSource.hasPermission(2))
7✔
45
                .executes(new CommandNetworkDiagnostics(false, false));
3✔
46

47
        // Add the operation/port subcommand chain
48
        builder.then(Commands.argument("operation", new ArgumentTypeEnum(StartStop.class))
14✔
49
                .executes(new CommandNetworkDiagnostics(true, false))
2✔
50
                .then(Commands.argument("port", IntegerArgumentType.integer())
8✔
51
                    .executes(new CommandNetworkDiagnostics(true, true))));
1✔
52

53
        // Add the measure subcommand
54
        builder.then(Commands.literal("measure")
9✔
55
                .executes(new CommandMeasure(false))
5✔
56
                .then(Commands.argument("seconds", IntegerArgumentType.integer(1, 600))
7✔
57
                        .executes(new CommandMeasure(true))));
1✔
58

59
        return builder;
2✔
60
    }
61

62
    public static enum StartStop {
×
63
        START,
×
64
        STOP;
×
65
    }
66

67
    /**
68
     * Subcommand for measuring network tick times.
69
     */
70
    public static class CommandMeasure implements Command<CommandSourceStack> {
71
        private final boolean hasSecondsArg;
72

73
        public CommandMeasure(boolean hasSecondsArg) {
2✔
74
            this.hasSecondsArg = hasSecondsArg;
3✔
75
        }
1✔
76

77
        @Override
78
        public int run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
79
            int seconds = hasSecondsArg ? IntegerArgumentType.getInteger(context, "seconds") : 10;
×
80
            NetworkDiagnostics.getInstance().startMeasurement(context.getSource().getPlayerOrException(), seconds);
×
81
            return 0;
×
82
        }
83
    }
84
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc