From 6f638ffb33e2aa1eb9b0f7a654cf596a8d48e5bd Mon Sep 17 00:00:00 2001 From: Vankka Date: Tue, 25 Jan 2022 18:25:21 +0200 Subject: [PATCH] Add OnlineMode & PluginManager --- .../discordsrv/bukkit/BukkitDiscordSRV.java | 35 ++++++++++++ .../bukkit/plugin/BukkitPluginManager.java | 52 +++++++++++++++++ .../discordsrv/bungee/BungeeDiscordSRV.java | 15 +++++ .../bungee/plugin/BungeePluginManager.java | 56 ++++++++++++++++++ .../com/discordsrv/common/DiscordSRV.java | 4 ++ .../common/debug/data/OnlineMode.java | 32 +++++++++++ .../com/discordsrv/common/plugin/Plugin.java | 56 ++++++++++++++++++ .../common/plugin/PluginManager.java | 28 +++++++++ .../com/discordsrv/common/MockDiscordSRV.java | 12 ++++ .../com/discordsrv/config/MockDiscordSRV.java | 12 ++++ .../discordsrv/sponge/SpongeDiscordSRV.java | 24 ++++++-- .../sponge/plugin/SpongePluginManager.java | 56 ++++++++++++++++++ .../velocity/VelocityDiscordSRV.java | 17 +++++- .../plugin/VelocityPluginManager.java | 57 +++++++++++++++++++ 14 files changed, 449 insertions(+), 7 deletions(-) create mode 100644 bukkit/src/main/java/com/discordsrv/bukkit/plugin/BukkitPluginManager.java create mode 100644 bungee/src/main/java/com/discordsrv/bungee/plugin/BungeePluginManager.java create mode 100644 common/src/main/java/com/discordsrv/common/debug/data/OnlineMode.java create mode 100644 common/src/main/java/com/discordsrv/common/plugin/Plugin.java create mode 100644 common/src/main/java/com/discordsrv/common/plugin/PluginManager.java create mode 100644 sponge/src/main/java/com/discordsrv/sponge/plugin/SpongePluginManager.java create mode 100644 velocity/src/main/java/com/discordsrv/velocity/plugin/VelocityPluginManager.java diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/BukkitDiscordSRV.java b/bukkit/src/main/java/com/discordsrv/bukkit/BukkitDiscordSRV.java index f987a3e6..ac01d94b 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/BukkitDiscordSRV.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/BukkitDiscordSRV.java @@ -29,11 +29,14 @@ import com.discordsrv.bukkit.listener.BukkitChatListener; import com.discordsrv.bukkit.listener.BukkitDeathListener; import com.discordsrv.bukkit.listener.BukkitStatusMessageListener; import com.discordsrv.bukkit.player.BukkitPlayerProvider; +import com.discordsrv.bukkit.plugin.BukkitPluginManager; import com.discordsrv.bukkit.scheduler.BukkitScheduler; import com.discordsrv.common.config.manager.ConnectionConfigManager; import com.discordsrv.common.config.manager.MainConfigManager; +import com.discordsrv.common.debug.data.OnlineMode; import com.discordsrv.common.logging.Logger; import com.discordsrv.common.messageforwarding.game.MinecraftToDiscordChatModule; +import com.discordsrv.common.plugin.PluginManager; import com.discordsrv.common.server.ServerDiscordSRV; import net.kyori.adventure.platform.bukkit.BukkitAudiences; import org.bukkit.Server; @@ -41,6 +44,7 @@ import org.bukkit.plugin.ServicePriority; import org.bukkit.plugin.java.JavaPlugin; import org.jetbrains.annotations.NotNull; +import java.lang.reflect.Field; import java.nio.file.Path; public class BukkitDiscordSRV extends ServerDiscordSRV { @@ -53,6 +57,7 @@ public class BukkitDiscordSRV extends ServerDiscordSRV paperConfig = Class.forName("com.destroystokyo.paper.PaperConfig"); + Field velocitySupport = paperConfig.getField("velocitySupport"); + Field velocityOnlineMode = paperConfig.getField("velocityOnlineMode"); + + if (velocitySupport.getBoolean(null) && velocityOnlineMode.getBoolean(null)) { + return OnlineMode.VELOCITY; + } + } catch (Throwable ignored) {} + + try { + Class spigotConfig = Class.forName("org.spigotmc.SpigotConfig"); + Field bungee = spigotConfig.getField("bungee"); + + if (bungee.getBoolean(null)) { + return OnlineMode.BUNGEE; + } + } catch (Throwable ignored) {} + + return OnlineMode.of(server().getOnlineMode()); + } + @Override public ConnectionConfigManager connectionConfigManager() { return connectionConfigManager; diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/plugin/BukkitPluginManager.java b/bukkit/src/main/java/com/discordsrv/bukkit/plugin/BukkitPluginManager.java new file mode 100644 index 00000000..d9fe1732 --- /dev/null +++ b/bukkit/src/main/java/com/discordsrv/bukkit/plugin/BukkitPluginManager.java @@ -0,0 +1,52 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2022 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.discordsrv.bukkit.plugin; + +import com.discordsrv.bukkit.BukkitDiscordSRV; +import com.discordsrv.common.plugin.Plugin; +import com.discordsrv.common.plugin.PluginManager; +import org.bukkit.plugin.PluginDescriptionFile; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +public class BukkitPluginManager implements PluginManager { + + private final BukkitDiscordSRV discordSRV; + + public BukkitPluginManager(BukkitDiscordSRV discordSRV) { + this.discordSRV = discordSRV; + } + + @Override + public boolean isPluginEnabled(String pluginName) { + return discordSRV.server().getPluginManager().isPluginEnabled(pluginName); + } + + @Override + public List getPlugins() { + return Arrays.stream(discordSRV.server().getPluginManager().getPlugins()) + .map(plugin -> { + PluginDescriptionFile description = plugin.getDescription(); + return new Plugin(plugin.getName(), description.getVersion(), description.getAuthors()); + }) + .collect(Collectors.toList()); + } +} diff --git a/bungee/src/main/java/com/discordsrv/bungee/BungeeDiscordSRV.java b/bungee/src/main/java/com/discordsrv/bungee/BungeeDiscordSRV.java index 795ff2a3..7820e3b3 100644 --- a/bungee/src/main/java/com/discordsrv/bungee/BungeeDiscordSRV.java +++ b/bungee/src/main/java/com/discordsrv/bungee/BungeeDiscordSRV.java @@ -20,11 +20,14 @@ package com.discordsrv.bungee; import com.discordsrv.bungee.console.BungeeConsole; import com.discordsrv.bungee.player.BungeePlayerProvider; +import com.discordsrv.bungee.plugin.BungeePluginManager; import com.discordsrv.common.config.connection.ConnectionConfig; import com.discordsrv.common.config.main.MainConfig; import com.discordsrv.common.config.manager.ConnectionConfigManager; import com.discordsrv.common.config.manager.MainConfigManager; +import com.discordsrv.common.debug.data.OnlineMode; import com.discordsrv.common.logging.Logger; +import com.discordsrv.common.plugin.PluginManager; import com.discordsrv.common.scheduler.StandardScheduler; import com.discordsrv.proxy.ProxyDiscordSRV; import net.kyori.adventure.platform.bungeecord.BungeeAudiences; @@ -44,6 +47,7 @@ public class BungeeDiscordSRV extends ProxyDiscordSRV connectionConfigManager() { return null; diff --git a/bungee/src/main/java/com/discordsrv/bungee/plugin/BungeePluginManager.java b/bungee/src/main/java/com/discordsrv/bungee/plugin/BungeePluginManager.java new file mode 100644 index 00000000..772bce3d --- /dev/null +++ b/bungee/src/main/java/com/discordsrv/bungee/plugin/BungeePluginManager.java @@ -0,0 +1,56 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2022 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.discordsrv.bungee.plugin; + +import com.discordsrv.bungee.BungeeDiscordSRV; +import com.discordsrv.common.plugin.Plugin; +import com.discordsrv.common.plugin.PluginManager; +import net.md_5.bungee.api.plugin.PluginDescription; + +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +public class BungeePluginManager implements PluginManager { + + private final BungeeDiscordSRV discordSRV; + + public BungeePluginManager(BungeeDiscordSRV discordSRV) { + this.discordSRV = discordSRV; + } + + @Override + public boolean isPluginEnabled(String pluginName) { + return discordSRV.proxy().getPluginManager().getPlugin(pluginName) != null; + } + + @Override + public List getPlugins() { + return discordSRV.proxy().getPluginManager().getPlugins().stream() + .map(plugin -> { + PluginDescription description = plugin.getDescription(); + return new Plugin( + description.getName(), + description.getVersion(), + Collections.singletonList(description.getAuthor()) + ); + }) + .collect(Collectors.toList()); + } +} diff --git a/common/src/main/java/com/discordsrv/common/DiscordSRV.java b/common/src/main/java/com/discordsrv/common/DiscordSRV.java index 4dafdbb0..7e095348 100644 --- a/common/src/main/java/com/discordsrv/common/DiscordSRV.java +++ b/common/src/main/java/com/discordsrv/common/DiscordSRV.java @@ -26,6 +26,7 @@ import com.discordsrv.common.config.main.MainConfig; import com.discordsrv.common.config.manager.ConnectionConfigManager; import com.discordsrv.common.config.manager.MainConfigManager; import com.discordsrv.common.console.Console; +import com.discordsrv.common.debug.data.OnlineMode; import com.discordsrv.common.discord.api.DiscordAPIImpl; import com.discordsrv.common.discord.connection.DiscordConnectionManager; import com.discordsrv.common.logging.impl.DiscordSRVLogger; @@ -33,6 +34,7 @@ import com.discordsrv.common.module.type.AbstractModule; import com.discordsrv.api.module.type.Module; import com.discordsrv.common.placeholder.PlaceholderServiceImpl; import com.discordsrv.common.player.provider.AbstractPlayerProvider; +import com.discordsrv.common.plugin.PluginManager; import com.discordsrv.common.scheduler.Scheduler; import com.discordsrv.common.logging.Logger; import com.github.benmanes.caffeine.cache.Caffeine; @@ -53,6 +55,8 @@ public interface DiscordSRV extends DiscordSRVApi { Scheduler scheduler(); Console console(); String version(); + PluginManager pluginManager(); + OnlineMode onlineMode(); // DiscordSRVApi @Override diff --git a/common/src/main/java/com/discordsrv/common/debug/data/OnlineMode.java b/common/src/main/java/com/discordsrv/common/debug/data/OnlineMode.java new file mode 100644 index 00000000..3c9c2c0f --- /dev/null +++ b/common/src/main/java/com/discordsrv/common/debug/data/OnlineMode.java @@ -0,0 +1,32 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2022 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.discordsrv.common.debug.data; + +public enum OnlineMode { + + ONLINE, + OFFLINE, + BUNGEE, + VELOCITY; + + public static OnlineMode of(boolean onlineMode) { + return onlineMode ? OnlineMode.ONLINE : OnlineMode.OFFLINE; + } + +} diff --git a/common/src/main/java/com/discordsrv/common/plugin/Plugin.java b/common/src/main/java/com/discordsrv/common/plugin/Plugin.java new file mode 100644 index 00000000..ea3e9977 --- /dev/null +++ b/common/src/main/java/com/discordsrv/common/plugin/Plugin.java @@ -0,0 +1,56 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2022 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.discordsrv.common.plugin; + +import java.util.List; + +public class Plugin { + + private final String identifier; + private final String name; + private final String version; + private final List authors; + + public Plugin(String name, String version, List authors) { + this(name, name, version, authors); + } + + public Plugin(String identifier, String name, String version, List authors) { + this.identifier = identifier; + this.name = name; + this.version = version; + this.authors = authors; + } + + public String identifier() { + return identifier; + } + + public String name() { + return name; + } + + public String version() { + return version; + } + + public List authors() { + return authors; + } +} diff --git a/common/src/main/java/com/discordsrv/common/plugin/PluginManager.java b/common/src/main/java/com/discordsrv/common/plugin/PluginManager.java new file mode 100644 index 00000000..9761b818 --- /dev/null +++ b/common/src/main/java/com/discordsrv/common/plugin/PluginManager.java @@ -0,0 +1,28 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2022 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.discordsrv.common.plugin; + +import java.util.List; + +public interface PluginManager { + + boolean isPluginEnabled(String pluginIdentifier); + List getPlugins(); + +} diff --git a/common/src/test/java/com/discordsrv/common/MockDiscordSRV.java b/common/src/test/java/com/discordsrv/common/MockDiscordSRV.java index 2769ecf2..67ba53a3 100644 --- a/common/src/test/java/com/discordsrv/common/MockDiscordSRV.java +++ b/common/src/test/java/com/discordsrv/common/MockDiscordSRV.java @@ -23,9 +23,11 @@ import com.discordsrv.common.config.main.MainConfig; import com.discordsrv.common.config.manager.ConnectionConfigManager; import com.discordsrv.common.config.manager.MainConfigManager; import com.discordsrv.common.console.Console; +import com.discordsrv.common.debug.data.OnlineMode; import com.discordsrv.common.logging.Logger; import com.discordsrv.common.logging.backend.impl.JavaLoggerImpl; import com.discordsrv.common.player.provider.AbstractPlayerProvider; +import com.discordsrv.common.plugin.PluginManager; import com.discordsrv.common.scheduler.Scheduler; import com.discordsrv.common.scheduler.StandardScheduler; import org.jetbrains.annotations.NotNull; @@ -69,6 +71,16 @@ public class MockDiscordSRV extends AbstractDiscordSRV playerProvider() { return null; diff --git a/i18n/src/main/java/com/discordsrv/config/MockDiscordSRV.java b/i18n/src/main/java/com/discordsrv/config/MockDiscordSRV.java index 0d3f27e4..b752fb05 100644 --- a/i18n/src/main/java/com/discordsrv/config/MockDiscordSRV.java +++ b/i18n/src/main/java/com/discordsrv/config/MockDiscordSRV.java @@ -24,8 +24,10 @@ import com.discordsrv.common.config.main.MainConfig; import com.discordsrv.common.config.manager.ConnectionConfigManager; import com.discordsrv.common.config.manager.MainConfigManager; import com.discordsrv.common.console.Console; +import com.discordsrv.common.debug.data.OnlineMode; import com.discordsrv.common.logging.Logger; import com.discordsrv.common.player.provider.AbstractPlayerProvider; +import com.discordsrv.common.plugin.PluginManager; import com.discordsrv.common.scheduler.Scheduler; import org.jetbrains.annotations.NotNull; @@ -59,6 +61,16 @@ public class MockDiscordSRV extends AbstractDiscordSRV playerProvider() { return null; diff --git a/sponge/src/main/java/com/discordsrv/sponge/SpongeDiscordSRV.java b/sponge/src/main/java/com/discordsrv/sponge/SpongeDiscordSRV.java index f761cff2..7284acca 100644 --- a/sponge/src/main/java/com/discordsrv/sponge/SpongeDiscordSRV.java +++ b/sponge/src/main/java/com/discordsrv/sponge/SpongeDiscordSRV.java @@ -23,13 +23,15 @@ import com.discordsrv.common.config.connection.ConnectionConfig; import com.discordsrv.common.config.main.MainConfig; import com.discordsrv.common.config.manager.ConnectionConfigManager; import com.discordsrv.common.config.manager.MainConfigManager; +import com.discordsrv.common.debug.data.OnlineMode; import com.discordsrv.common.logging.Logger; +import com.discordsrv.common.plugin.PluginManager; import com.discordsrv.common.server.ServerDiscordSRV; import com.discordsrv.sponge.console.SpongeConsole; import com.discordsrv.sponge.player.SpongePlayerProvider; +import com.discordsrv.sponge.plugin.SpongePluginManager; import com.discordsrv.sponge.scheduler.SpongeScheduler; import dev.vankka.mcdependencydownload.classloader.JarInJarClassLoader; -import org.apache.maven.artifact.versioning.ArtifactVersion; import org.jetbrains.annotations.NotNull; import org.spongepowered.api.Game; import org.spongepowered.api.event.Listener; @@ -48,6 +50,7 @@ public class SpongeDiscordSRV extends ServerDiscordSRV. + */ + +package com.discordsrv.sponge.plugin; + +import com.discordsrv.common.plugin.Plugin; +import com.discordsrv.common.plugin.PluginManager; +import com.discordsrv.sponge.SpongeDiscordSRV; +import org.spongepowered.plugin.metadata.PluginMetadata; +import org.spongepowered.plugin.metadata.model.PluginContributor; + +import java.util.List; +import java.util.stream.Collectors; + +public class SpongePluginManager implements PluginManager { + + private final SpongeDiscordSRV discordSRV; + + public SpongePluginManager(SpongeDiscordSRV discordSRV) { + this.discordSRV = discordSRV; + } + + @Override + public boolean isPluginEnabled(String pluginName) { + return discordSRV.game().pluginManager().plugin(pluginName).isPresent(); + } + + @Override + public List getPlugins() { + return discordSRV.game().pluginManager().plugins().stream() + .map(container -> { + PluginMetadata metadata = container.metadata(); + String id = metadata.id(); + List authors = metadata.contributors().stream() + .map(PluginContributor::name) + .collect(Collectors.toList()); + return new Plugin(id, metadata.name().orElse(id), metadata.version().toString(), authors); + }) + .collect(Collectors.toList()); + } +} diff --git a/velocity/src/main/java/com/discordsrv/velocity/VelocityDiscordSRV.java b/velocity/src/main/java/com/discordsrv/velocity/VelocityDiscordSRV.java index 7560a07c..0ad5f310 100644 --- a/velocity/src/main/java/com/discordsrv/velocity/VelocityDiscordSRV.java +++ b/velocity/src/main/java/com/discordsrv/velocity/VelocityDiscordSRV.java @@ -22,11 +22,14 @@ import com.discordsrv.common.config.connection.ConnectionConfig; import com.discordsrv.common.config.main.MainConfig; import com.discordsrv.common.config.manager.ConnectionConfigManager; import com.discordsrv.common.config.manager.MainConfigManager; +import com.discordsrv.common.debug.data.OnlineMode; import com.discordsrv.common.logging.Logger; +import com.discordsrv.common.plugin.PluginManager; import com.discordsrv.common.scheduler.StandardScheduler; import com.discordsrv.proxy.ProxyDiscordSRV; import com.discordsrv.velocity.console.VelocityConsole; import com.discordsrv.velocity.player.VelocityPlayerProvider; +import com.discordsrv.velocity.plugin.VelocityPluginManager; import com.velocitypowered.api.plugin.PluginContainer; import com.velocitypowered.api.proxy.ProxyServer; import org.jetbrains.annotations.NotNull; @@ -44,6 +47,7 @@ public class VelocityDiscordSRV extends ProxyDiscordSRV new IllegalStateException("No version")); + return container().getDescription().getVersion().orElseThrow(() -> new IllegalStateException("No version")); + } + + @Override + public PluginManager pluginManager() { + return pluginManager; + } + + @Override + public OnlineMode onlineMode() { + return OnlineMode.of(proxy().getConfiguration().isOnlineMode()); } @Override diff --git a/velocity/src/main/java/com/discordsrv/velocity/plugin/VelocityPluginManager.java b/velocity/src/main/java/com/discordsrv/velocity/plugin/VelocityPluginManager.java new file mode 100644 index 00000000..8b29d3b8 --- /dev/null +++ b/velocity/src/main/java/com/discordsrv/velocity/plugin/VelocityPluginManager.java @@ -0,0 +1,57 @@ +/* + * This file is part of DiscordSRV, licensed under the GPLv3 License + * Copyright (c) 2016-2022 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.discordsrv.velocity.plugin; + +import com.discordsrv.common.plugin.Plugin; +import com.discordsrv.common.plugin.PluginManager; +import com.discordsrv.velocity.VelocityDiscordSRV; +import com.velocitypowered.api.plugin.PluginDescription; + +import java.util.List; +import java.util.stream.Collectors; + +public class VelocityPluginManager implements PluginManager { + + private final VelocityDiscordSRV discordSRV; + + public VelocityPluginManager(VelocityDiscordSRV discordSRV) { + this.discordSRV = discordSRV; + } + + @Override + public boolean isPluginEnabled(String pluginName) { + return discordSRV.proxy().getPluginManager().isLoaded(pluginName); + } + + @Override + public List getPlugins() { + return discordSRV.proxy().getPluginManager().getPlugins().stream() + .map(container -> { + PluginDescription description = container.getDescription(); + String id = description.getId(); + return new Plugin( + id, + description.getName().orElse(id), + description.getVersion().orElse("Unknown"), + description.getAuthors() + ); + }) + .collect(Collectors.toList()); + } +}