45 lines
1.1 KiB
Java
45 lines
1.1 KiB
Java
package net.knarcraft.timeismoney.manager;
|
|
|
|
import org.bukkit.entity.Player;
|
|
import org.jetbrains.annotations.NotNull;
|
|
import org.jetbrains.annotations.Nullable;
|
|
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
|
|
/**
|
|
* A tracker keeping track of players' payment times
|
|
*/
|
|
public final class PlayerTracker {
|
|
|
|
private static final Map<Player, Long> playerLastPaid = new HashMap<>();
|
|
|
|
private PlayerTracker() {
|
|
|
|
}
|
|
|
|
/**
|
|
* Track's a player's last payment time
|
|
*
|
|
* <p>Call this when the player joins to set the 0 time.</p>
|
|
*
|
|
* @param player <p>The player to track</p>
|
|
*/
|
|
public static void trackPlayer(@NotNull Player player) {
|
|
playerLastPaid.put(player, System.currentTimeMillis());
|
|
}
|
|
|
|
/**
|
|
* Gets the last time the given player was paid
|
|
*
|
|
* <p>The return time is in the format of 'System.currentTimeMillis()'</p>
|
|
*
|
|
* @param player <p>The player to check player time for</p>
|
|
* @return <p>The last time the player was paid</p>
|
|
*/
|
|
public static @Nullable Long getPaymentTime(@NotNull Player player) {
|
|
return playerLastPaid.get(player);
|
|
}
|
|
|
|
}
|