GenisysPro  for Minecraft PE/Windows 10 v1.1.x
Feature-rich server software for Minecraft PE and Windows 10 Edition
ExtractPluginCommand Class Reference

Public Member Functions

 __construct ($name)
 
 execute (CommandSender $sender, $commandLabel, array $args)
 
- Public Member Functions inherited from VanillaCommand
 __construct ($name, $description="", $usageMessage=null, array $aliases=[])
 
- Public Member Functions inherited from Command
 __construct ($name, $description="", $usageMessage=null, array $aliases=[])
 
 getDefaultCommandData ()
 
 generateCustomCommandData (Player $player)
 
 getOverloads ()
 
 execute (CommandSender $sender, $commandLabel, array $args)
 
 getName ()
 
 getPermission ()
 
 setPermission ($permission)
 
 testPermission (CommandSender $target)
 
 testPermissionSilent (CommandSender $target)
 
 getLabel ()
 
 setLabel ($name)
 
 register (CommandMap $commandMap)
 
 unregister (CommandMap $commandMap)
 
 isRegistered ()
 
 getAliases ()
 
 getPermissionMessage ()
 
 getDescription ()
 
 getUsage ()
 
 setAliases (array $aliases)
 
 setDescription ($description)
 
 setPermissionMessage ($permissionMessage)
 
 setUsage ($usage)
 
 __toString ()
 

Additional Inherited Members

- Static Public Member Functions inherited from Command
static generateDefaultData ()
 
static broadcastCommandMessage (CommandSender $source, $message, $sendToSource=true)
 
- Data Fields inherited from VanillaCommand
const MAX_COORD = 30000000
 
const MIN_COORD = -30000000
 
- Data Fields inherited from Command
 $timings
 
- Protected Member Functions inherited from VanillaCommand
 getInteger (CommandSender $sender, $value, $min=self::MIN_COORD, $max=self::MAX_COORD)
 
 getRelativeDouble ($original, CommandSender $sender, $input, $min=self::MIN_COORD, $max=self::MAX_COORD)
 
 getDouble (CommandSender $sender, $value, $min=self::MIN_COORD, $max=self::MAX_COORD)
 
- Protected Attributes inherited from Command
 $commandData = null
 
 $description = ""
 
 $usageMessage
 

Constructor & Destructor Documentation

◆ __construct()

__construct (   $name)

ExtractPluginCommand constructor.

Parameters
$name
47  {
48  parent::__construct(
49  $name,
50  "Extracts the source code from a Phar plugin",
51  "/extractplugin <pluginName>"
52  );
53  $this->setPermission("pocketmine.command.extractplugin");
54  }

Member Function Documentation

◆ execute()

execute ( CommandSender  $sender,
  $commandLabel,
array  $args 
)
Parameters
CommandSender$sender
string$commandLabel
array$args
Returns
bool
63  {
64  if(!$this->testPermission($sender)){
65  return false;
66  }
67 
68  if(count($args) === 0){
69  $sender->sendMessage(TextFormat::RED . "Usage: " . $this->usageMessage);
70  return true;
71  }
72 
73  $pluginName = trim(implode(" ", $args));
74  if($pluginName === "" or !(($plugin = Server::getInstance()->getPluginManager()->getPlugin($pluginName)) instanceof Plugin)){
75  $sender->sendMessage(TextFormat::RED . "Invalid plugin name, check the name case.");
76  $this->sendPluginList($sender);
77  return true;
78  }
79  $description = $plugin->getDescription();
80 
81  if(!($plugin->getPluginLoader() instanceof PharPluginLoader)){
82  $sender->sendMessage(TextFormat::RED . "Plugin " . $description->getName() . " is not in Phar structure.");
83  return true;
84  }
85 
86  $folderPath = Server::getInstance()->getPluginPath() . DIRECTORY_SEPARATOR . "GenisysPro" . DIRECTORY_SEPARATOR . $description->getName() . "_v" . $description->getVersion() . "/";
87  if(file_exists($folderPath)){
88  $sender->sendMessage("Plugin already exists, overwriting...");
89  }else{
90  @mkdir($folderPath);
91  }
92 
93  $reflection = new \ReflectionClass("pocketmine\\plugin\\PluginBase");
94  $file = $reflection->getProperty("file");
95  $file->setAccessible(true);
96  $pharPath = str_replace("\\", "/", rtrim($file->getValue($plugin), "\\/"));
97 
98  foreach(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($pharPath)) as $fInfo){
99  $path = $fInfo->getPathname();
100  @mkdir(dirname($folderPath . str_replace($pharPath, "", $path)), 0755, true);
101  file_put_contents($folderPath . str_replace($pharPath, "", $path), file_get_contents($path));
102  }
103  $license = "
104  _____ _ _____
105  / ____| (_) | __ \
106 | | __ ___ _ __ _ ___ _ _ ___| |__) | __ ___
107 | | |_ |/ _ \ '_ \| / __| | | / __| ___/ '__/ _ \
108 | |__| | __/ | | | \__ \ |_| \__ \ | | | | (_) |
109  \_____|\___|_| |_|_|___/\__, |___/_| |_| \___/
110  __/ |
111  |___/
112  ";
113  $sender->sendMessage($license);
114  $sender->sendMessage("Source plugin " . $description->getName() . " v" . $description->getVersion() . " has been created on " . $folderPath);
115  return true;
116  }

The documentation for this class was generated from the following file: