private function generateMainClass()
 {
     $class = new ClassGenerator($this->project->namespace, "MainClass");
     $class->addImport("pocketmine\\plugin\\PluginBase");
     $class->addImport("pocketmine\\utils\\TextFormat");
     $class->setSuperClass("PluginBase");
     $onEnable = new GeneratedFunctionContainer();
     $onEnable->name = "onEnable";
     $onEnable->code .= '$this->getLogger()->info(TextFormat::YELLOW . "This plugin is auto-generated by http://pmt.mcpe.me/pg, an online tool written by PEMapModder. Use at your own risk. If this plugin misbehaves, the user should bear his/her own responsibilities.");' . ClassGenerator::STANDARD_EOL;
     foreach ($this->project->cmds as $cmd) {
         $pluginName = strtolower(str_replace([":", " "], "-", $this->project->getDesc()->getName()));
         $onEnable->code .= '$this->getServer()->getCommandMap()->register(' . beautified_var_export($pluginName, true) . ', new cmds\\' . $cmd->getClassName() . '($this)); // this line registers the command /' . str_replace(["\r", "\n"], "<br>", $cmd->name) . ClassGenerator::STANDARD_EOL;
     }
     if (count($this->project->events) > 0) {
         $onEnable->code .= '$this->getServer()->getPluginManager()->registerEvents(new EventHandler($this), $this);' . ClassGenerator::STANDARD_EOL;
     }
     $class->addFunction($onEnable);
     $this->addFile("src/" . $this->project->namespace . "/MainClass.php", $class);
 }
 protected function ex($var)
 {
     return beautified_var_export($var, true);
 }
}
/** @var Context $ctx */
$ctx = $_SESSION["contexts"][$_REQUEST["ctx"]];
$type = $_REQUEST["type"];
$literal = $_REQUEST["literal"];
if ($type === "number") {
    if (!is_numeric($literal)) {
        echo json_encode(["status" => false, "error" => "Malformed number - please enter a valid number!"]);
        return;
    }
    $value = preg_match('#^[0-9]+$#', $literal) ? intval($literal) : floatval($literal);
    $res = new NumberResource(beautified_var_export($value, true), $value);
} elseif ($type === "string") {
    $res = new StringResource(beautified_var_export($literal, true), $literal);
} elseif ($type === "bool" or $type === "boolean") {
    if ($literal === "true" or $literal === "on") {
        $value = true;
    } elseif ($literal === "false" or $literal === "off") {
        $value = false;
    } else {
        echo json_encode(["status" => false, "error" => "Invalid boolean literal"]);
        return;
    }
    $res = new BooleanResource(beautified_var_export($value, true), $value);
}
if (!isset($res)) {
    echo json_encode(["status" => false, "error" => "Unknown type {$type}"]);
    return;
}
$ctx->addResource($res);
echo json_encode(["status" => true, "resId" => $res->resId]);