Skip to content

Commit

Permalink
Fixed more bugs
Browse files Browse the repository at this point in the history
+ Fixed buying enchantments when item isn't in the shop
+ Fixed shop not paginating properly when items in section were less than (pane-size + 7)
+ Improved getting item price data locally
+ Improved some default values
+ Updated to 0.12.3
  • Loading branch information
noahbclarkson committed Jan 3, 2021
1 parent cb25778 commit f257bc7
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 49 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.2</version>
<version>0.12.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.12.2</version>
<version>0.12.3</version>
<!-- Info -->
<name>Auto-Tune</name>
<url>https://github.com/Unprotesting/Auto-Tune</url>
Expand Down
10 changes: 5 additions & 5 deletions Auto-Tune/src/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ currency-symbol: '$'
sell-price-difference-variation-enabled: true

## Starting percententage sell price difference for sell price variation
sell-price-difference-variation-start: 22.5
sell-price-difference-variation-start: 25

## Time in minutes until sell price reaches sell-price-difference set in pricing model settings (default 7 days)
sell-price-variation-time-period: 10080
## Time in minutes until sell price reaches sell-price-difference set in pricing model settings (default 4 weeks)
sell-price-variation-time-period: 43200

## Time in minutes that the sell-price-difference updates
## Info: Must be a factor of sell-price-variation-time-period or it won't work!
Expand All @@ -128,11 +128,11 @@ static-inflation-value: 0.1

## Intrest rate per interest-rate-update-period
## Info: This is the increase in the current debt payment per-time period
interest-rate: 0.005
interest-rate: 0.0075

## Intrest rate for compound-intrest loans
## Info: Compound interest loans grow faster so should have a lower initial interest rate
compound-interest-rate: 0.0025
compound-interest-rate: 0.005

