From f59c580dc2479f13e5c1eb7a464c061328b8650c Mon Sep 17 00:00:00 2001 From: MetallicGoat Date: Fri, 29 Oct 2021 22:22:20 -0400 Subject: [PATCH] Fix not getting tools on respawn if only buy tier 1 --- .../advancedswords/DowngradeTools.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/main/java/me/metallicgoat/MBedwarsTweaks/advancedswords/DowngradeTools.java b/src/main/java/me/metallicgoat/MBedwarsTweaks/advancedswords/DowngradeTools.java index 64a27fb..75f5abf 100644 --- a/src/main/java/me/metallicgoat/MBedwarsTweaks/advancedswords/DowngradeTools.java +++ b/src/main/java/me/metallicgoat/MBedwarsTweaks/advancedswords/DowngradeTools.java @@ -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; @@ -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")