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;
|
Logger logger;
|
||||||
States states;
|
States states;
|
||||||
FileConfiguration config;
|
FileConfiguration config;
|
||||||
|
PlayerPointsAPI pointsAPI;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
|
@ -72,6 +73,8 @@ public final class Smp4 extends JavaPlugin {
|
||||||
|
|
||||||
Utilities.initScore();
|
Utilities.initScore();
|
||||||
|
|
||||||
|
pointsAPI = PlayerPoints.getInstance().getAPI();
|
||||||
|
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
@ -95,8 +98,6 @@ public final class Smp4 extends JavaPlugin {
|
||||||
int currentWorth = states.worths.getPlayerWorth(eggOwner);
|
int currentWorth = states.worths.getPlayerWorth(eggOwner);
|
||||||
states.worths.setPlayerWorth(eggOwner, currentWorth + worthGain);
|
states.worths.setPlayerWorth(eggOwner, currentWorth + worthGain);
|
||||||
|
|
||||||
|
|
||||||
PlayerPointsAPI pointsAPI = PlayerPoints.getInstance().getAPI();
|
|
||||||
if (pointsAPI != null) {
|
if (pointsAPI != null) {
|
||||||
int moneyGain = config.getInt("moneyGainWhenHoldingEgg");
|
int moneyGain = config.getInt("moneyGainWhenHoldingEgg");
|
||||||
pointsAPI.give(eggOwner.getUniqueId(), moneyGain);
|
pointsAPI.give(eggOwner.getUniqueId(), moneyGain);
|
||||||
|
|
@ -128,6 +129,20 @@ public final class Smp4 extends JavaPlugin {
|
||||||
|
|
||||||
}
|
}
|
||||||
}.runTaskTimer(this, 0L, config.getInt("worthUpdateInterval") * 20L);
|
}.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
|
@Override
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue