From f9dc00e89501ec9f7a0ad1e3c6b4d5653e30649c Mon Sep 17 00:00:00 2001 From: TheAMDGuy <64478051+TheAMDGuy@users.noreply.github.com> Date: Wed, 29 Apr 2020 15:41:50 +0200 Subject: [PATCH] Add files via upload --- Main.php | 145 +++++++++++++++++++++++++++++++++++++++++++++++++++++ config.yml | 18 +++++++ plugin.yml | 70 ++++++++++++++++++++++++++ 3 files changed, 233 insertions(+) create mode 100644 Main.php create mode 100644 config.yml create mode 100644 plugin.yml diff --git a/Main.php b/Main.php new file mode 100644 index 0000000..a034a9e --- /dev/null +++ b/Main.php @@ -0,0 +1,145 @@ +config = $this->getConfig()->getAll(); + } + + public function onCommand(CommandSender $sender, Command $command, string $label, array $args): bool + { + switch ($command->getName()){ + case "day": + if ($sender->hasPermission("dan.day")) { + if ($sender instanceof Player){ + $level = $sender->getLevel(); + $level->setTime(0); + $sender->sendMessage(TextFormat::GREEN.$this->config["succesday"]); + return true; + } else { + $sender->sendMessage(TextFormat::DARK_RED.$this->config["ingameonly"]); + return true; + } + } else { + $sender->sendMessage(TextFormat::DARK_RED.$this->config["nopermission"]); + return true; + } + case "night": + if ($sender->hasPermission("dan.night")){ + if ($sender instanceof Player){ + $level = $sender->getLevel(); + $level->setTime(14000); + $sender->sendMessage(TextFormat::GREEN.$this->config["succesnight"]); + return true; + } else { + $sender->sendMessage(TextFormat::DARK_RED.$this->config["ingameonly"]); + return true; + } + } else { + $sender->sendMessage(TextFormat::DARK_RED.$this->config["nopermission"]); + return true; + } + case "set": + if ($sender->hasPermission("dan.set")){ + if ($sender instanceof Player){ + $level = $sender->getLevel(); + $level->setTime(18000); + $sender->sendMessage(TextFormat::GREEN.$this->config["successet"]); + return true; + } else { + $sender->sendMessage(TextFormat::DARK_RED.$this->config["ingameonly"]); + return true; + } + } else { + $sender->sendMessage(TextFormat::DARK_RED.$this->config["nopermission"]); + return true; + } + case "rise": + if ($sender->hasPermission("dan.rise")){ + if ($sender instanceof Player){ + $level = $sender->getLevel(); + $level->setTime(23000); + $sender->sendMessage(TextFormat::GREEN.$this->config["succesrise"]); + return true; + } else { + $sender->sendMessage(TextFormat::DARK_RED.$this->config["ingameonly"]); + return true; + } + } else { + $sender->sendMessage(TextFormat::DARK_RED.$this->config["nopermission"]); + return true; + } + case "midday": + if ($sender->hasPermission("dan.midday")){ + if ($sender instanceof Player){ + $level = $sender->getLevel(); + $level->setTime(6000); + $sender->sendMessage(TextFormat::GREEN.$this->config["succesmidday"]); + return true; + } else { + $sender->sendMessage(TextFormat::DARK_RED.$this->config["ingameonly"]); + return true; + } + } else { + $sender->sendMessage(TextFormat::DARK_RED.$this->config["nopermission"]); + return true; + } + case "midnight": + if ($sender->hasPermission("dan.midnight")){ + if ($sender instanceof Player){ + $level = $sender->getLevel(); + $level->setTime(18000); + $sender->sendMessage(TextFormat::GREEN.$this->config["succesmidnight"]); + return true; + } else { + $sender->sendMessage(TextFormat::DARK_RED.$this->config["ingameonly"]); + return true; + } + } else { + $sender->sendMessage(TextFormat::DARK_RED.$this->config["nopermission"]); + return true; + } + case "dayandnight": + if ($sender->hasPermission("dan.info")){ + $sender->sendMessage(TextFormat::AQUA.$this->config["avaiable"]); + if ($sender->hasPermission("dan.day")){ + $sender->sendMessage(TextFormat::GREEN.$this->config["daycommandav"]); + } + if ($sender->hasPermission("dan.night")){ + $sender->sendMessage(TextFormat::GREEN.$this->config["nightcommandav"]); + } + if ($sender->hasPermission("dan.set")){ + $sender->sendMessage(TextFormat::GREEN.$this->config["setcommandav"]); + } + if ($sender->hasPermission("dan.rise")){ + $sender->sendMessage(TextFormat::GREEN.$this->config["risecommandav"]); + } + if ($sender->hasPermission("dan.midday")){ + $sender->sendMessage(TextFormat::GREEN.$this->config["middaycommandav"]); + } + if ($sender->hasPermission("dan.midnight")){ + $sender->sendMessage(TextFormat::GREEN.$this->config["midnightcommandav"]); + } + return true; + } else { + $sender->sendMessage(TextFormat::DARK_RED.$this->config["nopermission"]); + return true; + } + + } + return true; + } +} diff --git a/config.yml b/config.yml new file mode 100644 index 0000000..352b4b1 --- /dev/null +++ b/config.yml @@ -0,0 +1,18 @@ +--- +#set thoose things to the messages you want. +ingameonly: Sorry, but this command only works only ingame. +nopermission: Sorry, but you dont have the permission to use this command. +succesday: Succesfully set the time to day. +succesnight: Succesfully set the time to night. +successet: Succesfully set the time to sunset. +succesrise: Succesfully set the time to sunrise. +succesmidday: Succesfully set the time to midday. +succesmidnight: Succesfully set the time to midnight. +avaiable: Following commands are avaiable. +daycommandav: You can set the time to day. +nightcommandav: You can set the time to night. +setcommandav: You can set the time to sunset. +risecommandav: You can set the time to sunrise. +middaycommandav: You can set the time to midday. +midnightcommandav: You can set the time to midnight. +... \ No newline at end of file diff --git a/plugin.yml b/plugin.yml new file mode 100644 index 0000000..6809d32 --- /dev/null +++ b/plugin.yml @@ -0,0 +1,70 @@ +--- +name: DayandNight +version: 1.2.5-STABLE +main: TheAMDGuy\DayandNight\Main +api: [3.12.0, 3.12.1] +commands: + day: + description: Sets the time to day. + usage: /day + aliases: + - tsd + night: + description: Sets the time to night. + usage: /night + aliases: + - tsn + set: + description: Sets the time to sunset. + usage: /set + aliases: + - tss + rise: + description: Sets the time to sunrise. + usage: /rise + aliases: + - tsr + midday: + description: Sets the time to midday. + usage: /midday + aliases: + - tsmd + midnight: + description: Sets the time to midnight. + usage: /midnight + aliases: + - tsmn + dayandnight: + description: Informates about all avaiable DayandNight commands. + usage: /dayandnight + aliases: + - dan + - daninfo + - danhelp +permissions: + dan: + default: op + description: Permission for all DayandNight commands. + children: + dan.day: + default: op + description: Permission to set the time to day. + dan.night: + default: op + description: Permission to set the time to night. + dan.set: + default: op + description: Permission to set the time to set. + dan.rise: + default: op + description: Permission to set the time to rise. + dan.midday: + default: op + description: Permission to set the time to midday. + dan.midnight: + default: op + description: Permission to set the time to midnight. + dan.info: + default: op + description: Permission to get all avaiable DayandNight commands. +...