added container rent
This commit is contained in:
parent
d7fa646356
commit
a14504861f
@ -28,6 +28,8 @@ public class Config extends AnnotationConfig
|
||||
public List<String> cfgSellKeywords = Arrays.asList("[sell]", "[sell claim]", "[sc]", "[re]", "[realestate]");
|
||||
@ConfigField(name="RealEstate.Keywords.Rent", comment = "List of all possible possible signs headers to rent a claim")
|
||||
public List<String> cfgRentKeywords = Arrays.asList("[rent]", "[rent claim]", "[rc]");
|
||||
@ConfigField(name="RealEstate.Keywords.ContainerRent", comment = "List of all possible possible signs headers to rent a claim")
|
||||
public List<String> cfgContainerRentKeywords = Arrays.asList("[container rent]", "[crent]");
|
||||
@ConfigField(name="RealEstate.Keywords.Lease", comment = "List of all possible possible signs headers to lease a claim")
|
||||
public List<String> cfgLeaseKeywords = Arrays.asList("[lease]", "[lease claim]", "[lc]");
|
||||
|
||||
@ -39,6 +41,8 @@ public class Config extends AnnotationConfig
|
||||
public String cfgReplaceLease = "FOR LEASE";
|
||||
@ConfigField(name="RealEstate.Keywords.Replace.Ongoing.Rent", comment = "What is displayed on the first line of the sign once someone rents a claim.")
|
||||
public String cfgReplaceOngoingRent = "[Rented]";
|
||||
@ConfigField(name="RealEstate.Keywords.Replace.ContainerRent", comment = "What is displayed on the third line of the sign when renting container access only.")
|
||||
public String cfgContainerRentLine = ChatColor.BLUE + "Containers only";
|
||||
|
||||
@ConfigField(name="RealEstate.Rules.Sell", comment = "Is selling claims enabled?")
|
||||
public boolean cfgEnableSell = true;
|
||||
|
||||
@ -35,7 +35,8 @@ public class REListener implements Listener
|
||||
{
|
||||
if(RealEstate.instance.config.cfgSellKeywords.contains(event.getLine(0).toLowerCase()) ||
|
||||
RealEstate.instance.config.cfgLeaseKeywords.contains(event.getLine(0).toLowerCase()) ||
|
||||
RealEstate.instance.config.cfgRentKeywords.contains(event.getLine(0).toLowerCase()))
|
||||
RealEstate.instance.config.cfgRentKeywords.contains(event.getLine(0).toLowerCase()) ||
|
||||
RealEstate.instance.config.cfgContainerRentKeywords.contains(event.getLine(0).toLowerCase()))
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
Location loc = event.getBlock().getLocation();
|
||||
@ -144,7 +145,8 @@ public class REListener implements Listener
|
||||
event.setCancelled(true);// need to cancel the event, so we can update the sign elsewhere
|
||||
RealEstate.transactionsStore.sell(claim, claim.isAdminClaim() ? null : player, price, event.getBlock().getLocation());
|
||||
}
|
||||
else if(RealEstate.instance.config.cfgRentKeywords.contains(event.getLine(0).toLowerCase()))// we want to rent it
|
||||
else if(RealEstate.instance.config.cfgRentKeywords.contains(event.getLine(0).toLowerCase()) ||
|
||||
RealEstate.instance.config.cfgContainerRentKeywords.contains(event.getLine(0).toLowerCase()))// we want to rent it
|
||||
{
|
||||
if(!RealEstate.instance.config.cfgEnableRent)
|
||||
{
|
||||
@ -253,7 +255,8 @@ public class REListener implements Listener
|
||||
|
||||
// all should be good, we can create the rent
|
||||
event.setCancelled(true);
|
||||
RealEstate.transactionsStore.rent(claim, player, price, event.getBlock().getLocation(), duration, rentPeriods);
|
||||
RealEstate.transactionsStore.rent(claim, player, price, event.getBlock().getLocation(), duration, rentPeriods,
|
||||
RealEstate.instance.config.cfgRentKeywords.contains(event.getLine(0).toLowerCase()));
|
||||
}
|
||||
else if(RealEstate.instance.config.cfgLeaseKeywords.contains(event.getLine(0).toLowerCase()))// we want to rent it
|
||||
{
|
||||
|
||||
@ -28,6 +28,7 @@ public class ClaimRent extends BoughtTransaction
|
||||
LocalDateTime startDate = null;
|
||||
int duration;
|
||||
public boolean autoRenew = false;
|
||||
public boolean buildTrust = true;
|
||||
public int periodCount = 0;
|
||||
public int maxPeriod;
|
||||
|
||||
@ -40,13 +41,20 @@ public class ClaimRent extends BoughtTransaction
|
||||
autoRenew = (boolean) map.get("autoRenew");
|
||||
periodCount = (int) map.get("periodCount");
|
||||
maxPeriod = (int) map.get("maxPeriod");
|
||||
try {
|
||||
buildTrust = (boolean) map.get("buildTrust");
|
||||
}
|
||||
catch (Exception e) {
|
||||
buildTrust = true;
|
||||
}
|
||||
}
|
||||
|
||||
public ClaimRent(Claim claim, Player player, double price, Location sign, int duration, int rentPeriods)
|
||||
public ClaimRent(Claim claim, Player player, double price, Location sign, int duration, int rentPeriods, boolean buildTrust)
|
||||
{
|
||||
super(claim, player, price, sign);
|
||||
this.duration = duration;
|
||||
this.maxPeriod = RealEstate.instance.config.cfgEnableRentPeriod ? rentPeriods : 1;
|
||||
this.buildTrust = buildTrust;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -59,6 +67,7 @@ public class ClaimRent extends BoughtTransaction
|
||||
map.put("autoRenew", autoRenew);
|
||||
map.put("periodCount", periodCount);
|
||||
map.put("maxPeriod", maxPeriod);
|
||||
map.put("buildTrust", buildTrust);
|
||||
|
||||
return map;
|
||||
}
|
||||
@ -74,15 +83,16 @@ public class ClaimRent extends BoughtTransaction
|
||||
s.setLine(0, RealEstate.instance.config.cfgSignsHeader);
|
||||
s.setLine(1, ChatColor.DARK_GREEN + RealEstate.instance.config.cfgReplaceRent);
|
||||
//s.setLine(2, owner != null ? Bukkit.getOfflinePlayer(owner).getName() : "SERVER");
|
||||
String price_line = "";
|
||||
if(RealEstate.instance.config.cfgUseCurrencySymbol)
|
||||
{
|
||||
if(RealEstate.instance.config.cfgUseDecimalCurrency == false)
|
||||
{
|
||||
s.setLine(2, RealEstate.instance.config.cfgCurrencySymbol + " " + (int)Math.round(price));
|
||||
price_line = RealEstate.instance.config.cfgCurrencySymbol + " " + (int)Math.round(price);
|
||||
}
|
||||
else
|
||||
{
|
||||
s.setLine(2, RealEstate.instance.config.cfgCurrencySymbol + " " + price);
|
||||
price_line = RealEstate.instance.config.cfgCurrencySymbol + " " + price;
|
||||
}
|
||||
|
||||
}
|
||||
@ -90,14 +100,21 @@ public class ClaimRent extends BoughtTransaction
|
||||
{
|
||||
if(RealEstate.instance.config.cfgUseDecimalCurrency == false)
|
||||
{
|
||||
s.setLine(2, (int)Math.round(price) + " " + RealEstate.econ.currencyNamePlural());
|
||||
price_line = (int)Math.round(price) + " " + RealEstate.econ.currencyNamePlural();
|
||||
}
|
||||
else
|
||||
{
|
||||
s.setLine(2, price + " " + RealEstate.econ.currencyNamePlural());
|
||||
price_line = price + " " + RealEstate.econ.currencyNamePlural();
|
||||
}
|
||||
}
|
||||
s.setLine(3, (maxPeriod > 1 ? maxPeriod + "x " : "") + Utils.getTime(duration, null, false));
|
||||
String period = (maxPeriod > 1 ? maxPeriod + "x " : "") + Utils.getTime(duration, null, false);
|
||||
if(this.buildTrust) {
|
||||
s.setLine(2, price_line);
|
||||
s.setLine(3, period);
|
||||
} else {
|
||||
s.setLine(2, RealEstate.instance.config.cfgContainerRentLine);
|
||||
s.setLine(3, price_line + " - " + period);
|
||||
}
|
||||
s.update(true);
|
||||
}
|
||||
else
|
||||
@ -311,7 +328,7 @@ public class ClaimRent extends BoughtTransaction
|
||||
buyer = player.getUniqueId();
|
||||
startDate = LocalDateTime.now();
|
||||
autoRenew = false;
|
||||
claim.setPermission(buyer.toString(), ClaimPermission.Build);
|
||||
claim.setPermission(buyer.toString(), buildTrust ? ClaimPermission.Build : ClaimPermission.Inventory);
|
||||
claim.allowGrantPermission(player);
|
||||
claim.managers.add(player.getUniqueId().toString());
|
||||
claim.setSubclaimRestrictions(true);
|
||||
|
||||
@ -218,15 +218,15 @@ public class TransactionsStore
|
||||
}
|
||||
}
|
||||
|
||||
public void rent(Claim claim, Player player, double price, Location sign, int duration, int rentPeriods)
|
||||
public void rent(Claim claim, Player player, double price, Location sign, int duration, int rentPeriods, boolean buildTrust)
|
||||
{
|
||||
ClaimRent cr = new ClaimRent(claim, claim.isAdminClaim() ? null : player, price, sign, duration, rentPeriods);
|
||||
ClaimRent cr = new ClaimRent(claim, claim.isAdminClaim() ? null : player, price, sign, duration, rentPeriods, buildTrust);
|
||||
claimRent.put(claim.getID().toString(), cr);
|
||||
cr.update();
|
||||
saveData();
|
||||
|
||||
RealEstate.instance.addLogEntry("[" + this.dateFormat.format(this.date) + "] " + (player == null ? "The Server" : player.getName()) +
|
||||
" has made " + (claim.isAdminClaim() ? "an admin" : "a") + " " + (claim.parent == null ? "claim" : "subclaim") + " for rent at " +
|
||||
" has made " + (claim.isAdminClaim() ? "an admin" : "a") + " " + (claim.parent == null ? "claim" : "subclaim") + " for" + (buildTrust ? "" : " container") + " rent at " +
|
||||
"[" + claim.getLesserBoundaryCorner().getWorld() + ", " +
|
||||
"X: " + claim.getLesserBoundaryCorner().getBlockX() + ", " +
|
||||
"Y: " + claim.getLesserBoundaryCorner().getBlockY() + ", " +
|
||||
@ -236,7 +236,7 @@ public class TransactionsStore
|
||||
if(player != null)
|
||||
{
|
||||
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.AQUA + "You have successfully put " +
|
||||
(claim.isAdminClaim() ? "an admin" : "a") + " " + (claim.parent == null ? "claim" : "subclaim") + " for rent for " +
|
||||
(claim.isAdminClaim() ? "an admin" : "a") + " " + (claim.parent == null ? "claim" : "subclaim") + " for" + (buildTrust ? "" : " container") + " rent for " +
|
||||
ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural());
|
||||
}
|
||||
if(RealEstate.instance.config.cfgBroadcastSell)
|
||||
@ -247,7 +247,7 @@ public class TransactionsStore
|
||||
{
|
||||
p.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.DARK_GREEN + (player == null ? "The Server" : player.getDisplayName()) +
|
||||
ChatColor.AQUA + " has put " +
|
||||
(claim.isAdminClaim() ? "an admin" : "a") + " " + (claim.parent == null ? "claim" : "subclaim") + " for rent for " +
|
||||
(claim.isAdminClaim() ? "an admin" : "a") + " " + (claim.parent == null ? "claim" : "subclaim") + " for" + (buildTrust ? "" : " container") + " rent for " +
|
||||
ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural());
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user