Created
May 9, 2020 04:09
-
-
Save PJZ9n/935882dd17ca47348165c4aa94870b18 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
namespace author\plugin; | |
use Generator; | |
use pocketmine\command\Command; | |
use pocketmine\command\CommandSender; | |
use pocketmine\event\Listener; | |
use pocketmine\event\player\PlayerJoinEvent; | |
use pocketmine\Player; | |
use pocketmine\plugin\PluginBase; | |
use pocketmine\utils\TextFormat; | |
class Main extends PluginBase implements Listener | |
{ | |
public function onEnable() | |
{ | |
$this->getLogger()->info("ここまでしか分からない"); | |
$this->getServer()->getPluginManager()->registerEvents($this, $this); | |
} | |
public function onJoin(PlayerJoinEvent $event) | |
{ | |
$player = $event->getPlayer(); | |
$name = $player->getName(); | |
$event->setJoinMessage(TextFormat::GREEN . $name . "さんが世界にやってきました模様にてございます"); | |
} | |
public function onCommand(CommandSender $sender, Command $command, string $label, array $args): bool | |
{ | |
if (!$sender instanceof Player) { | |
$sender->sendMessage("プレイヤーではないので不可能にてございます.."); | |
return true; | |
} | |
switch ($command) { | |
case "yurisi": | |
$function = function () use ($sender): Generator { | |
$yurisi = ["y", "r", "s"]; | |
$slot1 = $yurisi[array_rand($yurisi)]; | |
$slot2 = $yurisi[array_rand($yurisi)]; | |
$slot3 = $yurisi[array_rand($yurisi)]; | |
if ($slot1 === "y" && $slot2 === "r" && $slot3 === "s") { | |
$sender->sendMessage("あたりました"); | |
} else { | |
$sender->sendMessage("はずれました"); | |
} | |
$sender->sendTip("Slot: {$slot1} | {$slot2} | {$slot3}"); | |
} | |
return true; | |
} | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment