Add files via upload

master
TheAMDGuy 2020-04-29 15:41:50 +02:00 committed by GitHub
parent b6628e3c57
commit 8fb09ae166
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 233 additions and 0 deletions

145
Main.php Normal file
View File

@ -0,0 +1,145 @@
<?php
declare(strict_types=1);
namespace TheAMDGuy\DayandNight;
use pocketmine\command\Command;
use pocketmine\command\CommandSender;
use pocketmine\Player;
use pocketmine\plugin\PluginBase;
use pocketmine\utils\TextFormat;
class Main extends PluginBase{
/** @var string[] */
private $config;
public function onEnable() : void
{
$this->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;
}
}

18
config.yml Normal file
View File

@ -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.
...

70
plugin.yml Normal file
View File

@ -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.
...