mirror of
https://github.com/Melledy/Nebula.git
synced 2026-09-19 17:19:58 +02:00
Implement setting disc music as main theme
This commit is contained in:
@@ -75,6 +75,7 @@ public class Player implements GameDatabaseObject {
|
||||
private int skinId;
|
||||
private int titlePrefix;
|
||||
private int titleSuffix;
|
||||
private long music;
|
||||
private int[] honor;
|
||||
private int[] showChars;
|
||||
private int[] boards;
|
||||
@@ -344,6 +345,22 @@ public class Player implements GameDatabaseObject {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean setMusic(long id) {
|
||||
// Make sure we own the disc
|
||||
if (id != 0 && !this.getCharacters().hasDisc((int) id)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set main menu music
|
||||
this.music = id;
|
||||
|
||||
// Update in database
|
||||
Nebula.getGameDatabase().update(this, this.getUid(), "music", this.getMusic());
|
||||
|
||||
// Success
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean setSkin(int skinId) {
|
||||
// Skip if we are setting the same skin
|
||||
if (this.skinId == skinId) {
|
||||
@@ -871,6 +888,7 @@ public class Player implements GameDatabaseObject {
|
||||
.setSigninIndex(this.getSignInIndex())
|
||||
.setTowerTicket(this.getProgress().getTowerTickets())
|
||||
.setDailyShopRewardStatus(this.getQuestManager().hasDailyReward())
|
||||
.setMusicInfo(this.getMusic())
|
||||
.setAchievements(new byte[64]);
|
||||
|
||||
var acc = proto.getMutableAcc()
|
||||
|
||||
@@ -2,6 +2,7 @@ package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.proto.Public.I64;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@@ -10,7 +11,18 @@ public class HandlerPlayerMusicSetReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
return session.encodeMsg(NetMsgId.player_music_set_failed_ack);
|
||||
// Parse request
|
||||
var req = I64.parseFrom(message);
|
||||
|
||||
// Set music
|
||||
boolean success = session.getPlayer().setMusic(req.getValue());
|
||||
|
||||
if (success == false) {
|
||||
return session.encodeMsg(NetMsgId.player_music_set_failed_ack);
|
||||
}
|
||||
|
||||
// Encode and send
|
||||
return session.encodeMsg(NetMsgId.player_music_set_succeed_ack);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user