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;
}
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());
}
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());
}
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());
}
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());
}
Aggregations