Skip to content

Commit

Permalink
Fixed JoinItem NPE
Browse files Browse the repository at this point in the history
  • Loading branch information
A5H73Y committed Jun 15, 2022
1 parent 79e88b4 commit e0b03e6
Showing 1 changed file with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1217,13 +1217,9 @@ private void restorePlayerData(Player player, PlayerConfig playerConfig) {
private void preparePlayerForCourse(Player player, String courseName) {
CourseConfig courseConfig = parkour.getConfigManager().getCourseConfig(courseName);

List<ItemStack> joinItems = Stream.of(
parkour.getConfigManager().getDefaultConfig().getDefaultJoinItems(),
courseConfig.getJoinItems())
.flatMap(Collection::stream)
.collect(Collectors.toList());

populatePlayersInventory(player, joinItems);
populatePlayersInventory(player);
addItemsToInventory(player, parkour.getConfigManager().getDefaultConfig().getDefaultJoinItems());
addItemsToInventory(player, courseConfig.getJoinItems());
prepareParkourPlayer(player);
setGameMode(player, parkour.getParkourConfig().getString("OnJoin.SetGameMode"));

Expand Down Expand Up @@ -1258,9 +1254,8 @@ private void resetDeathCounter(Player player) {
* Each Tool and JoinItem can be disabled - leaving no impact on their inventory.
*
* @param player player
* @param joinItems course join items
*/
private void populatePlayersInventory(Player player, List<ItemStack> joinItems) {
private void populatePlayersInventory(Player player) {
if (parkour.getParkourConfig().getBoolean("Other.Parkour.InventoryManagement")) {
PlayerUtils.clearInventoryArmor(player);
}
Expand All @@ -1270,8 +1265,12 @@ private void populatePlayersInventory(Player player, List<ItemStack> joinItems)
giveParkourTool(player, "ParkourTool.Leave");
giveParkourTool(player, "ParkourTool.Restart");

if (joinItems != null) {
for (ItemStack joinItem : joinItems) {
player.updateInventory();
}

private void addItemsToInventory(Player player, List<ItemStack> items) {
if (items != null) {
for (ItemStack joinItem : items) {
player.getInventory().addItem(joinItem);
}
}
Expand Down

0 comments on commit e0b03e6

Please sign in to comment.