Rewrite packet listener

This commit is contained in:
Shevchik 2013-12-11 15:35:02 +04:00
parent b114b13902
commit 3f60b5ee27

View File

@ -2,7 +2,7 @@ package com.cnaude.chairs;
import org.bukkit.entity.Player;
import com.comphenix.protocol.Packets;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolManager;
import com.comphenix.protocol.events.ListenerPriority;
import com.comphenix.protocol.events.PacketAdapter;
@ -17,14 +17,13 @@ public class PacketListener {
this.pm = pm;
this.pluginInstance = plugin;
playerDismountListener();
falledPlayerDismountListener();
}
private void playerDismountListener()
{
pm.getAsynchronousManager().registerAsyncHandler(
new PacketAdapter(PacketAdapter
.params(pluginInstance, Packets.Client.PLAYER_INPUT)
.params(pluginInstance, PacketType.Play.Client.STEER_VEHICLE)
.clientSide()
.listenerPriority(ListenerPriority.HIGHEST)
.optionIntercept()
@ -49,30 +48,4 @@ public class PacketListener {
}).syncStart();
}
private void falledPlayerDismountListener()
{
pm.getAsynchronousManager().registerAsyncHandler(
new PacketAdapter(PacketAdapter
.params(pluginInstance, Packets.Client.ENTITY_ACTION)
.clientSide()
.listenerPriority(ListenerPriority.HIGHEST)
.optionIntercept()
)
{
@Override
public void onPacketReceiving(final PacketEvent e)
{
if (!e.isCancelled())
{
//eject player if he is in chair and tryes to sneak (it is impossible unless arrow will disappear in client due to server lags)
Player player = e.getPlayer();
if (pluginInstance.sit.containsKey(player.getName()))
{
pluginInstance.unSitPlayer(player,false);
}
}
}
}).syncStart();
}
}