Skip to content

Commit

Permalink
0.13.0 initial pre-release
Browse files Browse the repository at this point in the history
+ Added transaction command and transactions to view transaction data (unstable).
+ Improved stability of a number of commands
+ Imporved enchantment algorithm
+ Completely rewritten sell command for performance / stability
+ Improved preformance of a number of functions
+ Reduced null exceptions
+ Updated to 0.13.0-pre-release-1
  • Loading branch information
noahbclarkson committed Jan 17, 2021
1 parent fbc49ca commit fb83828
Show file tree
Hide file tree
Showing 17 changed files with 541 additions and 181 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.4</version>
<version>0.13.0-pre-release-1</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.4</version>
<version>0.13.0-pre-release-1</version>
<!-- Info -->
<name>Auto-Tune</name>
<url>https://github.com/Unprotesting/Auto-Tune</url>
Expand Down
12 changes: 6 additions & 6 deletions Auto-Tune/src/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ inflation-enabled: true
inflation-method: 'Mixed'

## Time period in ticks between dynamic price increases
dynamic-inflation-time-period: 5000
dynamic-inflation-time-period: 2500

## Percentage increase in prices per time-period.
dynamic-inflation-value: 0.00025
dynamic-inflation-value: 0.000025

## Percentage increase for buy value per price calculation update period.
static-inflation-value: 0.1
## Percentage increase for buy value per price calculation update period. E.g 0.05%
static-inflation-value: 0.05

## Intrest rate per interest-rate-update-period
## Info: This is the increase in the current debt payment per-time period
Expand All @@ -147,9 +147,9 @@ disable-max-buys-sells: false
max-debt-value: -100.00

## The percentage value to decrease items sold with enchantments
## Info: Stacked enchantments etc. can become very expensive so a number between 10% - 25% is usually fine
## Info: Stacked enchantments etc. can become very expensive so a number between 25% - 50% is usually fine
## Info: This doesn't affect buys
enchantment-limiter: 20.00
enchantment-limiter: 45.00

## The percentage value to decrease items sold with a loss in durability
## Info: This is applied ON TOP of the durability algorithm to limit the exploitability of selling tools
Expand Down
10 changes: 9 additions & 1 deletion Auto-Tune/src/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,15 @@ commands:
usage: /<loan> <amount> (Optional)<compound-interest-enabled>
gdp:
description: View GDP info
usage: <GDP>
usage: /GDP
atconfig:
description: View and change plugin config settings
buy:
description: Buy items not available in the shop
aliases: [purchase]
transactions:
description: View player transactions
usage: /transactions <page-no> | /transactions all <page-no> | /transactions <player-name> <page-no>
permssions:
at.help:
description: Displays Auto-Tune help information
Expand Down Expand Up @@ -83,6 +86,11 @@ permssions:
at.buy:
description: Allow players to purchase custom items
default: true
at.transactions:
description: View your own transactions
default: true
at.transactions.other:
description: View another players transactions | View all transactions



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import unprotesting.com.github.util.EnchantmentAlgorithm;
import unprotesting.com.github.util.EnchantmentSetting;
import unprotesting.com.github.util.TextHandler;
import unprotesting.com.github.util.Transaction;

