Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix report command #429

Merged
merged 1 commit into from
Mar 12, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.leavesmc.leaves.command.subcommands;

import com.destroystokyo.paper.util.VersionFetcher;
import io.papermc.paper.plugin.configuration.PluginMeta;
import io.papermc.paper.plugin.entrypoint.Entrypoint;
import io.papermc.paper.plugin.entrypoint.LaunchEntryPointHandler;
Expand All @@ -11,7 +10,6 @@
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.format.TextDecoration;
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.packs.repository.Pack;
import net.minecraft.server.packs.repository.PackRepository;
Expand All @@ -38,16 +36,12 @@
import static net.kyori.adventure.text.format.NamedTextColor.AQUA;
import static net.kyori.adventure.text.format.NamedTextColor.RED;


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 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 VersionFetcher versionFetcher = new LeavesVersionFetcher();


@Override
public boolean execute(CommandSender sender, String subCommand, String[] args) {
if (args.length < 1) {
Expand Down Expand Up @@ -79,7 +73,7 @@ public List<String> tabComplete(CommandSender sender, String subCommand, String[

private void sendOnSuccess(CommandSender sender, String template, Component component) {
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("${datapacks}", URLEncoder.encode(generateDataPackMessage(), StandardCharsets.UTF_8));
if (sender instanceof ConsoleCommandSender) {
Expand All @@ -90,10 +84,6 @@ private void sendOnSuccess(CommandSender sender, String template, Component comp
}
}

private static String generateVersionMessage() {
return PlainTextComponentSerializer.plainText().serialize(versionFetcher.getVersionMessage(Bukkit.getVersion())).replaceAll("\\n", ". ");
}

private static String generatePluginMessage() {
final StringBuilder pluginList = new StringBuilder();

Expand Down Expand Up @@ -177,5 +167,4 @@ private static String generateDataPackMessage() {
}
return dataPackList.toString();
}

}