mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-27 02:49:15 +00:00
补一个声音的
This commit is contained in:
@@ -103,6 +103,7 @@ warning.config.vanilla_loot.type_not_exist: "<yellow>Issue found in file <arg:0>
|
||||
warning.config.vanilla_loot.block.invalid_target: "<yellow>Issue found in file <arg:0> - Invalid block target [<arg:2>] in vanilla loot '<arg:1>'.</yellow>"
|
||||
warning.config.sound.duplicated: "<yellow>Issue found in file <arg:0> - Duplicated sound '<arg:1>'.</yellow>"
|
||||
warning.config.sound.lack_sounds: "<yellow>Issue found in file <arg:0> - The sound '<arg:1>' is missing the required argument 'sounds'.</yellow>"
|
||||
warning.config.sound.lack_name: "<yellow>Issue found in file <arg:0> - The sound '<arg:1>' is missing the required argument 'name'.</yellow>"
|
||||
warning.config.jukebox_song.duplicated: "<yellow>Issue found in file <arg:0> - Duplicated jukebox song '<arg:1>'.</yellow>"
|
||||
warning.config.jukebox_song.lack_sound: "<yellow>Issue found in file <arg:0> - The jukebox song '<arg:1>' is missing the required 'sound' argument.</yellow>"
|
||||
warning.config.furniture.duplicated: "<yellow>Issue found in file <arg:0> - Duplicated furniture '<arg:1>'.</yellow>"
|
||||
|
||||
@@ -3,6 +3,7 @@ package net.momirealms.craftengine.core.sound;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
|
||||
import net.momirealms.craftengine.core.util.MiscUtils;
|
||||
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
|
||||
|
||||
@@ -51,13 +52,11 @@ public interface Sound extends Supplier<JsonElement> {
|
||||
}
|
||||
|
||||
public static SoundFile fromMap(Map<String, Object> map) {
|
||||
String name = (String) map.get("name");
|
||||
if (name == null) throw new IllegalArgumentException("Missing 'name' for sound");
|
||||
Builder builder = file(name);
|
||||
Object name = map.get("name");
|
||||
if (name == null) throw new LocalizedResourceConfigException("warning.config.sound.lack_name", new NullPointerException("Missing required property 'name'"));
|
||||
Builder builder = file(name.toString());
|
||||
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
||||
Optional.ofNullable(Builder.MODIFIERS.get(entry.getKey())).ifPresent(modifier -> {
|
||||
modifier.apply(builder, entry.getValue());
|
||||
});
|
||||
Optional.ofNullable(Builder.MODIFIERS.get(entry.getKey())).ifPresent(modifier -> modifier.apply(builder, entry.getValue()));
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user