@Override public void onVoteReceived(Channel channel, final Vote vote, VotifierSession.ProtocolVersion protocolVersion) { if (debug) { if (protocolVersion == VotifierSession.ProtocolVersion.ONE) { logger.info("Got a protocol v1 vote record from " + channel.remoteAddress() + " -> " + vote); } else { logger.info("Got a protocol v2 vote record from " + channel.remoteAddress() + " -> " + vote); } } server.getEventManager().fireAndForget(new VotifierEvent(vote)); if (forwardingMethod != null) { forwardingMethod.forward(vote); } }
/** * Requests that the specified {@code handler} listen for events and associate it with the {@code * plugin}. * * @param plugin the plugin to associate with the handler * @param eventClass the class for the event handler to register * @param handler the handler to register * @param <E> the event type to handle */ default <E> void register(Object plugin, Class<E> eventClass, EventHandler<E> handler) { register(plugin, eventClass, PostOrder.NORMAL, handler); }
/** * Posts the specified event to the event bus and discards the result. * * @param event the event to fire */ default void fireAndForget(Object event) { fire(event); }
@Override protected void unregisterListeners() { plugin.getProxy().getEventManager().unregisterListeners(plugin); }
public void setModInfo(ModInfo modInfo) { this.modInfo = modInfo; server.getEventManager().fireAndForget(new PlayerModInfoEvent(this, modInfo)); }
/** * Sets up permissions for the console. */ public void setupPermissions() { PermissionsSetupEvent event = new PermissionsSetupEvent(this, s -> ALWAYS_TRUE); // we can safely block here, this is before any listeners fire this.permissionFunction = this.server.getEventManager().fire(event).join().createFunction(this); }
public OnlineForwardPluginMessagingForwardingSource(String channel, ServerFilter serverFilter, VotifierPlugin plugin, VoteCache cache, String fallbackServer, int dumpRate) { super(channel, serverFilter, plugin, cache, dumpRate); this.fallbackServer = fallbackServer; this.plugin = plugin; this.velocityChannelId = VelocityUtil.getId(channel); plugin.getServer().getChannelRegistrar().register(velocityChannelId); plugin.getServer().getEventManager().register(plugin, this); }
void setPlayerSettings(ClientSettings settings) { ClientSettingsWrapper cs = new ClientSettingsWrapper(settings); this.settings = cs; server.getEventManager().fireAndForget(new PlayerSettingsChangedEvent(this, cs)); }
return server.getEventManager().fire(event) .thenCompose(newEvent -> { Optional<RegisteredServer> connectTo = newEvent.getResult().getServer();
public PluginMessagingForwardingSource(String channel, ServerFilter serverFilter, VotifierPlugin plugin, VoteCache cache, int dumpRate) { super(channel, serverFilter, plugin, cache, dumpRate); this.plugin = plugin; this.velocityChannelId = VelocityUtil.getId(channel); plugin.getServer().getChannelRegistrar().register(velocityChannelId); plugin.getServer().getEventManager().register(plugin, this); }
@Override public boolean handle(ResourcePackResponse packet) { server.getEventManager().fireAndForget(new PlayerResourcePackStatusEvent(player, packet.getStatus())); return false; }
@Override public boolean handle(StatusRequest packet) { ServerPing initialPing = createInitialPing(); ProxyPingEvent event = new ProxyPingEvent(inboundWrapper, initialPing); server.getEventManager().fire(event) .thenRunAsync( () -> connection.write(new StatusResponse(VelocityServer.GSON.toJson(event.getPing()))), connection.eventLoop()); return true; }
@Override public void load() { Object plugin = VelocityPlugin.PROXY.getPluginManager() .getPlugin("viaversion").flatMap(PluginContainer::getInstance).get(); Via.getManager().getProviders().use(MovementTransmitterProvider.class, new VelocityMovementTransmitter()); Via.getManager().getProviders().use(BossBarProvider.class, new VelocityBossBarProvider()); Via.getManager().getProviders().use(VersionProvider.class, new VelocityVersionProvider()); // We probably don't need a EntityIdProvider because velocity sends a Join packet on server change VelocityPlugin.PROXY.getEventManager().register(plugin, new UpdateListener()); VelocityPlugin.PROXY.getEventManager().register(plugin, new VelocityServerHandler()); VelocityPlugin.PROXY.getEventManager().register(plugin, new MainHandPatch()); VelocityPlugin.PROXY.getEventManager().register(plugin, new ElytraPatch()); int pingInterval = ((VelocityViaConfig) Via.getPlatform().getConf()).getVelocityPingInterval(); if (pingInterval > 0) { Via.getPlatform().runRepeatingSync( new ProtocolDetectorService(), pingInterval * 20L); } }
@Override public void callEnableEvent(PlanPlugin plugin) { PlanVelocityEnableEvent event = new PlanVelocityEnableEvent(plugin.isSystemEnabled()); ((PlanVelocity) plugin).getProxy().getEventManager().fireAndForget(event); } }
private void initializePlayer(GameProfile profile, boolean onlineMode) { // Some connection types may need to alter the game profile. profile = mcConnection.getType().addGameProfileTokensIfRequired(profile, server.getConfiguration().getPlayerInfoForwardingMode()); GameProfileRequestEvent profileRequestEvent = new GameProfileRequestEvent(inbound, profile, onlineMode); server.getEventManager().fire(profileRequestEvent).thenCompose(profileEvent -> { // Initiate a regular connection and move over to it. ConnectedPlayer player = new ConnectedPlayer(server, profileEvent.getGameProfile(), mcConnection, inbound.getVirtualHost().orElse(null)); this.connectedPlayer = player; if (!server.canRegisterConnection(player)) { player.disconnect(VelocityMessages.ALREADY_CONNECTED); return CompletableFuture.completedFuture(null); } logger.info("{} has connected", player); return server.getEventManager() .fire(new PermissionsSetupEvent(player, ConnectedPlayer.DEFAULT_PERMISSIONS)) .thenAcceptAsync(event -> { if (!mcConnection.isClosed()) { // wait for permissions to load, then set the players permission function player.setPermissionFunction(event.createFunction(player)); finishLogin(player); } }, mcConnection.eventLoop()); }); }
void teardown() { if (connectionInFlight != null) { connectionInFlight.disconnect(); } if (connectedServer != null) { connectedServer.disconnect(); } server.unregisterConnection(this); server.getEventManager().fireAndForget(new DisconnectEvent(this)); }
@Override public boolean handle(LegacyPing packet) { ServerPing initialPing = createInitialPing(); ProxyPingEvent event = new ProxyPingEvent(inboundWrapper, initialPing); server.getEventManager().fire(event) .thenRunAsync(() -> { connection.closeWith(LegacyDisconnect.fromServerPing(event.getPing(), packet.getVersion())); }, connection.eventLoop()); return true; }
server.getEventManager().fireAndForget(new ConnectionHandshakeEvent(ic)); connection.setSessionHandler(new LoginSessionHandler(server, connection, ic)); return true;
.fire(new ProxyQueryEvent(isBasic ? BASIC : FULL, senderAddress, response)) .whenCompleteAsync((event, exc) -> {
server.getEventManager().fire(event) .thenAcceptAsync(pme -> { PlayerChatEvent.ChatResult chatResult = pme.getResult();