-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
118 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/main/java/be4rjp/parallel/nms/manager/FlyingPacketManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package be4rjp.parallel.nms.manager; | ||
|
||
import be4rjp.parallel.nms.NMSUtil; | ||
import be4rjp.parallel.nms.PacketHandler; | ||
import io.netty.channel.ChannelHandlerContext; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.scheduler.BukkitRunnable; | ||
|
||
import java.lang.reflect.Field; | ||
import java.nio.channels.ClosedChannelException; | ||
|
||
public class FlyingPacketManager extends BukkitRunnable { | ||
|
||
private static Class<?> PacketPlayInFlying; | ||
private static Field f; | ||
|
||
static { | ||
try { | ||
PacketPlayInFlying = NMSUtil.getNMSClass("PacketPlayInFlying"); | ||
f = PacketPlayInFlying.getDeclaredField("f"); | ||
f.setAccessible(true); | ||
}catch (Exception e){ | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
|
||
|
||
private final ChannelHandlerContext channelHandlerContext; | ||
private final Object packet; | ||
private final PacketHandler packetHandler; | ||
private final Player player; | ||
|
||
public FlyingPacketManager(ChannelHandlerContext channelHandlerContext, Object packet, PacketHandler packetHandler, Player player){ | ||
this.channelHandlerContext = channelHandlerContext; | ||
this.packet = packet; | ||
this.packetHandler = packetHandler; | ||
this.player = player; | ||
} | ||
|
||
@Override | ||
public void run() { | ||
try{ | ||
boolean onGround = (boolean)f.get(packet); | ||
|
||
if(onGround) NMSUtil.setSEtoZero(player); | ||
|
||
packetHandler.doRead(channelHandlerContext, packet); | ||
}catch (ClosedChannelException e){ | ||
}catch (Exception e){ | ||
e.printStackTrace(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters