Search in sources :

Example 1 with PacketHandler

use of thpmc.vanilla_source.nms.PacketHandler in project VanillaSource by TheHollowPlanetMC.

the class PlayerJoinQuitListener method onJoin.

@EventHandler
public void onJoin(PlayerJoinEvent event) {
    // Inject packet handler
    Player player = event.getPlayer();
    EnginePlayer enginePlayer = ImplEnginePlayer.onPlayerJoin(player);
    ParallelUniverse universe = VanillaSourceAPI.getInstance().createUniverse(player.getUniqueId().toString());
    universe.addPlayer(enginePlayer);
    Object wrappedParallelPlayer = ChiyogamiManager.getWrappedParallelPlayer(player);
    if (wrappedParallelPlayer != null)
        ChiyogamiManager.setCheckFunction(enginePlayer, wrappedParallelPlayer);
    PacketHandler packetHandler = new PacketHandler(enginePlayer);
    try {
        ChannelPipeline pipeline = NMSManager.getNMSHandler().getChannel(player).pipeline();
        pipeline.addBefore("packet_handler", VanillaSource.getPlugin().getName() + "PacketInjector:" + player.getName(), packetHandler);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : ImplEnginePlayer(thpmc.vanilla_source.impl.ImplEnginePlayer) Player(org.bukkit.entity.Player) EnginePlayer(thpmc.vanilla_source.api.player.EnginePlayer) PacketHandler(thpmc.vanilla_source.nms.PacketHandler) ParallelUniverse(thpmc.vanilla_source.api.world.parallel.ParallelUniverse) ImplEnginePlayer(thpmc.vanilla_source.impl.ImplEnginePlayer) EnginePlayer(thpmc.vanilla_source.api.player.EnginePlayer) ChannelPipeline(io.netty.channel.ChannelPipeline) EventHandler(org.bukkit.event.EventHandler)

Aggregations

ChannelPipeline (io.netty.channel.ChannelPipeline)1 Player (org.bukkit.entity.Player)1 EventHandler (org.bukkit.event.EventHandler)1 EnginePlayer (thpmc.vanilla_source.api.player.EnginePlayer)1 ParallelUniverse (thpmc.vanilla_source.api.world.parallel.ParallelUniverse)1 ImplEnginePlayer (thpmc.vanilla_source.impl.ImplEnginePlayer)1 PacketHandler (thpmc.vanilla_source.nms.PacketHandler)1