@@ -150,10 +150,10 @@ void update(String key, Object value){
150150 tick = (short ) value ;
151151 break ;
152152 case "addplayer" :
153- addPlayer ((Player ) value , false );
153+ addPlayer ((( Player ) value ). getUniqueId () , false );
154154 break ;
155155 case "removeplayer" :
156- removePlayer ((Player ) value , false );
156+ removePlayer ((( Player ) value ). getUniqueId () , false );
157157 break ;
158158 case "autoDestroy" :
159159 autoDestroy = (boolean ) value ;
@@ -401,22 +401,33 @@ public Set<UUID> getPlayerUUIDs() {
401401 * @param player
402402 */
403403 public void addPlayer (Player player ) {
404+ addPlayer (player .getUniqueId ());
405+ }
406+
407+ /**
408+ * Adds a Player to the list of Players listening to this SongPlayer
409+ * @param player's uuid
410+ */
411+ public void addPlayer (UUID player ) {
404412 addPlayer (player , true );
405413 }
406414
407- private void addPlayer (Player player , boolean notify ){
415+ private void addPlayer (UUID player , boolean notify ){
408416 lock .lock ();
409417 try {
410- if (!playerList .containsKey (player . getUniqueId () )) {
411- playerList .put (player . getUniqueId () , false );
418+ if (!playerList .containsKey (player )) {
419+ playerList .put (player , false );
412420 ArrayList <SongPlayer > songs = NoteBlockAPI .getSongPlayersByPlayer (player );
413421 if (songs == null ) {
414422 songs = new ArrayList <SongPlayer >();
415423 }
416424 songs .add (this );
417425 NoteBlockAPI .setSongPlayersByPlayer (player , songs );
418426 if (notify ){
419- CallUpdate ("addplayer" , player );
427+ Player p = Bukkit .getPlayer (player );
428+ if (p != null ){
429+ CallUpdate ("addplayer" , p );
430+ }
420431 }
421432 }
422433 } finally {
@@ -525,16 +536,27 @@ public void setTick(short tick) {
525536 * @param player to remove
526537 */
527538 public void removePlayer (Player player ) {
539+ removePlayer (player .getUniqueId ());
540+ }
541+
542+ /**
543+ * Removes a player from this SongPlayer
544+ * @param uuid of player to remove
545+ */
546+ public void removePlayer (UUID player ) {
528547 removePlayer (player , true );
529548 }
530549
531- private void removePlayer (Player player , boolean notify ) {
550+ private void removePlayer (UUID player , boolean notify ) {
532551 lock .lock ();
533552 try {
534553 if (notify ){
535- CallUpdate ("removeplayer" , player );
554+ Player p = Bukkit .getPlayer (player );
555+ if (p != null ){
556+ CallUpdate ("removeplayer" , p );
557+ }
536558 }
537- playerList .remove (player . getUniqueId () );
559+ playerList .remove (player );
538560 if (NoteBlockAPI .getSongPlayersByPlayer (player ) == null ) {
539561 return ;
540562 }
0 commit comments