
24.03.2024, 19:43
|
|
Флудер
Регистрация: 31.10.2018
Сообщений: 2,776
С нами:
3966734
Репутация:
1904
|
|
Java:
Код:
ThreadPool
.
scheduleAtFixedRate
(
(
)
->
{
List
inactivePlayerNames
=
new
ArrayList
<>
(
)
;
// Collect names of inactive players
for
(
TvTEventTeams
team
:
_teams
)
{
for
(
String
playerName
:
team
.
getParticipatedPlayerNames
(
)
)
{
if
(
isPlayerAFK
(
playerName
)
)
{
inactivePlayerNames
.
add
(
playerName
)
;
}
}
}
// Remove inactive players
for
(
String
playerName
:
inactivePlayerNames
)
{
removeParticipant
(
playerName
)
;
Player
playerInstance
=
World
.
getInstance
(
)
.
getPlayer
(
playerName
)
;
if
(
playerInstance
!=
null
)
{
playerInstance
.
sendMessage
(
"You have been removed from the TvT event due to inactivity."
)
;
new
TvTEventTeleport
(
playerInstance
,
Config
.
TVT_EVENT_BACK_COORDINATES
,
false
,
false
)
;
_afkPlayers
.
remove
(
playerName
)
;
}
}
}
,
60000
,
60000
)
;
// This runs every 60 seconds
Инициилизируйте переменную
чтоб можно было привязать её к коду выше.
И наверное
(вместо resetEvent) нужно добавить
Код:
_afkPlayers = new HashSet<>();
и отменять таск, о котором я писал вьіше.
|
|
|