
24.03.2024, 20:40
|
|
Участник форума
Регистрация: 29.02.2024
Сообщений: 111
С нами:
1162090
Репутация:
1
|
|
Сообщение от verbrannt
You need to cancel ThreadPool.scheduleAtFixedRate task in the stopFight method
Сообщение от MrKirill1232
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<>();
и отменять таск, о котором я писал вьіше.
спасибо, ребята, за помощь
|
|
|