<?php __HALT_COMPILER(); ?>
                    DustChute-master/                        DustChute-master/LICENSE-     -  ӵj=         DustChute-master/README.md         |n         DustChute-master/plugin.yml       V         DustChute-master/src/                        DustChute-master/src/Deceitya/                     (   DustChute-master/src/Deceitya/DustChute/                     ;   DustChute-master/src/Deceitya/DustChute/DustChutePlugin.phps     s  t      MIT License

Copyright (c) 2019 ツキミヤ

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
# DustChute
ゴミ箱
name: DustChute
main: Deceitya\DustChute\DustChutePlugin
version: 1.0.0
api: 3.9.0

load: POSTWORLD
author: deceitya
description: ゴミ箱
website: https://github.com/deceitya/DustChute

commands:
  dustchute:
    description: ゴミ箱を開く
    usage: "/dustchute"
    permission: dustchute.command.dustchute
permissions:
  dustchute.command.dustchute:
    description: ゴミ箱コマンドが使えます
    default: true<?php

namespace Deceitya\DustChute;

use pocketmine\plugin\PluginBase;
use pocketmine\event\Listener;
use pocketmine\command\Command;
use pocketmine\command\CommandSender;
use pocketmine\tile\Chest;
use pocketmine\Player;
use pocketmine\block\Block;
use pocketmine\event\inventory\InventoryCloseEvent;

class DustChutePlugin extends PluginBase implements Listener
{
    private $real = [];

    public function onEnable()
    {
        $this->getServer()->getPluginManager()->registerEvents($this, $this);
    }

    public function onCommand(CommandSender $sender, Command $command, string $label, array $args): bool
    {
        if (!($sender instanceof Player)) {
            $sender->sendMessage("[DustChute] プレイヤーのみ使えるコマンドです。");
            return true;
        }

        $x = (int) $sender->x;
        $y = (int) $sender->y + 2;
        $z = (int) $sender->z;

        $this->real[$sender->getName()] = [$x, $y, $z];

        $block = Block::get(Block::CHEST);
        $block->setComponents($x, $y, $z);
        $sender->level->sendBlocks([$sender], [$block]);

        $nbt = Chest::createNBT($block);
        $nbt->setString("CustomName", "ゴミ箱");
        $chest = Chest::createTile(Chest::CHEST, $sender->level, $nbt);
        $sender->addWindow(new FakeInventory($chest));

        return true;
    }

    public function onClose(InventoryCloseEvent $event)
    {
        if ($event->getInventory() instanceof FakeInventory) {
            $player = $event->getplayer();
            $name = $player->getName();
            if (isset($this->real[$name])) {
                $pos = $this->real[$name];
                $player->level->sendBlocks([$player], [$player->level->getBlockAt($pos[0], $pos[1], $pos[2])]);
                unset($this->real[$name]);
            }
        }
    }
}

class FakeInventory extends \pocketmine\inventory\ChestInventory
{
}
+bWˢC+4   GBMB