Fixes, update test data

This commit is contained in:
Nassim Jahnke 2022-12-24 18:59:54 +01:00
parent dc7641a17d
commit 34f2c4ee25
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
2 changed files with 14 additions and 10 deletions

View File

@ -30,20 +30,19 @@ public class BBCodeConverter {
REPLACERS.put("user", (tag, tagArg, content) -> content);
REPLACERS.put("list", (tag, tagArg, content) -> content);
REPLACERS.put("spoiler", (tag, tagArg, content) -> {
return "<details>\n" +
" <summary>" + removeQuotes(tagArg) + "</summary>\n" +
" " + content + "\n" +
"</details>\n";
});
REPLACERS.put("spoiler", (tag, tagArg, content) -> "<details>\n<summary>%s</summary>\n\n%s\n</details>\n".formatted(removeQuotes(tagArg), content));
REPLACERS.put("b", (tag, tagArg, content) -> "**" + content + "**");
REPLACERS.put("i", (tag, tagArg, content) -> "*" + content + "*");
REPLACERS.put("s", (tag, tagArg, content) -> "~~" + content + "~~");
REPLACERS.put("img", (tag, tagArg, content) -> "![" + content + "](" + content + ")");
REPLACERS.put("media", (tag, tagArg, content) -> "youtube".equals(tagArg) ? "@[YouTube](https://youtu.be/" + content + ")" : null);
REPLACERS.put("size", (tag, tagArg, content) -> {
if (content.isBlank()) {
return content;
}
Integer size = Ints.tryParse(tagArg);
if (size == null) {
if (size == null || size == 4) { // 4 is the default size
return content;
}
@ -177,7 +176,7 @@ public class BBCodeConverter {
TagReplacer replacer = REPLACERS.get(currentTag);
if (replacer != null && replacer.appendNewline()) {
int lastChar = s.length() - 1;
if (s.lastIndexOf("\n") == lastChar) {
if (s.lastIndexOf('\n') == lastChar) {
return s.substring(0, lastChar);
}
}
@ -309,7 +308,7 @@ public class BBCodeConverter {
if (s.length() > 2) {
final char c = s.charAt(0);
if ((c == '\'' || c == '"') && c == s.charAt(s.length() - 1)) {
return s.substring(0, s.length() - 1);
return s.substring(1, s.length() - 1);
}
}
return s;

View File

@ -27,7 +27,7 @@ IMPORTANT: If using the plugin on a Spigot server, the plugin **[ProtocolLib](ht
![https://www.spigotmc.org/attachments/401279](https://www.spigotmc.org/attachments/401279)
Did you find a bug? Use the [**issue tracker**](https://github.com/kennytv/maintenance/issues)
### Did you find a bug? Use the [**issue tracker**](https://github.com/kennytv/maintenance/issues)
Other questions or problems? Click the wonderful icon below ✨
[![https://www.spigotmc.org/attachments/401277](https://www.spigotmc.org/attachments/401277)](https://discord.gg/vgcuzhq)
@ -72,6 +72,9 @@ config-version: 4
```
<details>
<summary>language-en.yml</summary>
```
noPermission: "&cYou do not have the permission to execute that command."
kickmessage: "&cThe server is currently under maintenance!%NEWLINE%&cTry again later!"
@ -79,6 +82,8 @@ kickmessage: "&cThe server is currently under maintenance!%NEWLINE%&cTry again l
```
</details>
![https://www.spigotmc.org/attachments/401278](https://www.spigotmc.org/attachments/401278)
If you have the ServerListPlus plugin on your BungeeCord/Spigot server, Maintenance will toggle its status. If you enable maintenance, the ServerListPlus motd will be disabled and then reenabled, when you disable maintenance to prevent any issues with them overriding each other.