Skip to content

Commit

Permalink
Fixed selling issues
Browse files Browse the repository at this point in the history
+ Fixed selling sometimes not registering by splitting up GUI's for players like the shop
+ Updated to 0.12.4
  • Loading branch information
noahbclarkson committed Jan 5, 2021
1 parent 945ea39 commit 9013107
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 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.3</version>
<version>0.12.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.3</version>
<version>0.12.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
@@ -1,5 +1,6 @@
package unprotesting.com.github.Commands;

import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;

import com.github.stefvanschie.inventoryframework.Gui;
Expand All @@ -24,7 +25,8 @@
public class AutoTuneSellCommand implements CommandExecutor {

public Integer menuRows = Config.getMenuRows();
private Gui GUI;

ConcurrentHashMap<UUID, Gui> guis = new ConcurrentHashMap<UUID, Gui>();

@Override
public boolean onCommand(CommandSender sender, Command command, String sell, String[] args) {
Expand All @@ -37,6 +39,7 @@ public boolean onCommand(CommandSender sender, Command command, String sell, Str
CommandSender sender2 = sender;
Player p = (Player) sender;
if (args.length == 0){
guis.put(p.getUniqueId(), loadSellGUI(p, sender2));
if (p.hasPermission("at.sell") || p.isOp()){loadSellGUI(p, sender2);}
else if (!(p.hasPermission("at.sell")) && !(p.isOp())){TextHandler.noPermssion(p);}
return true;
Expand All @@ -51,7 +54,8 @@ public boolean onCommand(CommandSender sender, Command command, String sell, Str
}

public void sell(Player player, Gui GUI) {
sellItems(player, GUI.getInventory().getContents(), false);
ItemStack[] items = GUI.getInventory().getContents();
sellItems(player, items, false);
GUI.getInventory().clear();
}

Expand Down Expand Up @@ -137,22 +141,21 @@ else if (autoSell == false){
}
}

public void sell(Player player) {
sellItems(player, GUI.getInventory().getContents(), false);
GUI.getInventory().clear();
}

public void loadSellGUI(Player player, CommandSender sender2) {
GUI = new Gui(menuRows, "Selling Panel");
public Gui loadSellGUI(Player player, CommandSender sender2) {
Gui GUI = new Gui(menuRows, "Selling Panel");
StaticPane SellingPane = new StaticPane(0, 0, 9, menuRows, Priority.HIGH);
GUI.addPane(SellingPane);
GUI.setOnClose(this::onSellClose);
GUI.show((HumanEntity) sender2);
guis.put(player.getUniqueId(), GUI);
return GUI;
}

private void onSellClose(InventoryCloseEvent event) {
Player player = (Player) event.getPlayer();
sell(player);
UUID uuid = player.getUniqueId();
sell(player, guis.get(uuid));
guis.remove(uuid);
}

public static void roundAndGiveMoney(Player player, double moneyToGive, Boolean autoSell) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ public class EnchantmentAlgorithm {
public static void loadEnchantmentSettings() {
ConfigurationSection config = Main.getEnchantmentConfig().getConfigurationSection("enchantments");
ConcurrentHashMap<String, EnchantmentSetting> newMap = Main.enchMap.get("Auto-Tune");
if (newMap == null){
newMap = new ConcurrentHashMap<String, EnchantmentSetting>();
}
if (Main.enchMap.containsKey("Auto-Tune")) {
newMap = Main.enchMap.get("Auto-Tune");
for (String str : config.getKeys(false)) {
Expand Down

0 comments on commit 9013107

Please sign in to comment.