Skip to content

Instantly share code, notes, and snippets.

@jasonw4331
Created August 14, 2019 14:38
Show Gist options
  • Save jasonw4331/916e138c1386f6bc58bfc9fc2f2fe915 to your computer and use it in GitHub Desktop.
Save jasonw4331/916e138c1386f6bc58bfc9fc2f2fe915 to your computer and use it in GitHub Desktop.
A plugin script for MyPlot debugging
<?php
declare(strict_types=1);
/**
* @name MyPlotDumper
* @main jasonwynn10\MyPlotDumper\Main
* @version 0.1.0
* @api 3.0.0
* @description A plugin script for MyPlot debugging
* @author jasonwynn10
* @softdepend MyPlot
*/
namespace jasonwynn10\MyPlotDumper {
use MyPlot\Commands;
use MyPlot\MyPlot;
use MyPlot\subcommand\SubCommand;
use pocketmine\command\CommandSender;
use pocketmine\Player;
use pocketmine\plugin\PluginBase;
class Main extends PluginBase {
/** @var self|null $instance */
private static $instance = null;
/**
* @return self|null
*/
public static function getInstance() : ?self {
return self::$instance;
}
public function onEnable() {
self::$instance = $this;
$command = new class(MyPlot::getInstance(), "dump") extends SubCommand {
public function getName() : string {
return "dump";
}
public function getAlias() : string {
return "d";
}
public function getUsage() : string {
return "/p dump";
}
/**
* @param CommandSender $sender
*
* @return bool
*/
public function canUse(CommandSender $sender) : bool {
return $sender instanceof Player;
}
/**
* @param Player $sender
* @param array $args
*
* @return bool
*/
public function execute(CommandSender $sender, array $args) : bool {
$plot = MyPlot::getInstance()->getPlotByPosition($sender);
var_dump($plot);
$aabb = MyPlot::getInstance()->getPlotBB($plot);
var_dump($aabb);
$startPos = MyPlot::getInstance()->getPlotPosition($plot);
var_dump($startPos);
$mid = MyPlot::getInstance()->getPlotMid($plot);
var_dump($mid);
return true;
}
};
/** @var Commands $commands */
$commands = $this->getServer()->getCommandMap()->getCommand("plot");
$commands->loadSubCommand($command);
$this->getLogger()->debug("SubCommand loaded");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment