Search in sources :

Example 1 with Platform

use of space.arim.libertybans.bootstrap.Platform in project LibertyBans by A248.

the class VelocityInitializer method initialize.

BaseFoundation initialize() {
    Platform platform = detectPlatform();
    ProxyServer server = velocityPlugin.server;
    Path folder = velocityPlugin.folder;
    Logger logger = velocityPlugin.logger;
    PluginContainer plugin = server.getPluginManager().fromInstance(velocityPlugin).get();
    Scheduler scheduler = server.getScheduler();
    Executor executor = (cmd) -> scheduler.buildTask(plugin, cmd).schedule();
    Path jarFile = plugin.getDescription().getSource().get();
    LibertyBansLauncher launcher = new LibertyBansLauncher(new Slf4jBootstrapLogger(velocityPlugin.logger), platform, velocityPlugin.folder, executor, jarFile, new VelocityCulpritFinder(server));
    ClassLoader launchLoader = launcher.attemptLaunch().join();
    if (launchLoader == null) {
        logger.warn("Failed to launch LibertyBans");
        return null;
    }
    BaseFoundation base;
    try {
        base = new Instantiator("space.arim.libertybans.env.velocity.VelocityLauncher", launchLoader).invoke(Map.Entry.class, Map.entry(plugin, server), folder);
    } catch (IllegalArgumentException | SecurityException | ReflectiveOperationException ex) {
        logger.warn("Failed to launch LibertyBans", ex);
        return null;
    }
    base.startup();
    return base;
}
Also used : Path(java.nio.file.Path) Platforms(space.arim.libertybans.bootstrap.Platforms) Logger(org.slf4j.Logger) Executor(java.util.concurrent.Executor) LibertyBansLauncher(space.arim.libertybans.bootstrap.LibertyBansLauncher) BaseFoundation(space.arim.libertybans.bootstrap.BaseFoundation) Platform(space.arim.libertybans.bootstrap.Platform) Slf4jBootstrapLogger(space.arim.libertybans.bootstrap.logger.Slf4jBootstrapLogger) Scheduler(com.velocitypowered.api.scheduler.Scheduler) ProxyServer(com.velocitypowered.api.proxy.ProxyServer) Map(java.util.Map) Instantiator(space.arim.libertybans.bootstrap.Instantiator) PluginContainer(com.velocitypowered.api.plugin.PluginContainer) Path(java.nio.file.Path) LibertyBansLauncher(space.arim.libertybans.bootstrap.LibertyBansLauncher) BaseFoundation(space.arim.libertybans.bootstrap.BaseFoundation) PluginContainer(com.velocitypowered.api.plugin.PluginContainer) Platform(space.arim.libertybans.bootstrap.Platform) Scheduler(com.velocitypowered.api.scheduler.Scheduler) Slf4jBootstrapLogger(space.arim.libertybans.bootstrap.logger.Slf4jBootstrapLogger) Instantiator(space.arim.libertybans.bootstrap.Instantiator) Logger(org.slf4j.Logger) Slf4jBootstrapLogger(space.arim.libertybans.bootstrap.logger.Slf4jBootstrapLogger) ProxyServer(com.velocitypowered.api.proxy.ProxyServer) Executor(java.util.concurrent.Executor)

Example 2 with Platform

use of space.arim.libertybans.bootstrap.Platform in project LibertyBans by A248.

the class PaperSlf4jTest method detectPlatform.

@Test
public void detectPlatform() {
    JavaPlugin plugin = MockJavaPlugin.create(dataFolder, (server) -> {
        when(server.getVersion()).thenReturn("version");
    });
    BootstrapLogger logger = new Slf4jBootstrapLogger(LoggerFactory.getLogger(getClass()));
    Platform platform = new BaseWrapper.Creator(plugin, logger, dataFolder).detectPlatform();
    assertTrue(platform.hasSlf4jSupport());
    assertFalse(platform.hasKyoriAdventureSupport());
}
Also used : Platform(space.arim.libertybans.bootstrap.Platform) JavaPlugin(org.bukkit.plugin.java.JavaPlugin) Slf4jBootstrapLogger(space.arim.libertybans.bootstrap.logger.Slf4jBootstrapLogger) BootstrapLogger(space.arim.libertybans.bootstrap.logger.BootstrapLogger) Slf4jBootstrapLogger(space.arim.libertybans.bootstrap.logger.Slf4jBootstrapLogger) Test(org.junit.jupiter.api.Test)

