Revert "Revert "Use async packet listener for sounds packets. Prevents async concurrent modification exception. May be replaced later.""

This reverts commit c6875da657.
This commit is contained in:
libraryaddict 2014-07-28 17:03:41 +12:00
parent c6875da657
commit a06a81182e

View File

@ -41,6 +41,7 @@ import org.bukkit.util.Vector;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.async.AsyncListenerHandler;
import com.comphenix.protocol.events.ListenerPriority;
import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketContainer;
@ -54,6 +55,7 @@ import com.comphenix.protocol.wrappers.WrappedGameProfile;
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
public class PacketsManager {
private static AsyncListenerHandler asyncSoundsListener;
/**
* This is a fix for the stupidity that is
* "I can't separate the sounds from the sounds the player heard, and the sounds of the entity tracker heard"
@ -1062,9 +1064,10 @@ public class PacketsManager {
if (soundsListenerEnabled != enabled) {
soundsListenerEnabled = enabled;
if (soundsListenerEnabled) {
ProtocolLibrary.getProtocolManager().addPacketListener(soundsListener);
asyncSoundsListener = ProtocolLibrary.getProtocolManager().getAsynchronousManager()
.registerAsyncHandler(soundsListener);
} else {
ProtocolLibrary.getProtocolManager().removePacketListener(soundsListener);
ProtocolLibrary.getProtocolManager().getAsynchronousManager().unregisterAsyncHandler(asyncSoundsListener);
}
}
}