feat: give money every half hour according to player's worth
This commit is contained in:
parent
d13e8160d6
commit
ad5e22517a
1 changed files with 17 additions and 2 deletions
|
|
@ -25,6 +25,7 @@ public final class Smp4 extends JavaPlugin {
|
|||
Logger logger;
|
||||
States states;
|
||||
FileConfiguration config;
|
||||
PlayerPointsAPI pointsAPI;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
|
@ -72,6 +73,8 @@ public final class Smp4 extends JavaPlugin {
|
|||
|
||||
Utilities.initScore();
|
||||
|
||||
pointsAPI = PlayerPoints.getInstance().getAPI();
|
||||
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
|
@ -95,8 +98,6 @@ public final class Smp4 extends JavaPlugin {
|
|||
int currentWorth = states.worths.getPlayerWorth(eggOwner);
|
||||
states.worths.setPlayerWorth(eggOwner, currentWorth + worthGain);
|
||||
|
||||
|
||||
PlayerPointsAPI pointsAPI = PlayerPoints.getInstance().getAPI();
|
||||
if (pointsAPI != null) {
|
||||
int moneyGain = config.getInt("moneyGainWhenHoldingEgg");
|
||||
pointsAPI.give(eggOwner.getUniqueId(), moneyGain);
|
||||
|
|
@ -128,6 +129,20 @@ public final class Smp4 extends JavaPlugin {
|
|||
|
||||
}
|
||||
}.runTaskTimer(this, 0L, config.getInt("worthUpdateInterval") * 20L);
|
||||
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
int worth = states.worths.getPlayerWorth(p);
|
||||
int moneyGain = worth/50;
|
||||
pointsAPI.give(p.getUniqueId(), moneyGain);
|
||||
|
||||
p.sendRichMessage(String.format("[SMP4] <gold>You got %s points from your worth.</gold>", moneyGain));
|
||||
}
|
||||
|
||||
}
|
||||
}.runTaskTimer(this, 0L, 1800*20L); // Every half hour
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue