Rewrote the ProtectedPlayer class.

This commit is contained in:
2022-05-21 20:56:28 +01:00
parent 9bf6bd6dce
commit a20da22703

View File

@ -1,37 +1,71 @@
package dev.micle.loginprotection.data; package dev.micle.loginprotection.data;
import dev.micle.loginprotection.setup.Config; import java.util.Timer;
import java.util.UUID; import java.util.UUID;
public class ProtectedPlayer { public class ProtectedPlayer {
private final UUID player_uuid; // Initialize variables
private int grace_period; private final UUID playerUUID;
private boolean is_loading; private int gracePeriodTimeRemaining = 0;
private final Timer gracePeriodTimer = new Timer();
private State state;
public ProtectedPlayer(UUID player_uuid) { /**
this.player_uuid = player_uuid; * Constructor for a ProtectedPlayer.
this.grace_period = (Config.Server.POST_GRACE_DURATION.get() * 40); * @param playerUUID UUID of player to use.
this.is_loading = true; */
public ProtectedPlayer(UUID playerUUID, State state) {
this.playerUUID = playerUUID;
this.state = state;
} }
/**
* @return UUID of player,
*/
public UUID getPlayerUUID() { public UUID getPlayerUUID() {
return this.player_uuid; return playerUUID;
} }
public int getGracePeriod() { /**
return this.grace_period; * @return Remaining grade period time.
*/
public int getGracePeriodTimeRemaining() {
return gracePeriodTimeRemaining;
} }
public void setGracePeriod(int new_grace_period) { /**
this.grace_period = new_grace_period; * Set the remaining grace period time.
* @param gracePeriodLength Grade period length.
*/
public void setGracePeriod(int gracePeriodLength) {
this.gracePeriodTimeRemaining = gracePeriodLength;
} }
public boolean isLoading() { /**
return this.is_loading; * @return Grace period timer.
*/
public Timer getGracePeriodTimer() {
return gracePeriodTimer;
} }
public void setLoading(boolean new_loading) { /**
this.is_loading = new_loading; * @return Current state of the player.
*/
public State getState() {
return state;
}
/**
* Set the state of the player.
* @param state Player's new state.
*/
public void setState(State state) {
this.state = state;
}
public enum State {
JOINING,
AFK,
ACTIVE
} }
} }