com.velocitypowered.api.event.PostOrder Java Examples

The following examples show how to use com.velocitypowered.api.event.PostOrder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ElytraPatch.java    From ViaVersion with MIT License 6 votes vote down vote up
@Subscribe(order = PostOrder.LAST)
public void onServerConnected(ServerConnectedEvent event) {
    UserConnection user = Via.getManager().getConnection(event.getPlayer().getUniqueId());
    if (user == null) return;

    try {
        if (user.getProtocolInfo().getPipeline().contains(Protocol1_9To1_8.class)) {
            int entityId = user.get(EntityTracker1_9.class).getProvidedEntityId();

            PacketWrapper wrapper = new PacketWrapper(0x39, null, user);

            wrapper.write(Type.VAR_INT, entityId);
            wrapper.write(Types1_9.METADATA_LIST, Collections.singletonList(new Metadata(0, MetaType1_9.Byte, (byte) 0)));

            wrapper.send(Protocol1_9To1_8.class);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #2
Source File: VelocityBootstrap.java    From AntiVPN with MIT License 5 votes vote down vote up
@Subscribe(order = PostOrder.EARLY)
public void onEnable(ProxyInitializeEvent event) {
    try {
        concreteClass.getMethod("onEnable").invoke(concrete);
    } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
        logger.error(ex.getMessage(), ex);
        throw new RuntimeException("Could not invoke onEnable.");
    }

    if (ExternalAPI.getInstance() == null) {
        ExternalAPI.setInstance(proxiedClassLoader);
    }
}
 
Example #3
Source File: VelocityBootstrap.java    From AntiVPN with MIT License 5 votes vote down vote up
@Subscribe(order = PostOrder.LATE)
public void onDisable(ProxyShutdownEvent event) {
    try {
        concreteClass.getMethod("onDisable").invoke(concrete);
    } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
        logger.error(ex.getMessage(), ex);
        throw new RuntimeException("Could not invoke onDisable.");
    }
}
 
Example #4
Source File: PlayerEvents.java    From AntiVPN with MIT License 5 votes vote down vote up
public PlayerEvents(Object plugin, ProxyServer proxy) {
    this.proxy = proxy;

    events.add(
            VelocityEvents.subscribe(plugin, proxy, PreLoginEvent.class, PostOrder.LATE)
                    .handler(this::cachePlayer)
    );

    events.add(
            VelocityEvents.subscribe(plugin, proxy, PostLoginEvent.class, PostOrder.FIRST)
                    .handler(this::checkPlayer)
    );
}
 
Example #5
Source File: VelocityEventManager.java    From Velocity with MIT License 5 votes vote down vote up
@Override
@SuppressWarnings("type.argument.type.incompatible")
public <E> void register(Object plugin, Class<E> eventClass, PostOrder postOrder,
    EventHandler<E> handler) {
  ensurePlugin(plugin);
  Preconditions.checkNotNull(eventClass, "eventClass");
  Preconditions.checkNotNull(postOrder, "postOrder");
  Preconditions.checkNotNull(handler, "listener");

  registeredHandlersByPlugin.put(plugin, handler);
  bus.register(eventClass, new KyoriToVelocityHandler<>(handler, postOrder));
}
 
Example #6
Source File: VelocityPlugin.java    From ViaRewind with MIT License 5 votes vote down vote up
@Subscribe(order = PostOrder.LATE)
public void onProxyStart(ProxyInitializeEvent e) {
	// Setup Logger
	this.logger = new LoggerWrapper(loggerSlf4j);
	// Init!
	ViaRewindConfigImpl conf = new ViaRewindConfigImpl(configDir.resolve("config.yml").toFile());
	conf.reloadConfig();
	this.init(conf);
}
 
Example #7
Source File: PlayerOnlineListener.java    From Plan with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Subscribe(order = PostOrder.LAST)
public void onPostLogin(PostLoginEvent event) {
    try {
        actOnLogin(event);
    } catch (Exception e) {
        errorLogger.log(L.ERROR, e, ErrorContext.builder().related(event).build());
    }
}
 
Example #8
Source File: PlayerOnlineListener.java    From Plan with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Subscribe(order = PostOrder.NORMAL)
public void beforeLogout(DisconnectEvent event) {
    Player player = event.getPlayer();
    UUID playerUUID = player.getUniqueId();
    String playerName = player.getUsername();
    processing.submitNonCritical(() -> extensionService.updatePlayerValues(playerUUID, playerName, CallEvents.PLAYER_LEAVE));
}
 
Example #9
Source File: PlayerOnlineListener.java    From Plan with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Subscribe(order = PostOrder.LAST)
public void onLogout(DisconnectEvent event) {
    try {
        actOnLogout(event);
    } catch (Exception e) {
        errorLogger.log(L.ERROR, e, ErrorContext.builder().related(event).build());
    }
}
 
Example #10
Source File: PlayerOnlineListener.java    From Plan with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Subscribe(order = PostOrder.LAST)
public void onServerSwitch(ServerConnectedEvent event) {
    try {
        actOnServerSwitch(event);
    } catch (Exception e) {
        errorLogger.log(L.ERROR, e, ErrorContext.builder().related(event).build());
    }
}
 
Example #11
Source File: VelocityServerHandler.java    From ViaVersion with MIT License 5 votes vote down vote up
@Subscribe(order = PostOrder.LATE)
public void connectedEvent(ServerConnectedEvent e) {
    UserConnection user = Via.getManager().getConnection(e.getPlayer().getUniqueId());
    CompletableFuture.runAsync(() -> {
        try {
            checkServerChange(e, Via.getManager().getConnection(e.getPlayer().getUniqueId()));
        } catch (Exception e1) {
            e1.printStackTrace();
        }
    }, user.getChannel().eventLoop()).join();
}
 
Example #12
Source File: LPVelocityBootstrap.java    From LuckPerms with MIT License 5 votes vote down vote up
@Subscribe(order = PostOrder.FIRST)
public void onEnable(ProxyInitializeEvent e) {
    this.startTime = Instant.now();
    try {
        this.plugin.load();
    } finally {
        this.loadLatch.countDown();
    }

    try {
        this.plugin.enable();
    } finally {
        this.enableLatch.countDown();
    }
}
 
Example #13
Source File: MonitoringPermissionCheckListener.java    From LuckPerms with MIT License 5 votes vote down vote up
@Subscribe(order = PostOrder.LAST)
public void onOtherPermissionSetup(PermissionsSetupEvent e) {
    // players are handled separately
    if (e.getSubject() instanceof Player) {
        return;
    }

    e.setProvider(new MonitoredPermissionProvider(e.getProvider()));
}
 
Example #14
Source File: VelocityPlugin.java    From ViaBackwards with MIT License 4 votes vote down vote up
@Subscribe(order = PostOrder.LATE)
public void onProxyStart(ProxyInitializeEvent e) {
    // Setup Logger
    this.logger = new LoggerWrapper(loggerSlf4j);
    Via.getManager().addEnableListener(() -> this.init(configPath.resolve("config.yml").toFile()));
}
 
Example #15
Source File: VelocitySparkPlugin.java    From spark with GNU General Public License v3.0 4 votes vote down vote up
@Subscribe(order = PostOrder.FIRST)
public void onEnable(ProxyInitializeEvent e) {
    this.platform = new SparkPlatform(this);
    this.platform.enable();
    this.proxy.getCommandManager().register(this, "sparkv", "sparkvelocity");
}
 
Example #16
Source File: LPVelocityBootstrap.java    From LuckPerms with MIT License 4 votes vote down vote up
@Subscribe(order = PostOrder.LAST)
public void onDisable(ProxyShutdownEvent e) {
    this.plugin.disable();
}
 
Example #17
Source File: VelocityConnectionListener.java    From LuckPerms with MIT License 4 votes vote down vote up
@Subscribe(order = PostOrder.LAST)
public void onPlayerQuit(DisconnectEvent e) {
    handleDisconnect(e.getPlayer().getUniqueId());
}
 
Example #18
Source File: VelocityConnectionListener.java    From LuckPerms with MIT License 4 votes vote down vote up
@Subscribe(order = PostOrder.FIRST)
public void onPlayerLogin(LoginEvent e) {
    if (this.deniedLogin.remove(e.getPlayer().getUniqueId())) {
        e.setResult(ResultedEvent.ComponentResult.denied(Message.LOADING_DATABASE_ERROR.asComponent(this.plugin.getLocaleManager())));
    }
}
 
Example #19
Source File: VelocityPlugin.java    From ViaVersion with MIT License 4 votes vote down vote up
@Subscribe(order = PostOrder.LAST)
public void onProxyLateInit(ProxyInitializeEvent e) {
    Via.getManager().init();
}
 
Example #20
Source File: VelocityEventManager.java    From Velocity with MIT License 4 votes vote down vote up
private KyoriToVelocityHandler(EventHandler<E> handler, PostOrder postOrder) {
  this.handler = handler;
  this.postOrder = postOrder.ordinal();
}
 
Example #21
Source File: VelocitySparkPlugin.java    From spark with GNU General Public License v3.0 4 votes vote down vote up
@Subscribe(order = PostOrder.LAST)
public void onDisable(ProxyShutdownEvent e) {
    this.platform.disable();
}