-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathCommandAuth.java
More file actions
38 lines (34 loc) · 1.6 KB
/
Copy pathCommandAuth.java
File metadata and controls
38 lines (34 loc) · 1.6 KB
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
package dev.dfonline.codeclient.command.impl;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import dev.dfonline.codeclient.ChatType;
import dev.dfonline.codeclient.CodeClient;
import dev.dfonline.codeclient.Utility;
import dev.dfonline.codeclient.command.Command;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import net.minecraft.command.CommandRegistryAccess;
import net.minecraft.text.Text;
import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal;
public class CommandAuth extends Command {
@Override
public String name() {
return "auth";
}
@Override
public LiteralArgumentBuilder<FabricClientCommandSource> create(LiteralArgumentBuilder<FabricClientCommandSource> cmd, CommandRegistryAccess registryAccess) {
return cmd.executes(context -> {
CodeClient.API.setAcceptedScopes(true);
Utility.sendMessage(Text.translatable("codeclient.api.authorised")
.append(Text.literal("\n")).append(Text.translatable("codeclient.api.remove"))
, ChatType.SUCCESS);
return 0;
}).then(literal("remove").executes(context -> {
CodeClient.API.setAcceptedScopes(false);
Utility.sendMessage(Text.translatable("codeclient.api.removed"), ChatType.SUCCESS);
return 0;
})).then(literal("disconnect").executes(context -> {
Utility.sendMessage(Text.translatable("codeclient.api.disconnected"), ChatType.SUCCESS);
CodeClient.API.setConnection(null);
return 0;
}));
}
}