package: add a default support url

This commit is contained in:
Max Weber
2021-01-25 20:24:56 -07:00
parent 5628e4feef
commit 65fb757e19
2 changed files with 23 additions and 15 deletions

View File

@@ -40,12 +40,12 @@ There are two methods to create an external plugin, you can either:
```
displayName=Helmet check
author=dekvall
support=https://github.com/dekvall/helmet-check
support=
description=Alerts you when you have nothing equipped in your head slot
tags=hint,gear,head
plugins=com.helmetcheck.HelmetCheckPlugin
```
`support` is the URL you want players to use to leave feedback for your plugin; you can just use your repository for that. `tags` will make it easier to find your plugin when searching for related words. If you want to add multiple plugin files, the `plugins` field allows for comma separated values, but this is not usually needed.
`support` is the URL you want players to use to leave feedback for your plugin; by default this links to your repository. `tags` will make it easier to find your plugin when searching for related words. If you want to add multiple plugin files, the `plugins` field allows for comma separated values, but this is not usually needed.
11. Optionally, you can add an icon to be displayed alongside with your plugin. Place a file with the name `icon.png` no larger than 48x72 px at the root of the repository.
@@ -69,7 +69,7 @@ There are two methods to create an external plugin, you can either:
![run-test](https://i.imgur.com/tKSQH5e.png)
5. Edit `runelite-plugin.properties` with a support link and tags. `support` is the URL you want players to use to leave feedback for your plugin; you can just use your repository for that. `tags` will make it easier to find your plugin when searching for related words. If you want to add multiple plugin files, the `plugins` field allows for comma separated values, but this is not usually needed.
5. Edit `runelite-plugin.properties` with a support link and tags. `support` is the URL you want players to use to leave feedback for your plugin; by default this links to your repository. `tags` will make it easier to find your plugin when searching for related words. If you want to add multiple plugin files, the `plugins` field allows for comma separated values, but this is not usually needed.
6. Optionally, you can add an icon to be displayed alongside with your plugin. Place a file with the name `icon.png` no larger than 48x72 px at the root of the repository.

View File

@@ -65,6 +65,7 @@ import java.util.concurrent.BlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.jar.JarEntry;
import java.util.jar.JarInputStream;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
@@ -96,7 +97,7 @@ public class Plugin implements Closeable
private static final long MAX_SRC_SIZE = 10 * MIB;
private static final Pattern PLUGIN_INTERNAL_NAME_TEST = Pattern.compile("^[a-z0-9-]+$");
private static final Pattern REPOSITORY_TEST = Pattern.compile("^https://github\\.com/.*\\.git$");
private static final Pattern REPOSITORY_TEST = Pattern.compile("^(https://github\\.com/.*)\\.git$");
private static final Pattern COMMIT_TEST = Pattern.compile("^[a-fA-F0-9]{40}$");
private static final File TMP_ROOT;
@@ -148,6 +149,7 @@ public class Plugin implements Closeable
private final String repositoryURL;
private final String commit;
private final String defaultSupportURL;
@Getter
private final ExternalPluginManifest manifest = new ExternalPluginManifest();
@@ -183,7 +185,8 @@ public class Plugin implements Closeable
.withFile(pluginCommitDescriptor);
}
if (!REPOSITORY_TEST.matcher(repositoryURL).matches())
Matcher repoMatcher = REPOSITORY_TEST.matcher(repositoryURL);
if (!repoMatcher.matches())
{
throw PluginBuildException.of(internalName, "repository is not an accepted url")
.withFileLine(pluginCommitDescriptor, "repository=" + repositoryURL)
@@ -204,6 +207,7 @@ public class Plugin implements Closeable
return null;
});
}
String repoRoot = repoMatcher.group(1);
commit = (String) cd.remove("commit");
if (!COMMIT_TEST.matcher(commit).matches())
@@ -212,6 +216,8 @@ public class Plugin implements Closeable
.withFileLine(pluginCommitDescriptor, "commit=" + commit);
}
defaultSupportURL = repoRoot + "/tree/" + commit;
warning = (String) cd.remove("warning");
for (Map.Entry<Object, Object> extra : cd.entrySet())
@@ -567,17 +573,19 @@ public class Plugin implements Closeable
{
String supportStr = (String) props.remove("support");
if (!Strings.isNullOrEmpty(supportStr))
if (Strings.isNullOrEmpty(supportStr))
{
try
{
manifest.setSupport(new URL(supportStr));
}
catch (MalformedURLException e)
{
throw PluginBuildException.of(this, "support url is malformed", e)
.withFileLine(propFile, "support=" + supportStr);
}
supportStr = this.defaultSupportURL;
}
try
{
manifest.setSupport(new URL(supportStr));
}
catch (MalformedURLException e)
{
throw PluginBuildException.of(this, "support url is malformed", e)
.withFileLine(propFile, "support=" + supportStr);
}
}