Skip to content

Commit

Permalink
Fix not getting tools on respawn if only buy tier 1
Browse files Browse the repository at this point in the history
  • Loading branch information
MetallicGoat committed Oct 30, 2021
1 parent b9198b4 commit f59c580
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import de.marcely.bedwars.api.BedwarsAPI;
import de.marcely.bedwars.api.arena.Arena;
import de.marcely.bedwars.api.event.arena.RoundStartEvent;
import de.marcely.bedwars.api.event.player.PlayerBuyInShopEvent;
import de.marcely.bedwars.api.event.player.PlayerIngameDeathEvent;
import de.marcely.bedwars.api.event.player.PlayerIngameRespawnEvent;
import de.marcely.bedwars.api.game.shop.BuyGroup;
Expand Down Expand Up @@ -62,6 +63,32 @@ public void onRespawn(PlayerIngameRespawnEvent e){
}
}

@EventHandler
public void levelOneBuy(PlayerBuyInShopEvent e) {
Player p = e.getPlayer();

//If enabled, and item has buy-group
if(e.getProblems().isEmpty() && e.getItem().hasBuyGroup() &&
ServerManager.getSwordsToolsConfig().getBoolean("Degraded-Tool-BuyGroups")
&& ServerManager.getSwordsToolsConfig().getBoolean("Advanced-Tool-Replacement.Enabled")){

BuyGroup group = e.getItem().getBuyGroup();
int level = e.getItem().getBuyGroupLevel();

assert group != null;
//if proper buy-group
if(level == 1 && (group.getName().equalsIgnoreCase("axe")
|| group.getName().equalsIgnoreCase("pickaxe"))) {

if(group.getName().equalsIgnoreCase("pickaxe")){
pickaxeHashMap.put(p, 1);
}else{
axeHashMap.put(p, 1);
}
}
}
}

@EventHandler
public void onRespawn(PlayerIngameDeathEvent e){
if(ServerManager.getSwordsToolsConfig().getBoolean("Degraded-Tool-BuyGroups")
Expand Down

0 comments on commit f59c580

Please sign in to comment.