Skip to content

Commit

Permalink
Fixed degarding buy groups not going for level 0
Browse files Browse the repository at this point in the history
  • Loading branch information
MrEAlderson committed Mar 16, 2024
1 parent becdf07 commit 7a5b1f2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,31 @@ public void onRespawn(PlayerIngameRespawnEvent event) {
final Player player = event.getPlayer();
final Arena arena = event.getArena();

for (BuyGroup buyGroup : GameAPI.get().getBuyGroups()) {
final String buyGroupName = buyGroup.getName();
for (String name : SwordsToolsConfig.degrading_buygroups) {
final BuyGroup buyGroup = GameAPI.get().getBuyGroup(name);

// TODO case sensitive
if (!SwordsToolsConfig.degrading_buygroups.contains(buyGroupName))
if (buyGroup == null)
continue;

int level = ToolSwordHelper.getBuyGroupTracker(player).getBuyGroupLevel(player, buyGroupName);
final BuyGroupTracker tracker = ToolSwordHelper.getBuyGroupTracker(arena);
int newLevel = tracker.getBuyGroupLevel(player, name);

if (level > 1) {
level -= 1;
ToolSwordHelper.getBuyGroupTracker(player).setBuyGroupLevel(player, buyGroupName, level);
}
if (buyGroup.getLevels().contains(newLevel - 1))
newLevel--;

arena.setBuyGroupLevel(player, buyGroup, level);
tracker.setBuyGroupLevel(player, name, newLevel);
arena.setBuyGroupLevel(player, buyGroup, newLevel);

// Give items
final Collection<? extends ShopItem> shopItems = buyGroup.getItems(newLevel);

// Give item
final Collection<? extends ShopItem> shopItems = buyGroup.getItems(level);
if (shopItems == null)
continue;

final Team team = arena.getPlayerTeam(player);

for (ShopItem item : shopItems)
ToolSwordHelper.givePlayerShopItem(arena, team, player, item);

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,6 @@ private void removeArena(Arena arena) {
buyGroupTrackerMap.remove(arena);
}

public static BuyGroupTracker getBuyGroupTracker(Player player) {
return getBuyGroupTracker(GameAPI.get().getArenaByPlayer(player));
}

public static BuyGroupTracker getBuyGroupTracker(Arena arena) {
if(arena == null || !buyGroupTrackerMap.containsKey(arena))
return new BuyGroupTracker();
Expand Down

0 comments on commit 7a5b1f2

Please sign in to comment.