Skip to content

Commit

Permalink
Added transaction GUI and improved a number of functions
Browse files Browse the repository at this point in the history
+ Improved sell command stability
+ Greatly improved /transaction command, new GUI, improved stability and ease of use.
+ Cleaned up some code and error statements
+ Improved stability of the enchantment algorithm
+ Improved HTTP request stability
+ Fixed illegal enchants
+ Updated to 0.13.0-pre-release-3
  • Loading branch information
noahbclarkson committed Jan 22, 2021
1 parent fa7dcee commit 4dde80e
Show file tree
Hide file tree
Showing 15 changed files with 278 additions and 96 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.13.0-pre-release-2</version>
<version>0.13.0-pre-release-3</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.13.0-pre-release-2</version>
<version>0.13.0-pre-release-3</version>
<!-- Info -->
<name>Auto-Tune</name>
<url>https://github.com/Unprotesting/Auto-Tune</url>
Expand Down
6 changes: 3 additions & 3 deletions Auto-Tune/src/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ web-server-enabled: true
port: 8123

## The maximum length in data points that the trade-short.html will show (this doesn't affect data)
## Info: When the time-period is set to 5, 288 is one day.
maximum-short-trade-length: 288
## Info: When the time-period is set to 144, 1 is one day.
maximum-short-trade-length: 144

## Server name that will show up in commands and requests
server-name: 'My Server'

## Time Period in minutes
## Info: This should be around a tenth of the total items in your shop (i.e with 150 items this would be 15) to prevent overload
## Info: When decreasing or increasing this adjust your volatility settings accordingly
time-period: 5
time-period: 10

## The amount of menu rows in the GUI shop, value of 4-6.
menu-rows: 6
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import unprotesting.com.github.Main;
import unprotesting.com.github.util.Config;
import unprotesting.com.github.util.EnchantmentAlgorithm;
import unprotesting.com.github.util.EnchantmentSetting;
import unprotesting.com.github.util.TextHandler;
import unprotesting.com.github.util.Transaction;
Expand Down Expand Up @@ -72,6 +73,10 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
boolean enchantExists = false;
Map<Enchantment, Integer> map = is.getEnchantments();
Enchantment ench = Enchantment.getByName(setting.name);
if (EnchantmentAlgorithm.checkForEnchantConflicts(is, ench)){
player.sendMessage(ChatColor.RED + "Cannot enchant item: " + is.getType().toString() + " with enchantment " + setting.name);
return true;
}
if (map.get(ench) != null){
enchantExists = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,14 @@ public static void loadGUISECTIONS(Player player, boolean autosell) {
Gui front = new Gui((lines + 2), Config.getMenuTitle());
OutlinePane pane = new OutlinePane(1, 1, 7, lines);
for (int i = 0; i < Main.sectionedItems.length; i++) {
ItemStack is = new ItemStack((Main.sectionedItems[i].image));
ItemStack is;
try{
is = new ItemStack((Main.sectionedItems[i].image));
}
catch(IllegalArgumentException ex){
Main.log("Section: " + Main.sectionedItems[i].name + " has a null or invalid material-name");
continue;
}
ItemMeta im = is.getItemMeta();
im.setDisplayName(ChatColor.GOLD + Main.sectionedItems[i].name);
if (!autosell){
Expand Down Expand Up @@ -632,7 +639,7 @@ public static StaticPane loadMainMenuBackPane(PaginatedPane pPane, boolean autos
}

public static void sendPlayerShopMessageAndUpdateGDP(int amount, Player player, String matClickedString, boolean sell){
ItemStack itemstack = new ItemStack(Material.getMaterial(matClickedString));
ItemStack itemstack = new ItemStack(Material.getMaterial(matClickedString), amount);
if (!sell){
ConcurrentHashMap<String, Integer> cMap = Main.maxBuyMap.get(player.getUniqueId());
cMap.put(matClickedString, (cMap.get(matClickedString)+amount));
Expand All @@ -641,7 +648,7 @@ public static void sendPlayerShopMessageAndUpdateGDP(int amount, Player player,
Double[] arr = inputMap.get(inputMap.size()-1);
Double[] outputArr = {arr[0], (arr[1]+amount), arr[2]};
Main.tempdatadata.put("GDP", (Main.tempdatadata.get("GDP")+(arr[0]*amount)));
Transaction transaction = new Transaction(player, itemstack, "Buy", arr[0]);
Transaction transaction = new Transaction(player.getName(), itemstack, "Buy", arr[0]);
inputMap.put((inputMap.size()-1), outputArr);
Main.map.put(matClickedString, inputMap);
Main.getEconomy().withdrawPlayer(player, (arr[0]*amount));
Expand All @@ -658,7 +665,7 @@ else if (sell){
Double[] outputArr = {arr[0], arr[1], (arr[2]+amount)};
Double price = AutoTuneGUIShopUserCommand.getItemPrice(matClickedString, true);
Main.tempdatadata.put("GDP", (Main.tempdatadata.get("GDP")+(price*amount)));
Transaction transaction = new Transaction(player, itemstack, "Sell", price);
Transaction transaction = new Transaction(player.getName(), itemstack, "Sell", price);
inputMap.put((inputMap.size()-1), outputArr);
Main.map.put(matClickedString, inputMap);
Main.getEconomy().depositPlayer(player, (price*amount));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package unprotesting.com.github.Commands;

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

Expand Down Expand Up @@ -102,7 +103,7 @@ public static void sellItems(Player player, ItemStack[] items, Boolean autoSell)
String item_name = item.getType().toString();
increaseMaxSells(player, quantity, item_name);
increaseSells(item_name, quantity);
Transaction transaction = new Transaction(player, item, "Sell", totalPrice);
Transaction transaction = new Transaction(player.getName(), item, "Sell", totalPrice);
transaction.loadIntoMap();
loadEnchantmentTransactions(item, player);
increaseMaxSells(player, quantity, itemString);
Expand Down Expand Up @@ -133,9 +134,12 @@ public static void loadEnchantmentTransactions (ItemStack item, Player player){
return;
}
else {
for (Enchantment ench : item.getEnchantments().keySet()){
Transaction transaction = new Transaction(player, ench, "Sell");
Map<Enchantment, Integer> ench = item.getEnchantments();
for (Map.Entry<Enchantment, Integer> enchants : ench.entrySet()){
Enchantment enchant = enchants.getKey();
Transaction transaction = new Transaction(player, enchant, "Sell");
transaction.loadIntoMap();
EnchantmentAlgorithm.updateEnchantSellData(enchant, enchants.getValue());
}
}
}
Expand Down
Loading

0 comments on commit 4dde80e

Please sign in to comment.