Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-09-08 20:43:04 +02:00
Add message when playing record (#549)
It appears that the record message is client-sided in Java Edition, so this sends a message whenever a record is played in-world.
Dieser Commit ist enthalten in:
Ursprung
278f59103e
Commit
d5c14921e9
@ -33,6 +33,7 @@ import com.nukkitx.protocol.bedrock.data.LevelEventType;
|
|||||||
import com.nukkitx.protocol.bedrock.data.SoundEvent;
|
import com.nukkitx.protocol.bedrock.data.SoundEvent;
|
||||||
import com.nukkitx.protocol.bedrock.packet.LevelEventPacket;
|
import com.nukkitx.protocol.bedrock.packet.LevelEventPacket;
|
||||||
import com.nukkitx.protocol.bedrock.packet.LevelSoundEventPacket;
|
import com.nukkitx.protocol.bedrock.packet.LevelSoundEventPacket;
|
||||||
|
import com.nukkitx.protocol.bedrock.packet.TextPacket;
|
||||||
import org.geysermc.connector.GeyserConnector;
|
import org.geysermc.connector.GeyserConnector;
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||||
@ -40,6 +41,10 @@ import org.geysermc.connector.network.translators.Translator;
|
|||||||
import org.geysermc.connector.network.translators.world.block.BlockTranslator;
|
import org.geysermc.connector.network.translators.world.block.BlockTranslator;
|
||||||
import org.geysermc.connector.network.translators.effect.Effect;
|
import org.geysermc.connector.network.translators.effect.Effect;
|
||||||
import org.geysermc.connector.utils.EffectUtils;
|
import org.geysermc.connector.utils.EffectUtils;
|
||||||
|
import org.geysermc.connector.utils.LocaleUtils;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Translator(packet = ServerPlayEffectPacket.class)
|
@Translator(packet = ServerPlayEffectPacket.class)
|
||||||
public class JavaPlayEffectTranslator extends PacketTranslator<ServerPlayEffectPacket> {
|
public class JavaPlayEffectTranslator extends PacketTranslator<ServerPlayEffectPacket> {
|
||||||
@ -125,6 +130,22 @@ public class JavaPlayEffectTranslator extends PacketTranslator<ServerPlayEffectP
|
|||||||
if (geyserEffect.getJavaName().equals("RECORD")) {
|
if (geyserEffect.getJavaName().equals("RECORD")) {
|
||||||
RecordEffectData recordEffectData = (RecordEffectData) packet.getData();
|
RecordEffectData recordEffectData = (RecordEffectData) packet.getData();
|
||||||
soundEvent.setSound(EffectUtils.RECORDS.get(recordEffectData.getRecordId()));
|
soundEvent.setSound(EffectUtils.RECORDS.get(recordEffectData.getRecordId()));
|
||||||
|
if (EffectUtils.RECORDS.get(recordEffectData.getRecordId()) != SoundEvent.STOP_RECORD) {
|
||||||
|
// Send text packet as it seems to be handled in Java Edition client-side.
|
||||||
|
TextPacket textPacket = new TextPacket();
|
||||||
|
textPacket.setType(TextPacket.Type.JUKEBOX_POPUP);
|
||||||
|
textPacket.setNeedsTranslation(true);
|
||||||
|
textPacket.setXuid("");
|
||||||
|
textPacket.setPlatformChatId("");
|
||||||
|
textPacket.setSourceName(null);
|
||||||
|
textPacket.setMessage("record.nowPlaying");
|
||||||
|
List<String> params = new ArrayList<>();
|
||||||
|
// Couldn't figure out how to set this to Bedrock translation so it just uses the Java translation
|
||||||
|
String recordString = "item.minecraft." + EffectUtils.RECORDS.get(recordEffectData.getRecordId()).name().toLowerCase().replace("record_", "music_disc_") + ".desc";
|
||||||
|
params.add(LocaleUtils.getLocaleString(recordString, session.getClientData().getLanguageCode()));
|
||||||
|
textPacket.setParameters(params);
|
||||||
|
session.sendUpstreamPacket(textPacket);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
soundEvent.setSound(SoundEvent.valueOf(geyserEffect.getBedrockName()));
|
soundEvent.setSound(SoundEvent.valueOf(geyserEffect.getBedrockName()));
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren