mirror of
https://github.com/NLthijs48/AreaShop.git
synced 2024-11-18 16:25:25 +01:00
Fix '/as find' not getting your balance correctly
- If you search with your balance (and do not give a maxprice) it would always use 0.0 as your balance, therefore not finding any regions. - Also fixes the incorrect feedback, it would say it searched with a maxprice instead of your balance and the other way around if no regions are found. - Fixed maxprice and balance display to use correct currency symbols and layouts (decimals, metric prefixes, separator). Fixes #59
This commit is contained in:
parent
bf181d69d7
commit
9ca029176d
@ -1,7 +1,5 @@
|
|||||||
package nl.evolutioncoding.areashop.commands;
|
package nl.evolutioncoding.areashop.commands;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.math.RoundingMode;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
@ -51,7 +49,7 @@ public class FindCommand extends CommandAreaShop {
|
|||||||
Player player = (Player)sender;
|
Player player = (Player)sender;
|
||||||
double balance = 0.0;
|
double balance = 0.0;
|
||||||
if(plugin.getEconomy() != null) {
|
if(plugin.getEconomy() != null) {
|
||||||
plugin.getEconomy().getBalance(player);
|
balance = plugin.getEconomy().getBalance(player);
|
||||||
}
|
}
|
||||||
double maxPrice = 0;
|
double maxPrice = 0;
|
||||||
boolean maxPriceSet = false;
|
boolean maxPriceSet = false;
|
||||||
@ -66,6 +64,7 @@ public class FindCommand extends CommandAreaShop {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
AreaShop.debug("maxPriceSet="+maxPriceSet+", balance="+balance);
|
||||||
// Parse optional group argument
|
// Parse optional group argument
|
||||||
if(args.length >= 4) {
|
if(args.length >= 4) {
|
||||||
group = plugin.getFileManager().getGroup(args[3]);
|
group = plugin.getFileManager().getGroup(args[3]);
|
||||||
@ -87,32 +86,25 @@ public class FindCommand extends CommandAreaShop {
|
|||||||
if(!results.isEmpty()) {
|
if(!results.isEmpty()) {
|
||||||
// Draw a random one
|
// Draw a random one
|
||||||
BuyRegion region = results.get(new Random().nextInt(results.size()));
|
BuyRegion region = results.get(new Random().nextInt(results.size()));
|
||||||
|
|
||||||
BigDecimal bigDecimal = new BigDecimal(balance);
|
|
||||||
bigDecimal = bigDecimal.setScale(2, RoundingMode.HALF_UP);
|
|
||||||
balance = bigDecimal.doubleValue();
|
|
||||||
String onlyInGroup = "";
|
String onlyInGroup = "";
|
||||||
if(group != null) {
|
if(group != null) {
|
||||||
onlyInGroup = plugin.getLanguageManager().getLang("find-onlyInGroup", args[3]);
|
onlyInGroup = plugin.getLanguageManager().getLang("find-onlyInGroup", args[3]);
|
||||||
}
|
}
|
||||||
if(maxPriceSet) {
|
if(maxPriceSet) {
|
||||||
plugin.message(player, "find-successMax", "buy", region.getName(), maxPrice, onlyInGroup);
|
plugin.message(player, "find-successMax", "buy", region.getName(), plugin.formatCurrency(maxPrice), onlyInGroup);
|
||||||
} else {
|
} else {
|
||||||
plugin.message(player, "find-success", "buy", region.getName(), balance, onlyInGroup);
|
plugin.message(player, "find-success", "buy", region.getName(), plugin.formatCurrency(balance), onlyInGroup);
|
||||||
}
|
}
|
||||||
region.teleportPlayer(player, region.getBooleanSetting("general.findTeleportToSign"), false);
|
region.teleportPlayer(player, region.getBooleanSetting("general.findTeleportToSign"), false);
|
||||||
} else {
|
} else {
|
||||||
BigDecimal bigDecimal = new BigDecimal(balance);
|
|
||||||
bigDecimal = bigDecimal.setScale(2, RoundingMode.HALF_UP);
|
|
||||||
balance = bigDecimal.doubleValue();
|
|
||||||
String onlyInGroup = "";
|
String onlyInGroup = "";
|
||||||
if(group != null) {
|
if(group != null) {
|
||||||
onlyInGroup = plugin.getLanguageManager().getLang("find-onlyInGroup", args[3]);
|
onlyInGroup = plugin.getLanguageManager().getLang("find-onlyInGroup", args[3]);
|
||||||
}
|
}
|
||||||
if(maxPriceSet) {
|
if(maxPriceSet) {
|
||||||
plugin.message(player, "find-noneFound", "buy", maxPrice, onlyInGroup);
|
plugin.message(player, "find-noneFoundMax", "buy", plugin.formatCurrency(maxPrice), onlyInGroup);
|
||||||
} else {
|
} else {
|
||||||
plugin.message(player, "find-noneFoundMax", "buy", balance, onlyInGroup);
|
plugin.message(player, "find-noneFound", "buy", plugin.formatCurrency(balance), onlyInGroup);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -128,32 +120,25 @@ public class FindCommand extends CommandAreaShop {
|
|||||||
if(!results.isEmpty()) {
|
if(!results.isEmpty()) {
|
||||||
// Draw a random one
|
// Draw a random one
|
||||||
RentRegion region = results.get(new Random().nextInt(results.size()));
|
RentRegion region = results.get(new Random().nextInt(results.size()));
|
||||||
|
|
||||||
BigDecimal bigDecimal = new BigDecimal(balance);
|
|
||||||
bigDecimal = bigDecimal.setScale(2, RoundingMode.HALF_UP);
|
|
||||||
balance = bigDecimal.doubleValue();
|
|
||||||
String onlyInGroup = "";
|
String onlyInGroup = "";
|
||||||
if(group != null) {
|
if(group != null) {
|
||||||
onlyInGroup = plugin.getLanguageManager().getLang("find-onlyInGroup", args[3]);
|
onlyInGroup = plugin.getLanguageManager().getLang("find-onlyInGroup", args[3]);
|
||||||
}
|
}
|
||||||
if(maxPriceSet) {
|
if(maxPriceSet) {
|
||||||
plugin.message(player, "find-successMax", "rent", region.getName(), maxPrice, onlyInGroup);
|
plugin.message(player, "find-successMax", "rent", region.getName(), plugin.formatCurrency(maxPrice), onlyInGroup);
|
||||||
} else {
|
} else {
|
||||||
plugin.message(player, "find-success", "rent", region.getName(), balance, onlyInGroup);
|
plugin.message(player, "find-success", "rent", region.getName(), plugin.formatCurrency(balance), onlyInGroup);
|
||||||
}
|
}
|
||||||
region.teleportPlayer(player, region.getBooleanSetting("general.findTeleportToSign"), false);
|
region.teleportPlayer(player, region.getBooleanSetting("general.findTeleportToSign"), false);
|
||||||
} else {
|
} else {
|
||||||
BigDecimal bigDecimal = new BigDecimal(balance);
|
|
||||||
bigDecimal = bigDecimal.setScale(2, RoundingMode.HALF_UP);
|
|
||||||
balance = bigDecimal.doubleValue();
|
|
||||||
String onlyInGroup = "";
|
String onlyInGroup = "";
|
||||||
if(group != null) {
|
if(group != null) {
|
||||||
onlyInGroup = plugin.getLanguageManager().getLang("find-onlyInGroup", args[3]);
|
onlyInGroup = plugin.getLanguageManager().getLang("find-onlyInGroup", args[3]);
|
||||||
}
|
}
|
||||||
if(maxPriceSet) {
|
if(maxPriceSet) {
|
||||||
plugin.message(player, "find-noneFound", "rent", maxPrice, onlyInGroup);
|
plugin.message(player, "find-noneFoundMax", "rent", plugin.formatCurrency(maxPrice), onlyInGroup);
|
||||||
} else {
|
} else {
|
||||||
plugin.message(player, "find-noneFoundMax", "rent", balance, onlyInGroup);
|
plugin.message(player, "find-noneFound", "rent", plugin.formatCurrency(balance), onlyInGroup);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ description: "Selling and renting WorldGuard regions to your players, highly con
|
|||||||
depend: [Vault, WorldGuard, WorldEdit]
|
depend: [Vault, WorldGuard, WorldEdit]
|
||||||
softdepend: [Multiverse-Core]
|
softdepend: [Multiverse-Core]
|
||||||
author: NLThijs48
|
author: NLThijs48
|
||||||
website: http://dev.bukkit.org/bukkit-plugins/regionbuyandrent/
|
website: https://github.com/NLthijs48/AreaShop
|
||||||
commands:
|
commands:
|
||||||
AreaShop:
|
AreaShop:
|
||||||
description: 'For all commands use /as help.'
|
description: 'For all commands use /as help.'
|
||||||
|
Loading…
Reference in New Issue
Block a user