Fixed the unlocking of region-wide music tracks
This commit is contained in:
@@ -10,9 +10,7 @@ import core.net.packet.context.StringContext;
|
||||
import core.net.packet.out.MusicPacket;
|
||||
import core.net.packet.out.StringPacket;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.*;
|
||||
|
||||
import static core.api.ContentAPIKt.*;
|
||||
|
||||
@@ -199,10 +197,9 @@ public final class MusicPlayer {
|
||||
public void unlock(int id, boolean play) {
|
||||
MusicEntry entry = MusicEntry.forId(id);
|
||||
if (entry == null) {
|
||||
|
||||
return;
|
||||
}
|
||||
if (!unlocked.containsKey(entry.getIndex())) {
|
||||
if (!entry.getName().equals(" ") && !unlocked.containsKey(entry.getIndex())) {
|
||||
unlocked.put(entry.getIndex(), entry);
|
||||
player.getPacketDispatch().sendMessage("<col=FF0000>You have unlocked a new music track: " + entry.getName() + ".</col>");
|
||||
refreshList();
|
||||
|
||||
@@ -40,7 +40,7 @@ class MusicConfigLoader {
|
||||
val e = config as JSONObject
|
||||
val region = Integer.parseInt(e["region"].toString())
|
||||
val id = Integer.parseInt(e["id"].toString())
|
||||
RegionManager.forId(region).music = MusicEntry.forId(id)
|
||||
RegionManager.forId(region).music = id
|
||||
count++
|
||||
}
|
||||
log(this::class.java, Log.FINE, "Parsed $count region music configs.")
|
||||
|
||||
@@ -3,7 +3,6 @@ package core.game.world.map;
|
||||
import core.cache.Cache;
|
||||
import core.game.node.entity.npc.NPC;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.entity.player.link.music.MusicEntry;
|
||||
import core.game.node.entity.player.link.music.MusicZone;
|
||||
import core.game.system.communication.CommunicationInfo;
|
||||
import core.game.system.task.Pulse;
|
||||
@@ -62,9 +61,9 @@ public class Region {
|
||||
private final List<RegionZone> regionZones = new ArrayList<>(20);
|
||||
|
||||
/**
|
||||
* The region-wide music track for this region.
|
||||
* The region-wide music track ID for this region.
|
||||
*/
|
||||
private MusicEntry music = null;
|
||||
private int music = -1;
|
||||
|
||||
/**
|
||||
* Any tile-specific music zones lying in this region.
|
||||
@@ -481,15 +480,15 @@ public class Region {
|
||||
/**
|
||||
* Sets the region-wide music track.
|
||||
*/
|
||||
public void setMusic(MusicEntry music) {
|
||||
public void setMusic(int music) {
|
||||
this.music = music;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the region-wide music track
|
||||
* @return The music entry
|
||||
* @return The music entry ID
|
||||
*/
|
||||
public MusicEntry getMusic() {
|
||||
public int getMusic() {
|
||||
return this.music;
|
||||
}
|
||||
|
||||
|
||||
@@ -410,13 +410,13 @@ public final class ZoneMonitor {
|
||||
return;
|
||||
}
|
||||
}
|
||||
MusicEntry music = r.getMusic();
|
||||
if (music == null) {
|
||||
int music = r.getMusic();
|
||||
if (music == -1) {
|
||||
if (!player.getMusicPlayer().isPlaying()) {
|
||||
player.getMusicPlayer().playDefault();
|
||||
}
|
||||
} else {
|
||||
player.getMusicPlayer().play(music);
|
||||
player.getMusicPlayer().unlock(music, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user