Skip to content

Commit

Permalink
Add SendPlaySoundMessage and supporting code.
Browse files Browse the repository at this point in the history
  • Loading branch information
tlf30 committed Nov 6, 2017
1 parent 397d9b2 commit 6a7afd2
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
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.
*/
private final int delay;

/**
* The type of sound to play.
*/
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.
* @param delay The delay 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 delay of the sound.
*
* @return The delay of the sound.
*/
public int getDelay() {
return delay;
}

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

import org.apollo.game.message.impl.SendFriendMessage;
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;
import org.apollo.util.NameUtil;

/**
* 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();
}

}

0 comments on commit 6a7afd2

Please sign in to comment.