the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1/*
2package net.minecraft.commands.common;
3
4import java.util.List;
5
6import net.minecraft.commands.*;
7import net.minecraft.commands.exceptions.UsageException;
8import net.minecraft.locale.I18n;
9import net.minecraft.network.chat.ChatMessageComponent;
10import net.minecraft.server.MinecraftServer;
11
12public class GameDifficultyCommand extends BaseCommand {
13
14 // note: copied from Options.java, move to shared location?
15 private static final String[] DIFFICULTY_NAMES = {
16 "options.difficulty.peaceful", "options.difficulty.easy", "options.difficulty.normal", "options.difficulty.hard"
17 };
18
19 @Override
20 public String getName() {
21 return "difficulty";
22 }
23
24 @Override
25 public int getPermissionLevel() {
26 return LEVEL_GAMEMASTERS;
27 }
28
29
30 @Override
31 public String getUsage(CommandSender source) {
32 return "commands.difficulty.usage";
33 }
34
35 @Override
36 public void execute(CommandSender source, String[] args) {
37 if (args.length > 0) {
38 int newDiff = getDifficultyForString(source, args[0]);
39
40 MinecraftServer.getInstance().setDifficulty(newDiff);
41
42 logAdminAction(source, "commands.difficulty.success", ChatMessageComponent.forTranslation(DIFFICULTY_NAMES[newDiff]));
43
44 return;
45 }
46
47 throw new UsageException("commands.difficulty.usage");
48 }
49
50 protected int getDifficultyForString(CommandSender source, String name) {
51 if (name.equalsIgnoreCase("peaceful") || name.equalsIgnoreCase("p")) {
52 return 0;
53 } else if (name.equalsIgnoreCase("easy") || name.equalsIgnoreCase("e")) {
54 return 1;
55 } else if (name.equalsIgnoreCase("normal") || name.equalsIgnoreCase("n")) {
56 return 2;
57 } else if (name.equalsIgnoreCase("hard") || name.equalsIgnoreCase("h")) {
58 return 3;
59 } else {
60 return convertArgToInt(source, name, 0, 3);
61 }
62 }
63
64 @Override
65 public List<String> matchArguments(CommandSender source, String[] args) {
66 if (args.length == 1) {
67 return matchArguments(args, "peaceful", "easy", "normal", "hard");
68 }
69
70 return null;
71 }
72
73}
74
75*/