Changed afk now bar to be afk kick soon
This commit is contained in:
parent
baad49a608
commit
e9ed408489
|
|
@ -55,6 +55,9 @@ public class AFKCheckTimer extends BukkitRunnable {
|
|||
if (!afkPlayer.isAFK() && System.currentTimeMillis() - standingTime > TimeUnit.MINUTES.toMillis(Config.TOGGLE_TIME)) {
|
||||
setPlayerAFK(afkPlayer, player);
|
||||
}
|
||||
if (afkPlayer.isAFK()) {
|
||||
afkPlayer.updateBossBarProgress((int) TimeUnit.MINUTES.toSeconds(afkPlayer.getAfkTimeMinutes()));
|
||||
}
|
||||
runMessageTimerCheck(afkPlayer, uuid, standingTime);
|
||||
}
|
||||
}
|
||||
|
|
@ -109,7 +112,7 @@ public class AFKCheckTimer extends BukkitRunnable {
|
|||
}
|
||||
|
||||
private void runMessageTimerCheck(AFKPlayer afkPlayer, UUID uuid, long standingTime) {
|
||||
if (System.currentTimeMillis() - standingTime > TimeUnit.MINUTES.toMillis(afkPlayer.getAfkTime())) {
|
||||
if (System.currentTimeMillis() - standingTime > TimeUnit.MINUTES.toMillis(afkPlayer.getAfkTimeMinutes())) {
|
||||
MessageTimer currentTimer = plugin.messageTimers.get(uuid);
|
||||
if (currentTimer == null) {
|
||||
currentTimer = new MessageTimer(plugin, afkPlayer, Config.MESSAGE_REPEATS);
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ public class AFKPlayer {
|
|||
private boolean isWarned;
|
||||
private final BossBar bossBar;
|
||||
private final String afkSoon;
|
||||
private final String afkNow;
|
||||
private final String afkKickSoon;
|
||||
|
||||
public AFKPlayer(Player player, AFKDetector plugin) {
|
||||
this.playerName = player.getName();
|
||||
|
|
@ -41,7 +41,7 @@ public class AFKPlayer {
|
|||
this.bossBar = Bukkit.createBossBar("Time until AFK", BarColor.PURPLE, BarStyle.SOLID);
|
||||
MiniMessage miniMessage = MiniMessage.miniMessage();
|
||||
this.afkSoon = LegacyComponentSerializer.builder().build().serialize(miniMessage.deserialize(Messages.AFK_SOON_BOSS_BAR.getMessage()));
|
||||
this.afkNow = LegacyComponentSerializer.builder().build().serialize(miniMessage.deserialize(Messages.AFK_NOW_BOSS_BAR.getMessage()));
|
||||
this.afkKickSoon = LegacyComponentSerializer.builder().build().serialize(miniMessage.deserialize(Messages.AFK_KICK_SOON_BOSS_BAR.getMessage()));
|
||||
}
|
||||
|
||||
public String getPlayerName() {
|
||||
|
|
@ -68,7 +68,7 @@ public class AFKPlayer {
|
|||
standingTime = Time;
|
||||
}
|
||||
|
||||
public int getAfkTime() {
|
||||
public int getAfkTimeMinutes() {
|
||||
if (isInSpawn())
|
||||
return this.afkTime + Config.EXTRA_MIN_IN_SPAWN;
|
||||
return this.afkTime;
|
||||
|
|
@ -96,7 +96,8 @@ public class AFKPlayer {
|
|||
}
|
||||
|
||||
public void setAFK(Player player) {
|
||||
bossBar.setTitle(afkNow);
|
||||
bossBar.setTitle(afkKickSoon);
|
||||
bossBar.setColor(BarColor.RED);
|
||||
player.setAfk(true);
|
||||
isAFK = true;
|
||||
}
|
||||
|
|
@ -113,17 +114,18 @@ public class AFKPlayer {
|
|||
}
|
||||
|
||||
public void warnPlayer(Player player) {
|
||||
updateBossBarProgress();
|
||||
updateBossBarProgress(Config.TOGGLE_TIME);
|
||||
if (isWarned)
|
||||
return;
|
||||
bossBar.setColor(BarColor.PURPLE);
|
||||
bossBar.setTitle(afkSoon);
|
||||
bossBar.addPlayer(player);
|
||||
isWarned = true;
|
||||
}
|
||||
|
||||
public void updateBossBarProgress() {
|
||||
public void updateBossBarProgress(int totalAllowedSeconds) {
|
||||
double afkSeconds = TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis() - getStandingTime());
|
||||
double toggleSeconds = TimeUnit.MINUTES.toSeconds(Config.TOGGLE_TIME);
|
||||
double toggleSeconds = TimeUnit.MINUTES.toSeconds(totalAllowedSeconds);
|
||||
bossBar.setProgress(Math.min(afkSeconds / toggleSeconds, 1));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ public enum Messages {
|
|||
AFK_KICK_STAFF_MESSAGE("afkkick-staff-messsge", "<gold><player> got afk kicked after being afk for <afk_time> minutes."),
|
||||
SUSPICIOUS_KICK_COUNT("afkkick-suspicious-message", "<gold><player> has had <count> suspicious AFK kicks since last reboot."),
|
||||
AFK_SOON_BOSS_BAR("afk-soon-boss-bar", "<dark_aqua>Time until AFK.</dark_aqua>"),
|
||||
AFK_KICK_SOON_BOSS_BAR("afk-kick-soon-boss-bar", "<dark_aqua>Time until <red>AFK kick</red>.</dark_aqua>"),
|
||||
AFK_NOW_BOSS_BAR("afk-now-boss-bar", "<red>AFK</red>");
|
||||
|
||||
private final String key;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user