Skip to content

Commit

Permalink
Fix player store not being found on respawn
Browse files Browse the repository at this point in the history
  • Loading branch information
jaskarth committed Oct 12, 2023
1 parent 92c1b0f commit f7828b3
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,21 @@ private static Map<ResourceLocation, List<SpawnItems.Stack>> getDiff(Map<Resourc

@SubscribeEvent
static void onPlayerClone(final PlayerEvent.Clone event) {
final SpawnItemsStore oldStore = get(event.getOriginal());
final SpawnItemsStore newStore = get(event.getEntity());
final SpawnItemsStore oldStore = getNullable(event.getOriginal());
final SpawnItemsStore newStore = getNullable(event.getEntity());

if (oldStore == null || newStore == null) {
return;
}

newStore.receivedItems.putAll(oldStore.receivedItems);
}

public static SpawnItemsStore get(final Player player) {
return player.getCapability(LTExtras.SPAWN_ITEMS_STORE).orElseThrow(IllegalStateException::new);
}

@Nullable public static SpawnItemsStore getNullable(final Player player) {
return player.getCapability(LTExtras.SPAWN_ITEMS_STORE).orElse(null);
}
}

0 comments on commit f7828b3

Please sign in to comment.