4646import java .util .ArrayList ;
4747import java .util .Collections ;
4848import java .util .Comparator ;
49- import java .util .HashMap ;
5049import java .util .List ;
5150import java .util .Map ;
5251import java .util .Random ;
5352import java .util .Timer ;
5453import java .util .TimerTask ;
5554import java .util .UUID ;
55+ import java .util .concurrent .ConcurrentHashMap ;
5656import java .util .concurrent .atomic .AtomicInteger ;
5757import java .util .stream .Collectors ;
5858
@@ -67,7 +67,7 @@ public class ZKoth extends ZUtils implements Koth {
6767 private final int stopAfterSeconds ;
6868 private final int randomItemStacks ;
6969 private final int scoreboardRadius ;
70- private final Map <UUID , Integer > playersValues = new HashMap <>();
70+ private final Map <UUID , Integer > playersValues = new ConcurrentHashMap <>();
7171 private final boolean enableStartCapMessage ;
7272 private final boolean enableLooseCapMessage ;
7373 private final boolean enableEverySecondsCapMessage ;
@@ -92,6 +92,7 @@ public class ZKoth extends ZUtils implements Koth {
9292 private AtomicInteger remainingSeconds ;
9393 private TimerTask timerTask ;
9494 private TimerTask timerTaskStop ;
95+ private Timer stopTimer ;
9596 private List <PlayerResult > playerResults = new ArrayList <>();
9697
9798 public ZKoth (KothPlugin plugin , String fileName , KothType kothType , String name , int captureSeconds , Location minLocation , Location maxLocation , List <String > startCommands , List <String > endCommands , ScoreboardConfiguration cooldownScoreboard , ScoreboardConfiguration startScoreboard , int cooldownStart , int stopAfterSeconds , boolean enableStartCapMessage , boolean enableLooseCapMessage , boolean enableEverySecondsCapMessage , boolean enableEverySecondsCooldownMessage , HologramConfig hologramConfig , List <ItemStack > itemStacks , KothLootType kothLootType , DiscordWebhookConfig discordWebhookConfig , int randomItemStacks , List <String > blacklistTeamId , ProgressBar progressBar , List <RandomCommand > randomCommands , int maxRandomCommands ) {
@@ -304,6 +305,10 @@ public void stop() {
304305 this .plugin .getScoreBoardManager ().clearBoard ();
305306 // this.resetBlocks();
306307 if (this .timerTaskStop != null ) this .timerTaskStop .cancel ();
308+ if (this .stopTimer != null ) {
309+ this .stopTimer .cancel ();
310+ this .stopTimer = null ;
311+ }
307312
308313 this .plugin .getKothHologram ().end (this );
309314 }
@@ -415,15 +420,15 @@ private void spawnNow() {
415420 }*/
416421
417422 Koth koth = this ;
418- Timer timer = new Timer ();
423+ this . stopTimer = new Timer ();
419424 this .timerTaskStop = new TimerTask () {
420425 @ Override
421426 public void run () {
422427 plugin .getKothHologram ().end (koth );
423428 Bukkit .getScheduler ().runTask (plugin , () -> stop (Bukkit .getConsoleSender ()));
424429 }
425430 };
426- timer .schedule (this .timerTaskStop , this .stopAfterSeconds * 1000L );
431+ this . stopTimer .schedule (this .timerTaskStop , this .stopAfterSeconds * 1000L );
427432
428433 this .plugin .getKothHologram ().start (this );
429434
0 commit comments