-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add SendPlaySoundMessage and supporting code.
- Loading branch information
Showing
2 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
67 changes: 67 additions & 0 deletions
67
game/src/main/java/org/apollo/game/message/impl/SendPlaySoundMessage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
game/src/main/java/org/apollo/game/release/r377/SendPlaySoundMessageEncoder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
|
||
} |