Skip to content

Commit

Permalink
/genplugin: remove example junk
Browse files Browse the repository at this point in the history
new devs should go and look at ExamplePlugin for code examples
  • Loading branch information
dktapps committed Oct 27, 2019
1 parent 3fadb2c commit 161b343
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 93 deletions.
19 changes: 0 additions & 19 deletions resources/plugin_skeleton/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,7 @@
#%{Namespace}

use pocketmine\plugin\PluginBase;
use pocketmine\command\CommandSender;
use pocketmine\command\Command;

class Main extends PluginBase{

public function onEnable() : void{
$this->getLogger()->info("Hello World!");
}

public function onCommand(CommandSender $sender, Command $command, string $label, array $args) : bool{
switch($command->getName()){
case "examplecommand":
$sender->sendMessage("Example command output");
return true;
default:
return false;
}
}

public function onDisable() : void{
$this->getLogger()->info("Bye");
}
}
59 changes: 0 additions & 59 deletions resources/plugin_skeleton/plugin.yml

This file was deleted.

22 changes: 7 additions & 15 deletions src/DevTools/commands/GeneratePluginCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,27 +76,22 @@ public function execute(CommandSender $sender, string $commandLabel, array $args

mkdir($rootDirectory . $namespacePath, 0755, true); //create all the needed directories

$pluginYmlTemplate = $this->getPlugin()->getResource("plugin_skeleton/plugin.yml");
$mainPhpTemplate = $this->getPlugin()->getResource("plugin_skeleton/Main.php");

try{
if($mainPhpTemplate === null or $pluginYmlTemplate === null){
if($mainPhpTemplate === null){
$sender->sendMessage(TextFormat::RED . "Error: missing template files");
return true;
}

$replace = [
"%{PluginName}" => $pluginName,
"%{ApiVersion}" => $this->getPlugin()->getServer()->getApiVersion(),
"%{AuthorName}" => $author,
"%{Namespace}" => $namespace
$manifest = [
"name" => $pluginName,
"version" => "0.0.1",
"main" => $namespace . "\\Main",
"api" => $this->getPlugin()->getServer()->getApiVersion()
];

file_put_contents($rootDirectory . "plugin.yml", str_replace(
array_keys($replace),
array_values($replace),
stream_get_contents($pluginYmlTemplate)
));
file_put_contents($rootDirectory . "plugin.yml", yaml_emit($manifest));

file_put_contents($rootDirectory . $namespacePath . "Main.php", str_replace(
"#%{Namespace}", "namespace " . $namespace . ";",
Expand All @@ -109,9 +104,6 @@ public function execute(CommandSender $sender, string $commandLabel, array $args
if($mainPhpTemplate !== null){
fclose($mainPhpTemplate);
}
if($pluginYmlTemplate !== null){
fclose($pluginYmlTemplate);
}
}
}

Expand Down

0 comments on commit 161b343

Please sign in to comment.