Пример #1
0
 public void playMusic(int musicId) {
   if (!player.hasStarted()) return;
   playingMusicDelay = Utils.currentTimeMillis();
   if (musicId == -2) {
     playingMusic = musicId;
     player.getPackets().sendMusic(-1);
     player.getPackets().sendIComponentText(187, 4, "");
     return;
   }
   player.getPackets().sendMusic(musicId, playingMusic == -1 ? 0 : 100, 255);
   playingMusic = musicId;
   int musicIndex = (int) ClientScriptMap.getMap(1351).getKeyForValue(musicId);
   if (musicIndex != -1) {
     String musicName = ClientScriptMap.getMap(1345).getStringValue(musicIndex);
     if (musicName.equals(" ")) musicName = Region.getMusicName1(player.getRegionId());
     player.getPackets().sendIComponentText(187, 4, musicName != null ? musicName : "");
     if (!unlockedMusics.contains(musicId)) {
       addMusic(musicId);
       if (musicName != null)
         player
             .getPackets()
             .sendGameMessage(
                 "<col=ff0000>You have unlocked a new music track: " + musicName + ".");
     }
   }
 }
Пример #2
0
 public void playAnotherMusic(int musicIndex) {
   int musicId = ClientScriptMap.getMap(1351).getIntValue(musicIndex);
   if (musicId != -1 && unlockedMusics.contains(musicId)) {
     settedMusic = true;
     if (playListOn) switchPlayListOn();
     playMusic(musicId);
   }
 }
Пример #3
0
 public void removeFromPlayList(int musicIndex) {
   Integer musicId = ClientScriptMap.getMap(1351).getIntValue(musicIndex);
   if (musicId != -1 && unlockedMusics.contains(musicId) && playList.contains(musicId)) {
     playList.remove(musicId);
     if (playListOn) switchPlayListOn();
     else refreshPlayListConfigs();
   }
 }
Пример #4
0
 public void addToPlayList(int musicIndex) {
   if (playList.size() == 12) return;
   int musicId = ClientScriptMap.getMap(1351).getIntValue(musicIndex);
   if (musicId != -1 && unlockedMusics.contains(musicId) && !playList.contains(musicId)) {
     playList.add(musicId);
     if (playListOn) switchPlayListOn();
     else refreshPlayListConfigs();
   }
 }
Пример #5
0
 public void refreshPlayListConfigs() {
   int[] configValues = new int[PLAY_LIST_CONFIG_IDS.length];
   for (int i = 0; i < configValues.length; i++) configValues[i] = -1;
   for (int i = 0; i < playList.size(); i += 2) {
     Integer musicId1 = playList.get(i);
     Integer musicId2 = (i + 1) >= playList.size() ? null : playList.get(i + 1);
     if (musicId1 == null && musicId2 == null) break;
     int musicIndex = (int) ClientScriptMap.getMap(1351).getKeyForValue(musicId1);
     int configValue;
     if (musicId2 != null) {
       int musicIndex2 = (int) ClientScriptMap.getMap(1351).getKeyForValue(musicId2);
       configValue = musicIndex | musicIndex2 << 15;
     } else configValue = musicIndex | -1 << 15;
     configValues[i / 2] = configValue;
   }
   for (int i = 0; i < PLAY_LIST_CONFIG_IDS.length; i++)
     if (PLAY_LIST_CONFIG_IDS[i] == -1)
       player.getPackets().sendConfig(PLAY_LIST_CONFIG_IDS[i], configValues[i]);
 }
Пример #6
0
 public void sendHint(int musicIndex) {
   int musicId = ClientScriptMap.getMap(1351).getIntValue(musicIndex);
   if (musicId != -1) {
     player
         .getPackets()
         .sendGameMessage(
             "This track "
                 + (unlockedMusics.contains(musicId) ? "was unlocked" : "unlocks")
                 + " "
                 + MusicHints.getHint(musicId));
   }
 }
Пример #7
0
 public void refreshListConfigs() {
   int[] configValues = new int[CONFIG_IDS.length];
   for (int musicId : unlockedMusics) {
     int musicIndex = (int) ClientScriptMap.getMap(1351).getKeyForValue(musicId);
     if (musicIndex == -1) continue;
     int index = getConfigIndex(musicIndex);
     if (index >= CONFIG_IDS.length) continue;
     configValues[index] |= 1 << (musicIndex - (index * 32));
   }
   for (int i = 0; i < CONFIG_IDS.length; i++) {
     if (CONFIG_IDS[i] != -1 && configValues[i] != 0)
       player.getPackets().sendConfig(CONFIG_IDS[i], configValues[i]);
   }
 }
Пример #8
0
 public void addPlayingMusicToPlayList() {
   addToPlayList((int) ClientScriptMap.getMap(1351).getKeyForValue(playingMusic));
 }