All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.nukkit.network.CompressBatchedPacket Maven / Gradle / Ivy

Go to download

A Minecraft Bedrock Edition server software implementation made in Java from scratch which supports all new features.

There is a newer version: 1.6.0.1-PN
Show newest version
package cn.nukkit.network;

import cn.nukkit.Server;
import cn.nukkit.scheduler.AsyncTask;

import java.net.InetSocketAddress;
import java.util.List;

/**
 * @author MagicDroidX (Nukkit Project)
 */
public class CompressBatchedPacket extends AsyncTask {

    public int level = 7;
    public byte[] data;
    public byte[] finalData;
    public int channel = 0;
    public List targets;

    public CompressBatchedPacket(byte[] data, List targets) {
        this(data, targets, 7);
    }

    public CompressBatchedPacket(byte[] data, List targets, int level) {
        this(data, targets, level, 0);
    }

    public CompressBatchedPacket(byte[] data, List targets, int level, int channel) {
        this.data = data;
        this.targets = targets;
        this.level = level;
        this.channel = channel;
    }

    @Override
    public void onRun() {
        try {
            this.finalData = Network.deflateRaw(data, level);
            this.data = null;
        } catch (Exception e) {
            //ignore
        }
    }

    @Override
    public void onCompletion(Server server) {
        server.broadcastPacketsCallback(this.finalData, this.targets);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy