Skip to content
This repository has been archived by the owner on Sep 23, 2019. It is now read-only.

Commit

Permalink
Capsuled info check into a method
Browse files Browse the repository at this point in the history
  • Loading branch information
Flaflo committed Sep 20, 2016
1 parent 01c0a14 commit 605da12
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/net/hybridhacker/scyus/user/ScyusUser.java
Expand Up @@ -72,6 +72,19 @@ public ScyusUser(final String id, final long premiumEnd) {
this.id = id;
this.premiumEnd = premiumEnd;
}

/**
* Check if informations need to be refreshed
* and if true it re-downloads the user informations
*/
private void checkRefreshInfos() {
if (System.currentTimeMillis() - lastInfoCheck >= 10000)
try {
this.downloadUserInfo();
} catch (SQLException e) {
e.printStackTrace();
}
}

/**
* Downloads User info from mysql
Expand Down Expand Up @@ -169,12 +182,7 @@ public String getSkypeUserId() {
* @return the premium
*/
public boolean isPremium() {
if (System.currentTimeMillis() - lastInfoCheck >= 10000)
try {
this.downloadUserInfo();
} catch (SQLException e) {
e.printStackTrace();
}
checkRefreshInfos();

return System.currentTimeMillis() < premiumEnd;
}
Expand All @@ -183,12 +191,7 @@ public boolean isPremium() {
* @return the premiumEnd
*/
public long getPremiumEnd() {
if (System.currentTimeMillis() - lastInfoCheck >= 10000)
try {
this.downloadUserInfo();
} catch (SQLException e) {
e.printStackTrace();
}
checkRefreshInfos();

return premiumEnd;
}
Expand Down

0 comments on commit 605da12

Please sign in to comment.