aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/thatgravyboat/skyblockhud/commands/Commands.java
blob: 8304906f6662f9e114c717b8e6493457ebe15715 (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
package com.thatgravyboat.skyblockhud.commands;

import com.thatgravyboat.skyblockhud.SkyblockHud;
import com.thatgravyboat.skyblockhud.config.SBHConfigEditor;
import com.thatgravyboat.skyblockhud.core.GuiScreenElementWrapper;
import com.thatgravyboat.skyblockhud.handlers.MapHandler;
import com.thatgravyboat.skyblockhud.location.LocationHandler;
import net.minecraft.client.Minecraft;
import net.minecraft.command.ICommandSender;
import net.minecraftforge.client.ClientCommandHandler;
import org.apache.commons.lang3.StringUtils;

public class Commands {

    private static final SimpleCommand.ProcessCommandRunnable settingsRunnable = new SimpleCommand.ProcessCommandRunnable() {
        public void processCommand(ICommandSender sender, String[] args) {
            if (args.length > 0) {
                SkyblockHud.screenToOpen =
                    new GuiScreenElementWrapper(new SBHConfigEditor(SkyblockHud.config, StringUtils.join(args, " ")));
            } else {
                SkyblockHud.screenToOpen = new GuiScreenElementWrapper(new SBHConfigEditor(SkyblockHud.config));
            }
        }
    };

    private static final SimpleCommand settingsCommand = new SimpleCommand("sbh", settingsRunnable);
    private static final SimpleCommand settingsCommand2 = new SimpleCommand("sbhsettings", settingsRunnable);
    private static final SimpleCommand settingsCommand3 = new SimpleCommand("sbhud", settingsRunnable);

    private static final SimpleCommand mapCommand = new SimpleCommand(
        "sbhmap",
        new SimpleCommand.ProcessCommandRunnable() {
            public void processCommand(ICommandSender sender, String[] args) {
                if (LocationHandler.getCurrentLocation().getCategory().getMap() != null) SkyblockHud.screenToOpen =
                    new MapHandler.MapScreen();
            }
        }
    );

    public static void init() {
        ClientCommandHandler.instance.registerCommand(settingsCommand);
        ClientCommandHandler.instance.registerCommand(settingsCommand2);
        ClientCommandHandler.instance.registerCommand(settingsCommand3);
        ClientCommandHandler.instance.registerCommand(mapCommand);
    }
}