|
| 1 | +package io.github._4drian3d.signedvelocity.sponge14; |
| 2 | + |
| 3 | +import com.google.inject.Inject; |
| 4 | +import com.google.inject.Injector; |
| 5 | +import io.github._4drian3d.signedvelocity.sponge10.listener.DecorateChatListener; |
| 6 | +import io.github._4drian3d.signedvelocity.sponge10.listener.SubmitChatListener; |
| 7 | +import io.github._4drian3d.signedvelocity.sponge14.handler.ProxyDataHandler; |
| 8 | +import io.github._4drian3d.signedvelocity.sponge.common.listener.PlayerCommandListener; |
| 9 | +import io.github._4drian3d.signedvelocity.sponge.common.listener.SignedListener; |
| 10 | +import io.github._4drian3d.signedvelocity.sponge.common.modules.SignedModule; |
| 11 | +import io.github._4drian3d.signedvelocity.sponge14.listener.PlayerQuitListener; |
| 12 | +import org.spongepowered.api.ResourceKey; |
| 13 | +import org.spongepowered.api.Server; |
| 14 | +import org.spongepowered.api.event.Listener; |
| 15 | +import org.spongepowered.api.event.lifecycle.StartedEngineEvent; |
| 16 | +import org.spongepowered.api.network.EngineConnectionState; |
| 17 | +import org.spongepowered.api.network.channel.raw.RawDataChannel; |
| 18 | +import org.spongepowered.plugin.builtin.jvm.Plugin; |
| 19 | + |
| 20 | +import java.util.stream.Stream; |
| 21 | + |
| 22 | +@Plugin("signedvelocity") |
| 23 | +public class SignedVelocity { |
| 24 | + @Inject |
| 25 | + private Injector injector; |
| 26 | + |
| 27 | + @Listener |
| 28 | + public void onEngineStart(final StartedEngineEvent<Server> event) { |
| 29 | + this.injector = this.injector.createChildInjector(new SignedModule()); |
| 30 | + |
| 31 | + Stream.of(SubmitChatListener.class, DecorateChatListener.class, PlayerCommandListener.class, PlayerQuitListener.class) |
| 32 | + .map(injector::getInstance) |
| 33 | + .forEach(SignedListener::register); |
| 34 | + event.game() |
| 35 | + .channelManager() |
| 36 | + .ofType(ResourceKey.of("signedvelocity", "main"), RawDataChannel.class) |
| 37 | + .play() |
| 38 | + .addHandler(EngineConnectionState.Game.class, injector.getInstance(ProxyDataHandler.class)); |
| 39 | + } |
| 40 | +} |
0 commit comments