public class AutoTuneBuyCommand implements CommandExecutor {

Expand All @@ -44,9 +45,8 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
}
if (args.length == 1){
if (args[0].contains("enchantments")){
ConcurrentHashMap<String, EnchantmentSetting> inputMap = Main.enchMap.get("Auto-Tune");
for (String str : Main.enchMap.get("Auto-Tune").keySet()){
EnchantmentSetting setting = inputMap.get(str);
for (String str : Main.enchMap.keySet()){
EnchantmentSetting setting = Main.enchMap.get(str);
player.sendMessage(ChatColor.WHITE + "Enchantment: " + ChatColor.AQUA + str + ChatColor.YELLOW +
" | Price : "+ Config.getCurrencySymbol() + AutoTuneGUIShopUserCommand.df2.format(setting.price) + " | Item Multiplier: " + setting.ratio + "x");
}
Expand All @@ -59,10 +59,12 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
}
if (args.length == 2){
if (args[0].contains("enchantments")){
ConcurrentHashMap<String, EnchantmentSetting> inputMap = Main.enchMap.get("Auto-Tune");
EnchantmentSetting setting = inputMap.get((args[1].toUpperCase()));
EnchantmentSetting setting = Main.enchMap.get((args[1].toUpperCase()));
ItemStack is = player.getInventory().getItemInMainHand();
Material mat = is.getType();
if (Main.getEconomy().getBalance(player) < setting.price){
player.sendMessage(ChatColor.RED + "Cannot enchant item: " + is.getType().toString() + " with enchantment " + setting.name);
return true;
}
boolean enchantExists = false;
Map<Enchantment, Integer> map = is.getEnchantments();
Enchantment ench = Enchantment.getByName(setting.name);
Expand All @@ -73,10 +75,14 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
try{
if (!enchantExists){
is.addEnchantment(ench, 1);
Transaction transaction = new Transaction(player, ench, "Buy");
transaction.loadIntoMap();
}
else{
int level = is.getEnchantmentLevel(ench);
is.addEnchantment(ench, level+1);
Transaction transaction = new Transaction(player, ench, "Buy");
transaction.loadIntoMap();
}
}
catch(IllegalArgumentException ex){
Expand Down Expand Up @@ -108,8 +114,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
arr[1] = arr[1]+1;
buySellMap.put(buySellMap.size()-1, arr);
setting.buySellData = buySellMap;
inputMap.put(setting.name, setting);
Main.enchMap.put("Auto-Tune", inputMap);
Main.enchMap.put(setting.name, setting);
return true;
}
player.sendMessage(ChatColor.RED + "Hold the item you want to enchant in your main hand!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ public double getLoanBalance(){
for (Loan loan : map){
output += loan.current_value;
}

}
return output;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@
import net.md_5.bungee.api.ChatColor;
import unprotesting.com.github.Main;
import unprotesting.com.github.util.Config;
import unprotesting.com.github.util.EnchantmentAlgorithm;
import unprotesting.com.github.util.Section;
import unprotesting.com.github.util.TextHandler;
import unprotesting.com.github.util.Transaction;

public class AutoTuneGUIShopUserCommand implements CommandExecutor {

Expand Down Expand Up @@ -314,6 +316,7 @@ public static OutlinePane loadTradingItems(String itemName, Section sec, Outline
Integer[] max = sec.itemMaxBuySell.get(itemName);
ItemStack test = new ItemStack(Material.matchMaterial(itemName));
test = checkForEnchantAndApply(test, sec);
EnchantmentAlgorithm.updateEnchantSellData(test, player);
if (!player.getInventory().containsAtLeast(test, amounts[finalI - 7])) {
player.sendMessage(ChatColor.BOLD + "Cant Sell " + Integer.toString(amounts[finalI - 7])
+ "x of " + itemName);
Expand Down Expand Up @@ -523,8 +526,8 @@ public static Double getItemPrice(String item, boolean sell) {
}
catch(NullPointerException e){
ConcurrentHashMap<Integer, Double[]> map = Main.map.get(item);
output = map.get(map.size()-1)[0];
try{
output = map.get(map.size()-1)[0];
output = output - output*0.01*getSellDifference(item);
return output;
}
Expand All @@ -535,6 +538,18 @@ public static Double getItemPrice(String item, boolean sell) {
}
}

@Deprecated
public static Double getItemPrice(ItemStack item, boolean sell){
Double output;
try{
output = getItemPrice(item.getType().toString(), sell);
}
catch (NullPointerException ex){
return null;
}
return output;
}

public static StaticPane loadReturnButton(Section sec, boolean autosell) {
StaticPane output = new StaticPane(0, 0, 1, 1);
ItemStack iStack = new ItemStack(Material.ARROW);
Expand Down Expand Up @@ -617,6 +632,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));
if (!sell){
ConcurrentHashMap<String, Integer> cMap = Main.maxBuyMap.get(player.getUniqueId());
cMap.put(matClickedString, (cMap.get(matClickedString)+amount));
Expand All @@ -625,9 +641,11 @@ 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]);
inputMap.put((inputMap.size()-1), outputArr);
Main.map.put(matClickedString, inputMap);
Main.getEconomy().withdrawPlayer(player, (arr[0]*amount));
transaction.loadIntoMap();
player.sendMessage(ChatColor.GOLD + "Purchased " + amount + "x " + matClickedString + " for " + ChatColor.GREEN + Config.getCurrencySymbol() + df2.format(arr[0]*amount));

}
Expand All @@ -638,11 +656,13 @@ else if (sell){
ConcurrentHashMap<Integer, Double[]> inputMap = Main.map.get(matClickedString);
Double[] arr = inputMap.get(inputMap.size()-1);
Double[] outputArr = {arr[0], arr[1], (arr[2]+amount)};
Double price = arr[0] - (arr[0]*0.01*getSellDifference(matClickedString));
Double price = AutoTuneGUIShopUserCommand.getItemPrice(matClickedString, true);
Main.tempdatadata.put("GDP", (Main.tempdatadata.get("GDP")+(price*amount)));
Transaction transaction = new Transaction(player, itemstack, "Sell", price);
inputMap.put((inputMap.size()-1), outputArr);
Main.map.put(matClickedString, inputMap);
Main.getEconomy().depositPlayer(player, (price*amount));
transaction.loadIntoMap();
player.sendMessage(ChatColor.GOLD + "Sold " + amount + "x " + matClickedString + " for " + ChatColor.GREEN + Config.getCurrencySymbol() + df2.format(price*amount));
}
}
Expand Down
Loading

0 comments on commit fb83828

Please sign in to comment.