added admin /re cancel command
This commit is contained in:
parent
2fd872d707
commit
b7eb449146
@ -304,6 +304,7 @@ public class RECommand extends BaseCommand
|
|||||||
}
|
}
|
||||||
bt.exitOffer = null;
|
bt.exitOffer = null;
|
||||||
claim.dropPermission(bt.buyer.toString());
|
claim.dropPermission(bt.buyer.toString());
|
||||||
|
claim.managers.remove(bt.buyer.toString());
|
||||||
GriefPrevention.instance.dataStore.saveClaim(claim);
|
GriefPrevention.instance.dataStore.saveClaim(claim);
|
||||||
bt.buyer = null;
|
bt.buyer = null;
|
||||||
bt.update();// eventual cancel is contained in here
|
bt.update();// eventual cancel is contained in here
|
||||||
@ -399,6 +400,17 @@ public class RECommand extends BaseCommand
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subcommand("cancel")
|
||||||
|
@Conditions("claimHasTransaction")
|
||||||
|
@CommandPermission("realestate.admin")
|
||||||
|
public static void cancelTransaction(Player player)
|
||||||
|
{
|
||||||
|
Location loc = player.getLocation();
|
||||||
|
Claim claim = GriefPrevention.instance.dataStore.getClaimAt(loc, false, null);
|
||||||
|
Transaction t = RealEstate.transactionsStore.getTransaction(claim);
|
||||||
|
t.tryCancelTransaction(player, true);
|
||||||
|
}
|
||||||
|
|
||||||
@HelpCommand
|
@HelpCommand
|
||||||
public static void onHelp(CommandSender sender, CommandHelp help)
|
public static void onHelp(CommandSender sender, CommandHelp help)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -108,6 +108,22 @@ public class RealEstate extends JavaPlugin
|
|||||||
}
|
}
|
||||||
throw new ConditionFailedException("You must stand inside of a claim to use this command!");
|
throw new ConditionFailedException("You must stand inside of a claim to use this command!");
|
||||||
});
|
});
|
||||||
|
manager.getCommandConditions().addCondition("claimHasTransaction", (context) -> {
|
||||||
|
if(!context.getIssuer().isPlayer())
|
||||||
|
{
|
||||||
|
throw new ConditionFailedException("Only Players can perform this command!");
|
||||||
|
}
|
||||||
|
Claim c = GriefPrevention.instance.dataStore.getClaimAt(context.getIssuer().getPlayer().getLocation(), false, null);
|
||||||
|
if(c == null)
|
||||||
|
{
|
||||||
|
throw new ConditionFailedException("You must stand inside of a claim to use this command!");
|
||||||
|
}
|
||||||
|
Transaction tr = transactionsStore.getTransaction(c);
|
||||||
|
if(tr == null)
|
||||||
|
{
|
||||||
|
throw new ConditionFailedException("This claim has no ongoing transactions!");
|
||||||
|
}
|
||||||
|
});
|
||||||
manager.getCommandConditions().addCondition("inPendingTransactionClaim", (context) -> {
|
manager.getCommandConditions().addCondition("inPendingTransactionClaim", (context) -> {
|
||||||
if(!context.getIssuer().isPlayer())
|
if(!context.getIssuer().isPlayer())
|
||||||
{
|
{
|
||||||
|
|||||||
@ -206,6 +206,23 @@ public class ClaimLease extends BoughtTransaction
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
this.exitLease();
|
||||||
|
}
|
||||||
|
// no need to re update, since there's no sign
|
||||||
|
RealEstate.transactionsStore.saveData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void exitLease()
|
||||||
|
{
|
||||||
|
if(buyer != null)
|
||||||
|
{
|
||||||
|
OfflinePlayer buyerPlayer = Bukkit.getOfflinePlayer(buyer);
|
||||||
|
OfflinePlayer seller = owner == null ? null : Bukkit.getOfflinePlayer(owner);
|
||||||
|
|
||||||
|
Claim claim = GriefPrevention.instance.dataStore.getClaimAt(sign, false, null);
|
||||||
|
|
||||||
|
String claimType = claim.parent == null ? "claim" : "subclaim";
|
||||||
|
|
||||||
if(buyerPlayer.isOnline() && RealEstate.instance.config.cfgMessageBuyer)
|
if(buyerPlayer.isOnline() && RealEstate.instance.config.cfgMessageBuyer)
|
||||||
{
|
{
|
||||||
((Player)buyerPlayer).sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED +
|
((Player)buyerPlayer).sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED +
|
||||||
@ -238,23 +255,36 @@ public class ClaimLease extends BoughtTransaction
|
|||||||
sign.getBlockY() + ", Z: " + sign.getBlockZ() + "]" +
|
sign.getBlockY() + ", Z: " + sign.getBlockZ() + "]" +
|
||||||
ChatColor.AQUA + ", the transaction has been cancelled");
|
ChatColor.AQUA + ", the transaction has been cancelled");
|
||||||
}
|
}
|
||||||
RealEstate.transactionsStore.cancelTransaction(this);
|
|
||||||
|
claim.managers.remove(buyer.toString());
|
||||||
|
claim.dropPermission(buyer.toString());
|
||||||
}
|
}
|
||||||
// no need to re update, since there's no sign
|
else
|
||||||
RealEstate.transactionsStore.saveData();
|
{
|
||||||
|
getHolder().breakNaturally();// the sign should still be there since the lease has netver begun
|
||||||
|
}
|
||||||
|
RealEstate.transactionsStore.cancelTransaction(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean tryCancelTransaction(Player p)
|
public boolean tryCancelTransaction(Player p, boolean force)
|
||||||
{
|
{
|
||||||
if(buyer != null)
|
if(buyer != null)
|
||||||
|
{
|
||||||
|
if(p.hasPermission("realestate.admin") && force == true)
|
||||||
|
{
|
||||||
|
this.exitLease();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
Claim claim = GriefPrevention.instance.dataStore.getClaimAt(sign, false, null);
|
Claim claim = GriefPrevention.instance.dataStore.getClaimAt(sign, false, null);
|
||||||
if(p != null)
|
if(p != null)
|
||||||
p.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "This " + (claim.parent == null ? "claim" : "subclaim") +
|
p.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "This " + (claim.parent == null ? "claim" : "subclaim") +
|
||||||
" is currently rented, you can't cancel the transaction!");
|
" is currently leased, you can't cancel the transaction!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RealEstate.transactionsStore.cancelTransaction(this);
|
RealEstate.transactionsStore.cancelTransaction(this);
|
||||||
|
|||||||
@ -222,9 +222,17 @@ public class ClaimRent extends BoughtTransaction
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean tryCancelTransaction(Player p)
|
public boolean tryCancelTransaction(Player p, boolean force)
|
||||||
{
|
{
|
||||||
if(buyer != null)
|
if(buyer != null)
|
||||||
|
{
|
||||||
|
if(p.hasPermission("realestate.admin") && force == true)
|
||||||
|
{
|
||||||
|
this.unRent(true);
|
||||||
|
RealEstate.transactionsStore.cancelTransaction(this);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
Claim claim = GriefPrevention.instance.dataStore.getClaimAt(sign, false, null);
|
Claim claim = GriefPrevention.instance.dataStore.getClaimAt(sign, false, null);
|
||||||
if(p != null)
|
if(p != null)
|
||||||
@ -232,6 +240,7 @@ public class ClaimRent extends BoughtTransaction
|
|||||||
" is currently rented, you can't cancel the transaction!");
|
" is currently rented, you can't cancel the transaction!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RealEstate.transactionsStore.cancelTransaction(this);
|
RealEstate.transactionsStore.cancelTransaction(this);
|
||||||
|
|||||||
@ -58,8 +58,9 @@ public class ClaimSell extends ClaimTransaction
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean tryCancelTransaction(Player p)
|
public boolean tryCancelTransaction(Player p, boolean force)
|
||||||
{
|
{
|
||||||
|
// nothing special here, this transaction can only be waiting for a buyer
|
||||||
RealEstate.transactionsStore.cancelTransaction(this);
|
RealEstate.transactionsStore.cancelTransaction(this);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -68,4 +68,10 @@ public abstract class ClaimTransaction implements ConfigurationSerializable, Tra
|
|||||||
{
|
{
|
||||||
return owner;
|
return owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean tryCancelTransaction(Player p)
|
||||||
|
{
|
||||||
|
return this.tryCancelTransaction(p, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,5 +15,6 @@ public interface Transaction
|
|||||||
public void preview(Player player);
|
public void preview(Player player);
|
||||||
public boolean update();
|
public boolean update();
|
||||||
public boolean tryCancelTransaction(Player p);
|
public boolean tryCancelTransaction(Player p);
|
||||||
|
public boolean tryCancelTransaction(Player p, boolean force);
|
||||||
public void msgInfo(CommandSender cs);
|
public void msgInfo(CommandSender cs);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user