mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2026-01-04 15:41:38 +00:00
测试翻译报错
This commit is contained in:
@@ -115,4 +115,7 @@ warning.config.model.generation.parent.invalid_resource_location: "<yellow>Issue
|
||||
warning.config.emoji.lack_keywords: "<yellow>Issue found in file <arg:0> - The emoji '<arg:1>' is missing the required 'keywords' argument.</yellow>"
|
||||
warning.config.emoji.duplicated: "<yellow>Issue found in file <arg:0> - Duplicated emoji '<arg:1>'.</yellow>"
|
||||
warning.config.emoji.invalid_image: "<yellow>Issue found in file <arg:0> - The emoji '<arg:1>' has an invalid 'image' argument '<arg:2>'.</yellow>"
|
||||
warning.config.advancement.duplicated: "<yellow>Issue found in file <arg:0> - Duplicated advancement '<arg:1>'.</yellow>"
|
||||
warning.config.advancement.duplicated: "<yellow>Issue found in file <arg:0> - Duplicated advancement '<arg:1>'.</yellow>"
|
||||
warning.config.host.lack_type: "<yellow>Issue found in config.yml at 'resource-pack.delivery.hosting' - Missing require argument 'type' for host."
|
||||
warning.config.host.invalid_type: "<yellow>Issue found in config.yml at 'resource-pack.delivery.hosting' - Host 'type' [<arg:0>] is invalid. Please read https://mo-mi.gitbook.io/xiaomomi-plugins/craftengine/plugin-wiki/craftengine/resource-pack/host"
|
||||
warning.config.host.external.lack_url: "<yellow>Issue found in config.yml at 'resource-pack.delivery.hosting' - Missing require argument 'url' for external host."
|
||||
@@ -21,6 +21,8 @@ import net.momirealms.craftengine.core.plugin.config.Config;
|
||||
import net.momirealms.craftengine.core.plugin.config.ConfigSectionParser;
|
||||
import net.momirealms.craftengine.core.plugin.config.StringKeyConstructor;
|
||||
import net.momirealms.craftengine.core.plugin.locale.I18NData;
|
||||
import net.momirealms.craftengine.core.plugin.locale.LocalizedException;
|
||||
import net.momirealms.craftengine.core.plugin.locale.TranslationManager;
|
||||
import net.momirealms.craftengine.core.sound.AbstractSoundManager;
|
||||
import net.momirealms.craftengine.core.sound.SoundEvent;
|
||||
import net.momirealms.craftengine.core.util.*;
|
||||
@@ -151,7 +153,12 @@ public abstract class AbstractPackManager implements PackManager {
|
||||
if (list == null || list.isEmpty()) {
|
||||
this.resourcePackHost = NoneHost.INSTANCE;
|
||||
} else {
|
||||
this.resourcePackHost = ResourcePackHosts.fromMap(MiscUtils.castToMap(list.get(0), false));
|
||||
try {
|
||||
this.resourcePackHost = ResourcePackHosts.fromMap(MiscUtils.castToMap(list.get(0), false));
|
||||
} catch (LocalizedException e) {
|
||||
TranslationManager.instance().log(e.node(), e.arguments());
|
||||
this.resourcePackHost = NoneHost.INSTANCE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package net.momirealms.craftengine.core.pack.host;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.momirealms.craftengine.core.pack.host.impl.*;
|
||||
import net.momirealms.craftengine.core.plugin.locale.LocalizedException;
|
||||
import net.momirealms.craftengine.core.registry.BuiltInRegistries;
|
||||
import net.momirealms.craftengine.core.registry.Holder;
|
||||
import net.momirealms.craftengine.core.registry.Registries;
|
||||
@@ -42,12 +44,12 @@ public class ResourcePackHosts {
|
||||
public static ResourcePackHost fromMap(Map<String, Object> map) {
|
||||
String type = (String) map.get("type");
|
||||
if (type == null) {
|
||||
throw new NullPointerException("host type cannot be null");
|
||||
throw new LocalizedException("warning.config.host.external.lack_url");
|
||||
}
|
||||
Key key = Key.withDefaultNamespace(type, "craftengine");
|
||||
ResourcePackHostFactory factory = BuiltInRegistries.RESOURCE_PACK_HOST_FACTORY.getValue(key);
|
||||
if (factory == null) {
|
||||
throw new IllegalArgumentException("Unknown resource pack host type: " + type);
|
||||
throw new LocalizedException("warning.config.host.invalid_type", type);
|
||||
}
|
||||
return factory.create(map);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import net.momirealms.craftengine.core.pack.host.ResourcePackDownloadData;
|
||||
import net.momirealms.craftengine.core.pack.host.ResourcePackHost;
|
||||
import net.momirealms.craftengine.core.pack.host.ResourcePackHostFactory;
|
||||
import net.momirealms.craftengine.core.pack.host.ResourcePackHosts;
|
||||
import net.momirealms.craftengine.core.plugin.locale.LocalizedException;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
|
||||
import java.nio.file.Path;
|
||||
@@ -46,7 +47,7 @@ public class ExternalHost implements ResourcePackHost {
|
||||
public ResourcePackHost create(Map<String, Object> arguments) {
|
||||
String url = (String) arguments.get("url");
|
||||
if (url == null || url.isEmpty()) {
|
||||
throw new IllegalArgumentException("'url' cannot be empty for external host");
|
||||
throw new LocalizedException("warning.config.host.external.lack_url");
|
||||
}
|
||||
String uuid = (String) arguments.get("uuid");
|
||||
if (uuid == null || uuid.isEmpty()) {
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package net.momirealms.craftengine.core.plugin.event;
|
||||
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
|
||||
public class Trigger {
|
||||
private final Key id;
|
||||
|
||||
public Trigger(Key id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Key id() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package net.momirealms.craftengine.core.plugin.event;
|
||||
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class Triggers {
|
||||
public static final Map<Key, Trigger> TRIGGERS = new HashMap<>();
|
||||
|
||||
public static final Trigger USE_ITEM = create(Key.of("use_item"));
|
||||
public static final Trigger INTERACT = create(Key.of("interact"));
|
||||
public static final Trigger CONSUME = create(Key.of("consume"));
|
||||
public static final Trigger BREAK = create(Key.of("break"));
|
||||
|
||||
private static Trigger create(Key id) {
|
||||
Trigger trigger = new Trigger(id);
|
||||
TRIGGERS.put(id, trigger);
|
||||
return trigger;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package net.momirealms.craftengine.core.plugin.locale;
|
||||
|
||||
public class LocalizedException extends RuntimeException {
|
||||
private final String node;
|
||||
private final String[] arguments;
|
||||
|
||||
public LocalizedException(String node, String... arguments) {
|
||||
super(node);
|
||||
this.node = node;
|
||||
this.arguments = arguments;
|
||||
}
|
||||
|
||||
public String[] arguments() {
|
||||
return arguments;
|
||||
}
|
||||
|
||||
public String node() {
|
||||
return node;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx1G
|
||||
|
||||
# Project settings
|
||||
# Rule: [major update].[feature update].[bug fix]
|
||||
project_version=0.0.50-beta.1
|
||||
project_version=0.0.50-beta.2
|
||||
config_version=30
|
||||
lang_version=7
|
||||
project_group=net.momirealms
|
||||
|
||||
Reference in New Issue
Block a user