Search in sources :

Example 6 with PluginContainer

use of com.velocitypowered.api.plugin.PluginContainer in project Geyser by GeyserMC.

the class GeyserVelocityConfiguration method loadFloodgate.

public void loadFloodgate(GeyserVelocityPlugin plugin, ProxyServer proxyServer, File dataFolder) {
    Optional<PluginContainer> floodgate = proxyServer.getPluginManager().getPlugin("floodgate");
    Path floodgateDataPath = floodgate.isPresent() ? Paths.get("plugins/floodgate/") : null;
    floodgateKeyPath = FloodgateKeyLoader.getKeyPath(this, floodgateDataPath, dataFolder.toPath(), plugin.getGeyserLogger());
}
Also used : Path(java.nio.file.Path) PluginContainer(com.velocitypowered.api.plugin.PluginContainer)

Example 7 with PluginContainer

use of com.velocitypowered.api.plugin.PluginContainer in project ViaVersion by ViaVersion.

the class VelocityPlugin method getDump.

@Override
public JsonObject getDump() {
    JsonObject extra = new JsonObject();
    List<PluginInfo> plugins = new ArrayList<>();
    for (PluginContainer p : PROXY.getPluginManager().getPlugins()) {
        plugins.add(new PluginInfo(true, p.getDescription().getName().orElse(p.getDescription().getId()), p.getDescription().getVersion().orElse("Unknown Version"), p.getInstance().isPresent() ? p.getInstance().get().getClass().getCanonicalName() : "Unknown", p.getDescription().getAuthors()));
    }
    extra.add("plugins", GsonUtil.getGson().toJsonTree(plugins));
    extra.add("servers", GsonUtil.getGson().toJsonTree(ProtocolDetectorService.getDetectedIds()));
    return extra;
}
Also used : PluginContainer(com.velocitypowered.api.plugin.PluginContainer) ArrayList(java.util.ArrayList) JsonObject(com.google.gson.JsonObject) PluginInfo(com.viaversion.viaversion.dump.PluginInfo)

Example 8 with PluginContainer

use of com.velocitypowered.api.plugin.PluginContainer in project LibertyBans by A248.

the class VelocityCulpritFinderTest method findCulprit.

@Test
public void findCulprit(@Mock ProxyServer server, @Mock PluginManager pluginManager, @Mock PluginContainer pluginString, @Mock PluginContainer pluginOwnClass) {
    class OwnClass {
    }
    {
        when(server.getPluginManager()).thenReturn(pluginManager);
        when(pluginManager.getPlugins()).thenReturn(List.of(pluginString, pluginOwnClass));
        when(pluginString.getInstance()).thenAnswer((i) -> Optional.of("a".concat("b")));
        setDescription(pluginString, "JDK", "0");
        when(pluginOwnClass.getInstance()).thenAnswer((i) -> Optional.of(new OwnClass()));
        setDescription(pluginOwnClass, "Self", "1");
    }
    CulpritFinder culpritFinder = new VelocityCulpritFinder(server);
    assertEquals("JDK 0", culpritFinder.findCulprit(List.class));
    assertEquals("Self 1", culpritFinder.findCulprit(getClass()));
}
Also used : MockitoExtension(org.mockito.junit.jupiter.MockitoExtension) CulpritFinder(space.arim.libertybans.bootstrap.CulpritFinder) PluginDescription(com.velocitypowered.api.plugin.PluginDescription) Mock(org.mockito.Mock) Mockito.when(org.mockito.Mockito.when) Test(org.junit.jupiter.api.Test) List(java.util.List) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) ProxyServer(com.velocitypowered.api.proxy.ProxyServer) Optional(java.util.Optional) PluginContainer(com.velocitypowered.api.plugin.PluginContainer) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) PluginManager(com.velocitypowered.api.plugin.PluginManager) Mockito.mock(org.mockito.Mockito.mock) CulpritFinder(space.arim.libertybans.bootstrap.CulpritFinder) List(java.util.List) Test(org.junit.jupiter.api.Test)

Aggregations

PluginContainer (com.velocitypowered.api.plugin.PluginContainer)8 ProxyServer (com.velocitypowered.api.proxy.ProxyServer)3 PluginDescription (com.velocitypowered.api.plugin.PluginDescription)2 Path (java.nio.file.Path)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Test (org.junit.jupiter.api.Test)2 ListMultimap (com.google.common.collect.ListMultimap)1 JsonObject (com.google.gson.JsonObject)1 Subscribe (com.velocitypowered.api.event.Subscribe)1 PluginManager (com.velocitypowered.api.plugin.PluginManager)1 Scheduler (com.velocitypowered.api.scheduler.Scheduler)1 PluginInfo (com.viaversion.viaversion.dump.PluginInfo)1 ChocolateCommand (io.alerium.chocolate.command.constructor.ChocolateCommand)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Executor (java.util.concurrent.Executor)1 Channel (net.william278.huskchat.channel.Channel)1 DefaultDataGetter (net.william278.huskchat.getter.DefaultDataGetter)1 LuckPermsDataGetter (net.william278.huskchat.getter.LuckPermsDataGetter)1