cn.nukkit.network.CompressBatchedTask Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of powernukkit Show documentation
Show all versions of powernukkit Show documentation
A Minecraft Bedrock Edition server software implementation made in Java from scratch which supports all new features.
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 CompressBatchedTask extends AsyncTask {
public int level = 7;
public byte[][] data;
public byte[] finalData;
public int channel = 0;
public List targets;
public CompressBatchedTask(byte[][] data, List targets) {
this(data, targets, 7);
}
public CompressBatchedTask(byte[][] data, List targets, int level) {
this(data, targets, level, 0);
}
public CompressBatchedTask(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(this.data, this.level);
this.data = null;
} catch (Exception e) {
//ignore
}
}
@Override
public void onCompletion(Server server) {
server.broadcastPacketsCallback(this.finalData, this.targets);
}
}