Dieser Commit ist enthalten in:
Ursprung
c19e3bc2f4
Commit
a46fbbbedb
@ -23,9 +23,14 @@ import com.comphenix.tinyprotocol.Reflection;
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.ViaAPI;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.core.CraftbukkitWrapper;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* TinyProtocol can't translate BlockEntities during 1.16 to 1.17 conversions du to removed partial chunk update support. This class cancels PartialChunkUpdates for this players and sends them a complete chunk instead.
|
||||
* This class can only be loaded on 1.9 to 1.15 with active ViaVersion.
|
||||
@ -40,16 +45,40 @@ public class PartialChunkFixer {
|
||||
|
||||
private final ViaAPI<Player> via = Via.getAPI();
|
||||
|
||||
private final List<ResendChunk> chunksToResend = new ArrayList<>();
|
||||
|
||||
public PartialChunkFixer() {
|
||||
TinyProtocol.instance.addFilter(mapChunk, this::chunkFilter);
|
||||
Bukkit.getScheduler().runTaskTimer(Core.getInstance(), () -> {
|
||||
synchronized (chunksToResend) {
|
||||
for(ResendChunk chunk : chunksToResend) {
|
||||
CraftbukkitWrapper.impl.sendChunk(chunk.player, chunk.x, chunk.z);
|
||||
}
|
||||
chunksToResend.clear();
|
||||
}
|
||||
}, 1, 1);
|
||||
}
|
||||
|
||||
private Object chunkFilter(Player player, Object packet) {
|
||||
if(via.getPlayerVersion(player) >= PROTOCOL1_17 && !fullChunkFlag.get(packet)) {
|
||||
// partial chunk update
|
||||
CraftbukkitWrapper.impl.sendChunk(player, chunkX.get(packet), chunkZ.get(packet));
|
||||
synchronized (chunksToResend) {
|
||||
chunksToResend.add(new ResendChunk(player, chunkX.get(packet), chunkZ.get(packet)));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
|
||||
private static class ResendChunk {
|
||||
private final Player player;
|
||||
private final int x;
|
||||
private final int z;
|
||||
|
||||
private ResendChunk(Player player, int x, int z) {
|
||||
this.player = player;
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren