de.eldoria.eldoutilities.debug.payload.ServerMeta Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of debugging Show documentation
Show all versions of debugging Show documentation
Utilitites for debugging plugins
/*
* SPDX-License-Identifier: LGPL-3.0-or-later
*
* Copyright (C) EldoriaRPG Team and Contributor
*/
package de.eldoria.eldoutilities.debug.payload;
import de.eldoria.eldoutilities.debug.data.PluginMetaData;
import de.eldoria.eldoutilities.debug.data.ServerMetaData;
import org.bukkit.Bukkit;
import org.bukkit.World;
import java.util.Arrays;
public final class ServerMeta extends ServerMetaData {
private ServerMeta(String version, int currentPlayers, String[] loadedWorlds, PluginMetaData[] plugins) {
super(version, currentPlayers, loadedWorlds, plugins);
}
public static ServerMetaData create() {
var server = Bukkit.getServer();
var version = server.getVersion();
var currentPlayers = server.getOnlinePlayers().size();
var loadedWorlds = server.getWorlds().stream().map(World::getName).toArray(String[]::new);
var plugins = Arrays.stream(server.getPluginManager().getPlugins())
.map(PluginMeta::create)
.toArray(PluginMeta[]::new);
return new ServerMeta(version, currentPlayers, loadedWorlds, plugins);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy