use of com.bergerkiller.bukkit.common.protocol.PacketListener in project BKCommonLib by bergerhealer.
the class PortalHandler_1_9 method enable.
@Override
public void enable(CommonPlugin plugin) {
// Listener to disable player portal events pre-emptively while players are viewing credits
// This is required, otherwise other plugins get very confused and teleport players out of the
// credits screen.
plugin.register(new Listener() {
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPortalEvent(PlayerPortalEvent event) {
if (EntityPlayerHandle.fromBukkit(event.getPlayer()).isViewingCredits()) {
event.setCancelled(true);
}
}
});
// While the player is inside the end portal, it continuously fires a portal enter event.
// This causes a horrible sound effect to play, because that effect is sent every tick.
// This is obviously very unwanted while viewing the credits!
plugin.register(new PacketListener() {
@Override
public void onPacketReceive(PacketReceiveEvent event) {
}
@Override
public void onPacketSend(PacketSendEvent event) {
if (EntityPlayerHandle.fromBukkit(event.getPlayer()).isViewingCredits()) {
event.setCancelled(true);
}
}
}, PacketType.OUT_WORLD_EVENT);
}
Aggregations