Compare commits

...
3 Commits
Author SHA1 Message Date
Thijs Wiefferink 21340af89f Change the '/as find' command to randomly pick a region that suits
First searches all matching regions (rent/buy, maxprice and group), then
randomly picks one.
2015-01-12 21:55:01 +01:00
Thijs Wiefferink db06eae6c9 Add a message to show resell price when using '/as info region' 2015-01-12 21:42:54 +01:00
Thijs Wiefferink 5bae5ecf67 Fix a bug with buying a region while it is in resell mode 2015-01-12 17:11:08 +01:00
7 changed files with 83 additions and 60 deletions

No files matched your search

+1 -1
View File
@@ -233,7 +233,7 @@ schematicProfiles:
## You can add groups by using 'g:<groupname>', so in total you could use: '%uuid%, %friendsuuid%, g:vip, n:cool-guy'
## For flags like 'entry' and 'exit' you can add group setting by using 'g:<scope>' behind it, <scope> is one of the following:
## members, non_members, owners, non_owners, all. Example, only owners can enter the region:
## entry: 'allow g:owners'
## entry: 'deny g:non_owners'
## Use '' for a flag to reset it.
flagProfiles:
default:
+2
View File
@@ -147,9 +147,11 @@ info-regionFooterRent: ""
info-regionFooterBuy: ""
info-regionRented: "&2&l►&r Rented by %player% until: &7%until%"
info-regionBought: "&2&l►&r Bought by %player%"
info-regionReselling: "&2&l►&r Bought by %player%, currently reselling"
info-regionExtending: "&2&l►&r Price to extend: &7%price% per %duration%"
info-regionCanBeRented: "&2&l►&r Price to rent: &7%price% per %duration%"
info-regionCanBeBought: "&2&l►&r Price to buy: &7%price%"
info-regionReselPrice: "&2&l►&r Resell price: &7%resellprice% (you can buy it from %player%)"
info-regionFriends: "&2&l►&r Added friends: &7%friends%"
info-regionMoneyBackBuy: "&2&l►&r Selling payback: &7%moneyback% (%moneybackpercent%% of the price)"
info-regionMoneyBackRent: "&2&l►&r Unrenting payback: &7%moneyback% (%moneybackpercent%% of the remaining time)"
+3 -5
View File
@@ -1,6 +1,6 @@
name: AreaShop
main: nl.evolutioncoding.areashop.AreaShop
version: 2.1.3
version: 2.1.4
depend: [Vault, WorldGuard, WorldEdit]
softdepend: [Multiverse-Core]
author: NLThijs48
@@ -9,8 +9,6 @@ commands:
AreaShop:
description: For all commands use /as help
usage: AreaShop has not started correctly, check the console and correct any errors
permission: areashop.help
permission-message: You don't have <permission>
aliases: [as]
permissions:
areashop.*:
@@ -53,7 +51,7 @@ permissions:
areashop.stopresellall: true
areashop.addfriendall: true
areashop.delfriendall: true
areashop.nofityupdate: true
areashop.notifyupdate: true
areashop.help:
description: Allows you to see the help pages
default: true
@@ -207,6 +205,6 @@ permissions:
areashop.delfriendall:
description: Allows you to delete friends from all regions
default: op
areashop.nofityupdate:
areashop.notifyupdate:
description: Will notify this player when an update is available
default: op
@@ -4,6 +4,7 @@ import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import nl.evolutioncoding.areashop.AreaShop;
import nl.evolutioncoding.areashop.regions.BuyRegion;
@@ -72,72 +73,85 @@ public class FindCommand extends CommandAreaShop {
}
if(args[1].equalsIgnoreCase("buy")) {
List<BuyRegion> regions = plugin.getFileManager().getBuys();
List<BuyRegion> results = new ArrayList<BuyRegion>();
for(BuyRegion region : regions) {
if(!region.isSold()
&& ((region.getPrice() <= balance && !maxPriceSet) || (region.getPrice() <= maxPrice && maxPriceSet))
&& (group == null || group.isMember(region))) {
BigDecimal bigDecimal = new BigDecimal(balance);
bigDecimal = bigDecimal.setScale(2, RoundingMode.HALF_UP);
balance = bigDecimal.doubleValue();
String onlyInGroup = "";
if(group != null) {
onlyInGroup = plugin.getLanguageManager().getLang("find-onlyInGroup", args[3]);
}
if(maxPriceSet) {
plugin.message(player, "find-successMax", "buy", region.getName(), maxPrice, onlyInGroup);
} else {
plugin.message(player, "find-success", "buy", region.getName(), balance, onlyInGroup);
}
region.teleportPlayer(player, true, false);
return;
results.add(region);
}
}
BigDecimal bigDecimal = new BigDecimal(balance);
bigDecimal = bigDecimal.setScale(2, RoundingMode.HALF_UP);
balance = bigDecimal.doubleValue();
String onlyInGroup = "";
if(group != null) {
onlyInGroup = plugin.getLanguageManager().getLang("find-onlyInGroup", args[3]);
}
if(maxPriceSet) {
plugin.message(player, "find-noneFound", "buy", maxPrice, onlyInGroup);
if(!results.isEmpty()) {
// Draw a random one
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 = "";
if(group != null) {
onlyInGroup = plugin.getLanguageManager().getLang("find-onlyInGroup", args[3]);
}
if(maxPriceSet) {
plugin.message(player, "find-successMax", "buy", region.getName(), maxPrice, onlyInGroup);
} else {
plugin.message(player, "find-success", "buy", region.getName(), balance, onlyInGroup);
}
region.teleportPlayer(player, true, false);
} else {
plugin.message(player, "find-noneFoundMax", "buy", balance, onlyInGroup);
BigDecimal bigDecimal = new BigDecimal(balance);
bigDecimal = bigDecimal.setScale(2, RoundingMode.HALF_UP);
balance = bigDecimal.doubleValue();
String onlyInGroup = "";
if(group != null) {
onlyInGroup = plugin.getLanguageManager().getLang("find-onlyInGroup", args[3]);
}
if(maxPriceSet) {
plugin.message(player, "find-noneFound", "buy", maxPrice, onlyInGroup);
} else {
plugin.message(player, "find-noneFoundMax", "buy", balance, onlyInGroup);
}
}
} else {
List<RentRegion> regions = plugin.getFileManager().getRents();
List<RentRegion> results = new ArrayList<RentRegion>();
for(RentRegion region : regions) {
if(!region.isRented()
&& ((region.getPrice() <= balance && !maxPriceSet) || (region.getPrice() <= maxPrice && maxPriceSet))
&& (group == null || group.isMember(region))) {
BigDecimal bigDecimal = new BigDecimal(balance);
bigDecimal = bigDecimal.setScale(2, RoundingMode.HALF_UP);
balance = bigDecimal.doubleValue();
String onlyInGroup = "";
if(group != null) {
onlyInGroup = plugin.getLanguageManager().getLang("find-onlyInGroup", args[3]);
}
if(maxPriceSet) {
plugin.message(player, "find-successMax", "rent", region.getName(), maxPrice, onlyInGroup);
} else {
plugin.message(player, "find-success", "rent", region.getName(), balance, onlyInGroup);
}
region.teleportPlayer(player, true, false);
return;
results.add(region);
}
}
BigDecimal bigDecimal = new BigDecimal(balance);
bigDecimal = bigDecimal.setScale(2, RoundingMode.HALF_UP);
balance = bigDecimal.doubleValue();
String onlyInGroup = "";
if(group != null) {
onlyInGroup = plugin.getLanguageManager().getLang("find-onlyInGroup", args[3]);
}
if(maxPriceSet) {
plugin.message(player, "find-noneFound", "rent", maxPrice, onlyInGroup);
if(!results.isEmpty()) {
// Draw a random one
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 = "";
if(group != null) {
onlyInGroup = plugin.getLanguageManager().getLang("find-onlyInGroup", args[3]);
}
if(maxPriceSet) {
plugin.message(player, "find-successMax", "rent", region.getName(), maxPrice, onlyInGroup);
} else {
plugin.message(player, "find-success", "rent", region.getName(), balance, onlyInGroup);
}
region.teleportPlayer(player, true, false);
} else {
plugin.message(player, "find-noneFoundMax", "rent", balance, onlyInGroup);
BigDecimal bigDecimal = new BigDecimal(balance);
bigDecimal = bigDecimal.setScale(2, RoundingMode.HALF_UP);
balance = bigDecimal.doubleValue();
String onlyInGroup = "";
if(group != null) {
onlyInGroup = plugin.getLanguageManager().getLang("find-onlyInGroup", args[3]);
}
if(maxPriceSet) {
plugin.message(player, "find-noneFound", "rent", maxPrice, onlyInGroup);
} else {
plugin.message(player, "find-noneFoundMax", "rent", balance, onlyInGroup);
}
}
}
@@ -305,7 +305,12 @@ public class InfoCommand extends CommandAreaShop {
} else if(buy != null) {
plugin.message(sender, "info-regionHeaderBuy", buy);
if(buy.isSold()) {
plugin.messageNoPrefix(sender, "info-regionBought", buy);
if(buy.isInResellingMode()) {
plugin.messageNoPrefix(sender, "info-regionReselling", buy);
plugin.messageNoPrefix(sender, "info-regionReselPrice", buy);
} else {
plugin.messageNoPrefix(sender, "info-regionBought", buy);
}
plugin.messageNoPrefix(sender, "info-regionMoneyBackBuy", buy);
if(!buy.getFriendNames().isEmpty()) {
plugin.messageNoPrefix(sender, "info-regionFriends", buy);
@@ -266,7 +266,7 @@ public class BuyRegion extends GeneralRegion {
}
/* Check if the player has enough money */
if(plugin.getEconomy().has(player, getWorldName(), getPrice())) {
if((!isResell && plugin.getEconomy().has(player, getWorldName(), getPrice())) || (isResell && plugin.getEconomy().has(player, getWorldName(), getResellPrice()))) {
UUID oldOwner = getBuyer();
if(isResell && oldOwner != null) {
clearFriends();
@@ -335,7 +335,13 @@ public class BuyRegion extends GeneralRegion {
return true;
} else {
/* Player has not enough money */
plugin.message(player, "buy-lowMoney", plugin.formatCurrency(plugin.getEconomy().getBalance(player, getWorldName())), getFormattedPrice());
String requiredMoney = "";
if(isResell) {
requiredMoney = getFormattedResellPrice();
} else {
requiredMoney = getFormattedPrice();
}
plugin.message(player, "buy-lowMoney", plugin.formatCurrency(plugin.getEconomy().getBalance(player, getWorldName())), requiredMoney);
}
} else {
if(isBuyer(player)) {
@@ -1028,7 +1028,6 @@ public abstract class GeneralRegion {
uuid = null;
}
if(uuid != null) {
//AreaShop.debug(" Added player by UUID");
members.addPlayer(uuid);
}
}
@@ -1062,7 +1061,6 @@ public abstract class GeneralRegion {
uuid = null;
}
if(uuid != null) {
//AreaShop.debug(" Added player by UUID");
owners.addPlayer(uuid);
}
}