mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-23 00:49:31 +00:00
Updated Upstream (Paper/Purpur/Leaves)
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@03efecf0 Do not fire PlayerDropItemEvent for /give command PaperMC/Paper@3527ccdf feat: expose updateDemand and restock on Villager (#12608) PaperMC/Paper@320f25cb fix sponge-absorb deleting chest content (#12647) PaperMC/Paper@95565e0f Add missing attribute serialization updater PaperMC/Paper@519e4224 Fix infinite loop in RegionFile IO Purpur Changes: PurpurMC/Purpur@eb0ba67d Updated Upstream (Paper) PurpurMC/Purpur@7c6502dc Updated Upstream (Paper) PurpurMC/Purpur@aa289e2c Updated Upstream (Paper) Leaves Changes: LeavesMC/Leaves@f09fbb24 1.21.5 (#470) LeavesMC/Leaves@f1cc3ef9 Fix version fetch LeavesMC/Leaves@73bd42af Remove fast resume, mojang added it LeavesMC/Leaves@59856751 Configurable trading with the void LeavesMC/Leaves@9d32c5bd Fix protocols (#534)
This commit is contained in:
@@ -13,6 +13,7 @@ import net.minecraft.world.entity.vehicle.ContainerEntity;
|
||||
import net.minecraft.world.inventory.PlayerEnderChestContainer;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.ChestBlock;
|
||||
import net.minecraft.world.level.block.EnderChestBlock;
|
||||
import net.minecraft.world.level.block.entity.BaseContainerBlockEntity;
|
||||
import net.minecraft.world.level.block.entity.ChestBlockEntity;
|
||||
import net.minecraft.world.level.block.entity.EnderChestBlockEntity;
|
||||
@@ -99,6 +100,9 @@ public enum ItemStorageExtensionProvider implements IServerExtensionProvider<Ite
|
||||
case ContainerEntity containerEntity when containerEntity.getContainerLootTable() != null -> {
|
||||
return List.of();
|
||||
}
|
||||
case EnderChestBlockEntity enderChest when request.getPlayer().getEnderChestInventory().isEmpty() -> {
|
||||
return List.of();
|
||||
}
|
||||
default -> {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,21 +46,19 @@ import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.CompletionException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class Recorder extends Connection {
|
||||
|
||||
private static final LeavesLogger LOGGER = LeavesLogger.LOGGER;
|
||||
public static final Executor saveService = Executors.newVirtualThreadPerTaskExecutor();
|
||||
public static final LeavesLogger LOGGER = LeavesLogger.LOGGER;
|
||||
|
||||
private final ReplayFile replayFile;
|
||||
private final ServerPhotographer photographer;
|
||||
private final RecorderOption recorderOption;
|
||||
private final RecordMetaData metaData;
|
||||
|
||||
private final ExecutorService saveService = Executors.newSingleThreadExecutor();
|
||||
|
||||
private boolean stopped = false;
|
||||
private boolean paused = false;
|
||||
private boolean resumeOnNextPacket = true;
|
||||
@@ -209,7 +207,7 @@ public class Recorder extends Connection {
|
||||
}
|
||||
|
||||
private void saveMetadata() {
|
||||
saveService.submit(() -> {
|
||||
saveService.execute(() -> {
|
||||
try {
|
||||
replayFile.saveMetaData(metaData);
|
||||
} catch (IOException e) {
|
||||
@@ -225,14 +223,7 @@ public class Recorder extends Connection {
|
||||
private void savePacket(Packet<?> packet, final ConnectionProtocol protocol) {
|
||||
try {
|
||||
final long timestamp = getCurrentTimeAndUpdate();
|
||||
saveService.submit(() -> {
|
||||
try {
|
||||
replayFile.savePacket(timestamp, packet, protocol);
|
||||
} catch (Exception e) {
|
||||
LOGGER.severe("Error saving packet");
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
replayFile.savePacket(timestamp, packet, protocol);
|
||||
} catch (Exception e) {
|
||||
LOGGER.severe("Error saving packet");
|
||||
e.printStackTrace();
|
||||
@@ -250,13 +241,7 @@ public class Recorder extends Connection {
|
||||
metaData.duration = (int) lastPacket;
|
||||
return CompletableFuture.runAsync(() -> {
|
||||
saveMetadata();
|
||||
saveService.shutdown();
|
||||
boolean interrupted = false;
|
||||
try {
|
||||
saveService.awaitTermination(10, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
interrupted = true;
|
||||
}
|
||||
try {
|
||||
if (save) {
|
||||
replayFile.closeAndSave(dest);
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.leavesmc.leaves.replay;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufUtil;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.network.ConnectionProtocol;
|
||||
@@ -37,6 +38,9 @@ import java.util.zip.CRC32;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import static org.leavesmc.leaves.replay.Recorder.LOGGER;
|
||||
import static org.leavesmc.leaves.replay.Recorder.saveService;
|
||||
|
||||
public class ReplayFile {
|
||||
|
||||
private static final String RECORDING_FILE = "recording.tmcpr";
|
||||
@@ -93,8 +97,7 @@ public class ReplayFile {
|
||||
protocol.codec().encode(buf, packet);
|
||||
|
||||
buf.readerIndex(0);
|
||||
byte[] ret = new byte[buf.readableBytes()];
|
||||
buf.readBytes(ret);
|
||||
byte[] ret = ByteBufUtil.getBytes(buf);
|
||||
buf.release();
|
||||
return ret;
|
||||
}
|
||||
@@ -118,9 +121,16 @@ public class ReplayFile {
|
||||
|
||||
public void savePacket(long timestamp, Packet<?> packet, ConnectionProtocol protocol) throws Exception {
|
||||
byte[] data = getPacketBytes(packet, protocol);
|
||||
packetStream.writeInt((int) timestamp);
|
||||
packetStream.writeInt(data.length);
|
||||
packetStream.write(data);
|
||||
saveService.execute(() -> {
|
||||
try {
|
||||
packetStream.writeInt((int) timestamp);
|
||||
packetStream.writeInt(data.length);
|
||||
packetStream.write(data);
|
||||
} catch (Exception e) {
|
||||
LOGGER.severe("Error saving packet");
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public synchronized void closeAndSave(File file) throws IOException {
|
||||
|
||||
Reference in New Issue
Block a user