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

feature: Add language files to debugpaste #3645

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Changes from 6 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
23 changes: 20 additions & 3 deletions Core/src/main/java/com/plotsquared/core/command/DebugPaste.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.concurrent.TimeUnit;
import java.util.stream.Stream;

@CommandDeclaration(command = "debugpaste",
aliases = "dp",
Expand Down Expand Up @@ -76,9 +78,9 @@ public boolean onCommand(final PlotPlayer<?> player, String[] args) {
StringBuilder b = new StringBuilder();
b.append(
"""
# Welcome to this paste
# It is meant to provide us at IntellectualSites with better information about your problem
"""
# Welcome to this paste
# It is meant to provide us at IntellectualSites with better information about your problem
"""
Xaver106 marked this conversation as resolved.
Show resolved Hide resolved
);
b.append("# PlotSquared Information\n");
b.append("PlotSquared Version: ").append(PlotSquared.get().getVersion())
Expand Down Expand Up @@ -173,6 +175,21 @@ public boolean onCommand(final PlotPlayer<?> player, String[] args) {
);
}

final Path langDir = PlotSquared.platform().getDirectory().toPath().resolve("lang");
if (Files.isDirectory(langDir)) {
try (Stream<Path> files = Files.list(langDir)) {
files.filter(Files::isRegularFile)
.filter(path -> path.getFileName().toString().startsWith("messages_") &&
path.getFileName().toString().endsWith(".json")
).forEach(path -> {
try {
incendoPaster.addFile(path.toFile());
} catch (IOException ignored) {
}
});
}
}

try {
final String rawResponse = incendoPaster.upload();
final JsonObject jsonObject =
Expand Down