Skip to content
Merged
Show file tree
Hide file tree
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
57 changes: 5 additions & 52 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ import org.ajoberstar.grgit.Grgit
import java.util.*

plugins {
kotlin("jvm") version "1.8.21"
java
id("org.ajoberstar.grgit") version "5.2.0"
`java-library`
`maven-publish`
signing
id("org.jetbrains.dokka") version "1.8.10"
}

if (!File("$rootDir/.git").exists()) {
Expand All @@ -22,7 +21,7 @@ if (!File("$rootDir/.git").exists()) {
}

group = "dev.themeinerlp"
var baseVersion by extra("1.0.0")
var baseVersion by extra("1.1.0")
var extension by extra("")
var snapshot by extra("-SNAPSHOT")

Expand All @@ -44,73 +43,27 @@ repositories {
dependencies {
implementation("net.lingala.zip4j:zip4j:2.11.5")
implementation("com.google.code.gson:gson:2.10.1")
// Test
testImplementation("net.lingala.zip4j:zip4j:2.11.5")
testImplementation("com.google.code.gson:gson:2.10.1")
testImplementation(kotlin("test"))
}

tasks {
test {
useJUnitPlatform()
}
dokkaHtml {
dokkaSourceSets {
named("main") {
moduleName.set("Plugin Debug")
includes.from("module.md")
description = "A simple library to upload plugin debugs"
version = "%s%s".format(Locale.ROOT, baseVersion, snapshot)
}
}
}
dokkaJavadoc {
dokkaSourceSets {
named("main") {
moduleName.set("Plugin Debug")
description = "A simple library to upload plugin debugs"
includes.from("module.md")
version = "%s%s".format(Locale.ROOT, baseVersion, snapshot)
}
}
}
}

kotlin {
jvmToolchain(17)
sourceSets.all {
languageSettings {
languageVersion = "2.0"
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}

val sourceJar by tasks.register<Jar>("kotlinJar") {
from(sourceSets.main.get().allSource)
archiveClassifier.set("sources")
}
val dokkaJavadocJar by tasks.register<Jar>("dokkaHtmlJar") {
dependsOn(rootProject.tasks.dokkaHtml)
from(rootProject.tasks.dokkaHtml.flatMap { it.outputDirectory })
archiveClassifier.set("html-docs")
}

val dokkaHtmlJar by tasks.register<Jar>("dokkaJavadocJar") {
dependsOn(rootProject.tasks.dokkaJavadoc)
from(rootProject.tasks.dokkaJavadoc.flatMap { it.outputDirectory })
archiveClassifier.set("javadoc")
}

publishing {
publications {
create<MavenPublication>("mavenJava") {
from(components.findByName("java"))
groupId = "dev.themeinerlp"
artifactId = "plugin-debug"
version = "%s%s".format(Locale.ROOT, baseVersion, snapshot)
artifact(dokkaJavadocJar)
artifact(dokkaHtmlJar)
artifact(sourceJar)
pom {
name.set("Plugin debug")
description.set("A simple library to upload plugin debugs")
Expand Down
55 changes: 6 additions & 49 deletions bukkit-extension/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ import org.ajoberstar.grgit.Grgit
import java.util.*

plugins {
kotlin("jvm") version "1.8.21"
java
`java-library`
`maven-publish`
signing
id("org.jetbrains.dokka") version "1.8.10"
}

group = "dev.themeinerlp"
var baseVersion by extra("1.0.0")
var baseVersion by extra("1.1.0")
var extension by extra("")
var snapshot by extra("-SNAPSHOT")

Expand All @@ -34,58 +33,19 @@ dependencies {
compileOnly(rootProject)
compileOnly("io.papermc.paper:paper-api:1.19.4-R0.1-SNAPSHOT")
implementation("io.papermc:paperlib:1.0.8")
testImplementation(platform("org.junit:junit-bom:5.9.3"))
testImplementation("org.junit.jupiter:junit-jupiter")
}

tasks {
test {
useJUnitPlatform()
}

dokkaHtml {
dokkaSourceSets {
named("main") {
moduleName.set("Plugin Debug Bukkit Extension")
description = "Extends the main api with some nice features for bukkit"
version = "%s%s".format(Locale.ROOT, baseVersion, snapshot)
}
}
}
dokkaJavadoc {
dokkaSourceSets {
named("main") {
moduleName.set("Plugin Debug Bukkit Extension")
description = "Extends the main api with some nice features for bukkit"
version = "%s%s".format(Locale.ROOT, baseVersion, snapshot)
}
}
}
}

kotlin {
jvmToolchain(17)
sourceSets.all {
languageSettings {
languageVersion = "2.0"
}
}
}

val sourceJar by tasks.register<Jar>("kotlinJar") {
from(sourceSets.main.get().allSource)
archiveClassifier.set("sources")
}
val dokkaJavadocJar by tasks.register<Jar>("dokkaHtmlJar") {
dependsOn(rootProject.tasks.dokkaHtml)
from(rootProject.tasks.dokkaHtml.flatMap { it.outputDirectory })
archiveClassifier.set("html-docs")
}

val dokkaHtmlJar by tasks.register<Jar>("dokkaJavadocJar") {
dependsOn(rootProject.tasks.dokkaJavadoc)
from(rootProject.tasks.dokkaJavadoc.flatMap { it.outputDirectory })
archiveClassifier.set("javadoc")
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}

publishing {
Expand All @@ -95,9 +55,6 @@ publishing {
groupId = "dev.themeinerlp.plugin-debug"
artifactId = "bukkit-extension"
version = "%s%s".format(Locale.ROOT, baseVersion, snapshot)
artifact(dokkaJavadocJar)
artifact(dokkaHtmlJar)
artifact(sourceJar)
pom {
name.set("Bukkit Extension")
description.set("The extension for bukkit/paper/spigot for plugin debug")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
package dev.themeinerlp.plugindebug;

import io.papermc.lib.PaperLib;
import io.papermc.paper.datapack.Datapack;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;

import java.io.IOException;
import java.lang.management.ManagementFactory;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.regex.Pattern;

public final class BukkitDebugBuilder extends DebugBuilder<BukkitDebugBuilder> {

private Pattern privacyRegex = Pattern.compile("\\b(1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])\\.(1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])\\.(1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])\\.(1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])\\b");
private BukkitDebugBuilder(String uploadServer) {
super(uploadServer);
}

/**
* Collects the latest log file from bukkit
* @return the builder
* @throws IOException if the file empty/null
*/
public BukkitDebugBuilder collectLatestSpigotLog() throws IOException {
var latestLogFile = Path.of("logs", "latest.log");
if (Files.size(latestLogFile) >= maxZipFileSize) throw new IllegalStateException(
String.format("Latest log file is to big only %d bytes allowed", maxZipFileSize)
);
var tempLogFile = Files.createTempFile(tempFile, ".log");
var cleanedList = Files.readAllLines(latestLogFile).stream().map(s -> s.replaceAll(privacyRegex.pattern(), "*")).toList();
Files.write(tempLogFile, cleanedList);
addFile(tempLogFile, FileType.LOG, "Latest Log");
return this;
}

/**
* Collects default paper debug information
* @return the bukkit builder
* @throws IOException if the file empty/null
*/

public BukkitDebugBuilder defaultPaperDebugInformation() throws IOException {
var tempLogFile = Files.createTempFile(tempFile, ".yaml");
var plugins = Arrays.asList(Bukkit.getServer().getPluginManager().getPlugins());
plugins.sort(this::sortPluginABC);
var debugInformation = new YamlConfiguration();
debugInformation.set("server.version", Bukkit.getVersion());
debugInformation.set("server.plugins", plugins.size());
for (Plugin plugin : plugins) {
var name = plugin.getName();
debugInformation.set(String.format("server.plugin.%s.version", name), plugin.getDescription().getVersion());
debugInformation.set(String.format("server.plugin.%s.main", name), plugin.getDescription().getMain());
debugInformation.set(String.format("server.plugin.%s.authors", name), plugin.getDescription().getAuthors());
debugInformation.set(String.format("server.plugin.%s.load-before", name), plugin.getDescription().getLoadBefore());
debugInformation.set(String.format("server.plugin.%s.dependencies", name), plugin.getDescription().getDepend());
debugInformation.set(String.format("server.plugin.%s.soft-dependencies", name), plugin.getDescription().getSoftDepend());
debugInformation.set(String.format("server.plugin.%s.provides", name), plugin.getDescription().getProvides());
debugInformation.set(String.format("server.plugin.%s.enabled", name), plugin.isEnabled());
}
if (PaperLib.isPaper()) {
var dataPacks = Bukkit.getServer().getDatapackManager().getEnabledPacks();
debugInformation.set("server.datapacks.count", dataPacks.size());
debugInformation.set("server.datapacks.packs", dataPacks.stream().map(Datapack::getName).toList());
}
var runtime = Runtime.getRuntime();
var rb = ManagementFactory.getRuntimeMXBean();
debugInformation.set("uptime", rb.getUptime());
debugInformation.set("jvm-flags", rb.getInputArguments());
debugInformation.set("free-memory", runtime.freeMemory());
debugInformation.set("max-memory", runtime.maxMemory());
debugInformation.set("total-memory", runtime.totalMemory());
debugInformation.set("available-processors", runtime.availableProcessors());
debugInformation.set("java-name", rb.getVmName());
debugInformation.set("java-version", System.getProperty("java.version"));
debugInformation.set("java-vendor", System.getProperty("java.vendor"));
debugInformation.set("operating-system", System.getProperty("os.name"));
debugInformation.set("os-version", System.getProperty("os.version"));
debugInformation.set("os-arch", System.getProperty("os.arch"));
addYAML(debugInformation.saveToString(), "Default Paper Debug Information");
return this;
}

private int sortPluginABC(@NotNull Plugin A, @NotNull Plugin B) {
return A.getName().compareTo(B.getName());
}

/**
* Creates a bukkit builder instance with the given bytebin server
*
* @param uploadServer bytebin server base url
*/
public static BukkitDebugBuilder builder(String uploadServer) {
return new BukkitDebugBuilder(uploadServer);
}

}

This file was deleted.

Loading