forked from GeyserMC/Geyser
Nitpicks and add serverbound sound packet translator
This commit is contained in:
parent
12b99c5b1b
commit
987edbb217
7 changed files with 173 additions and 64 deletions
|
@ -0,0 +1,41 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @author GeyserMC
|
||||||
|
* @link https://github.com/GeyserMC/Geyser
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.geysermc.connector.network.translators.bedrock;
|
||||||
|
|
||||||
|
import com.nukkitx.protocol.bedrock.packet.LevelSoundEventPacket;
|
||||||
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
|
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||||
|
import org.geysermc.connector.network.translators.Translator;
|
||||||
|
|
||||||
|
@Translator(packet = LevelSoundEventPacket.class)
|
||||||
|
public class BedrockLevelSoundEventTranslator extends PacketTranslator<LevelSoundEventPacket> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void translate(LevelSoundEventPacket packet, GeyserSession session) {
|
||||||
|
// lol what even :thinking:
|
||||||
|
session.getUpstream().sendPacket(packet);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,3 +1,28 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @author GeyserMC
|
||||||
|
* @link https://github.com/GeyserMC/Geyser
|
||||||
|
*/
|
||||||
|
|
||||||
package org.geysermc.connector.network.translators.java.entity.player;
|
package org.geysermc.connector.network.translators.java.entity.player;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.data.game.world.sound.BuiltinSound;
|
import com.github.steveice10.mc.protocol.data.game.world.sound.BuiltinSound;
|
||||||
|
@ -8,15 +33,11 @@ import com.nukkitx.protocol.bedrock.packet.*;
|
||||||
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;
|
||||||
import org.geysermc.connector.network.translators.Translator;
|
import org.geysermc.connector.network.translators.Translator;
|
||||||
import org.geysermc.connector.sound.SoundMap;
|
import org.geysermc.connector.utils.SoundUtils;
|
||||||
|
|
||||||
@Translator(packet = ServerPlaySoundPacket.class)
|
@Translator(packet = ServerPlaySoundPacket.class)
|
||||||
public class JavaPlayerPlaySoundTranslator extends PacketTranslator<ServerPlaySoundPacket> {
|
public class JavaPlayerPlaySoundTranslator extends PacketTranslator<ServerPlaySoundPacket> {
|
||||||
|
|
||||||
public static double processCoordinate(double f) {
|
|
||||||
return (f / 3D) * 8D;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void translate(ServerPlaySoundPacket packet, GeyserSession session) {
|
public void translate(ServerPlaySoundPacket packet, GeyserSession session) {
|
||||||
String packetSound;
|
String packetSound;
|
||||||
|
@ -29,7 +50,7 @@ public class JavaPlayerPlaySoundTranslator extends PacketTranslator<ServerPlaySo
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SoundMap.SoundMapping soundMapping = SoundMap.get().fromJava(packetSound);
|
SoundUtils.SoundMapping soundMapping = SoundUtils.fromJava(packetSound);
|
||||||
session.getConnector().getLogger()
|
session.getConnector().getLogger()
|
||||||
.debug("[PlaySound] Sound mapping " + packetSound + " -> "
|
.debug("[PlaySound] Sound mapping " + packetSound + " -> "
|
||||||
+ soundMapping + (soundMapping == null ? "[not found]" : "")
|
+ soundMapping + (soundMapping == null ? "[not found]" : "")
|
||||||
|
@ -46,7 +67,7 @@ public class JavaPlayerPlaySoundTranslator extends PacketTranslator<ServerPlaySo
|
||||||
|
|
||||||
PlaySoundPacket playSoundPacket = new PlaySoundPacket();
|
PlaySoundPacket playSoundPacket = new PlaySoundPacket();
|
||||||
playSoundPacket.setSound(playsound);
|
playSoundPacket.setSound(playsound);
|
||||||
playSoundPacket.setPosition(Vector3f.from(processCoordinate(packet.getX()), processCoordinate(packet.getY()), processCoordinate(packet.getZ())));
|
playSoundPacket.setPosition(Vector3f.from(SoundUtils.processCoordinate(packet.getX()), SoundUtils.processCoordinate(packet.getY()), SoundUtils.processCoordinate(packet.getZ())));
|
||||||
playSoundPacket.setVolume(packet.getVolume());
|
playSoundPacket.setVolume(packet.getVolume());
|
||||||
playSoundPacket.setPitch(packet.getPitch());
|
playSoundPacket.setPitch(packet.getPitch());
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,28 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @author GeyserMC
|
||||||
|
* @link https://github.com/GeyserMC/Geyser
|
||||||
|
*/
|
||||||
|
|
||||||
package org.geysermc.connector.network.translators.java.entity.player;
|
package org.geysermc.connector.network.translators.java.entity.player;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.data.game.world.sound.BuiltinSound;
|
import com.github.steveice10.mc.protocol.data.game.world.sound.BuiltinSound;
|
||||||
|
@ -7,7 +32,7 @@ import com.nukkitx.protocol.bedrock.packet.StopSoundPacket;
|
||||||
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;
|
||||||
import org.geysermc.connector.network.translators.Translator;
|
import org.geysermc.connector.network.translators.Translator;
|
||||||
import org.geysermc.connector.sound.SoundMap;
|
import org.geysermc.connector.utils.SoundUtils;
|
||||||
|
|
||||||
@Translator(packet = ServerStopSoundPacket.class)
|
@Translator(packet = ServerStopSoundPacket.class)
|
||||||
public class JavaPlayerStopSoundTranslator extends PacketTranslator<ServerStopSoundPacket> {
|
public class JavaPlayerStopSoundTranslator extends PacketTranslator<ServerStopSoundPacket> {
|
||||||
|
@ -23,7 +48,7 @@ public class JavaPlayerStopSoundTranslator extends PacketTranslator<ServerStopSo
|
||||||
session.getConnector().getLogger().debug("Unknown sound packet, we were unable to map this. " + packet.toString());
|
session.getConnector().getLogger().debug("Unknown sound packet, we were unable to map this. " + packet.toString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SoundMap.SoundMapping soundMapping = SoundMap.get().fromJava(packetSound);
|
SoundUtils.SoundMapping soundMapping = SoundUtils.fromJava(packetSound);
|
||||||
session.getConnector().getLogger()
|
session.getConnector().getLogger()
|
||||||
.debug("[StopSound] Sound mapping " + packetSound + " -> "
|
.debug("[StopSound] Sound mapping " + packetSound + " -> "
|
||||||
+ soundMapping + (soundMapping == null ? "[not found]" : "")
|
+ soundMapping + (soundMapping == null ? "[not found]" : "")
|
||||||
|
|
|
@ -1,3 +1,28 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @author GeyserMC
|
||||||
|
* @link https://github.com/GeyserMC/Geyser
|
||||||
|
*/
|
||||||
|
|
||||||
package org.geysermc.connector.network.translators.java.world;
|
package org.geysermc.connector.network.translators.java.world;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerPlayBuiltinSoundPacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerPlayBuiltinSoundPacket;
|
||||||
|
@ -7,7 +32,7 @@ import com.nukkitx.protocol.bedrock.packet.LevelSoundEventPacket;
|
||||||
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;
|
||||||
import org.geysermc.connector.network.translators.Translator;
|
import org.geysermc.connector.network.translators.Translator;
|
||||||
import org.geysermc.connector.sound.SoundMap;
|
import org.geysermc.connector.utils.SoundUtils;
|
||||||
|
|
||||||
@Translator(packet = ServerPlayBuiltinSoundPacket.class)
|
@Translator(packet = ServerPlayBuiltinSoundPacket.class)
|
||||||
public class JavaPlayBuiltinSoundTranslator extends PacketTranslator<ServerPlayBuiltinSoundPacket> {
|
public class JavaPlayBuiltinSoundTranslator extends PacketTranslator<ServerPlayBuiltinSoundPacket> {
|
||||||
|
@ -16,7 +41,7 @@ public class JavaPlayBuiltinSoundTranslator extends PacketTranslator<ServerPlayB
|
||||||
public void translate(ServerPlayBuiltinSoundPacket packet, GeyserSession session) {
|
public void translate(ServerPlayBuiltinSoundPacket packet, GeyserSession session) {
|
||||||
String packetSound = packet.getSound().getName();
|
String packetSound = packet.getSound().getName();
|
||||||
|
|
||||||
SoundMap.SoundMapping soundMapping = SoundMap.get().fromJava(packetSound);
|
SoundUtils.SoundMapping soundMapping = SoundUtils.fromJava(packetSound);
|
||||||
session.getConnector().getLogger()
|
session.getConnector().getLogger()
|
||||||
.debug("[Builtin] Sound mapping " + packetSound + " -> "
|
.debug("[Builtin] Sound mapping " + packetSound + " -> "
|
||||||
+ soundMapping + (soundMapping == null ? "[not found]" : "")
|
+ soundMapping + (soundMapping == null ? "[not found]" : "")
|
||||||
|
@ -26,11 +51,11 @@ public class JavaPlayBuiltinSoundTranslator extends PacketTranslator<ServerPlayB
|
||||||
}
|
}
|
||||||
|
|
||||||
LevelSoundEventPacket soundPacket = new LevelSoundEventPacket();
|
LevelSoundEventPacket soundPacket = new LevelSoundEventPacket();
|
||||||
SoundEvent sound = SoundMap.toSoundEvent(soundMapping.getBedrock());
|
SoundEvent sound = SoundUtils.toSoundEvent(soundMapping.getBedrock());
|
||||||
if(sound == null) {
|
if(sound == null) {
|
||||||
sound = SoundMap.toSoundEvent(soundMapping.getBedrock());
|
sound = SoundUtils.toSoundEvent(soundMapping.getBedrock());
|
||||||
if(sound == null) {
|
if(sound == null) {
|
||||||
sound = SoundMap.toSoundEvent(packetSound);
|
sound = SoundUtils.toSoundEvent(packetSound);
|
||||||
if(sound == null) {
|
if(sound == null) {
|
||||||
session.getConnector().getLogger()
|
session.getConnector().getLogger()
|
||||||
.debug("[Builtin] Sound for original " + packetSound + " to mappings " + soundPacket
|
.debug("[Builtin] Sound for original " + packetSound + " to mappings " + soundPacket
|
||||||
|
|
|
@ -1,29 +1,51 @@
|
||||||
package org.geysermc.connector.sound;
|
/*
|
||||||
|
* Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @author GeyserMC
|
||||||
|
* @link https://github.com/GeyserMC/Geyser
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.geysermc.connector.utils;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.nukkitx.protocol.bedrock.data.SoundEvent;
|
import com.nukkitx.protocol.bedrock.data.SoundEvent;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
import org.geysermc.connector.utils.Toolbox;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class SoundMap {
|
public class SoundUtils {
|
||||||
|
|
||||||
private static SoundMap instance;
|
private static final Map<String, SoundMapping> SOUNDS;
|
||||||
|
|
||||||
public static SoundMap get() {
|
public static void init() {
|
||||||
if(instance == null) {
|
// no-op
|
||||||
instance = new SoundMap(make());
|
|
||||||
}
|
|
||||||
return instance;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ArrayList<SoundMapping> make() {
|
static {
|
||||||
/* Load sound mappings */
|
/* Load sound mappings */
|
||||||
InputStream stream = Toolbox.getResource("mappings/sounds.json");
|
InputStream stream = Toolbox.getResource("mappings/sounds.json");
|
||||||
JsonNode soundsTree;
|
JsonNode soundsTree;
|
||||||
|
@ -33,14 +55,13 @@ public class SoundMap {
|
||||||
throw new AssertionError("Unable to load sound mappings", e);
|
throw new AssertionError("Unable to load sound mappings", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<SoundMapping> soundMappings = new ArrayList<>();
|
Map<String, SoundMapping> soundMappings = new HashMap<>();
|
||||||
Iterator<Map.Entry<String, JsonNode>> soundsIterator = soundsTree.fields();
|
Iterator<Map.Entry<String, JsonNode>> soundsIterator = soundsTree.fields();
|
||||||
while(soundsIterator.hasNext()) {
|
while(soundsIterator.hasNext()) {
|
||||||
Map.Entry<String, JsonNode> next = soundsIterator.next();
|
Map.Entry<String, JsonNode> next = soundsIterator.next();
|
||||||
JsonNode brMap = next.getValue();
|
JsonNode brMap = next.getValue();
|
||||||
|
|
||||||
soundMappings.add(
|
soundMappings.put(next.getKey(), new SoundMapping(
|
||||||
new SoundMapping(
|
|
||||||
next.getKey(),
|
next.getKey(),
|
||||||
brMap.has("bedrock_mapping") && brMap.get("bedrock_mapping").isTextual() ? brMap.get("bedrock_mapping").asText() : null,
|
brMap.has("bedrock_mapping") && brMap.get("bedrock_mapping").isTextual() ? brMap.get("bedrock_mapping").asText() : null,
|
||||||
brMap.has("playsound_mapping") && brMap.get("playsound_mapping").isTextual() ? brMap.get("playsound_mapping").asText() : null,
|
brMap.has("playsound_mapping") && brMap.get("playsound_mapping").isTextual() ? brMap.get("playsound_mapping").asText() : null,
|
||||||
|
@ -48,15 +69,7 @@ public class SoundMap {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
SOUNDS = soundMappings;
|
||||||
|
|
||||||
return soundMappings;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ArrayList<SoundMapping> sounds;
|
|
||||||
|
|
||||||
public SoundMap(ArrayList<SoundMapping> sounds) {
|
|
||||||
this.sounds = sounds;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -64,35 +77,22 @@ public class SoundMap {
|
||||||
* @param java Java edition sound identifier
|
* @param java Java edition sound identifier
|
||||||
* @return SoundMapping object with information for bedrock, nukkit, java, etc. null if not found
|
* @return SoundMapping object with information for bedrock, nukkit, java, etc. null if not found
|
||||||
*/
|
*/
|
||||||
public SoundMapping fromJava(String java) {
|
public static SoundMapping fromJava(String java) {
|
||||||
for (SoundMapping sound : this.sounds) {
|
return SOUNDS.get(java);
|
||||||
if(sound.getJava().equals(java)) {
|
|
||||||
return sound;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static SoundEvent toSoundEvent(String sound) {
|
||||||
|
|
||||||
public void refresh() {
|
|
||||||
this.sounds = make();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static SoundEvent toSoundEvent(String s) {
|
|
||||||
SoundEvent sound;
|
|
||||||
try {
|
try {
|
||||||
sound = SoundEvent.valueOf(
|
return SoundEvent.valueOf(sound.toUpperCase().replaceAll("\\.", "_"));
|
||||||
s
|
} catch (IllegalArgumentException ex) {
|
||||||
.toUpperCase()
|
|
||||||
.replaceAll("\\.", "_")
|
|
||||||
);
|
|
||||||
return sound;
|
|
||||||
} catch(Exception e) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static double processCoordinate(double f) {
|
||||||
|
return (f / 3D) * 8D;
|
||||||
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@ToString
|
@ToString
|
||||||
public static class SoundMapping {
|
public static class SoundMapping {
|
||||||
|
@ -108,5 +108,4 @@ public class SoundMap {
|
||||||
this.extraData = extraData;
|
this.extraData = extraData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -39,8 +39,6 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
|
|
||||||
import org.geysermc.connector.GeyserConnector;
|
import org.geysermc.connector.GeyserConnector;
|
||||||
import org.geysermc.connector.network.translators.item.ItemEntry;
|
import org.geysermc.connector.network.translators.item.ItemEntry;
|
||||||
import org.geysermc.connector.sound.SoundMap;
|
|
||||||
|
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
@ -109,7 +107,7 @@ public class Toolbox {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load sound mappings
|
// Load sound mappings
|
||||||
SoundMap.get();
|
SoundUtils.init();
|
||||||
// Load the locale data
|
// Load the locale data
|
||||||
LocaleUtils.init();
|
LocaleUtils.init();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit efc9db6b7d51bdf145230933ac23b321ac1c132d
|
Subproject commit 9ecd90c71a26423a5f824554cce9b4236e544723
|
Loading…
Reference in a new issue