mirror of
https://github.com/NLthijs48/AreaShop.git
synced 2024-11-16 15:25:11 +01:00
Events: Add refunded money to UnrentedRegionEvent and SoldRegionEvent
Closes #147
This commit is contained in:
parent
0d4b034181
commit
868f4d6b58
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user