Example 3 with Platform

use of space.arim.libertybans.bootstrap.Platform in project LibertyBans by A248.

the class BaseWrapperTest method detectPlatform.

@Test
public void detectPlatform() {
    JavaPlugin plugin = MockJavaPlugin.create(dataFolder, (server) -> {
        when(server.getVersion()).thenReturn("version");
    });
    BootstrapLogger logger = new Slf4jBootstrapLogger(LoggerFactory.getLogger(getClass()));
    Platform platform = new BaseWrapper.Creator(plugin, logger, dataFolder).detectPlatform();
    assertFalse(platform.hasSlf4jSupport());
    assertFalse(platform.hasKyoriAdventureSupport());
}
Also used : Platform(space.arim.libertybans.bootstrap.Platform) JavaPlugin(org.bukkit.plugin.java.JavaPlugin) Slf4jBootstrapLogger(space.arim.libertybans.bootstrap.logger.Slf4jBootstrapLogger) Slf4jBootstrapLogger(space.arim.libertybans.bootstrap.logger.Slf4jBootstrapLogger) BootstrapLogger(space.arim.libertybans.bootstrap.logger.BootstrapLogger) Test(org.junit.jupiter.api.Test)

Example 4 with Platform

use of space.arim.libertybans.bootstrap.Platform in project LibertyBans by A248.

the class BaseWrapperTest method detectPlatform.

@Test
public void detectPlatform() {
    BootstrapLogger logger = new Slf4jBootstrapLogger(LoggerFactory.getLogger(getClass()));
    Platform platform = new BaseWrapper.Creator(MockPlugin.create(), logger).detectPlatform();
    assertTrue(platform.hasSlf4jSupport());
    assertFalse(platform.hasKyoriAdventureSupport());
}
Also used : Platform(space.arim.libertybans.bootstrap.Platform) Slf4jBootstrapLogger(space.arim.libertybans.bootstrap.logger.Slf4jBootstrapLogger) Slf4jBootstrapLogger(space.arim.libertybans.bootstrap.logger.Slf4jBootstrapLogger) BootstrapLogger(space.arim.libertybans.bootstrap.logger.BootstrapLogger) Test(org.junit.jupiter.api.Test)

Example 5 with Platform

use of space.arim.libertybans.bootstrap.Platform in project LibertyBans by A248.

the class WaterfallSlf4jTest method detectPlatform.

@Test
public void detectPlatform() {
    BootstrapLogger logger = new Slf4jBootstrapLogger(LoggerFactory.getLogger(getClass()));
    Platform platform = new BaseWrapper.Creator(MockPlugin.create(), logger).detectPlatform();
    assertTrue(platform.hasSlf4jSupport());
    assertFalse(platform.hasKyoriAdventureSupport());
}
Also used : Platform(space.arim.libertybans.bootstrap.Platform) Slf4jBootstrapLogger(space.arim.libertybans.bootstrap.logger.Slf4jBootstrapLogger) Slf4jBootstrapLogger(space.arim.libertybans.bootstrap.logger.Slf4jBootstrapLogger) BootstrapLogger(space.arim.libertybans.bootstrap.logger.BootstrapLogger) Test(org.junit.jupiter.api.Test)

Aggregations

Platform (space.arim.libertybans.bootstrap.Platform)9 Test (org.junit.jupiter.api.Test)8 Slf4jBootstrapLogger (space.arim.libertybans.bootstrap.logger.Slf4jBootstrapLogger)6 BootstrapLogger (space.arim.libertybans.bootstrap.logger.BootstrapLogger)5 ProxyServer (com.velocitypowered.api.proxy.ProxyServer)3 JavaPlugin (org.bukkit.plugin.java.JavaPlugin)3 PluginContainer (com.velocitypowered.api.plugin.PluginContainer)1 Scheduler (com.velocitypowered.api.scheduler.Scheduler)1 ClassGraph (io.github.classgraph.ClassGraph)1 ScanResult (io.github.classgraph.ScanResult)1 Path (java.nio.file.Path)1 Map (java.util.Map)1 Executor (java.util.concurrent.Executor)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 Logger (org.slf4j.Logger)1 BaseFoundation (space.arim.libertybans.bootstrap.BaseFoundation)1 Instantiator (space.arim.libertybans.bootstrap.Instantiator)1 LibertyBansLauncher (space.arim.libertybans.bootstrap.LibertyBansLauncher)1 Platforms (space.arim.libertybans.bootstrap.Platforms)1