Don't extend rent when using '/as setowner' to set a different owner

Also remove new owner from the friends list.
Fixes #219
This commit is contained in:
Thijs Wiefferink 2016-09-03 19:19:40 +02:00
parent feafa012dd
commit 570f7b4055

View File

@ -98,28 +98,21 @@ public class SetownerCommand extends CommandAreaShop {
calendar.setTimeInMillis(rent.getRentedUntil() + rent.getDuration()); calendar.setTimeInMillis(rent.getRentedUntil() + rent.getDuration());
rent.setRentedUntil(calendar.getTimeInMillis()); rent.setRentedUntil(calendar.getTimeInMillis());
rent.setRenter(uuid); rent.setRenter(uuid);
rent.update();
plugin.message(sender, "setowner-succesRentExtend", region); plugin.message(sender, "setowner-succesRentExtend", region);
} else { } else {
// change // change
Calendar calendar = Calendar.getInstance();
long current = calendar.getTimeInMillis();
if(rent.isRented()) {
current = rent.getRentedUntil();
}
calendar.setTimeInMillis(current + rent.getDuration());
rent.setRentedUntil(calendar.getTimeInMillis());
rent.setRenter(uuid); rent.setRenter(uuid);
rent.update();
plugin.message(sender, "setowner-succesRent", region); plugin.message(sender, "setowner-succesRent", region);
} }
} }
if(region.isBuyRegion()) { if(region.isBuyRegion()) {
BuyRegion buy = (BuyRegion)region; BuyRegion buy = (BuyRegion)region;
buy.setBuyer(uuid); buy.setBuyer(uuid);
buy.update();
plugin.message(sender, "setowner-succesBuy", region); plugin.message(sender, "setowner-succesBuy", region);
} }
region.getFriendsFeature().deleteFriend(region.getOwner(), null);
region.update();
region.saveRequired();
} }
@Override @Override