Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix game type not loading #180

Merged
merged 1 commit into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ public OpenPlayer(CraftServer server, ServerPlayer entity) {
@Override
public void loadData() {
// See CraftPlayer#loadData
CompoundTag loaded = this.server.getHandle().playerIo.load(this.getHandle());
ServerPlayer serverPlayer = getHandle();
CompoundTag loaded = this.server.getHandle().playerIo.load(serverPlayer);
if (loaded != null) {
getHandle().readAdditionalSaveData(loaded);
serverPlayer.readAdditionalSaveData(loaded);
serverPlayer.loadGameTypes(loaded);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
import com.lishid.openinv.internal.ISpecialInventory;
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;
Expand All @@ -47,6 +45,9 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.lang.reflect.Field;
import java.util.logging.Logger;

public class PlayerDataManager implements IPlayerDataManager {

private @Nullable Field bukkitEntity;
Expand Down Expand Up @@ -123,6 +124,7 @@ public PlayerDataManager() {

// Also read "extra" data.
entity.readAdditionalSaveData(loadedData);
entity.loadGameTypes(loadedData);

if (entity.level == null) {
// Paper: Move player to spawn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ static boolean loadData(@NotNull ServerPlayer player) {
player.load(loadedData);
// Also read "extra" data.
player.readAdditionalSaveData(loadedData);
// Game type settings are also loaded separately.
player.loadGameTypes(loadedData);

if (paper) {
// Paper: world is not loaded by ServerPlayer#load(CompoundTag).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ static boolean loadData(@NotNull ServerPlayer player) {
player.load(loadedData);
// Also read "extra" data.
player.readAdditionalSaveData(loadedData);
// Game type settings are also loaded separately.
player.loadGameTypes(loadedData);

if (paper) {
// Paper: world is not loaded by ServerPlayer#load(CompoundTag).
Expand Down