From 0956ba2a84f4f36c3c434475c7584f474f2293c4 Mon Sep 17 00:00:00 2001 From: MobiusDevelopment <8391001+MobiusDevelopment@users.noreply.github.com> Date: Mon, 21 Sep 2020 07:40:35 +0000 Subject: [PATCH] TvT concurrent player lists. --- .../data/scripts/custom/events/TeamVsTeam/TvT.java | 13 +++++++++---- .../data/scripts/custom/events/TeamVsTeam/TvT.java | 13 +++++++++---- .../data/scripts/custom/events/TeamVsTeam/TvT.java | 13 +++++++++---- .../data/scripts/custom/events/TeamVsTeam/TvT.java | 13 +++++++++---- .../data/scripts/custom/events/TeamVsTeam/TvT.java | 13 +++++++++---- .../data/scripts/custom/events/TeamVsTeam/TvT.java | 13 +++++++++---- .../data/scripts/custom/events/TeamVsTeam/TvT.java | 13 +++++++++---- .../data/scripts/custom/events/TeamVsTeam/TvT.java | 13 +++++++++---- .../data/scripts/custom/events/TeamVsTeam/TvT.java | 13 +++++++++---- .../data/scripts/custom/events/TeamVsTeam/TvT.java | 13 +++++++++---- .../data/scripts/custom/events/TeamVsTeam/TvT.java | 13 +++++++++---- .../data/scripts/custom/events/TeamVsTeam/TvT.java | 13 +++++++++---- .../data/scripts/custom/events/TeamVsTeam/TvT.java | 13 +++++++++---- .../data/scripts/custom/events/TeamVsTeam/TvT.java | 13 +++++++++---- .../data/scripts/custom/events/TeamVsTeam/TvT.java | 13 +++++++++---- 15 files changed, 135 insertions(+), 60 deletions(-) diff --git a/L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java b/L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java index 86a40c2761..58976649d6 100644 --- a/L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java +++ b/L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import org.l2jmobius.Config; @@ -109,9 +110,9 @@ public class TvT extends Event private static final ItemHolder REWARD = new ItemHolder(57, 1000000); // Adena // Misc private static final Map PLAYER_SCORES = new ConcurrentHashMap<>(); - private static final List PLAYER_LIST = new ArrayList<>(); - private static final List BLUE_TEAM = new ArrayList<>(); - private static final List RED_TEAM = new ArrayList<>(); + private static final Set PLAYER_LIST = ConcurrentHashMap.newKeySet(); + private static final Set BLUE_TEAM = ConcurrentHashMap.newKeySet(); + private static final Set RED_TEAM = ConcurrentHashMap.newKeySet(); private static volatile int BLUE_SCORE; private static volatile int RED_SCORE; private static Instance PVP_WORLD = null; @@ -235,7 +236,11 @@ public class TvT extends Event final InstanceTemplate template = manager.getInstanceTemplate(INSTANCE_ID); PVP_WORLD = manager.createInstance(template, null); // Randomize player list and separate teams. - Collections.shuffle(PLAYER_LIST); + final List playerList = new ArrayList<>(PLAYER_LIST.size()); + playerList.addAll(PLAYER_LIST); + Collections.shuffle(playerList); + PLAYER_LIST.clear(); + PLAYER_LIST.addAll(playerList); boolean team = getRandomBoolean(); // If teams are not even, randomize where extra player goes. for (PlayerInstance participant : PLAYER_LIST) { diff --git a/L2J_Mobius_2.5_Underground/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java b/L2J_Mobius_2.5_Underground/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java index 86a40c2761..58976649d6 100644 --- a/L2J_Mobius_2.5_Underground/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java +++ b/L2J_Mobius_2.5_Underground/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import org.l2jmobius.Config; @@ -109,9 +110,9 @@ public class TvT extends Event private static final ItemHolder REWARD = new ItemHolder(57, 1000000); // Adena // Misc private static final Map PLAYER_SCORES = new ConcurrentHashMap<>(); - private static final List PLAYER_LIST = new ArrayList<>(); - private static final List BLUE_TEAM = new ArrayList<>(); - private static final List RED_TEAM = new ArrayList<>(); + private static final Set PLAYER_LIST = ConcurrentHashMap.newKeySet(); + private static final Set BLUE_TEAM = ConcurrentHashMap.newKeySet(); + private static final Set RED_TEAM = ConcurrentHashMap.newKeySet(); private static volatile int BLUE_SCORE; private static volatile int RED_SCORE; private static Instance PVP_WORLD = null; @@ -235,7 +236,11 @@ public class TvT extends Event final InstanceTemplate template = manager.getInstanceTemplate(INSTANCE_ID); PVP_WORLD = manager.createInstance(template, null); // Randomize player list and separate teams. - Collections.shuffle(PLAYER_LIST); + final List playerList = new ArrayList<>(PLAYER_LIST.size()); + playerList.addAll(PLAYER_LIST); + Collections.shuffle(playerList); + PLAYER_LIST.clear(); + PLAYER_LIST.addAll(playerList); boolean team = getRandomBoolean(); // If teams are not even, randomize where extra player goes. for (PlayerInstance participant : PLAYER_LIST) { diff --git a/L2J_Mobius_3.0_Helios/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java b/L2J_Mobius_3.0_Helios/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java index 86a40c2761..58976649d6 100644 --- a/L2J_Mobius_3.0_Helios/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java +++ b/L2J_Mobius_3.0_Helios/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import org.l2jmobius.Config; @@ -109,9 +110,9 @@ public class TvT extends Event private static final ItemHolder REWARD = new ItemHolder(57, 1000000); // Adena // Misc private static final Map PLAYER_SCORES = new ConcurrentHashMap<>(); - private static final List PLAYER_LIST = new ArrayList<>(); - private static final List BLUE_TEAM = new ArrayList<>(); - private static final List RED_TEAM = new ArrayList<>(); + private static final Set PLAYER_LIST = ConcurrentHashMap.newKeySet(); + private static final Set BLUE_TEAM = ConcurrentHashMap.newKeySet(); + private static final Set RED_TEAM = ConcurrentHashMap.newKeySet(); private static volatile int BLUE_SCORE; private static volatile int RED_SCORE; private static Instance PVP_WORLD = null; @@ -235,7 +236,11 @@ public class TvT extends Event final InstanceTemplate template = manager.getInstanceTemplate(INSTANCE_ID); PVP_WORLD = manager.createInstance(template, null); // Randomize player list and separate teams. - Collections.shuffle(PLAYER_LIST); + final List playerList = new ArrayList<>(PLAYER_LIST.size()); + playerList.addAll(PLAYER_LIST); + Collections.shuffle(playerList); + PLAYER_LIST.clear(); + PLAYER_LIST.addAll(playerList); boolean team = getRandomBoolean(); // If teams are not even, randomize where extra player goes. for (PlayerInstance participant : PLAYER_LIST) { diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java index 86a40c2761..58976649d6 100644 --- a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java +++ b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import org.l2jmobius.Config; @@ -109,9 +110,9 @@ public class TvT extends Event private static final ItemHolder REWARD = new ItemHolder(57, 1000000); // Adena // Misc private static final Map PLAYER_SCORES = new ConcurrentHashMap<>(); - private static final List PLAYER_LIST = new ArrayList<>(); - private static final List BLUE_TEAM = new ArrayList<>(); - private static final List RED_TEAM = new ArrayList<>(); + private static final Set PLAYER_LIST = ConcurrentHashMap.newKeySet(); + private static final Set BLUE_TEAM = ConcurrentHashMap.newKeySet(); + private static final Set RED_TEAM = ConcurrentHashMap.newKeySet(); private static volatile int BLUE_SCORE; private static volatile int RED_SCORE; private static Instance PVP_WORLD = null; @@ -235,7 +236,11 @@ public class TvT extends Event final InstanceTemplate template = manager.getInstanceTemplate(INSTANCE_ID); PVP_WORLD = manager.createInstance(template, null); // Randomize player list and separate teams. - Collections.shuffle(PLAYER_LIST); + final List playerList = new ArrayList<>(PLAYER_LIST.size()); + playerList.addAll(PLAYER_LIST); + Collections.shuffle(playerList); + PLAYER_LIST.clear(); + PLAYER_LIST.addAll(playerList); boolean team = getRandomBoolean(); // If teams are not even, randomize where extra player goes. for (PlayerInstance participant : PLAYER_LIST) { diff --git a/L2J_Mobius_5.0_Salvation/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java b/L2J_Mobius_5.0_Salvation/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java index 3dda4bb24d..9a0c4d73c0 100644 --- a/L2J_Mobius_5.0_Salvation/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java +++ b/L2J_Mobius_5.0_Salvation/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import org.l2jmobius.Config; @@ -107,9 +108,9 @@ public class TvT extends Event private static final ItemHolder REWARD = new ItemHolder(57, 1000000); // Adena // Misc private static final Map PLAYER_SCORES = new ConcurrentHashMap<>(); - private static final List PLAYER_LIST = new ArrayList<>(); - private static final List BLUE_TEAM = new ArrayList<>(); - private static final List RED_TEAM = new ArrayList<>(); + private static final Set PLAYER_LIST = ConcurrentHashMap.newKeySet(); + private static final Set BLUE_TEAM = ConcurrentHashMap.newKeySet(); + private static final Set RED_TEAM = ConcurrentHashMap.newKeySet(); private static volatile int BLUE_SCORE; private static volatile int RED_SCORE; private static Instance PVP_WORLD = null; @@ -233,7 +234,11 @@ public class TvT extends Event final InstanceTemplate template = manager.getInstanceTemplate(INSTANCE_ID); PVP_WORLD = manager.createInstance(template, null); // Randomize player list and separate teams. - Collections.shuffle(PLAYER_LIST); + final List playerList = new ArrayList<>(PLAYER_LIST.size()); + playerList.addAll(PLAYER_LIST); + Collections.shuffle(playerList); + PLAYER_LIST.clear(); + PLAYER_LIST.addAll(playerList); boolean team = getRandomBoolean(); // If teams are not even, randomize where extra player goes. for (PlayerInstance participant : PLAYER_LIST) { diff --git a/L2J_Mobius_5.5_EtinasFate/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java b/L2J_Mobius_5.5_EtinasFate/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java index 3dda4bb24d..9a0c4d73c0 100644 --- a/L2J_Mobius_5.5_EtinasFate/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java +++ b/L2J_Mobius_5.5_EtinasFate/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import org.l2jmobius.Config; @@ -107,9 +108,9 @@ public class TvT extends Event private static final ItemHolder REWARD = new ItemHolder(57, 1000000); // Adena // Misc private static final Map PLAYER_SCORES = new ConcurrentHashMap<>(); - private static final List PLAYER_LIST = new ArrayList<>(); - private static final List BLUE_TEAM = new ArrayList<>(); - private static final List RED_TEAM = new ArrayList<>(); + private static final Set PLAYER_LIST = ConcurrentHashMap.newKeySet(); + private static final Set BLUE_TEAM = ConcurrentHashMap.newKeySet(); + private static final Set RED_TEAM = ConcurrentHashMap.newKeySet(); private static volatile int BLUE_SCORE; private static volatile int RED_SCORE; private static Instance PVP_WORLD = null; @@ -233,7 +234,11 @@ public class TvT extends Event final InstanceTemplate template = manager.getInstanceTemplate(INSTANCE_ID); PVP_WORLD = manager.createInstance(template, null); // Randomize player list and separate teams. - Collections.shuffle(PLAYER_LIST); + final List playerList = new ArrayList<>(PLAYER_LIST.size()); + playerList.addAll(PLAYER_LIST); + Collections.shuffle(playerList); + PLAYER_LIST.clear(); + PLAYER_LIST.addAll(playerList); boolean team = getRandomBoolean(); // If teams are not even, randomize where extra player goes. for (PlayerInstance participant : PLAYER_LIST) { diff --git a/L2J_Mobius_6.0_Fafurion/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java b/L2J_Mobius_6.0_Fafurion/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java index 3dda4bb24d..9a0c4d73c0 100644 --- a/L2J_Mobius_6.0_Fafurion/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java +++ b/L2J_Mobius_6.0_Fafurion/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import org.l2jmobius.Config; @@ -107,9 +108,9 @@ public class TvT extends Event private static final ItemHolder REWARD = new ItemHolder(57, 1000000); // Adena // Misc private static final Map PLAYER_SCORES = new ConcurrentHashMap<>(); - private static final List PLAYER_LIST = new ArrayList<>(); - private static final List BLUE_TEAM = new ArrayList<>(); - private static final List RED_TEAM = new ArrayList<>(); + private static final Set PLAYER_LIST = ConcurrentHashMap.newKeySet(); + private static final Set BLUE_TEAM = ConcurrentHashMap.newKeySet(); + private static final Set RED_TEAM = ConcurrentHashMap.newKeySet(); private static volatile int BLUE_SCORE; private static volatile int RED_SCORE; private static Instance PVP_WORLD = null; @@ -233,7 +234,11 @@ public class TvT extends Event final InstanceTemplate template = manager.getInstanceTemplate(INSTANCE_ID); PVP_WORLD = manager.createInstance(template, null); // Randomize player list and separate teams. - Collections.shuffle(PLAYER_LIST); + final List playerList = new ArrayList<>(PLAYER_LIST.size()); + playerList.addAll(PLAYER_LIST); + Collections.shuffle(playerList); + PLAYER_LIST.clear(); + PLAYER_LIST.addAll(playerList); boolean team = getRandomBoolean(); // If teams are not even, randomize where extra player goes. for (PlayerInstance participant : PLAYER_LIST) { diff --git a/L2J_Mobius_7.0_PreludeOfWar/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java b/L2J_Mobius_7.0_PreludeOfWar/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java index 3dda4bb24d..9a0c4d73c0 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java +++ b/L2J_Mobius_7.0_PreludeOfWar/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import org.l2jmobius.Config; @@ -107,9 +108,9 @@ public class TvT extends Event private static final ItemHolder REWARD = new ItemHolder(57, 1000000); // Adena // Misc private static final Map PLAYER_SCORES = new ConcurrentHashMap<>(); - private static final List PLAYER_LIST = new ArrayList<>(); - private static final List BLUE_TEAM = new ArrayList<>(); - private static final List RED_TEAM = new ArrayList<>(); + private static final Set PLAYER_LIST = ConcurrentHashMap.newKeySet(); + private static final Set BLUE_TEAM = ConcurrentHashMap.newKeySet(); + private static final Set RED_TEAM = ConcurrentHashMap.newKeySet(); private static volatile int BLUE_SCORE; private static volatile int RED_SCORE; private static Instance PVP_WORLD = null; @@ -233,7 +234,11 @@ public class TvT extends Event final InstanceTemplate template = manager.getInstanceTemplate(INSTANCE_ID); PVP_WORLD = manager.createInstance(template, null); // Randomize player list and separate teams. - Collections.shuffle(PLAYER_LIST); + final List playerList = new ArrayList<>(PLAYER_LIST.size()); + playerList.addAll(PLAYER_LIST); + Collections.shuffle(playerList); + PLAYER_LIST.clear(); + PLAYER_LIST.addAll(playerList); boolean team = getRandomBoolean(); // If teams are not even, randomize where extra player goes. for (PlayerInstance participant : PLAYER_LIST) { diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java index d1da901d24..81e7e483c1 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java +++ b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import org.l2jmobius.Config; @@ -113,9 +114,9 @@ public class TvT extends Event private static final ItemHolder REWARD = new ItemHolder(57, 100000); // Adena // Misc private static final Map PLAYER_SCORES = new ConcurrentHashMap<>(); - private static final List PLAYER_LIST = new ArrayList<>(); - private static final List BLUE_TEAM = new ArrayList<>(); - private static final List RED_TEAM = new ArrayList<>(); + private static final Set PLAYER_LIST = ConcurrentHashMap.newKeySet(); + private static final Set BLUE_TEAM = ConcurrentHashMap.newKeySet(); + private static final Set RED_TEAM = ConcurrentHashMap.newKeySet(); private static volatile int BLUE_SCORE; private static volatile int RED_SCORE; private static Instance PVP_WORLD = null; @@ -237,7 +238,11 @@ public class TvT extends Event final InstanceTemplate template = manager.getInstanceTemplate(INSTANCE_ID); PVP_WORLD = manager.createInstance(template, null); // Randomize player list and separate teams. - Collections.shuffle(PLAYER_LIST); + final List playerList = new ArrayList<>(PLAYER_LIST.size()); + playerList.addAll(PLAYER_LIST); + Collections.shuffle(playerList); + PLAYER_LIST.clear(); + PLAYER_LIST.addAll(playerList); boolean team = getRandomBoolean(); // If teams are not even, randomize where extra player goes. for (PlayerInstance participant : PLAYER_LIST) { diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java b/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java index d1da901d24..81e7e483c1 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java +++ b/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import org.l2jmobius.Config; @@ -113,9 +114,9 @@ public class TvT extends Event private static final ItemHolder REWARD = new ItemHolder(57, 100000); // Adena // Misc private static final Map PLAYER_SCORES = new ConcurrentHashMap<>(); - private static final List PLAYER_LIST = new ArrayList<>(); - private static final List BLUE_TEAM = new ArrayList<>(); - private static final List RED_TEAM = new ArrayList<>(); + private static final Set PLAYER_LIST = ConcurrentHashMap.newKeySet(); + private static final Set BLUE_TEAM = ConcurrentHashMap.newKeySet(); + private static final Set RED_TEAM = ConcurrentHashMap.newKeySet(); private static volatile int BLUE_SCORE; private static volatile int RED_SCORE; private static Instance PVP_WORLD = null; @@ -237,7 +238,11 @@ public class TvT extends Event final InstanceTemplate template = manager.getInstanceTemplate(INSTANCE_ID); PVP_WORLD = manager.createInstance(template, null); // Randomize player list and separate teams. - Collections.shuffle(PLAYER_LIST); + final List playerList = new ArrayList<>(PLAYER_LIST.size()); + playerList.addAll(PLAYER_LIST); + Collections.shuffle(playerList); + PLAYER_LIST.clear(); + PLAYER_LIST.addAll(playerList); boolean team = getRandomBoolean(); // If teams are not even, randomize where extra player goes. for (PlayerInstance participant : PLAYER_LIST) { diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java index d1da901d24..81e7e483c1 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java +++ b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import org.l2jmobius.Config; @@ -113,9 +114,9 @@ public class TvT extends Event private static final ItemHolder REWARD = new ItemHolder(57, 100000); // Adena // Misc private static final Map PLAYER_SCORES = new ConcurrentHashMap<>(); - private static final List PLAYER_LIST = new ArrayList<>(); - private static final List BLUE_TEAM = new ArrayList<>(); - private static final List RED_TEAM = new ArrayList<>(); + private static final Set PLAYER_LIST = ConcurrentHashMap.newKeySet(); + private static final Set BLUE_TEAM = ConcurrentHashMap.newKeySet(); + private static final Set RED_TEAM = ConcurrentHashMap.newKeySet(); private static volatile int BLUE_SCORE; private static volatile int RED_SCORE; private static Instance PVP_WORLD = null; @@ -237,7 +238,11 @@ public class TvT extends Event final InstanceTemplate template = manager.getInstanceTemplate(INSTANCE_ID); PVP_WORLD = manager.createInstance(template, null); // Randomize player list and separate teams. - Collections.shuffle(PLAYER_LIST); + final List playerList = new ArrayList<>(PLAYER_LIST.size()); + playerList.addAll(PLAYER_LIST); + Collections.shuffle(playerList); + PLAYER_LIST.clear(); + PLAYER_LIST.addAll(playerList); boolean team = getRandomBoolean(); // If teams are not even, randomize where extra player goes. for (PlayerInstance participant : PLAYER_LIST) { diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java index d1da901d24..81e7e483c1 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import org.l2jmobius.Config; @@ -113,9 +114,9 @@ public class TvT extends Event private static final ItemHolder REWARD = new ItemHolder(57, 100000); // Adena // Misc private static final Map PLAYER_SCORES = new ConcurrentHashMap<>(); - private static final List PLAYER_LIST = new ArrayList<>(); - private static final List BLUE_TEAM = new ArrayList<>(); - private static final List RED_TEAM = new ArrayList<>(); + private static final Set PLAYER_LIST = ConcurrentHashMap.newKeySet(); + private static final Set BLUE_TEAM = ConcurrentHashMap.newKeySet(); + private static final Set RED_TEAM = ConcurrentHashMap.newKeySet(); private static volatile int BLUE_SCORE; private static volatile int RED_SCORE; private static Instance PVP_WORLD = null; @@ -237,7 +238,11 @@ public class TvT extends Event final InstanceTemplate template = manager.getInstanceTemplate(INSTANCE_ID); PVP_WORLD = manager.createInstance(template, null); // Randomize player list and separate teams. - Collections.shuffle(PLAYER_LIST); + final List playerList = new ArrayList<>(PLAYER_LIST.size()); + playerList.addAll(PLAYER_LIST); + Collections.shuffle(playerList); + PLAYER_LIST.clear(); + PLAYER_LIST.addAll(playerList); boolean team = getRandomBoolean(); // If teams are not even, randomize where extra player goes. for (PlayerInstance participant : PLAYER_LIST) { diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java index d1da901d24..81e7e483c1 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import org.l2jmobius.Config; @@ -113,9 +114,9 @@ public class TvT extends Event private static final ItemHolder REWARD = new ItemHolder(57, 100000); // Adena // Misc private static final Map PLAYER_SCORES = new ConcurrentHashMap<>(); - private static final List PLAYER_LIST = new ArrayList<>(); - private static final List BLUE_TEAM = new ArrayList<>(); - private static final List RED_TEAM = new ArrayList<>(); + private static final Set PLAYER_LIST = ConcurrentHashMap.newKeySet(); + private static final Set BLUE_TEAM = ConcurrentHashMap.newKeySet(); + private static final Set RED_TEAM = ConcurrentHashMap.newKeySet(); private static volatile int BLUE_SCORE; private static volatile int RED_SCORE; private static Instance PVP_WORLD = null; @@ -237,7 +238,11 @@ public class TvT extends Event final InstanceTemplate template = manager.getInstanceTemplate(INSTANCE_ID); PVP_WORLD = manager.createInstance(template, null); // Randomize player list and separate teams. - Collections.shuffle(PLAYER_LIST); + final List playerList = new ArrayList<>(PLAYER_LIST.size()); + playerList.addAll(PLAYER_LIST); + Collections.shuffle(playerList); + PLAYER_LIST.clear(); + PLAYER_LIST.addAll(playerList); boolean team = getRandomBoolean(); // If teams are not even, randomize where extra player goes. for (PlayerInstance participant : PLAYER_LIST) { diff --git a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java index d1da901d24..81e7e483c1 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import org.l2jmobius.Config; @@ -113,9 +114,9 @@ public class TvT extends Event private static final ItemHolder REWARD = new ItemHolder(57, 100000); // Adena // Misc private static final Map PLAYER_SCORES = new ConcurrentHashMap<>(); - private static final List PLAYER_LIST = new ArrayList<>(); - private static final List BLUE_TEAM = new ArrayList<>(); - private static final List RED_TEAM = new ArrayList<>(); + private static final Set PLAYER_LIST = ConcurrentHashMap.newKeySet(); + private static final Set BLUE_TEAM = ConcurrentHashMap.newKeySet(); + private static final Set RED_TEAM = ConcurrentHashMap.newKeySet(); private static volatile int BLUE_SCORE; private static volatile int RED_SCORE; private static Instance PVP_WORLD = null; @@ -237,7 +238,11 @@ public class TvT extends Event final InstanceTemplate template = manager.getInstanceTemplate(INSTANCE_ID); PVP_WORLD = manager.createInstance(template, null); // Randomize player list and separate teams. - Collections.shuffle(PLAYER_LIST); + final List playerList = new ArrayList<>(PLAYER_LIST.size()); + playerList.addAll(PLAYER_LIST); + Collections.shuffle(playerList); + PLAYER_LIST.clear(); + PLAYER_LIST.addAll(playerList); boolean team = getRandomBoolean(); // If teams are not even, randomize where extra player goes. for (PlayerInstance participant : PLAYER_LIST) { diff --git a/L2J_Mobius_Classic_Interlude/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java b/L2J_Mobius_Classic_Interlude/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java index d1da901d24..81e7e483c1 100644 --- a/L2J_Mobius_Classic_Interlude/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java +++ b/L2J_Mobius_Classic_Interlude/dist/game/data/scripts/custom/events/TeamVsTeam/TvT.java @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import org.l2jmobius.Config; @@ -113,9 +114,9 @@ public class TvT extends Event private static final ItemHolder REWARD = new ItemHolder(57, 100000); // Adena // Misc private static final Map PLAYER_SCORES = new ConcurrentHashMap<>(); - private static final List PLAYER_LIST = new ArrayList<>(); - private static final List BLUE_TEAM = new ArrayList<>(); - private static final List RED_TEAM = new ArrayList<>(); + private static final Set PLAYER_LIST = ConcurrentHashMap.newKeySet(); + private static final Set BLUE_TEAM = ConcurrentHashMap.newKeySet(); + private static final Set RED_TEAM = ConcurrentHashMap.newKeySet(); private static volatile int BLUE_SCORE; private static volatile int RED_SCORE; private static Instance PVP_WORLD = null; @@ -237,7 +238,11 @@ public class TvT extends Event final InstanceTemplate template = manager.getInstanceTemplate(INSTANCE_ID); PVP_WORLD = manager.createInstance(template, null); // Randomize player list and separate teams. - Collections.shuffle(PLAYER_LIST); + final List playerList = new ArrayList<>(PLAYER_LIST.size()); + playerList.addAll(PLAYER_LIST); + Collections.shuffle(playerList); + PLAYER_LIST.clear(); + PLAYER_LIST.addAll(playerList); boolean team = getRandomBoolean(); // If teams are not even, randomize where extra player goes. for (PlayerInstance participant : PLAYER_LIST) {