Created
May 24, 2020 12:22
-
-
Save PJZ9n/970308dc271db1d427bcb707058a3ef8 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 | |
/** | |
* @name SlotTest | |
* @version 1.0.0 | |
* @main PJZ9n\SlotTest\Main | |
* @api 3.0.0 | |
*/ | |
declare(strict_types=1); | |
namespace PJZ9n\SlotTest { | |
use pocketmine\command\Command; | |
use pocketmine\command\CommandExecutor; | |
use pocketmine\command\CommandSender; | |
use pocketmine\command\PluginCommand; | |
use pocketmine\event\Listener; | |
use pocketmine\level\particle\FloatingTextParticle; | |
use pocketmine\permission\Permission; | |
use pocketmine\permission\PermissionManager; | |
use pocketmine\Player; | |
use pocketmine\plugin\Plugin; | |
use pocketmine\plugin\PluginBase; | |
class Main extends PluginBase | |
{ | |
public function onEnable(): void | |
{ | |
$this->getServer()->getPluginManager()->registerEvents(new EventListener($this), $this); | |
PermissionManager::getInstance()->addPermission(new Permission( | |
"slottest.command.slot", | |
null, | |
Permission::DEFAULT_TRUE | |
)); | |
$command = new PluginCommand("slot", $this); | |
$command->setDescription("スロットを回す"); | |
$command->setUsage("/slot <number>"); | |
$command->setPermission("slottest.command.slot"); | |
$command->setExecutor(new CommandProcessor()); | |
$this->getServer()->getCommandMap()->register($this->getName(), $command); | |
} | |
} | |
class EventListener implements Listener | |
{ | |
/** @var Plugin */ | |
private $plugin; | |
public function __construct(Plugin $plugin) | |
{ | |
$this->plugin = $plugin; | |
} | |
} | |
class CommandProcessor implements CommandExecutor | |
{ | |
public function onCommand(CommandSender $sender, Command $command, string $label, array $args): bool | |
{ | |
if (!$sender instanceof Player) { | |
return true; | |
} | |
$basePos = $sender->asVector3(); | |
$basePos = $basePos->add(0, 1, 0);//高さ上げ | |
switch ($sender->getDirection()) { | |
case 3: | |
$pos = $basePos->add(0.8, 0, 0); | |
break; | |
case 0: | |
$pos = $basePos->add(0, 0, 0.8); | |
break; | |
case 1: | |
$pos = $basePos->add(-0.8, 0, 0); | |
break; | |
case 2: | |
$pos = $basePos->add(0, 0, -0.8); | |
break; | |
} | |
$particle = new FloatingTextParticle($pos, "テキスト"); | |
$sender->getLevel()->addParticle($particle); | |
return false; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment