Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add play sound message #370

Open
wants to merge 3 commits into
base: kotlin-experiments
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package org.apollo.game.message.impl;

import org.apollo.net.message.Message;

/**
* A {@link Message} sent to the client to play a sound.
*
* @author tlf30
*/
public final class SendPlaySoundMessage extends Message {

/**
* The id of the sound to play.
*/
private final int id;

/**
* The delay that the client should use before playing the sound.
* Deplay is measured in milliseconds.
*/
private final int delay;

/**
* The type of sound to play.
* Usually 0.
*/
private final int type;

/**
* Creates a new send play sound message.
*
* @param id The id of the sound to play.
* @param type The type of the sound to play, usually 0.
* @param delay The delay in milliseconds before the client plays the sound
*/
public SendPlaySoundMessage(int id, int type, int delay) {
this.id = id;
this.type = type;
this.delay = delay;
}

/**
* Gets the id of the sound.
*
* @return The id of the sound.
*/
public int getId() {
return id;
}

/**
* Gets the type of the sound.
*
* @return The type of the sound.
*/
public int getType() {
return type;
}

/**
* Gets the number of milliseconds for the client to delay before playing the sound.
*
* @return The delay of the sound in milliseconds.
*/
public int getDelay() {
return delay;
}

}
51 changes: 3 additions & 48 deletions game/src/main/java/org/apollo/game/release/r377/Release377.java
Original file line number Diff line number Diff line change
@@ -1,53 +1,6 @@
package org.apollo.game.release.r377;

import org.apollo.game.message.impl.ClearRegionMessage;
import org.apollo.game.message.impl.CloseInterfaceMessage;
import org.apollo.game.message.impl.ConfigMessage;
import org.apollo.game.message.impl.DisplayCrossbonesMessage;
import org.apollo.game.message.impl.DisplayTabInterfaceMessage;
import org.apollo.game.message.impl.EnterAmountMessage;
import org.apollo.game.message.impl.FlashTabInterfaceMessage;
import org.apollo.game.message.impl.ForwardPrivateChatMessage;
import org.apollo.game.message.impl.FriendServerStatusMessage;
import org.apollo.game.message.impl.GroupedRegionUpdateMessage;
import org.apollo.game.message.impl.IdAssignmentMessage;
import org.apollo.game.message.impl.IgnoreListMessage;
import org.apollo.game.message.impl.LogoutMessage;
import org.apollo.game.message.impl.MobHintIconMessage;
import org.apollo.game.message.impl.NpcSynchronizationMessage;
import org.apollo.game.message.impl.OpenDialogueInterfaceMessage;
import org.apollo.game.message.impl.OpenDialogueOverlayMessage;
import org.apollo.game.message.impl.OpenInterfaceMessage;
import org.apollo.game.message.impl.OpenInterfaceSidebarMessage;
import org.apollo.game.message.impl.OpenOverlayMessage;
import org.apollo.game.message.impl.OpenSidebarMessage;
import org.apollo.game.message.impl.PlayerSynchronizationMessage;
import org.apollo.game.message.impl.PositionHintIconMessage;
import org.apollo.game.message.impl.PrivacyOptionMessage;
import org.apollo.game.message.impl.RegionChangeMessage;
import org.apollo.game.message.impl.RemoveObjectMessage;
import org.apollo.game.message.impl.RemoveTileItemMessage;
import org.apollo.game.message.impl.SendFriendMessage;
import org.apollo.game.message.impl.SendObjectMessage;
import org.apollo.game.message.impl.SendProjectileMessage;
import org.apollo.game.message.impl.SendPublicTileItemMessage;
import org.apollo.game.message.impl.SendTileItemMessage;
import org.apollo.game.message.impl.ServerChatMessage;
import org.apollo.game.message.impl.SetPlayerActionMessage;
import org.apollo.game.message.impl.SetUpdatedRegionMessage;
import org.apollo.game.message.impl.SetWidgetItemModelMessage;
import org.apollo.game.message.impl.SetWidgetModelAnimationMessage;
import org.apollo.game.message.impl.SetWidgetNpcModelMessage;
import org.apollo.game.message.impl.SetWidgetPlayerModelMessage;
import org.apollo.game.message.impl.SetWidgetTextMessage;
import org.apollo.game.message.impl.SetWidgetVisibilityMessage;
import org.apollo.game.message.impl.SwitchTabInterfaceMessage;
import org.apollo.game.message.impl.UpdateItemsMessage;
import org.apollo.game.message.impl.UpdateRunEnergyMessage;
import org.apollo.game.message.impl.UpdateSkillMessage;
import org.apollo.game.message.impl.UpdateSlottedItemsMessage;
import org.apollo.game.message.impl.UpdateTileItemMessage;
import org.apollo.game.message.impl.UpdateWeightMessage;
import org.apollo.game.message.impl.*;
import org.apollo.net.meta.PacketMetaDataGroup;
import org.apollo.net.release.Release;

Expand Down Expand Up @@ -226,6 +179,8 @@ private void init() {
register(OpenSidebarMessage.class, new OpenSidebarMessageEncoder());
register(OpenOverlayMessage.class, new OpenOverlayMessageEncoder());
register(OpenDialogueOverlayMessage.class, new OpenDialogueOverlayMessageEncoder());

register(SendPlaySoundMessage.class, new SendPlaySoundMessageEncoder());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.apollo.game.release.r377;

import org.apollo.game.message.impl.SendPlaySoundMessage;
import org.apollo.net.codec.game.DataType;
import org.apollo.net.codec.game.GamePacket;
import org.apollo.net.codec.game.GamePacketBuilder;
import org.apollo.net.release.MessageEncoder;

/**
* A {@link MessageEncoder} for the {@link SendPlaySoundMessage}.
*
* @author tlf30
*/
public final class SendPlaySoundMessageEncoder extends MessageEncoder<SendPlaySoundMessage> {

@Override
public GamePacket encode(SendPlaySoundMessage message) {
GamePacketBuilder builder = new GamePacketBuilder(26);
builder.put(DataType.SHORT, message.getId());
builder.put(DataType.BYTE, message.getType());
builder.put(DataType.SHORT, message.getDelay());
return builder.toGamePacket();
}

}