You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
2.1 KiB
Java
56 lines
2.1 KiB
Java
package net.minecraft.command;
|
|
|
|
import java.util.List;
|
|
import net.minecraft.server.MinecraftServer;
|
|
import net.minecraft.util.ChatComponentTranslation;
|
|
import net.minecraft.world.EnumDifficulty;
|
|
|
|
public class CommandDifficulty extends CommandBase
|
|
{
|
|
private static final String __OBFID = "CL_00000422";
|
|
|
|
public String getCommandName()
|
|
{
|
|
return "difficulty";
|
|
}
|
|
|
|
/**
|
|
* Return the required permission level for this command.
|
|
*/
|
|
public int getRequiredPermissionLevel()
|
|
{
|
|
return 2;
|
|
}
|
|
|
|
public String getCommandUsage(ICommandSender sender)
|
|
{
|
|
return "commands.difficulty.usage";
|
|
}
|
|
|
|
public void processCommand(ICommandSender sender, String[] args)
|
|
{
|
|
if (args.length > 0)
|
|
{
|
|
EnumDifficulty enumdifficulty = this.func_147201_h(sender, args[0]);
|
|
MinecraftServer.getServer().func_147139_a(enumdifficulty);
|
|
func_152373_a(sender, this, "commands.difficulty.success", new Object[] {new ChatComponentTranslation(enumdifficulty.getDifficultyResourceKey(), new Object[0])});
|
|
}
|
|
else
|
|
{
|
|
throw new WrongUsageException("commands.difficulty.usage", new Object[0]);
|
|
}
|
|
}
|
|
|
|
protected EnumDifficulty func_147201_h(ICommandSender p_147201_1_, String p_147201_2_)
|
|
{
|
|
return !p_147201_2_.equalsIgnoreCase("peaceful") && !p_147201_2_.equalsIgnoreCase("p") ? (!p_147201_2_.equalsIgnoreCase("easy") && !p_147201_2_.equalsIgnoreCase("e") ? (!p_147201_2_.equalsIgnoreCase("normal") && !p_147201_2_.equalsIgnoreCase("n") ? (!p_147201_2_.equalsIgnoreCase("hard") && !p_147201_2_.equalsIgnoreCase("h") ? EnumDifficulty.getDifficultyEnum(parseIntBounded(p_147201_1_, p_147201_2_, 0, 3)) : EnumDifficulty.HARD) : EnumDifficulty.NORMAL) : EnumDifficulty.EASY) : EnumDifficulty.PEACEFUL;
|
|
}
|
|
|
|
/**
|
|
* Adds the strings available in this command to the given list of tab completion options.
|
|
*/
|
|
public List addTabCompletionOptions(ICommandSender sender, String[] args)
|
|
{
|
|
return args.length == 1 ? getListOfStringsMatchingLastWord(args, new String[] {"peaceful", "easy", "normal", "hard"}): null;
|
|
}
|
|
} |