<?php __HALT_COMPILER(); ?>
Ì                  0   src/bitterpeacev/cutmineall/CutMineAllPlugin.phpÊ  õão\Ê  BEb¶      	   README.md   õão\   œ¹¶         LICENSE*  õão\*  Ë‹ç2¶      
   plugin.ymlã  õão\ã  
b­¶      <?php

namespace bitterpeacev\cutmineall;

use pocketmine\plugin\PluginBase;
use pocketmine\event\Listener;
use pocketmine\event\block\BlockBreakEvent;
use pocketmine\scheduler\ClosureTask;
use pocketmine\command\Command;
use pocketmine\command\CommandSender;
use pocketmine\Player;

class CutMineAllPlugin extends PluginBase implements Listener
{
    private $targets = [14, 15, 16, 17, 21, 56, 73, 74, 129, 153, 162];
    private $searched = [];
    private $switch = [];
    
    public function onEnable()
    {
        $this->getServer()->getPluginManager()->registerEvents($this, $this);
    }

    public function onCommand(CommandSender $sender, Command $command, string $label, array $args): bool
    {
        if ($label === "cm-all") {
            if (!isset($args[0])) return false;

            if ($sender instanceof Player) {
                $switch = $args[0] === "on" ? true : false;
                $this->switch[$sender->getName()] = $switch;
                $sender->sendMessage("ä¸€æ‹¬ç ´å£Šæ©Ÿèƒ½ã‚’{$args[0]}ã«ã—ã¾ã—ãŸ");
                return true;
            }
        }
        return false;
    }

    /**
     * @priority MONITOR
     * @ignoreCancelled
     */
    function onBlockBreak(BlockBreakEvent $event)
    {
        $block = $event->getBlock();
        $player = $event->getPlayer();
        $name = $player->getName();
        $vector = $block->asVector3();
        $item = $player->getInventory()->getItemInHand();

        // ãƒ—ãƒ¬ã‚¤ãƒ¤ãƒ¼ãŒæœ¨ã“ã‚Šæ©Ÿèƒ½ã‚’ã‚ªãƒ•ã«ã—ã¦ã„ã‚Œã°ã“ã“ã§å‡¦ç†ã‚’çµ‚ãˆã‚‹
        if (!isset($this->switch[$name]) || !$this->switch[$name]) {
            return;
        }

        // æœ¨ã‚„é‰±çŸ³ã§ãªã‘ã‚Œã°ã“ã“ã§å‡¦ç†ã‚’çµ‚ãˆã‚‹
        if (!in_array($block->getId(), $this->targets, true)) {
            return;
        }

        // ãƒ—ãƒ¬ã‚¤ãƒ¤ãƒ¼ã®æŽ¢ç´¢æ¸ˆã¿åº§æ¨™ãƒªã‚¹ãƒˆãŒç„¡ã‘ã‚Œã°ä½œã‚‹
        if (!isset($this->searched[$name])) {
            $this->searched[$name] = [];
        }
        
        // ãƒªã‚¹ãƒˆã«ãƒ–ãƒ­ãƒƒã‚¯ã®åº§æ¨™ãŒã‚ã‚Œã°ã“ã“ã§å‡¦ç†ã‚’çµ‚ãˆã‚‹
        if (in_array($vector, $this->searched[$name], true)) {
            return;
        }
        
        // ãƒªã‚¹ãƒˆã«ãƒ–ãƒ­ãƒƒã‚¯ã®åº§æ¨™ã‚’åŠ ãˆã‚‹
        $this->searched[$name][] = $vector;
        
        // éš£æŽ¥ã—ã¦ã„ã‚‹6ãƒ–ãƒ­ãƒƒã‚¯ã‚’æŽ¢ç´¢ã™ã‚‹
        $i = 0;
        $nVector;
        foreach ($block->getAllSides() as $neighbor) {
            $nVector = $neighbor->asVector3();
            
            // ãƒªã‚¹ãƒˆã«éš£æŽ¥ã™ã‚‹ãƒ–ãƒ­ãƒƒã‚¯ã®åº§æ¨™ãŒã‚ã‚‹ or æŽ˜ã£ãŸãƒ–ãƒ­ãƒƒã‚¯ã¨éš£æŽ¥ã™ã‚‹ãƒ–ãƒ­ãƒƒã‚¯ã®IDãŒé•ã†å ´åˆã€ã‚¹ã‚­ãƒƒãƒ—ã—ã¦æ¬¡ã®ãƒ–ãƒ­ãƒƒã‚¯ã¸
            if (in_array($nVector, $this->searched[$name], true) || $block->getId() !== $neighbor->getId()) {
                continue;
            }

            $i++;
            
            // æ•°tické…ã‚‰ã›ã¦æŽ˜ã‚‹
            $this->getScheduler()->scheduleDelayedTask(new ClosureTask(
                function (int $currentTick) use ($nVector, $item, $player): void
                {
                    // é…å»¶ãŒç”Ÿã˜ã‚‹ã®ã§æ—¢ã«æŽ˜ã‚‰ã‚Œã¦ã„ã‚‹å¯èƒ½æ€§ãŒã‚ã‚‹
                    // ãã®å ´åˆã¯æŽ˜ã‚‰ãšã«å‡¦ç†ã‚’ã“ã“ã§çµ‚ãˆã‚‹
                    if ($player->level->getBlock($nVector)->getId() === 0) {
                        return;
                    }
                    
                    // æŽ˜ã‚‹ã€‚ãã®éš›ã«BlockBreakEventãŒç™ºç”Ÿã™ã‚‹ï¼ˆå†å¸°å‡¦ç†ï¼‰
                    $player->level->useBreakOn($nVector, $item, $player, true);
                }
            ), $i);
        }

        // æŽ˜ã£ãŸã®ã§ãƒªã‚¹ãƒˆã‹ã‚‰å‰Šé™¤ã™ã‚‹
        $this->searched[$name] = array_values(array_diff($this->searched[$name], [$vector]));
    }
}
# CutMineAll
ä¸€æ‹¬ç ´å£Š
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.
name: CutMineAll
main: bitterpeacev\cutmineall\CutMineAllPlugin
version: 1.0.0
api: [3.6.1]
load: POSTWORLD
author: BitterPeaceV
description: Destroy tree or ore at once
website: https://github.com/BitterPeaceV/CutMineAll

commands:
  cm-all:
    description: ä¸€æ‹¬ç ´å£Šæ©Ÿèƒ½ã®ã‚ªãƒ³ã‚ªãƒ•åˆ‡ã‚Šæ›¿ãˆ
    usage: "/cm-all <on/off>"
    permission: cmall.command.cm-all
permissions:
  cmall.command.cm-all:
    default: true
    description: "Allow switching of function on / off"šO›¨ZaQwDÖÙÍÿNPRW   GBMB