11package com .xxmicloxx .NoteBlockAPI ;
22
3- import org .bukkit .Bukkit ;
4- import org .bukkit .entity .Player ;
5-
63import java .util .ArrayList ;
74import java .util .Collections ;
5+ import java .util .HashMap ;
86import java .util .List ;
97import java .util .concurrent .Callable ;
108
9+ import org .bukkit .Bukkit ;
10+ import org .bukkit .entity .Player ;
11+
1112public abstract class SongPlayer {
1213
1314 protected Song song ;
1415 protected boolean playing = false ;
1516 protected short tick = -1 ;
16- protected ArrayList <String > playerList = new ArrayList <String >();
17+ //protected ArrayList<String> playerList = new ArrayList<String>();
18+ protected HashMap <String , Boolean > playerList = new HashMap <String , Boolean >();
1719 protected boolean autoDestroy = false ;
1820 protected boolean destroyed = false ;
1921 protected Thread playerThread ;
@@ -130,7 +132,7 @@ public Boolean call() {
130132 return false ;
131133 }
132134 }
133- for (String s : playerList ) {
135+ for (String s : playerList . keySet () ) {
134136 @ SuppressWarnings ("deprecation" )
135137 Player p = Bukkit .getPlayerExact (s );
136138 if (p == null ) {
@@ -169,13 +171,15 @@ public Boolean call() {
169171 }
170172
171173 public List <String > getPlayerList () {
172- return Collections .unmodifiableList (playerList );
174+ List <String > list = new ArrayList <String >();
175+ list .addAll (playerList .keySet ());
176+ return Collections .unmodifiableList (list );
173177 }
174178
175179 public void addPlayer (Player p ) {
176180 synchronized (this ) {
177- if (!playerList .contains (p .getName ())) {
178- playerList .add (p .getName ());
181+ if (!playerList .containsKey (p .getName ())) {
182+ playerList .put (p .getName (), false );
179183 ArrayList <SongPlayer > songs = NoteBlockPlayerMain .plugin .playingSongs
180184 .get (p .getName ());
181185 if (songs == null ) {
@@ -187,6 +191,8 @@ public void addPlayer(Player p) {
187191 }
188192 }
189193
194+
195+
190196 public boolean getAutoDestroy () {
191197 synchronized (this ) {
192198 return autoDestroy ;
0 commit comments