aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/djtheredstoner/perspectivemod/commands/PerspectiveModCommand.java
blob: cad7f79787902a6de48f84b6217219e70defc078 (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
package me.djtheredstoner.perspectivemod.commands;

import club.sk1er.mods.core.ModCore;
import me.djtheredstoner.perspectivemod.PerspectiveMod;
import net.minecraft.client.Minecraft;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.util.ChatComponentText;

import java.util.Collections;
import java.util.List;

public class PerspectiveModCommand extends CommandBase {

    private final String PREFIX = "§c[§6Perspective Mod§c] §r";

    @Override
    public String getCommandName() {
        return "perspectivemod";
    }

    @Override
    public List<String> getCommandAliases() {
        return Collections.singletonList("pmod");
    }

    @Override
    public String getCommandUsage(ICommandSender sender) {
        return "§6Perspective Mod Help\n" +
            "§b/pmod <enable|disable> §7- Enables or disables the mod.\n" +
            "§b/pmod mode <hold|toggle> §7- Changes the mode.\n" +
            "§7Edit the keybind in the minecraft controls menu.";
    }

    @Override
    public void processCommand(ICommandSender sender, String[] args) {
        if (args.length == 1 && args[0].equals("eW91IGZvdW5kIGEgc2VjcmV0IQo=")) {
            sendMessage("you found a secret!");
        } else {
            ModCore.getInstance().getGuiHandler().open(PerspectiveMod.instance.config.gui());
        }
    }

    @Override
    public int getRequiredPermissionLevel() {
        return -1;
    }

    private void sendHelp() {
        sendMessage(getCommandUsage(Minecraft.getMinecraft().thePlayer), false);
    }

    private void sendMessage(String message, boolean addPrefix) {
        Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText((addPrefix ? PREFIX : "") + message));
    }

    private void sendMessage(String message) {
        sendMessage(message, true);
    }
}