Add platform version information to debug reports

This commit is contained in:
Vankka 2024-11-30 14:41:38 +02:00
parent cdabd156ca
commit 611f8bba36
No known key found for this signature in database
GPG Key ID: 62E48025ED4E7EBB
6 changed files with 28 additions and 0 deletions

View File

@ -25,6 +25,7 @@ import com.discordsrv.common.core.logging.backend.impl.JavaLoggerImpl;
import dev.vankka.dependencydownload.classpath.ClasspathAppender;
import dev.vankka.dependencydownload.jarinjar.classloader.JarInJarClassLoader;
import dev.vankka.mcdependencydownload.bukkit.bootstrap.BukkitBootstrap;
import org.bukkit.Server;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.IOException;
@ -125,6 +126,12 @@ public class DiscordSRVBukkitBootstrap extends BukkitBootstrap implements IBoots
return getPlugin().getDataFolder().toPath();
}
@Override
public String platformVersion() {
Server server = getPlugin().getServer();
return server.getName() + " version " + server.getVersion() + " (implementation version " + server.getBukkitVersion() + ")";
}
public List<Runnable> mainThreadTasksForDisable() {
return mainThreadTasksForDisable;
}

View File

@ -25,6 +25,7 @@ import com.discordsrv.common.core.logging.backend.impl.JavaLoggerImpl;
import dev.vankka.dependencydownload.classpath.ClasspathAppender;
import dev.vankka.dependencydownload.jarinjar.classloader.JarInJarClassLoader;
import dev.vankka.mcdependencydownload.bungee.bootstrap.BungeeBootstrap;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.plugin.Plugin;
import java.io.IOException;
@ -82,4 +83,10 @@ public class DiscordSRVBungeeBootstrap extends BungeeBootstrap implements IBoots
public Path dataDirectory() {
return getPlugin().getDataFolder().toPath();
}
@Override
public String platformVersion() {
ProxyServer proxyServer = getPlugin().getProxy();
return proxyServer.getName() + " version " + proxyServer.getVersion();
}
}

View File

@ -33,5 +33,6 @@ public interface IBootstrap {
ClassLoader classLoader();
LifecycleManager lifecycleManager();
Path dataDirectory();
String platformVersion();
}

View File

@ -148,6 +148,7 @@ public class DebugReport {
private DebugFile environment() {
Map<String, Object> values = new LinkedHashMap<>();
values.put("discordSRV", discordSRV.getClass().getName());
values.put("platformVersion", discordSRV.bootstrap().platformVersion());
values.put("version", discordSRV.versionInfo().version());
values.put("gitRevision", discordSRV.versionInfo().gitRevision());
values.put("gitBranch", discordSRV.versionInfo().gitBranch());

View File

@ -100,6 +100,11 @@ public class MockDiscordSRV extends AbstractDiscordSRV<IBootstrap, MainConfig, C
public Path dataDirectory() {
return null;
}
@Override
public String platformVersion() {
return null;
}
});
load();
versionInfo = new VersionInfo("JUnit", "JUnit", "JUnit", "JUnit");

View File

@ -32,6 +32,7 @@ import com.velocitypowered.api.plugin.Plugin;
import com.velocitypowered.api.plugin.PluginContainer;
import com.velocitypowered.api.plugin.annotation.DataDirectory;
import com.velocitypowered.api.proxy.ProxyServer;
import com.velocitypowered.api.util.ProxyVersion;
import dev.vankka.dependencydownload.classpath.ClasspathAppender;
import dev.vankka.mcdependencydownload.velocity.classpath.VelocityClasspathAppender;
@ -111,6 +112,12 @@ public class DiscordSRVVelocityBootstrap implements IBootstrap {
return dataDirectory;
}
@Override
public String platformVersion() {
ProxyVersion version = proxyServer.getVersion();
return version.getName() + " (from " + version.getVendor() + ") version " + version.getVersion();
}
public ProxyServer proxyServer() {
return proxyServer;
}