-
-
Notifications
You must be signed in to change notification settings - Fork 104
/
DenizenPacketListener_v1_11_R1.java
56 lines (47 loc) · 2.25 KB
/
DenizenPacketListener_v1_11_R1.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package net.aufdemrand.denizen.nms.impl.packets.handlers;
import net.aufdemrand.denizen.nms.NMSHandler;
import net.aufdemrand.denizen.nms.impl.packets.PacketInResourcePackStatus_v1_11_R1;
import net.aufdemrand.denizen.nms.impl.packets.PacketInSteerVehicle_v1_11_R1;
import net.aufdemrand.denizen.nms.interfaces.packets.PacketHandler;
import net.minecraft.server.v1_11_R1.EntityPlayer;
import net.minecraft.server.v1_11_R1.NetworkManager;
import net.minecraft.server.v1_11_R1.Packet;
import net.minecraft.server.v1_11_R1.PacketPlayInResourcePackStatus;
import net.minecraft.server.v1_11_R1.PacketPlayInSteerVehicle;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
public class DenizenPacketListener_v1_11_R1 extends AbstractListenerPlayIn_v1_11_R1 {
private static PacketHandler packetHandler;
public DenizenPacketListener_v1_11_R1(NetworkManager networkManager, EntityPlayer entityPlayer) {
super(networkManager, entityPlayer, entityPlayer.playerConnection);
}
public static void enable(PacketHandler handler) {
packetHandler = handler;
Bukkit.getServer().getPluginManager().registerEvents(new PlayerEventListener(), NMSHandler.getJavaPlugin());
}
@Override
public void a(final PacketPlayInSteerVehicle packet) {
if (!packetHandler.receivePacket(player.getBukkitEntity(), new PacketInSteerVehicle_v1_11_R1(packet))) {
super.a(packet);
}
}
@Override
public void a(PacketPlayInResourcePackStatus packet) {
packetHandler.receivePacket(player.getBukkitEntity(), new PacketInResourcePackStatus_v1_11_R1(packet));
super.a(packet);
}
// For compatibility with other plugins using Reflection weirdly...
@Override
public void sendPacket(Packet packet) {
super.sendPacket(packet);
}
public static class PlayerEventListener implements Listener {
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerJoin(PlayerJoinEvent event) {
DenizenNetworkManager_v1_11_R1.setNetworkManager(event.getPlayer(), packetHandler);
}
}
}