PlayerData.java 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package de.Linus122.TimeIsMoney.data;
  2. import org.apache.commons.lang.time.DateUtils;
  3. import java.util.Date;
  4. public class PlayerData {
  5. private double receivedToday = 0d;
  6. private Date lastPayoutDate;
  7. private int secondsSinceLastPayout = 0;
  8. public PlayerData(double receivedToday, Date lastPayoutDate, int secondsSinceLastPayout) {
  9. this.receivedToday = receivedToday;
  10. this.lastPayoutDate = lastPayoutDate;
  11. this.secondsSinceLastPayout = secondsSinceLastPayout;
  12. }
  13. public double getReceivedToday() {
  14. if(lastPayoutDate == null || !DateUtils.isSameDay(lastPayoutDate, new Date())) {
  15. // new day, reset total money received
  16. receivedToday = 0d;
  17. }
  18. return receivedToday;
  19. }
  20. /**
  21. * Sets the total amount of money received for today and updates the {@link #lastPayoutDate} variable to now.
  22. * @param receivedToday Amount of money received today
  23. * @since 1.9.7
  24. */
  25. public void setReceivedToday(double receivedToday) {
  26. this.receivedToday = receivedToday;
  27. lastPayoutDate = new Date();
  28. }
  29. public int getSecondsSinceLastPayout() {
  30. return secondsSinceLastPayout;
  31. }
  32. public void setSecondsSinceLastPayout(int secondsSinceLastPayout) {
  33. this.secondsSinceLastPayout = secondsSinceLastPayout;
  34. }
  35. public Date getLastPayoutDate() {
  36. return lastPayoutDate;
  37. }
  38. public void setLastPayoutDate(Date lastPayoutDate) {
  39. this.lastPayoutDate = lastPayoutDate;
  40. }
  41. }