Return if packet is already cancelled

This commit is contained in:
Likaos 2014-09-13 20:45:17 +02:00
parent 13524e78f6
commit 42778bb214

View File

@ -77,6 +77,7 @@ public class PacketsManager {
PacketType.Play.Client.USE_ENTITY) { PacketType.Play.Client.USE_ENTITY) {
@Override @Override
public void onPacketReceiving(PacketEvent event) { public void onPacketReceiving(PacketEvent event) {
if (event.isCancelled()) return;
try { try {
Player observer = event.getPlayer(); Player observer = event.getPlayer();
StructureModifier<Entity> entityModifer = event.getPacket().getEntityModifier(observer.getWorld()); StructureModifier<Entity> entityModifer = event.getPacket().getEntityModifier(observer.getWorld());
@ -739,6 +740,7 @@ public class PacketsManager {
PacketType.Play.Server.UPDATE_ATTRIBUTES, PacketType.Play.Server.ENTITY_STATUS) { PacketType.Play.Server.UPDATE_ATTRIBUTES, PacketType.Play.Server.ENTITY_STATUS) {
@Override @Override
public void onPacketSending(PacketEvent event) { public void onPacketSending(PacketEvent event) {
if (event.isCancelled()) return;
final Player observer = event.getPlayer(); final Player observer = event.getPlayer();
if (event.getPacket().getIntegers().read(0) == observer.getEntityId()) { if (event.getPacket().getIntegers().read(0) == observer.getEntityId()) {
if (DisguiseAPI.isSelfDisguised(observer)) { if (DisguiseAPI.isSelfDisguised(observer)) {
@ -816,6 +818,7 @@ public class PacketsManager {
PacketType.Play.Client.SET_CREATIVE_SLOT, PacketType.Play.Client.WINDOW_CLICK) { PacketType.Play.Client.SET_CREATIVE_SLOT, PacketType.Play.Client.WINDOW_CLICK) {
@Override @Override
public void onPacketReceiving(final PacketEvent event) { public void onPacketReceiving(final PacketEvent event) {
if (event.isCancelled()) return;
if (!(event.getPlayer() instanceof com.comphenix.net.sf.cglib.proxy.Factory) if (!(event.getPlayer() instanceof com.comphenix.net.sf.cglib.proxy.Factory)
&& event.getPlayer().getVehicle() == null) { && event.getPlayer().getVehicle() == null) {
Disguise disguise = DisguiseAPI.getDisguise(event.getPlayer(), event.getPlayer()); Disguise disguise = DisguiseAPI.getDisguise(event.getPlayer(), event.getPlayer());
@ -1144,6 +1147,7 @@ public class PacketsManager {
mainListener = new PacketAdapter(libsDisguises, ListenerPriority.HIGH, packetsToListen) { mainListener = new PacketAdapter(libsDisguises, ListenerPriority.HIGH, packetsToListen) {
@Override @Override
public void onPacketSending(PacketEvent event) { public void onPacketSending(PacketEvent event) {
if (event.isCancelled()) return;
final Player observer = event.getPlayer(); final Player observer = event.getPlayer();
// First get the entity, the one sending this packet // First get the entity, the one sending this packet
StructureModifier<Entity> entityModifer = event.getPacket().getEntityModifier(observer.getWorld()); StructureModifier<Entity> entityModifer = event.getPacket().getEntityModifier(observer.getWorld());