mirror of
https://github.com/LeavesMC/Leaves.git
synced 2025-12-19 14:59:32 +00:00
Fix report command (#429)
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
package org.leavesmc.leaves.command.subcommands;
|
package org.leavesmc.leaves.command.subcommands;
|
||||||
|
|
||||||
import com.destroystokyo.paper.util.VersionFetcher;
|
|
||||||
import io.papermc.paper.plugin.configuration.PluginMeta;
|
import io.papermc.paper.plugin.configuration.PluginMeta;
|
||||||
import io.papermc.paper.plugin.entrypoint.Entrypoint;
|
import io.papermc.paper.plugin.entrypoint.Entrypoint;
|
||||||
import io.papermc.paper.plugin.entrypoint.LaunchEntryPointHandler;
|
import io.papermc.paper.plugin.entrypoint.LaunchEntryPointHandler;
|
||||||
@@ -11,7 +10,6 @@ import net.kyori.adventure.text.Component;
|
|||||||
import net.kyori.adventure.text.event.ClickEvent;
|
import net.kyori.adventure.text.event.ClickEvent;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import net.kyori.adventure.text.format.TextDecoration;
|
import net.kyori.adventure.text.format.TextDecoration;
|
||||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.packs.repository.Pack;
|
import net.minecraft.server.packs.repository.Pack;
|
||||||
import net.minecraft.server.packs.repository.PackRepository;
|
import net.minecraft.server.packs.repository.PackRepository;
|
||||||
@@ -38,16 +36,12 @@ import static net.kyori.adventure.text.Component.text;
|
|||||||
import static net.kyori.adventure.text.format.NamedTextColor.AQUA;
|
import static net.kyori.adventure.text.format.NamedTextColor.AQUA;
|
||||||
import static net.kyori.adventure.text.format.NamedTextColor.RED;
|
import static net.kyori.adventure.text.format.NamedTextColor.RED;
|
||||||
|
|
||||||
|
|
||||||
public class ReportCommand implements LeavesSubcommand {
|
public class ReportCommand implements LeavesSubcommand {
|
||||||
|
|
||||||
private static final String BUG_REPORT_URL = "https://github.com/LeavesMC/Leaves/issues/new?template=1-bug-report.yml&leaves-version=${version}&plugin-list=${plugins}%0a%0a${datapacks}";
|
private static final String BUG_REPORT_URL = "https://github.com/LeavesMC/Leaves/issues/new?template=1-bug-report.yml&leaves-version=${version}&plugin-list=${plugins}%0a%0a${datapacks}";
|
||||||
private static final String NOT_VANILLA_URL = "https://github.com/LeavesMC/Leaves/issues/new?template=2-not-vanilla.yml&leaves-version=${version}";
|
private static final String NOT_VANILLA_URL = "https://github.com/LeavesMC/Leaves/issues/new?template=2-not-vanilla.yml&leaves-version=${version}";
|
||||||
private static final String COMMAND_PERM = "bukkit.command.leaves.report";
|
private static final String COMMAND_PERM = "bukkit.command.leaves.report";
|
||||||
|
|
||||||
private static final VersionFetcher versionFetcher = new LeavesVersionFetcher();
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(CommandSender sender, String subCommand, String[] args) {
|
public boolean execute(CommandSender sender, String subCommand, String[] args) {
|
||||||
if (args.length < 1) {
|
if (args.length < 1) {
|
||||||
@@ -79,7 +73,7 @@ public class ReportCommand implements LeavesSubcommand {
|
|||||||
|
|
||||||
private void sendOnSuccess(CommandSender sender, String template, Component component) {
|
private void sendOnSuccess(CommandSender sender, String template, Component component) {
|
||||||
String finalUrl = template
|
String finalUrl = template
|
||||||
.replace("${version}", URLEncoder.encode(generateVersionMessage(), StandardCharsets.UTF_8))
|
.replace("${version}", URLEncoder.encode(Bukkit.getVersionMessage(), StandardCharsets.UTF_8))
|
||||||
.replace("${plugins}", URLEncoder.encode(generatePluginMessage(), StandardCharsets.UTF_8))
|
.replace("${plugins}", URLEncoder.encode(generatePluginMessage(), StandardCharsets.UTF_8))
|
||||||
.replace("${datapacks}", URLEncoder.encode(generateDataPackMessage(), StandardCharsets.UTF_8));
|
.replace("${datapacks}", URLEncoder.encode(generateDataPackMessage(), StandardCharsets.UTF_8));
|
||||||
if (sender instanceof ConsoleCommandSender) {
|
if (sender instanceof ConsoleCommandSender) {
|
||||||
@@ -90,10 +84,6 @@ public class ReportCommand implements LeavesSubcommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String generateVersionMessage() {
|
|
||||||
return PlainTextComponentSerializer.plainText().serialize(versionFetcher.getVersionMessage(Bukkit.getVersion())).replaceAll("\\n", ". ");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String generatePluginMessage() {
|
private static String generatePluginMessage() {
|
||||||
final StringBuilder pluginList = new StringBuilder();
|
final StringBuilder pluginList = new StringBuilder();
|
||||||
|
|
||||||
@@ -177,5 +167,4 @@ public class ReportCommand implements LeavesSubcommand {
|
|||||||
}
|
}
|
||||||
return dataPackList.toString();
|
return dataPackList.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user