public function addAttachment(Plugin $plugin, $name = null, $value = null)
{
if ($plugin === null) {
throw new PluginException("Plugin cannot be null");
} elseif (!$plugin->isEnabled()) {
throw new PluginException("Plugin " . $plugin->getDescription()->getName() . " is disabled");
}
$result = new PermissionAttachment($plugin, $this->parent !== null ? $this->parent : $this);
$this->attachments[spl_object_hash($result)] = $result;
if ($name !== null and $value !== null) {
$result->setPermission($name, $value);
}
$this->recalculatePermissions();
return $result;
}