public final function run(SubcommandMap $owner, array $args, CommandSender $sender) { if ($this->issuer === self::CONSOLE and !$sender instanceof ConsoleCommandSender) { $sender->sendMessage("Please run this command in-game."); return; } if (($this->issuer === self::PLAYER or $this->issuer === self::SELECTED) and !$sender instanceof Player) { $sender->sendMessage("Please run this command on-console."); return; } if ($this->issuer === self::SELECTED) { $p = $this->main->getAnchor($sender); if ($p instanceof Position) { $result = call_user_func(array($this, $this->callable), $args, $p, $sender); } else { $result = self::NO_SELECTED_POINT; } } elseif ($this->issuer === self::SEL_SPACE) { $space = $this->main->getSelection($sender); if ($space instanceof Space) { $result = call_user_func(array($this, $this->callable), $args, $space, $sender); } else { $result = self::NO_SELECTION; } } else { $result = call_user_func(array($this, $this->callable), $args, $sender); } if (is_string($result)) { $sender->sendMessage($result); return; } switch ($result) { case self::WRONG_USE: $sender->sendMessage("Usage: /{$owner->getName()} {$this->getName()} {$this->getUsage()}"); break; case self::NO_PERM: $sender->sendMessage("You don't have permission to do this!"); break; case self::NO_PLAYER: $sender->sendMessage("Player not found!"); break; case self::NO_SELECTION: $sender->sendMessage("You must make a selection first!"); break; case self::NO_SELECTED_POINT: $sender->sendMessage("You must select a point first!"); break; case self::NO_BLOCK: $sender->sendMessage("Block not found!"); break; case self::NO_ITEM: $sender->sendMessage("Item not found!"); break; case self::NO_ANCHOR: $sender->sendMessage("You don't have an anchor set!"); break; } }
private function registerCommands() { $wea = new SubcommandMap("worldeditart", $this, "WorldEditArt main command", "wea.cmd", ["wea", "we", "/"]); $cmds = []; $config = $this->getConfig()->get("beta safety")["enabled features"]; if ($config["selecting anchors"]) { $cmds[] = new Anchor($this); } $clipboard = $config["clipboard"]; if ($clipboard["copying"]) { $cmds[] = new Copy($this); } if ($clipboard["cutting"]) { $cmds[] = new Cut($this); } if ($clipboard["pasting"]) { $cmds[] = new Paste($this); } $sel = $config["selections"]; $selsel = $sel["selecting selections"]; $cubsel = $selsel["cuboid selection"]; $shoot = $cubsel["by shoot"]; $grow = $cubsel["by grow"]; if ($shoot or $grow) { $cmds[] = new Cuboid($this, $shoot, $grow); } if ($selsel["cylinder selection"]) { $cmds[] = new Cylinder($this); } if ($selsel["sphere selection"]) { $cmds[] = new Sphere($this); } if ($selsel["deselection"]) { $cmds[] = new Desel($this); } if ($sel["testing selections"]) { $cmds[] = new Test($this); } $edit = $sel["editing selections"]; $set = $edit["setting blocks by command"]; if ($set["any block types"]) { $twoNo = $set["two block types without percentage"]; $twoYes = $set["two block types with percentage"]; $mulNo = $set["multiple block types without percentage"]; $mulYes = $set["multiple block types with percentage"]; $cmds[] = new Set($this, $twoNo, $twoYes, $mulNo, $mulYes); } $rep = $edit["replacing blocks by command"]; if ($rep["any block types"]) { $twoNo = ["two target block types without percentage"]; $twoYes = ["two target block types with percentage"]; $mulNo = ["multiple target block types without percentage"]; $mulYes = ["multiple target block types with percentage"]; $cmds[] = new Replace($this, $twoNo, $twoYes, $mulNo, $mulYes); } if ($config["macros"]) { $cmds[] = new MacroSubcommand($this); } $misc = $config["miscellaneous"]; if ($misc["selecting points by //pos1 (or //1) and //pos2 (or //2)"]) { $cmds[] = new PosSubcommand($this, false); $cmds[] = new PosSubcommand($this, true); } $custom = $misc["custom tool selection"]; if ($custom["jump"]) { $cmds[] = new SelectedToolSetterSubcommand($this, "jump", PlayerData::JUMP, "jump"); } if ($custom["wand"]) { $cmds[] = new SelectedToolSetterSubcommand($this, "wand", PlayerData::WAND, "wand"); } $wea->registerAll($cmds); $this->doJump = $misc["jump"]; $this->doWand = $misc["wand"]; $this->getServer()->getCommandMap()->register("wea", $wea); }