mirror of
https://gitlab.com/SamB440/rpgregions-2.git
synced 2026-01-04 15:31:38 +00:00
Implement time between reward
This commit is contained in:
@@ -15,6 +15,8 @@ public abstract class DiscoveryReward implements IGuiEditable {
|
||||
@GuiEditable("Time Between Reward (s)")
|
||||
private int timeBetweenReward;
|
||||
|
||||
private long lastReward;
|
||||
|
||||
public DiscoveryReward(IRPGRegionsAPI api) {
|
||||
this.api = api;
|
||||
}
|
||||
@@ -29,6 +31,10 @@ public abstract class DiscoveryReward implements IGuiEditable {
|
||||
*/
|
||||
public abstract void award(Player player);
|
||||
|
||||
protected void updateAwardTime() {
|
||||
this.lastReward = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public boolean isAlwaysAward() {
|
||||
return alwaysAward;
|
||||
}
|
||||
@@ -45,6 +51,10 @@ public abstract class DiscoveryReward implements IGuiEditable {
|
||||
this.timeBetweenReward = timeBetweenReward;
|
||||
}
|
||||
|
||||
public boolean canAward() {
|
||||
return (System.currentTimeMillis() - lastReward) >= (timeBetweenReward * 1000L);
|
||||
}
|
||||
|
||||
public String getPluginRequirement() {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user