2222
2323package ca .tirelesstraveler .fancywarpmenu .commands ;
2424
25+ import ca .tirelesstraveler .fancywarpmenu .data .Settings ;
2526import ca .tirelesstraveler .fancywarpmenu .state .FancyWarpMenuState ;
26- import net .minecraft .command .CommandBase ;
27- import net .minecraft .command .ICommandSender ;
27+ import ca .tirelesstraveler .fancywarpmenu .utils .ChatUtils ;
28+ import net .minecraft .command .*;
29+ import net .minecraft .util .ChatComponentTranslation ;
30+ import net .minecraft .util .ChatStyle ;
31+ import net .minecraft .util .EnumChatFormatting ;
2832
2933import java .util .Collections ;
3034import java .util .List ;
3135
32- public class OpenConfigCommand extends CommandBase {
36+ /**
37+ * This is the main command of the mod.<br>
38+ * <bold>Syntax</bold><br>
39+ * <ul>
40+ * <li>/fancywarpmenu <args></li>
41+ * <li>/fwm <args></li>
42+ * </ul>
43+ * <br>
44+ * <bold>Arguments</bold>
45+ * <ul>
46+ * <li>(empty) - Open mod config menu</li>
47+ * <li>"on" or "1" - Enable Fancy Warp Menu</li>
48+ * <li>"off" or "0" - Disable Fancy Warp Menu</li>
49+ * </ul>
50+ */
51+ public class FancyWarpMenuCommand extends CommandBase {
3352 @ Override
3453 public int getRequiredPermissionLevel () {
3554 return 0 ;
@@ -42,7 +61,7 @@ public List<String> getCommandAliases() {
4261
4362 @ Override
4463 public String getCommandName () {
45- return "fancywarpmenuconfig " ;
64+ return "fancywarpmenu " ;
4665 }
4766
4867 @ Override
@@ -56,7 +75,28 @@ public String getCommandUsage(ICommandSender sender) {
5675 * The {@link net.minecraftforge.event.CommandEvent} is intercepted instead to prevent the screen from being closed.
5776 */
5877 @ Override
59- public void processCommand (ICommandSender sender , String [] args ) {
60- FancyWarpMenuState .setOpenConfigMenuRequested (true );
78+ public void processCommand (ICommandSender sender , String [] args ) throws CommandException {
79+ if (args .length > 0 ) {
80+ switch (args [0 ]) {
81+ case "1" :
82+ case "on" :
83+ Settings .setWarpMenuEnabled (true );
84+ ChatUtils .sendMessageWithModNamePrefix (
85+ new ChatComponentTranslation ("fancywarpmenu.messages.fancyWarpMenuEnabled" )
86+ .setChatStyle (new ChatStyle ().setColor (EnumChatFormatting .GREEN )));
87+ break ;
88+ case "0" :
89+ case "off" :
90+ Settings .setWarpMenuEnabled (false );
91+ ChatUtils .sendMessageWithModNamePrefix (
92+ new ChatComponentTranslation ("fancywarpmenu.messages.fancyWarpMenuDisabled" )
93+ .setChatStyle (new ChatStyle ().setColor (EnumChatFormatting .RED )));
94+ break ;
95+ default :
96+ throw new SyntaxErrorException ();
97+ }
98+ } else {
99+ FancyWarpMenuState .setOpenConfigMenuRequested (true );
100+ }
61101 }
62102}
0 commit comments