use of org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutStopSounds in project LanternServer by LanternPowered.
the class CommandStopSound method completeSpec.
@Override
public void completeSpec(PluginContainer pluginContainer, CommandSpec.Builder specBuilder) {
specBuilder.arguments(GenericArguments.player(Text.of("player")), GenericArguments.optional(GenericArguments.catalogedElement(Text.of("category"), SoundCategory.class)), GenericArguments.optional(GenericArguments.catalogedElement(Text.of("sound"), SoundType.class))).executor((src, args) -> {
SoundCategory category = args.<SoundCategory>getOne("category").orElse(null);
String type = args.<SoundType>getOne("sound").map(CatalogType::getId).orElse(null);
LanternPlayer player = args.<LanternPlayer>getOne("player").get();
player.getConnection().send(new MessagePlayOutStopSounds(type, category));
return CommandResult.success();
});
}
use of org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutStopSounds in project LanternServer by LanternPowered.
the class CodecPlayInOutCustomPayload method encode0.
@Override
protected MessageResult encode0(CodecContext context, Message message) throws CodecException {
if (message instanceof MessagePlayInOutBrand) {
return new MessageResult("MC|Brand", context.byteBufAlloc().buffer().writeString(((MessagePlayInOutBrand) message).getBrand()));
} else if (message instanceof MessagePlayOutOpenBook) {
final ByteBuffer buf = context.byteBufAlloc().buffer();
buf.writeVarInt(((MessagePlayOutOpenBook) message).getHandType() == HandTypes.MAIN_HAND ? 0 : 1);
return new MessageResult("MC|BOpen", buf);
} else if (message instanceof MessagePlayOutStopSounds) {
final MessagePlayOutStopSounds message0 = (MessagePlayOutStopSounds) message;
final ByteBuffer buf = context.byteBufAlloc().buffer();
buf.writeString(message0.getCategory() == null ? "" : message0.getCategory().getName());
buf.writeString(message0.getSound() == null ? "" : message0.getSound());
return new MessageResult("MC|StopSound", buf);
}
throw new EncoderException("Unsupported message type: " + message);
}
Aggregations