blob: 326c00b483a782daf280775700772c9dcb4353d2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
/*
* Copyright (C) 2022 NotEnoughUpdates contributors
*
* This file is part of NotEnoughUpdates.
*
* NotEnoughUpdates is free software: you can redistribute it
* and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* NotEnoughUpdates is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>.
*/
package io.github.moulberry.notenoughupdates.commands.dev;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.commands.ClientCommandBase;
import io.github.moulberry.notenoughupdates.miscfeatures.CrystalMetalDetectorSolver;
import io.github.moulberry.notenoughupdates.miscfeatures.CrystalWishingCompassSolver;
import io.github.moulberry.notenoughupdates.options.customtypes.NEUDebugFlag;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting;
public class DiagCommand extends ClientCommandBase {
public DiagCommand() {
super("neudiag");
}
private static final String USAGE_TEXT = EnumChatFormatting.WHITE +
"Usage: /neudiag <metal | wishing | debug>\n\n" +
"/neudiag metal Metal Detector Solver diagnostics\n" +
" <no sub-command> Show current solution diags\n" +
" center=<off | on> Disable / enable using center\n" +
"/neudiag wishing Wishing Compass Solver diagnostics\n" +
"/neudiag debug\n" +
" <no sub-command> Show current flags\n" +
" <enable | disable> <flag> Enable/disable flag\n";
private void showUsage(ICommandSender sender) {
sender.addChatMessage(new ChatComponentText(USAGE_TEXT));
}
@Override
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
if (args.length == 0) {
showUsage(sender);
return;
}
String command = args[0].toLowerCase();
switch (command) {
case "metal":
if (args.length == 1) {
CrystalMetalDetectorSolver.logDiagnosticData(true);
return;
}
String subCommand = args[1].toLowerCase();
if (subCommand.equals("center=off")) {
CrystalMetalDetectorSolver.setDebugDoNotUseCenter(true);
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW +
"Center coordinates-based solutions disabled"));
} else if (subCommand.equals("center=on")) {
CrystalMetalDetectorSolver.setDebugDoNotUseCenter(false);
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW +
"Center coordinates-based solutions enabled"));
} else {
showUsage(sender);
return;
}
break;
case "wishing":
CrystalWishingCompassSolver.getInstance().logDiagnosticData(true);
break;
case "debug":
if (args.length > 1) {
boolean enablingFlag = true;
String action = args[1];
switch (action) {
case "disable":
enablingFlag = false;
// falls through
case "enable":
if (args.length != 3) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED +
"You must specify a flag:\n" +
NEUDebugFlag.FLAG_LIST));
return;
}
String flagName = args[2].toUpperCase();
try {
NEUDebugFlag debugFlag = NEUDebugFlag.valueOf(flagName);
if (enablingFlag) {
NotEnoughUpdates.INSTANCE.config.hidden.debugFlags.add(debugFlag);
} else {
NotEnoughUpdates.INSTANCE.config.hidden.debugFlags.remove(debugFlag);
}
} catch (IllegalArgumentException e) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED +
flagName + " is invalid. Valid flags are:\n" +
NEUDebugFlag.FLAG_LIST));
return;
}
break;
default:
showUsage(sender);
return;
}
}
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Effective debug flags: " +
NotEnoughUpdates.INSTANCE.config.hidden.debugFlags.toString()));
break;
default:
showUsage(sender);
return;
}
}
}
|