Skip to content

Commit

Permalink
Fixed an issue with selling from the shop when on max-sells
Browse files Browse the repository at this point in the history
+ Fixed an issue with selling from the shop when on max-sells
  • Loading branch information
noahbclarkson committed Dec 8, 2020
1 parent b977b04 commit 78bd1ae
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Auto-Tune/dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>unprotesting.com.github</groupId>
<artifactId>Auto-Tune</artifactId>
<name>Auto-Tune</name>
<version>0.12.0-pre-release-3</version>
<version>0.12.0-pre-release-4</version>
<description>The automatic pricing plugin for minecraft</description>
<url>https://github.com/Unprotesting/Auto-Tune</url>
<issueManagement>
Expand Down
2 changes: 1 addition & 1 deletion Auto-Tune/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<!-- Project information -->
<groupId>unprotesting.com.github</groupId>
<artifactId>Auto-Tune</artifactId>
<version>0.12.0-pre-release-3</version>
<version>0.12.0-pre-release-4</version>
<!-- Info -->
<name>Auto-Tune</name>
<url>https://github.com/Unprotesting/Auto-Tune</url>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,12 @@ public void loadGUITRADING(Player player, String itemName, Section sec) {
+ "x of " + itemName);
int difference = (currentMax + amounts[finalI - 7]) - max[1];
if (difference != 0 && !(currentMax >= max[1])) {
removeItems(player, (amounts[finalI-7]-difference), itemName, sec);
removeItems(player, (finalI-7), itemName, sec, difference);
Main.maxSellMap.put(player.getUniqueId(), maxSellMapRec);
}
player.sendMessage(ChatColor.RED + "Max Sells Reached! - " + max[1] + "/" + max[1]);
} else {
removeItems(player, (finalI - 7), itemName, sec);
removeItems(player, (finalI - 7), itemName, sec, 0);
}
});
}
Expand All @@ -269,16 +269,16 @@ public void loadGUITRADING(Player player, String itemName, Section sec) {
main.show((HumanEntity) cSender);
}

public void removeItems(Player player, int finalI, String itemName, Section sec) {
public void removeItems(Player player, int finalI, String itemName, Section sec, int difference) {
try {
ItemStack iStack = new ItemStack(Material.matchMaterial(itemName), amounts[finalI]);
ItemStack iStack = new ItemStack(Material.matchMaterial(itemName), (amounts[finalI])-difference);
iStack = checkForEnchantAndApply(iStack, sec);
HashMap<Integer, ItemStack> takenItems = player.getInventory().removeItem(iStack);
if (takenItems.size() > 0) {
player.sendMessage(
ChatColor.BOLD + "Cant sell " + Integer.toString(amounts[finalI]) + "x of " + itemName);
ChatColor.BOLD + "Cant sell " + Integer.toString(amounts[finalI]-difference) + "x of " + itemName);
} else {
sendPlayerShopMessageAndUpdateGDP(amounts[finalI], player, itemName, true);
sendPlayerShopMessageAndUpdateGDP((amounts[finalI]-difference), player, itemName, true);
}
} catch (IllegalArgumentException ex) {
}
Expand Down

0 comments on commit 78bd1ae

Please sign in to comment.