add /re list command and other syntax
This commit is contained in:
parent
c18769d586
commit
05cf6754ea
@ -86,6 +86,9 @@ public class Config extends AnnotationConfig
|
|||||||
@ConfigField(name="RealEstate.Default.LeasePaymentsCount", comment = "How many lease periods are required before the buyer gets the claim's ownership by default")
|
@ConfigField(name="RealEstate.Default.LeasePaymentsCount", comment = "How many lease periods are required before the buyer gets the claim's ownership by default")
|
||||||
public int cfgLeasePayments = 5;
|
public int cfgLeasePayments = 5;
|
||||||
|
|
||||||
|
@ConfigField(name="RealEstate.Settings.PageSize", comment = "How many Real Estate offer should be shown by page using the '/re list' command")
|
||||||
|
public int cfgPageSize = 20;
|
||||||
|
|
||||||
public Config()
|
public Config()
|
||||||
{
|
{
|
||||||
this.pdf = RealEstate.instance.getDescription();
|
this.pdf = RealEstate.instance.getDescription();
|
||||||
|
|||||||
@ -1,5 +1,8 @@
|
|||||||
package me.EtienneDx.RealEstate;
|
package me.EtienneDx.RealEstate;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -22,6 +25,7 @@ import co.aikar.commands.annotation.Description;
|
|||||||
import co.aikar.commands.annotation.HelpCommand;
|
import co.aikar.commands.annotation.HelpCommand;
|
||||||
import co.aikar.commands.annotation.Optional;
|
import co.aikar.commands.annotation.Optional;
|
||||||
import co.aikar.commands.annotation.Subcommand;
|
import co.aikar.commands.annotation.Subcommand;
|
||||||
|
import co.aikar.commands.annotation.Syntax;
|
||||||
import me.EtienneDx.RealEstate.Transactions.BoughtTransaction;
|
import me.EtienneDx.RealEstate.Transactions.BoughtTransaction;
|
||||||
import me.EtienneDx.RealEstate.Transactions.ClaimRent;
|
import me.EtienneDx.RealEstate.Transactions.ClaimRent;
|
||||||
import me.EtienneDx.RealEstate.Transactions.ExitOffer;
|
import me.EtienneDx.RealEstate.Transactions.ExitOffer;
|
||||||
@ -50,10 +54,82 @@ public class RECommand extends BaseCommand
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subcommand("list")
|
||||||
|
@Description("Displays the list of all real estate offers currently existing")
|
||||||
|
@CommandCompletion("all|sell|rent|lease")
|
||||||
|
@Syntax("[all|sell|rent|lease] <page>")
|
||||||
|
public static void list(Player player, @Optional String type, @Default("1") int page)
|
||||||
|
{
|
||||||
|
if(page <= 0)
|
||||||
|
{
|
||||||
|
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "Page must be a positive option!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int count = 0;
|
||||||
|
int start = (page - 1) * RealEstate.instance.config.cfgPageSize;
|
||||||
|
String typeMsg;
|
||||||
|
if(type == null || type.equalsIgnoreCase("all"))
|
||||||
|
{
|
||||||
|
count = RealEstate.transactionsStore.claimSell.values().size() + RealEstate.transactionsStore.claimRent.values().size() +
|
||||||
|
RealEstate.transactionsStore.claimLease.values().size();
|
||||||
|
typeMsg = "Real Estate offers";
|
||||||
|
}
|
||||||
|
else if(type.equalsIgnoreCase("sell"))
|
||||||
|
{
|
||||||
|
count = RealEstate.transactionsStore.claimSell.values().size();
|
||||||
|
typeMsg = "Sell offers";
|
||||||
|
}
|
||||||
|
else if(type.equalsIgnoreCase("rent"))
|
||||||
|
{
|
||||||
|
count = RealEstate.transactionsStore.claimRent.values().size();
|
||||||
|
typeMsg = "Rent offers";
|
||||||
|
}
|
||||||
|
else if(type.equalsIgnoreCase("lease"))
|
||||||
|
{
|
||||||
|
count = RealEstate.transactionsStore.claimLease.values().size();
|
||||||
|
typeMsg = "Lease offers";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "Invalid option provided!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
player.sendMessage(ChatColor.DARK_BLUE + "----= " + ChatColor.WHITE + "[ " + ChatColor.GOLD + typeMsg + ChatColor.DARK_GREEN + " " +
|
||||||
|
page + ChatColor.GOLD + " / " + ChatColor.DARK_GREEN + (int)Math.ceil(count / (double)RealEstate.instance.config.cfgPageSize) +
|
||||||
|
ChatColor.WHITE + " ]" + ChatColor.DARK_BLUE + " =----");
|
||||||
|
ArrayList<Transaction> transactions = new ArrayList<Transaction>(count);
|
||||||
|
if(type == null || type.equalsIgnoreCase("all"))
|
||||||
|
{
|
||||||
|
transactions.addAll(RealEstate.transactionsStore.claimSell.values());
|
||||||
|
transactions.addAll(RealEstate.transactionsStore.claimRent.values());
|
||||||
|
transactions.addAll(RealEstate.transactionsStore.claimLease.values());
|
||||||
|
}
|
||||||
|
else if(type.equalsIgnoreCase("sell"))
|
||||||
|
{
|
||||||
|
transactions.addAll(RealEstate.transactionsStore.claimSell.values());
|
||||||
|
}
|
||||||
|
else if(type.equalsIgnoreCase("rent"))
|
||||||
|
{
|
||||||
|
transactions.addAll(RealEstate.transactionsStore.claimRent.values());
|
||||||
|
}
|
||||||
|
else if(type.equalsIgnoreCase("lease"))
|
||||||
|
{
|
||||||
|
transactions.addAll(RealEstate.transactionsStore.claimLease.values());
|
||||||
|
}
|
||||||
|
|
||||||
|
int max = Math.min(start + RealEstate.instance.config.cfgPageSize, count);
|
||||||
|
for(int i = start; i < max; i++)
|
||||||
|
{
|
||||||
|
RealEstate.instance.log.info("transaction " + i);
|
||||||
|
transactions.get(i).msgInfo(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Subcommand("renewrent")
|
@Subcommand("renewrent")
|
||||||
@Description("Allows the player renting a claim or subclaim to enable or disable the automatic renew of his rent")
|
@Description("Allows the player renting a claim or subclaim to enable or disable the automatic renew of his rent")
|
||||||
@Conditions("partOfRent")
|
@Conditions("partOfRent")
|
||||||
@CommandCompletion("enable|disable")
|
@CommandCompletion("enable|disable")
|
||||||
|
@Syntax("[enable|disable]")
|
||||||
public static void renewRent(Player player, @Optional String newStatus)
|
public static void renewRent(Player player, @Optional String newStatus)
|
||||||
{
|
{
|
||||||
Location loc = player.getLocation();
|
Location loc = player.getLocation();
|
||||||
@ -173,6 +249,7 @@ public class RECommand extends BaseCommand
|
|||||||
|
|
||||||
@Subcommand("create")
|
@Subcommand("create")
|
||||||
@Description("Creates an offer to break an ongoing transaction")
|
@Description("Creates an offer to break an ongoing transaction")
|
||||||
|
@Syntax("<price>")
|
||||||
public void create(Player player, @Conditions("positiveDouble") Double price)
|
public void create(Player player, @Conditions("positiveDouble") Double price)
|
||||||
{
|
{
|
||||||
BoughtTransaction bt = (BoughtTransaction)RealEstate.transactionsStore.getTransaction(player);
|
BoughtTransaction bt = (BoughtTransaction)RealEstate.transactionsStore.getTransaction(player);
|
||||||
|
|||||||
@ -410,4 +410,18 @@ public class ClaimLease extends BoughtTransaction
|
|||||||
player.sendMessage(msg);
|
player.sendMessage(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void msgInfo(Player player)
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.DARK_GREEN + "" + GriefPrevention.instance.dataStore.getClaim(claimId).getArea() +
|
||||||
|
ChatColor.AQUA + " blocks to " + ChatColor.DARK_GREEN + "Lease " + ChatColor.AQUA + "at " + ChatColor.DARK_GREEN +
|
||||||
|
"[" + GriefPrevention.instance.dataStore.getClaim(claimId).getLesserBoundaryCorner().getWorld().getName() + ", " +
|
||||||
|
"X: " + GriefPrevention.instance.dataStore.getClaim(claimId).getLesserBoundaryCorner().getBlockX() + ", " +
|
||||||
|
"Y: " + GriefPrevention.instance.dataStore.getClaim(claimId).getLesserBoundaryCorner().getBlockY() + ", " +
|
||||||
|
"Z: " + GriefPrevention.instance.dataStore.getClaim(claimId).getLesserBoundaryCorner().getBlockZ() + "] " + ChatColor.AQUA + "for " +
|
||||||
|
ChatColor.GREEN + paymentsLeft + ChatColor.AQUA + " periods of " + ChatColor.GREEN + Utils.getTime(frequency, Duration.ZERO, false) +
|
||||||
|
ChatColor.AQUA + ", each period costs " + ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -389,4 +389,17 @@ public class ClaimRent extends BoughtTransaction
|
|||||||
player.sendMessage(msg);
|
player.sendMessage(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void msgInfo(Player player)
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.DARK_GREEN + "" + GriefPrevention.instance.dataStore.getClaim(claimId).getArea() +
|
||||||
|
ChatColor.AQUA + " blocks to " + ChatColor.DARK_GREEN + "Rent " + ChatColor.AQUA + "at " + ChatColor.DARK_GREEN +
|
||||||
|
"[" + GriefPrevention.instance.dataStore.getClaim(claimId).getLesserBoundaryCorner().getWorld().getName() + ", " +
|
||||||
|
"X: " + GriefPrevention.instance.dataStore.getClaim(claimId).getLesserBoundaryCorner().getBlockX() + ", " +
|
||||||
|
"Y: " + GriefPrevention.instance.dataStore.getClaim(claimId).getLesserBoundaryCorner().getBlockY() + ", " +
|
||||||
|
"Z: " + GriefPrevention.instance.dataStore.getClaim(claimId).getLesserBoundaryCorner().getBlockZ() + "] " + ChatColor.AQUA + "for " +
|
||||||
|
ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural() + ChatColor.AQUA + " per period of " + ChatColor.GREEN +
|
||||||
|
Utils.getTime(duration, Duration.ZERO, false));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -190,4 +190,16 @@ public class ClaimSell extends ClaimTransaction
|
|||||||
{
|
{
|
||||||
this.owner = newOwner;
|
this.owner = newOwner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void msgInfo(Player player)
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.DARK_GREEN + "" + GriefPrevention.instance.dataStore.getClaim(claimId).getArea() +
|
||||||
|
ChatColor.AQUA + " blocks to " + ChatColor.DARK_GREEN + "Sell " + ChatColor.AQUA + "at " + ChatColor.DARK_GREEN +
|
||||||
|
"[" + GriefPrevention.instance.dataStore.getClaim(claimId).getLesserBoundaryCorner().getWorld().getName() + ", " +
|
||||||
|
"X: " + GriefPrevention.instance.dataStore.getClaim(claimId).getLesserBoundaryCorner().getBlockX() + ", " +
|
||||||
|
"Y: " + GriefPrevention.instance.dataStore.getClaim(claimId).getLesserBoundaryCorner().getBlockY() + ", " +
|
||||||
|
"Z: " + GriefPrevention.instance.dataStore.getClaim(claimId).getLesserBoundaryCorner().getBlockZ() + "] " + ChatColor.AQUA + "for " +
|
||||||
|
ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,4 +14,5 @@ public interface Transaction
|
|||||||
public void preview(Player player);
|
public void preview(Player player);
|
||||||
public void update();
|
public void update();
|
||||||
public boolean tryCancelTransaction(Player p);
|
public boolean tryCancelTransaction(Player p);
|
||||||
|
public void msgInfo(Player player);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user