22declare(strict_types=1);
24namespace pocketmine\command\defaults;
37 public function __construct(){
40 KnownTranslationFactory::pocketmine_command_difficulty_description(),
41 KnownTranslationFactory::commands_difficulty_usage()
43 $this->setPermission(DefaultPermissionNames::COMMAND_DIFFICULTY);
47 if(count($args) !== 1){
51 $difficulty = World::getDifficultyFromString($args[0]);
53 if($sender->getServer()->isHardcore()){
54 $difficulty = World::DIFFICULTY_HARD;
57 if($difficulty !== -1){
58 $sender->getServer()->getConfigGroup()->setConfigInt(ServerProperties::DIFFICULTY, $difficulty);
61 foreach($sender->getServer()->getWorldManager()->getWorlds() as $world){
62 $world->setDifficulty($difficulty);
65 Command::broadcastCommandMessage($sender, KnownTranslationFactory::commands_difficulty_success((
string) $difficulty));
execute(CommandSender $sender, string $commandLabel, array $args)