Skip to content

Instantly share code, notes, and snippets.

@PJZ9n
Created May 9, 2020 04:09
Show Gist options
  • Save PJZ9n/935882dd17ca47348165c4aa94870b18 to your computer and use it in GitHub Desktop.
Save PJZ9n/935882dd17ca47348165c4aa94870b18 to your computer and use it in GitHub Desktop.
<?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