Search in sources :

Example 1 with PacketHandler

use of thpmc.engine.nms.PacketHandler in project THP-Engine 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 = THPEngineAPI.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", THPEngine.getPlugin().getName() + "PacketInjector:" + player.getName(), packetHandler);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : ImplEnginePlayer(thpmc.engine.impl.ImplEnginePlayer) Player(org.bukkit.entity.Player) EnginePlayer(thpmc.engine.api.player.EnginePlayer) PacketHandler(thpmc.engine.nms.PacketHandler) ParallelUniverse(thpmc.engine.api.world.parallel.ParallelUniverse) ImplEnginePlayer(thpmc.engine.impl.ImplEnginePlayer) EnginePlayer(thpmc.engine.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.engine.api.player.EnginePlayer)1 ParallelUniverse (thpmc.engine.api.world.parallel.ParallelUniverse)1 ImplEnginePlayer (thpmc.engine.impl.ImplEnginePlayer)1 PacketHandler (thpmc.engine.nms.PacketHandler)1