Skip to content

Commit

Permalink
Fix game type not loading (#180)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jikoo authored Feb 8, 2024
1 parent c8fee82 commit c102e66
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
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

0 comments on commit c102e66

Please sign in to comment.