## Time period in ticks between updates of the interest rate for users loans
interest-rate-update-period: 1200
Expand Down
54 changes: 27 additions & 27 deletions Auto-Tune/src/resources/enchantments.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,109 +54,109 @@ enchantments:
## Increases the rate at which you mine/dig
DURABILITY:
price: 850.00
ratio: 0.85
ratio: 0.425
## Decreases the rate at which a tool looses durability
FIRE_ASPECT:
price: 1000.00
ratio: 0.9
ratio: 0.45
## When attacking a target, has a chance to set them on fire
FROST_WALKER:
price: 1100.00
ratio: 1.0
ratio: 0.5
## Freezes any still water adjacent to ice / frost which player is walking on
IMPALING:
price: 650.00
ratio: 0.8
ratio: 0.4
## Deals more damage to mobs that live in the ocean
KNOCKBACK:
price: 975.00
ratio: 0.8
ratio: 0.4
## All damage to other targets will knock them back when hit
LOOT_BONUS_BLOCKS:
price: 1250.00
ratio: 1.45
ratio: 0.725
## Provides a chance of gaining extra loot when destroying blocks
LOOT_BONUS_MOBS:
price: 1200.00
ratio: 1.35
ratio: 0.65
## Provides a chance of gaining extra loot when killing monsters
LOYALTY:
price: 1100.00
ratio: 0.8
ratio: 0.4
## Causes a thrown trident to return to the player who threw it
LUCK:
price: 750.00
ratio: 1.2
ratio: 0.6
## Decreases odds of catching worthless junk
LURE:
price: 550.00
ratio: 0.5
ratio: 0.25
## Increases rate of fish biting your hook
MENDING:
price: 4000.00
ratio: 2.25
ratio: 1.1
## Allows mending the item using experience orbs
MULTISHOT:
price: 800.00
ratio: 0.8
ratio: 0.4
## Shoot multiple arrows from crossbows
OXYGEN:
price: 600.00
ratio: 0.7
ratio: 0.35
## Decreases the rate of air loss whilst underwater
PIERCING:
price: 750.00
ratio: 0.8
ratio: 0.4
## Crossbow projectiles pierce entities
PROTECTION_ENVIRONMENTAL:
price: 900.00
ratio: 0.8
ratio: 0.4
## Provides protection against environmental damage
PROTECTION_EXPLOSIONS:
price: 950.00
ratio: 0.85
ratio: 0.425
## Provides protection against explosive damage
PROTECTION_FALL:
price: 950.00
ratio: 0.85
ratio: 0.425
## Provides protection against fall damage
PROTECTION_FIRE:
price: 950.00
ratio: 0.8
ratio: 0.4
## Provides protection against fire damage
PROTECTION_PROJECTILE:
price: 950.00
ratio: 0.85
ratio: 0.425
## Provides protection against projectile damage
QUICK_CHARGE:
price: 800.00
ratio: 0.85
ratio: 0.425
## Charges crossbows quickly
RIPTIDE:
price: 1050.00
ratio: 0.8
ratio: 0.4
## When it is rainy, launches the player in the direction their trident is thrown
SILK_TOUCH:
price: 1300.00
ratio: 1.2
ratio: 0.6
## Allows blocks to drop themselves instead of fragments (for example, stone instead of cobblestone)
SOUL_SPEED:
price: 1450.00
ratio: 1.5
ratio: 0.75
## Walk quicker on soul blocks
SWEEPING_EDGE:
price: 1900.00
ratio: 0.9
ratio: 0.4
## Increases damage against targets when using a sweep attack
THORNS:
price: 1600.00
ratio: 1.25
ratio: 0.6
## Damages the attacker
VANISHING_CURSE:
price: 50.00
ratio: 0.3
ratio: 0.15
## Item disappears instead of dropping
WATER_WORKER:
price: 800.00
ratio: 0.85
ratio: 0.45
## Increases the speed at which a player may mine underwater
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,13 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
ex.printStackTrace();
return true;
}
double price = setting.price + Main.map.get(is.getType().toString()).get(Main.map.get(is.getType().toString()).size()-1)[0]*setting.ratio;
double price = setting.price;
try{
price = setting.price + AutoTuneGUIShopUserCommand.getItemPrice(is.getType().toString(), false)*setting.ratio;
}
catch(NullPointerException e){
price = setting.price;
}
Main.getEconomy().withdrawPlayer(player, Double.parseDouble(AutoTuneGUIShopUserCommand.df1.format(price)));
player.sendMessage(ChatColor.GOLD + "Purchased " + setting.name + " for "
+ ChatColor.GREEN + Config.getCurrencySymbol() + AutoTuneGUIShopUserCommand.df2.format(price));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public static void loadGUIMAIN(Player player, Section sec, boolean twoArgs, bool
}
Gui main = new Gui((lines + 2), Config.getMenuTitle());
Integer paneSize = (lines + 1) * 7;
Integer paneAmount = (int) Math.ceil(itemAmount / paneSize) + 1;
Integer paneAmount = (int) Math.ceil((itemAmount+7) / paneSize) + 1;
PaginatedPane pPane = new PaginatedPane(0, 0, 9, (lines + 2));
OutlinePane[] shopPanes = new OutlinePane[paneAmount];
for (int i = 0; i < shopPanes.length; i++) {
Expand Down Expand Up @@ -459,26 +459,38 @@ public double getSellPriceDifference(String item) {
}

public static Double getItemPrice(String item, boolean sell) {
Double output = 0.0;
if (!sell) {
Double output = Main.getItemPrices().get(item).price;
if (output != null){
try{
output = Main.getItemPrices().get(item).price;
return output;
}
else{
catch(NullPointerException e){
ConcurrentHashMap<Integer, Double[]> map = Main.map.get(item);
output = map.get(map.size()-1)[0];
return output;
try{
output = map.get(map.size()-1)[0];
return output;
}
catch(NullPointerException e2){
return null;
}

}
} else {
Double output = Main.getItemPrices().get(item).sellPrice;
if (output != null){
try{
output = Main.getItemPrices().get(item).sellPrice;
return output;
}
else{
catch(NullPointerException e){
ConcurrentHashMap<Integer, Double[]> map = Main.map.get(item);
output = map.get(map.size()-1)[0];
output = output - output*0.01*getSellDifference(item);
return output;
try{
output = output - output*0.01*getSellDifference(item);
return output;
}
catch(NullPointerException e2){
return null;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import unprotesting.com.github.Main;
import unprotesting.com.github.Commands.AutoTuneGUIShopUserCommand;

public class EnchantmentAlgorithm {

Expand Down Expand Up @@ -39,10 +40,12 @@ public static void loadEnchantmentSettings() {
public static double calculatePriceWithEnch(ItemStack is, boolean buy) {
ItemMeta iMeta = is.getItemMeta();
Map<Enchantment, Integer> enchants = iMeta.getEnchants();
ConcurrentHashMap<Integer, Double[]> inMap = Main.map.get(is.getType().toString());
double price = 0.0;
if (inMap != null) {
price = inMap.get(inMap.size() - 1)[0];
try{
price = AutoTuneGUIShopUserCommand.getItemPrice(is.getType().toString(), !buy);
}
catch(NullPointerException e){
price = 0.0;
}
double cachePrice = 0;
for (Map.Entry<Enchantment, Integer> ench : enchants.entrySet()) {
Expand Down

0 comments on commit f257bc7

Please sign in to comment.