Search in sources :

Example 1 with ADPVelocityBootstrap

use of com.alessiodp.core.velocity.bootstrap.ADPVelocityBootstrap in project ADP-Core by AlessioDP.

the class VelocityCommandUtils method register.

@Override
@NotNull
public RegisterResult register(@NotNull ADPMainCommand command) {
    RegisterResult ret = RegisterResult.FAILED;
    try {
        ADPVelocityBootstrap velocityPlugin = (ADPVelocityBootstrap) plugin.getBootstrap();
        VelocityCommandImpl velocityCommandImplementation = new VelocityCommandImpl(plugin, command);
        CommandMeta meta = velocityPlugin.getServer().getCommandManager().metaBuilder(command.getCommandName()).aliases(command.getAliases().toArray(new String[0])).build();
        velocityPlugin.getServer().getCommandManager().register(meta, velocityCommandImplementation);
        ret = RegisterResult.SUCCESSFUL;
        plugin.getLoggerManager().logDebug(String.format(Constants.DEBUG_CMD_SETUP_REGISTER_MAINCOMMAND, CommonUtils.toLowerCase(command.getCommandName()), CommonUtils.toLowerCase(ret.name())), true);
    } catch (Exception ex) {
        plugin.getLoggerManager().logError(Constants.DEBUG_CMD_SETUP_REGISTER_FAILED, ex);
    }
    return ret;
}
Also used : ADPVelocityBootstrap(com.alessiodp.core.velocity.bootstrap.ADPVelocityBootstrap) CommandMeta(com.velocitypowered.api.command.CommandMeta) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with ADPVelocityBootstrap

use of com.alessiodp.core.velocity.bootstrap.ADPVelocityBootstrap in project ADP-Core by AlessioDP.

the class VelocityBungeecordListener method registerChannel.

@Override
public void registerChannel(@NotNull MessageChannel channel) {
    ChannelIdentifier identifier = MinecraftChannelIdentifier.create(plugin.getPluginFallbackName(), channel.getId());
    ((ADPVelocityBootstrap) plugin.getBootstrap()).getServer().getChannelRegistrar().register(identifier);
    getChannels().put(channel, identifier);
}
Also used : ADPVelocityBootstrap(com.alessiodp.core.velocity.bootstrap.ADPVelocityBootstrap) MinecraftChannelIdentifier(com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier) ChannelIdentifier(com.velocitypowered.api.proxy.messages.ChannelIdentifier)

Example 3 with ADPVelocityBootstrap

use of com.alessiodp.core.velocity.bootstrap.ADPVelocityBootstrap in project ADP-Core by AlessioDP.

the class VelocityBungeecordDispatcher method registerChannel.

@Override
public void registerChannel(@NotNull MessageChannel channel) {
    ChannelIdentifier identifier = MinecraftChannelIdentifier.create(plugin.getPluginFallbackName(), channel.getId());
    ((ADPVelocityBootstrap) plugin.getBootstrap()).getServer().getChannelRegistrar().register(identifier);
    getChannels().put(channel, identifier);
}
Also used : ADPVelocityBootstrap(com.alessiodp.core.velocity.bootstrap.ADPVelocityBootstrap) MinecraftChannelIdentifier(com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier) ChannelIdentifier(com.velocitypowered.api.proxy.messages.ChannelIdentifier)

Example 4 with ADPVelocityBootstrap

use of com.alessiodp.core.velocity.bootstrap.ADPVelocityBootstrap in project ADP-Core by AlessioDP.

the class ADPVelocityScheduler method scheduleAsyncRepeating.

@Override
public CancellableTask scheduleAsyncRepeating(@NotNull Runnable runnable, long delay, long period, TimeUnit unit) {
    ADPVelocityBootstrap velocityPlugin = ((ADPVelocityBootstrap) plugin.getBootstrap());
    // Use Velocity scheduler instead of mine
    ScheduledTask future = velocityPlugin.getServer().getScheduler().buildTask(velocityPlugin, runnable).delay(delay, unit).repeat(period, unit).schedule();
    return future::cancel;
}
Also used : ADPVelocityBootstrap(com.alessiodp.core.velocity.bootstrap.ADPVelocityBootstrap) ScheduledTask(com.velocitypowered.api.scheduler.ScheduledTask)

Example 5 with ADPVelocityBootstrap

use of com.alessiodp.core.velocity.bootstrap.ADPVelocityBootstrap in project ADP-Core by AlessioDP.

the class ADPVelocityScheduler method scheduleAsyncLater.

@Override
public CancellableTask scheduleAsyncLater(@NotNull Runnable runnable, long delay, TimeUnit unit) {
    ADPVelocityBootstrap velocityPlugin = ((ADPVelocityBootstrap) plugin.getBootstrap());
    // Use Velocity scheduler instead of mine
    ScheduledTask future = velocityPlugin.getServer().getScheduler().buildTask(velocityPlugin, runnable).delay(delay, unit).schedule();
    return future::cancel;
}
Also used : ADPVelocityBootstrap(com.alessiodp.core.velocity.bootstrap.ADPVelocityBootstrap) ScheduledTask(com.velocitypowered.api.scheduler.ScheduledTask)

Aggregations

ADPVelocityBootstrap (com.alessiodp.core.velocity.bootstrap.ADPVelocityBootstrap)5 ChannelIdentifier (com.velocitypowered.api.proxy.messages.ChannelIdentifier)2 MinecraftChannelIdentifier (com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier)2 ScheduledTask (com.velocitypowered.api.scheduler.ScheduledTask)2 CommandMeta (com.velocitypowered.api.command.CommandMeta)1 NotNull (org.jetbrains.annotations.NotNull)1