Search in sources :

Example 1 with ProxyServer

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());
}
Also used : PluginContainer(com.velocitypowered.api.plugin.PluginContainer) ProxyServer(com.velocitypowered.api.proxy.ProxyServer) Test(org.junit.jupiter.api.Test)

Example 2 with ProxyServer

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;
}
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 3 with ProxyServer

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();
        }
    };
}
Also used : Path(java.nio.file.Path) NormalFormatter(me.dreamerzero.chatregulator.placeholders.formatter.NormalFormatter) ChatRegulator(me.dreamerzero.chatregulator.ChatRegulator) Logger(org.slf4j.Logger) ProxyServer(com.velocitypowered.api.proxy.ProxyServer)

Example 4 with ProxyServer

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());
}
Also used : Player(com.velocitypowered.api.proxy.Player) PlanVelocityMocker(utilities.mocks.PlanVelocityMocker) ProxyServer(com.velocitypowered.api.proxy.ProxyServer) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 5 with ProxyServer

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;
}
Also used : InetSocketAddress(java.net.InetSocketAddress) ProxyServer(com.velocitypowered.api.proxy.ProxyServer)

Aggregations

ProxyServer (com.velocitypowered.api.proxy.ProxyServer)10 PluginContainer (com.velocitypowered.api.plugin.PluginContainer)3 Path (java.nio.file.Path)2 Test (org.junit.jupiter.api.Test)2 Logger (org.slf4j.Logger)2 PluginDescription (com.velocitypowered.api.plugin.PluginDescription)1 PluginManager (com.velocitypowered.api.plugin.PluginManager)1 ConsoleCommandSource (com.velocitypowered.api.proxy.ConsoleCommandSource)1 Player (com.velocitypowered.api.proxy.Player)1 Scheduler (com.velocitypowered.api.scheduler.Scheduler)1 BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 PrintWriter (java.io.PrintWriter)1 InetSocketAddress (java.net.InetSocketAddress)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Executor (java.util.concurrent.Executor)1 ChatRegulator (me.dreamerzero.chatregulator.ChatRegulator)1