File tree Expand file tree Collapse file tree
api/src/main/java/net/megavex/scoreboardlibrary/api
implementation/src/main/java/net/megavex/scoreboardlibrary/implementation/team Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -48,11 +48,21 @@ public boolean addEntry(@NotNull String entry) {
4848 return entries .add (entry );
4949 }
5050
51+ @ Override
52+ public boolean addEntries (@ NotNull final Collection <String > entries ) {
53+ return this .entries .addAll (entries );
54+ }
55+
5156 @ Override
5257 public boolean removeEntry (@ NotNull String entry ) {
5358 return entries .remove (entry );
5459 }
5560
61+ @ Override
62+ public boolean removeEntries (@ NotNull final Collection <String > entries ) {
63+ return this .entries .removeAll (entries );
64+ }
65+
5666 @ Override
5767 public @ NotNull Component displayName () {
5868 return displayName ;
Original file line number Diff line number Diff line change @@ -42,6 +42,15 @@ public interface TeamDisplay {
4242 */
4343 boolean addEntry (@ NotNull String entry );
4444
45+ /**
46+ * Adds multiple entries.
47+ *
48+ * @param entries entries to add
49+ * @return whether any entry was added
50+ * @see #entries
51+ */
52+ boolean addEntries (@ NotNull Collection <String > entries );
53+
4554 /**
4655 * Removes an entry.
4756 *
@@ -51,6 +60,15 @@ public interface TeamDisplay {
5160 */
5261 boolean removeEntry (@ NotNull String entry );
5362
63+ /**
64+ * Removes multiple entries.
65+ *
66+ * @param entries entries to remove
67+ * @return whether any entry was removed
68+ * @see #entries
69+ */
70+ boolean removeEntries (@ NotNull Collection <String > entries );
71+
5472 // Properties
5573
5674 /**
Original file line number Diff line number Diff line change @@ -67,6 +67,20 @@ public boolean addEntry(@NotNull String entry) {
6767 return false ;
6868 }
6969
70+ @ Override
71+ public boolean addEntries (@ NotNull Collection <String > entries ) {
72+ Set <String > existing = new HashSet <>(this .entries );
73+ List <String > toAdd = new ArrayList <>(entries );
74+ toAdd .removeIf (existing ::contains );
75+ if (!toAdd .isEmpty ()) {
76+ this .entries .addAll (toAdd );
77+ team .teamManager ().taskQueue ().add (new TeamManagerTask .AddEntries (this , toAdd ));
78+ return true ;
79+ }
80+
81+ return false ;
82+ }
83+
7084 @ Override
7185 public boolean removeEntry (@ NotNull String entry ) {
7286 if (entries .remove (entry )) {
@@ -77,6 +91,19 @@ public boolean removeEntry(@NotNull String entry) {
7791 return false ;
7892 }
7993
94+ @ Override
95+ public boolean removeEntries (@ NotNull Collection <String > entries ) {
96+ List <String > toRemove = new ArrayList <>(entries );
97+ toRemove .retainAll (this .entries );
98+ if (!toRemove .isEmpty ()) {
99+ this .entries .removeAll (toRemove );
100+ team .teamManager ().taskQueue ().add (new TeamManagerTask .RemoveEntries (this , toRemove ));
101+ return true ;
102+ }
103+
104+ return false ;
105+ }
106+
80107 @ Override
81108 public @ NotNull Component displayName () {
82109 return displayName ;
You can’t perform that action at this time.
0 commit comments