88import java .util .HashMap ;
99import java .util .Map ;
1010import java .util .UUID ;
11+ import java .util .concurrent .ConcurrentHashMap ;
1112
1213import org .bstats .bukkit .Metrics ;
1314import org .bukkit .Bukkit ;
@@ -28,9 +29,8 @@ public class NoteBlockAPI extends JavaPlugin {
2829
2930 private static NoteBlockAPI plugin ;
3031
31- private Map <UUID , ArrayList <SongPlayer >> playingSongs =
32- Collections .synchronizedMap (new HashMap <UUID , ArrayList <SongPlayer >>());
33- private Map <UUID , Byte > playerVolume = Collections .synchronizedMap (new HashMap <UUID , Byte >());
32+ private Map <UUID , ArrayList <SongPlayer >> playingSongs = new ConcurrentHashMap <UUID , ArrayList <SongPlayer >>();
33+ private Map <UUID , Byte > playerVolume = new ConcurrentHashMap <UUID , Byte >();
3434
3535 private boolean disabling = false ;
3636
@@ -42,19 +42,20 @@ public class NoteBlockAPI extends JavaPlugin {
4242 * @return is receiving a song
4343 */
4444 public static boolean isReceivingSong (Player player ) {
45- return (( plugin .playingSongs .get (player .getUniqueId ()) != null )
46- && (! plugin . playingSongs . get ( player . getUniqueId ()). isEmpty () ));
45+ ArrayList < SongPlayer > songs = plugin .playingSongs .get (player .getUniqueId ());
46+ return ( songs != null && ! songs . isEmpty ());
4747 }
4848
4949 /**
5050 * Stops the song for a Player
5151 * @param player
5252 */
5353 public static void stopPlaying (Player player ) {
54- if (plugin .playingSongs .get (player .getUniqueId ()) == null ) {
54+ ArrayList <SongPlayer > songs = plugin .playingSongs .get (player .getUniqueId ());
55+ if (songs == null ) {
5556 return ;
5657 }
57- for (SongPlayer songPlayer : plugin . playingSongs . get ( player . getUniqueId ()) ) {
58+ for (SongPlayer songPlayer : songs ) {
5859 songPlayer .removePlayer (player );
5960 }
6061 }
@@ -74,10 +75,11 @@ public static void setPlayerVolume(Player player, byte volume) {
7475 * @return volume (byte)
7576 */
7677 public static byte getPlayerVolume (Player player ) {
77- Byte byteObj = plugin .playerVolume .get (player .getUniqueId ());
78+ UUID uuid = player .getUniqueId ();
79+ Byte byteObj = plugin .playerVolume .get (uuid );
7880 if (byteObj == null ) {
7981 byteObj = 100 ;
80- plugin .playerVolume .put (player . getUniqueId () , byteObj );
82+ plugin .playerVolume .put (uuid , byteObj );
8183 }
8284 return byteObj ;
8385 }
0 commit comments