Update to 1.19.4 (#130)

* Improve data load/save slightly
* Fix longstanding issue with opening players in deleted worlds on Paper
This commit is contained in:
Adam
2023-03-16 16:30:43 -04:00
committed by GitHub
parent 3d4bed04d5
commit 0e6acdff36
12 changed files with 100 additions and 62 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2022 lishid. All rights reserved.
* Copyright (C) 2011-2023 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -37,7 +37,7 @@ public class OpenPlayer extends CraftPlayer {
// See CraftPlayer#loadData
CompoundTag loaded = this.server.getHandle().playerIo.load(this.getHandle());
if (loaded != null) {
readExtraData(loaded);
getHandle().readAdditionalSaveData(loaded);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2022 lishid. All rights reserved.
* Copyright (C) 2011-2023 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -23,6 +23,7 @@ import com.lishid.openinv.internal.OpenInventoryView;
import com.mojang.authlib.GameProfile;
import java.lang.reflect.Field;
import java.util.logging.Logger;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.network.protocol.game.ClientboundOpenScreenPacket;
import net.minecraft.server.MinecraftServer;
@@ -100,20 +101,34 @@ public class PlayerDataManager implements IPlayerDataManager {
ServerPlayer entity = new ServerPlayer(server, worldServer, profile);
// Stop listening for advancement progression - if this is not cleaned up, loading causes a memory leak.
entity.getAdvancements().stopListening();
try {
injectPlayer(entity);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
// Get the bukkit entity
Player target = entity.getBukkitEntity();
if (target != null) {
// Load data
target.loadData();
// Load data. This also reads basic data into the player.
// See CraftPlayer#loadData
CompoundTag loadedData = server.getPlayerList().playerIo.load(entity);
if (loadedData == null) {
// Exceptions with loading are logged by Mojang.
return null;
}
// Return the entity
return target;
// Also read "extra" data.
entity.readAdditionalSaveData(loadedData);
if (entity.level == null) {
// Paper: Move player to spawn
entity.spawnIn(null);
}
// Return the Bukkit entity.
return entity.getBukkitEntity();
}
void injectPlayer(ServerPlayer player) throws IllegalAccessException {