use of com.velocitypowered.api.proxy.ProxyServer in project LibertyBans by A248.
the class VelocityLauncherTest method allBindings.
@Test
public void allBindings() {
ProxyServer proxyServer = mock(ProxyServer.class);
PluginContainer pluginContainer = mock(PluginContainer.class);
assertNotNull(new VelocityLauncher(Map.entry(pluginContainer, proxyServer), tempDir).launch());
}
use of com.velocitypowered.api.proxy.ProxyServer 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 com.velocitypowered.api.proxy.ProxyServer in project ChatRegulator by 4drian3d.
the class TestsUtils method createRegulator.
public static ChatRegulator createRegulator() {
ProxyServer proxy = createProxy();
Logger logger = LoggerFactory.getLogger(TestsUtils.class);
Path path = Path.of("build", "reports", "tests", "test");
return new ChatRegulator(proxy, logger, path, null) {
@Override
public IFormatter getFormatter() {
return new NormalFormatter();
}
};
}
use of com.velocitypowered.api.proxy.ProxyServer in project Plan by plan-player-analytics.
the class VelocityPingCounterTest method setUp.
@BeforeEach
void setUp() {
PlanVelocityMocker mocker = PlanVelocityMocker.setUp().withProxy();
plugin = mocker.getPlanMock();
player = Mockito.mock(Player.class);
when(player.getPing()).thenReturn(5L);
when(player.getUniqueId()).thenReturn(TestConstants.PLAYER_ONE_UUID);
ProxyServer proxy = plugin.getProxy();
when(proxy.getPlayer(TestConstants.PLAYER_ONE_UUID)).thenReturn(Optional.empty());
}
use of com.velocitypowered.api.proxy.ProxyServer in project Plan by plan-player-analytics.
the class PlanVelocityMocker method withProxy.
public PlanVelocityMocker withProxy() {
ProxyServer server = Mockito.mock(ProxyServer.class);
InetSocketAddress ip = new InetSocketAddress(25565);
doReturn(new ArrayList<>()).when(server).getAllServers();
doReturn(ip).when(server).getBoundAddress();
doReturn(server).when(planMock).getProxy();
return this;
}
Aggregations