Events: Add refunded money to UnrentedRegionEvent and SoldRegionEvent

Closes #147
This commit is contained in:
Thijs Wiefferink 2016-05-28 17:00:52 +02:00
parent 0d4b034181
commit 868f4d6b58
4 changed files with 24 additions and 4 deletions

View File

@ -12,15 +12,17 @@ public class SoldRegionEvent extends NotifyAreaShopEvent {
private BuyRegion region;
private UUID oldBuyer;
private double refundedMoney;
/**
* Constructor
* @param region The region that has been sold
* @param oldBuyer The player for which the region has been sold
*/
public SoldRegionEvent(BuyRegion region, UUID oldBuyer) {
public SoldRegionEvent(BuyRegion region, UUID oldBuyer, double refundedMoney) {
this.region = region;
this.oldBuyer = oldBuyer;
this.refundedMoney = refundedMoney;
}
/**
@ -38,4 +40,12 @@ public class SoldRegionEvent extends NotifyAreaShopEvent {
public UUID getOldBuyer() {
return oldBuyer;
}
/**
* Get the amount that is paid back to the player
* @return The amount of money paid back to the player
*/
public double getRefundedMoney() {
return refundedMoney;
}
}

View File

@ -12,15 +12,17 @@ public class UnrentedRegionEvent extends NotifyAreaShopEvent {
private RentRegion region;
private UUID oldRenter;
private double refundedMoney;
/**
* Constructor
* @param region The region that has been unrented
* @param oldRenter The player that rented the region before it was unrented
*/
public UnrentedRegionEvent(RentRegion region, UUID oldRenter) {
public UnrentedRegionEvent(RentRegion region, UUID oldRenter, double refundedMoney) {
this.region = region;
this.oldRenter = oldRenter;
this.refundedMoney = refundedMoney;
}
/**
@ -38,4 +40,12 @@ public class UnrentedRegionEvent extends NotifyAreaShopEvent {
public UUID getOldRenter() {
return oldRenter;
}
/**
* Get the amount that is paid back to the player
* @return The amount of money paid back to the player
*/
public double getRefundedMoney() {
return refundedMoney;
}
}

View File

@ -521,7 +521,7 @@ public class BuyRegion extends GeneralRegion {
removeLastActiveTime();
// Notify about updates
this.notifyAndUpdate(new SoldRegionEvent(this, oldBuyer));
this.notifyAndUpdate(new SoldRegionEvent(this, oldBuyer, Math.max(moneyBack, 0)));
// Update everything
handleSchematicEvent(RegionEvent.SOLD);

View File

@ -680,7 +680,7 @@ public class RentRegion extends GeneralRegion {
removeLastActiveTime();
// Notify about updates
this.notifyAndUpdate(new UnrentedRegionEvent(this, oldRenter));
this.notifyAndUpdate(new UnrentedRegionEvent(this, oldRenter, Math.max(0, moneyBack)));
// Run commands
this.runEventCommands(RegionEvent.UNRENTED, false);