Skip to content

Commit

Permalink
Fix null pointer in ToolBuyV2 (Thanks Ralphie!)
Browse files Browse the repository at this point in the history
  • Loading branch information
MetallicGoat committed Oct 30, 2021
1 parent ef33947 commit b9198b4
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import java.util.Collection;
import java.util.HashMap;
import java.util.Objects;

public class DowngradeTools implements Listener {

Expand Down Expand Up @@ -47,13 +46,16 @@ public void onRespawn(PlayerIngameRespawnEvent e){
if (buyGroupName.equalsIgnoreCase("pickaxe")
|| buyGroup.getName().equalsIgnoreCase("axe")) {
int level = buyGroupName.equalsIgnoreCase("pickaxe") ? pickaxeHashMap.get(player) : axeHashMap.get(player);
for (ShopItem item : Objects.requireNonNull(buyGroup.getItems(level))) {
BukkitScheduler scheduler = Bukkit.getScheduler();
scheduler.runTaskLater(Main.getInstance(), () -> item.getProducts().forEach(shopProduct -> {
arena.setBuyGroupLevel(player, buyGroup, level);
shopProduct.give(e.getPlayer(), e.getArena().getPlayerTeam(player), e.getArena(), 1);
}), 1L);
break;
Collection<? extends ShopItem> shopItems = buyGroup.getItems(level);
if(shopItems != null) {
for (ShopItem item : shopItems) {
BukkitScheduler scheduler = Bukkit.getScheduler();
scheduler.runTaskLater(Main.getInstance(), () -> item.getProducts().forEach(shopProduct -> {
arena.setBuyGroupLevel(player, buyGroup, level);
shopProduct.give(e.getPlayer(), e.getArena().getPlayerTeam(player), e.getArena(), 1);
}), 1L);
break;
}
}
}
}
Expand Down

0 comments on commit b9198b4

Please sign in to comment.