mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-30 12:29:15 +00:00
添加铭牌支持
This commit is contained in:
@@ -63,6 +63,8 @@ dependencies {
|
||||
compileOnly("com.github.Zrips:Jobs:v5.2.2.3")
|
||||
// CustomFishing
|
||||
compileOnly("net.momirealms:custom-fishing:2.3.3")
|
||||
// CustomNameplates
|
||||
compileOnly("net.momirealms:custom-nameplates:3.0.33")
|
||||
// eco
|
||||
compileOnly("com.willfp:eco:6.70.1")
|
||||
compileOnly("com.willfp:EcoJobs:3.56.1")
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.momirealms.craftengine.bukkit.compatibility;
|
||||
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import net.momirealms.craftengine.bukkit.block.BukkitBlockManager;
|
||||
import net.momirealms.craftengine.bukkit.compatibility.item.*;
|
||||
import net.momirealms.craftengine.bukkit.compatibility.legacy.slimeworld.LegacySlimeFormatStorageAdaptor;
|
||||
@@ -16,6 +17,8 @@ import net.momirealms.craftengine.bukkit.compatibility.quickshop.QuickShopItemEx
|
||||
import net.momirealms.craftengine.bukkit.compatibility.region.WorldGuardRegionCondition;
|
||||
import net.momirealms.craftengine.bukkit.compatibility.skript.SkriptHook;
|
||||
import net.momirealms.craftengine.bukkit.compatibility.slimeworld.SlimeFormatStorageAdaptor;
|
||||
import net.momirealms.craftengine.bukkit.compatibility.tag.CustomNameplateProviders;
|
||||
import net.momirealms.craftengine.core.plugin.compatibility.TagResolverProvider;
|
||||
import net.momirealms.craftengine.bukkit.compatibility.viaversion.ViaVersionUtils;
|
||||
import net.momirealms.craftengine.bukkit.compatibility.worldedit.WorldEditBlockRegister;
|
||||
import net.momirealms.craftengine.bukkit.font.BukkitFontManager;
|
||||
@@ -29,8 +32,10 @@ import net.momirealms.craftengine.core.plugin.compatibility.CompatibilityManager
|
||||
import net.momirealms.craftengine.core.plugin.compatibility.LevelerProvider;
|
||||
import net.momirealms.craftengine.core.plugin.compatibility.ModelProvider;
|
||||
import net.momirealms.craftengine.core.plugin.config.Config;
|
||||
import net.momirealms.craftengine.core.plugin.context.Context;
|
||||
import net.momirealms.craftengine.core.plugin.context.condition.AlwaysFalseCondition;
|
||||
import net.momirealms.craftengine.core.plugin.context.event.EventConditions;
|
||||
import net.momirealms.craftengine.core.plugin.text.minimessage.FormattedLine;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
import net.momirealms.craftengine.core.util.VersionHelper;
|
||||
import net.momirealms.craftengine.core.world.WorldManager;
|
||||
@@ -43,6 +48,8 @@ public class BukkitCompatibilityManager implements CompatibilityManager {
|
||||
private final BukkitCraftEngine plugin;
|
||||
private final Map<String, ModelProvider> modelProviders;
|
||||
private final Map<String, LevelerProvider> levelerProviders;
|
||||
private final Map<String, TagResolverProvider> tagResolverProviders;
|
||||
private TagResolverProvider[] tagResolverProviderArray = null;
|
||||
private boolean hasPlaceholderAPI;
|
||||
|
||||
public BukkitCompatibilityManager(BukkitCraftEngine plugin) {
|
||||
@@ -52,6 +59,7 @@ public class BukkitCompatibilityManager implements CompatibilityManager {
|
||||
"BetterModel", BetterModelModel::new
|
||||
));
|
||||
this.levelerProviders = new HashMap<>();
|
||||
this.tagResolverProviders = new HashMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -146,6 +154,12 @@ public class BukkitCompatibilityManager implements CompatibilityManager {
|
||||
new QuickShopItemExpressionHandler(this.plugin).register();
|
||||
logHook("QuickShop-Hikari");
|
||||
}
|
||||
if (this.isPluginEnabled("CustomNameplates")) {
|
||||
registerTagResolverProvider(new CustomNameplateProviders.Background());
|
||||
registerTagResolverProvider(new CustomNameplateProviders.Nameplate());
|
||||
registerTagResolverProvider(new CustomNameplateProviders.Bubble());
|
||||
logHook("CustomNameplates");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -158,6 +172,13 @@ public class BukkitCompatibilityManager implements CompatibilityManager {
|
||||
this.levelerProviders.put(plugin, provider);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerTagResolverProvider(TagResolverProvider provider) {
|
||||
this.tagResolverProviders.put(provider.name(), provider);
|
||||
this.tagResolverProviderArray = this.tagResolverProviders.values().toArray(new TagResolverProvider[0]);
|
||||
FormattedLine.Companion.resetWithCustomResolvers(new ArrayList<>(this.tagResolverProviders.keySet()));
|
||||
}
|
||||
|
||||
private void logHook(String plugin) {
|
||||
this.plugin.logger().info("[Compatibility] " + plugin + " hooked");
|
||||
}
|
||||
@@ -326,4 +347,15 @@ public class BukkitCompatibilityManager implements CompatibilityManager {
|
||||
public int getPlayerProtocolVersion(UUID uuid) {
|
||||
return ViaVersionUtils.getPlayerProtocolVersion(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TagResolver[] createExternalTagResolvers(Context context) {
|
||||
if (this.tagResolverProviderArray == null) return null;
|
||||
int length = this.tagResolverProviderArray.length;
|
||||
TagResolver[] resolvers = new TagResolver[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
resolvers[i] = this.tagResolverProviderArray[i].getTagResolver(context);
|
||||
}
|
||||
return resolvers;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package net.momirealms.craftengine.bukkit.compatibility.tag;
|
||||
|
||||
import net.kyori.adventure.text.minimessage.Context;
|
||||
import net.kyori.adventure.text.minimessage.ParsingException;
|
||||
import net.kyori.adventure.text.minimessage.tag.Tag;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.ArgumentQueue;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
||||
import net.momirealms.craftengine.core.plugin.context.PlayerContext;
|
||||
import net.momirealms.craftengine.core.util.AdventureHelper;
|
||||
import net.momirealms.customnameplates.api.CustomNameplatesAPI;
|
||||
import net.momirealms.customnameplates.api.feature.background.Background;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class BackgroundTag implements TagResolver {
|
||||
private final net.momirealms.craftengine.core.plugin.context.Context context;
|
||||
|
||||
public BackgroundTag(net.momirealms.craftengine.core.plugin.context.Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Tag resolve(@NotNull String name, @NotNull ArgumentQueue arguments, @NotNull Context ctx) throws ParsingException {
|
||||
if (!this.has(name)) {
|
||||
return null;
|
||||
}
|
||||
String id = arguments.popOr("No background id provided").toString();
|
||||
Optional<Background> background = CustomNameplatesAPI.getInstance().getBackground(id);
|
||||
if (background.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
double left = arguments.popOr("No argument left provided").asDouble().orElseThrow(() -> ctx.newException("Invalid argument number", arguments));
|
||||
double right = arguments.popOr("No argument right provided").asDouble().orElseThrow(() -> ctx.newException("Invalid argument number", arguments));
|
||||
String content = arguments.popOr("No argument content provided").toString();
|
||||
String parsed = this.context instanceof PlayerContext playerContext ? CraftEngine.instance().compatibilityManager().parse(playerContext.player(), content) : CraftEngine.instance().compatibilityManager().parse(null, content);
|
||||
String textWithImage = CustomNameplatesAPI.getInstance().createTextWithImage(parsed, background.get(), (float) left, (float) right);
|
||||
return Tag.selfClosingInserting(AdventureHelper.miniMessage().deserialize(textWithImage, this.context.tagResolvers()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(@NotNull String name) {
|
||||
return "background".equals(name);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package net.momirealms.craftengine.bukkit.compatibility.tag;
|
||||
|
||||
import net.kyori.adventure.text.minimessage.Context;
|
||||
import net.kyori.adventure.text.minimessage.ParsingException;
|
||||
import net.kyori.adventure.text.minimessage.tag.Tag;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.ArgumentQueue;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
||||
import net.momirealms.craftengine.core.plugin.context.PlayerContext;
|
||||
import net.momirealms.craftengine.core.util.AdventureHelper;
|
||||
import net.momirealms.customnameplates.api.CustomNameplatesAPI;
|
||||
import net.momirealms.customnameplates.api.feature.bubble.Bubble;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class BubbleTag implements TagResolver {
|
||||
private final net.momirealms.craftengine.core.plugin.context.Context context;
|
||||
|
||||
public BubbleTag(net.momirealms.craftengine.core.plugin.context.Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Tag resolve(@NotNull String name, @NotNull ArgumentQueue arguments, @NotNull Context ctx) throws ParsingException {
|
||||
if (!this.has(name)) {
|
||||
return null;
|
||||
}
|
||||
String id = arguments.popOr("No bubble id provided").toString();
|
||||
Optional<Bubble> bubble = CustomNameplatesAPI.getInstance().getBubble(id);
|
||||
if (bubble.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
double left = arguments.popOr("No argument left provided").asDouble().orElseThrow(() -> ctx.newException("Invalid argument number", arguments));
|
||||
double right = arguments.popOr("No argument right provided").asDouble().orElseThrow(() -> ctx.newException("Invalid argument number", arguments));
|
||||
String content = arguments.popOr("No argument content provided").toString();
|
||||
String parsed = this.context instanceof PlayerContext playerContext ? CraftEngine.instance().compatibilityManager().parse(playerContext.player(), content) : CraftEngine.instance().compatibilityManager().parse(null, content);
|
||||
String textWithImage = CustomNameplatesAPI.getInstance().createTextWithImage(parsed, bubble.get(), (float) left, (float) right);
|
||||
return Tag.selfClosingInserting(AdventureHelper.miniMessage().deserialize(textWithImage, this.context.tagResolvers()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(@NotNull String name) {
|
||||
return "bubble".equals(name);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package net.momirealms.craftengine.bukkit.compatibility.tag;
|
||||
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import net.momirealms.craftengine.core.plugin.compatibility.TagResolverProvider;
|
||||
import net.momirealms.craftengine.core.plugin.context.Context;
|
||||
|
||||
public class CustomNameplateProviders {
|
||||
|
||||
public static class Background implements TagResolverProvider {
|
||||
@Override
|
||||
public String name() {
|
||||
return "background";
|
||||
}
|
||||
|
||||
@Override
|
||||
public TagResolver getTagResolver(Context context) {
|
||||
return new BackgroundTag(context);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Nameplate implements TagResolverProvider {
|
||||
@Override
|
||||
public String name() {
|
||||
return "nameplate";
|
||||
}
|
||||
|
||||
@Override
|
||||
public TagResolver getTagResolver(Context context) {
|
||||
return new NameplateTag(context);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Bubble implements TagResolverProvider {
|
||||
@Override
|
||||
public String name() {
|
||||
return "bubble";
|
||||
}
|
||||
|
||||
@Override
|
||||
public TagResolver getTagResolver(Context context) {
|
||||
return new BubbleTag(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package net.momirealms.craftengine.bukkit.compatibility.tag;
|
||||
|
||||
import net.kyori.adventure.text.minimessage.Context;
|
||||
import net.kyori.adventure.text.minimessage.ParsingException;
|
||||
import net.kyori.adventure.text.minimessage.tag.Tag;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.ArgumentQueue;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
||||
import net.momirealms.craftengine.core.plugin.context.PlayerContext;
|
||||
import net.momirealms.craftengine.core.util.AdventureHelper;
|
||||
import net.momirealms.customnameplates.api.CustomNameplatesAPI;
|
||||
import net.momirealms.customnameplates.api.feature.background.Background;
|
||||
import net.momirealms.customnameplates.api.feature.nameplate.Nameplate;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class NameplateTag implements TagResolver {
|
||||
private final net.momirealms.craftengine.core.plugin.context.Context context;
|
||||
|
||||
public NameplateTag(net.momirealms.craftengine.core.plugin.context.Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Tag resolve(@NotNull String name, @NotNull ArgumentQueue arguments, @NotNull Context ctx) throws ParsingException {
|
||||
if (!this.has(name)) {
|
||||
return null;
|
||||
}
|
||||
String id = arguments.popOr("No nameplate id provided").toString();
|
||||
Optional<Nameplate> nameplate = CustomNameplatesAPI.getInstance().getNameplate(id);
|
||||
if (nameplate.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
double left = arguments.popOr("No argument left provided").asDouble().orElseThrow(() -> ctx.newException("Invalid argument number", arguments));
|
||||
double right = arguments.popOr("No argument right provided").asDouble().orElseThrow(() -> ctx.newException("Invalid argument number", arguments));
|
||||
String content = arguments.popOr("No argument content provided").toString();
|
||||
String parsed = this.context instanceof PlayerContext playerContext ? CraftEngine.instance().compatibilityManager().parse(playerContext.player(), content) : CraftEngine.instance().compatibilityManager().parse(null, content);
|
||||
String textWithImage = CustomNameplatesAPI.getInstance().createTextWithImage(parsed, nameplate.get(), (float) left, (float) right);
|
||||
return Tag.selfClosingInserting(AdventureHelper.miniMessage().deserialize(textWithImage, this.context.tagResolvers()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(@NotNull String name) {
|
||||
return "nameplate".equals(name);
|
||||
}
|
||||
}
|
||||
@@ -77,6 +77,9 @@ paper {
|
||||
register("ViaVersion") { required = false }
|
||||
register("QuickShop-Hikari") { required = false }
|
||||
|
||||
// external tag
|
||||
register("CustomNameplates") { required = false }
|
||||
|
||||
// external models
|
||||
register("ModelEngine") { required = false }
|
||||
register("BetterModel") { required = false }
|
||||
|
||||
@@ -2,6 +2,7 @@ package net.momirealms.craftengine.bukkit.plugin;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import net.momirealms.craftengine.bukkit.api.BukkitAdaptors;
|
||||
import net.momirealms.craftengine.bukkit.nms.FastNMS;
|
||||
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.MRegistryOps;
|
||||
|
||||
@@ -145,7 +145,7 @@ warning.config.recipe.brewing.missing_container: "<yellow>Problem in Datei <arg:
|
||||
warning.config.recipe.brewing.missing_ingredient: "<yellow>Problem in Datei <arg:0> gefunden - Beim Brewing-Recipe '<arg:1>' fehlt das erforderliche 'ingredient'-Argument.</yellow>"
|
||||
warning.config.recipe.result.post_processor.missing_type: "<yellow>Problem in Datei <arg:0> gefunden - Beim Recipe '<arg:1>' fehlt das erforderliche 'type'-Argument für Result-Post-Processors.</yellow>"
|
||||
warning.config.recipe.result.post_processor.invalid_type: "<yellow>Problem in Datei <arg:0> gefunden - Das Recipe '<arg:1>' verwendet einen ungültigen Result-Post-Processor-Typ '<arg:2>'.</yellow>"
|
||||
warning.config.i18n.unknown_locale: "<yellow>Problem in Datei <arg:0> gefunden - Unbekannte Locale '<arg:1>'.</yellow>"
|
||||
warning.config.translation.unknown_locale: "<yellow>Problem in Datei <arg:0> gefunden - Unbekannte Locale '<arg:1>'.</yellow>"
|
||||
warning.config.template.duplicate: "<yellow>Problem in Datei <arg:0> gefunden - Doppeltes Template '<arg:1>'. Bitte prüfe, ob dieselbe Konfiguration in anderen Dateien vorhanden ist.</yellow>"
|
||||
warning.config.template.invalid: "<yellow>Problem in Datei <arg:0> gefunden - Die Config '<arg:1>' verwendet ein ungültiges Template '<arg:2>'.</yellow>"
|
||||
warning.config.template.argument.self_increase_int.invalid_range: "<yellow>Problem in Datei <arg:0> gefunden - Das Template '<arg:1>' verwendet ein 'from' '<arg:2>', das größer ist als 'to' '<arg:3>' im 'self_increase_int'-Argument.</yellow>"
|
||||
|
||||
@@ -161,7 +161,7 @@ warning.config.recipe.brewing.missing_container: "<yellow>Issue found in file <a
|
||||
warning.config.recipe.brewing.missing_ingredient: "<yellow>Issue found in file <arg:0> - The brewing recipe '<arg:1>' is missing the required 'ingredient' argument.</yellow>"
|
||||
warning.config.recipe.result.post_processor.missing_type: "<yellow>Issue found in file <arg:0> - The recipe '<arg:1>' is missing the required 'type' argument for result post processors.</yellow>"
|
||||
warning.config.recipe.result.post_processor.invalid_type: "<yellow>Issue found in file <arg:0> - The recipe '<arg:1>' is using an invalid result post processor type '<arg:2>'.</yellow>"
|
||||
warning.config.i18n.unknown_locale: "<yellow>Issue found in file <arg:0> - Unknown locale '<arg:1>'.</yellow>"
|
||||
warning.config.translation.unknown_locale: "<yellow>Issue found in file <arg:0> - Unknown locale '<arg:1>'.</yellow>"
|
||||
warning.config.template.duplicate: "<yellow>Issue found in file <arg:0> - Duplicated template '<arg:1>'. Please check if there is the same configuration in other files.</yellow>"
|
||||
warning.config.template.invalid: "<yellow>Issue found in file <arg:0> - The config '<arg:1>' is using an invalid template '<arg:2>'.</yellow>"
|
||||
warning.config.template.argument.self_increase_int.invalid_range: "<yellow>Issue found in file <arg:0> - The template '<arg:1>' is using a 'from' '<arg:2>' larger than 'to' '<arg:3>' in 'self_increase_int' argument.</yellow>"
|
||||
|
||||
@@ -98,7 +98,7 @@ warning.config.recipe.smithing_transform.post_processor.missing_type: "<yellow>P
|
||||
warning.config.recipe.smithing_transform.post_processor.invalid_type: "<yellow>Problema encontrado en el archivo <arg:0> - La receta de transformación de herrería '<arg:1>' está usando un tipo de postprocesador inválido '<arg:2>'.</yellow>"
|
||||
warning.config.recipe.smithing_transform.post_processor.keep_component.missing_components: "<yellow>Problema encontrado en el archivo <arg:0> - La receta de transformación de herrería '<arg:1>' carece del argumento requerido 'components' para el postprocesador 'keep_components'.</yellow>"
|
||||
warning.config.recipe.smithing_transform.post_processor.keep_component.missing_tags: "<yellow>Problema encontrado en el archivo <arg:0> - La receta de transformación de herrería '<arg:1>' carece del argumento requerido 'tags' para el postprocesador 'keep_tags'.</yellow>"
|
||||
warning.config.i18n.unknown_locale: "<yellow>Problema encontrado en el archivo <arg:0> - Configuración regional desconocida '<arg:1>'.</yellow>"
|
||||
warning.config.translation.unknown_locale: "<yellow>Problema encontrado en el archivo <arg:0> - Configuración regional desconocida '<arg:1>'.</yellow>"
|
||||
warning.config.template.duplicate: "<yellow>Problema encontrado en el archivo <arg:0> - Plantilla duplicada '<arg:1>'. Verifica si hay la misma configuración en otros archivos.</yellow>"
|
||||
warning.config.template.argument.self_increase_int.invalid_range: "<yellow>Problema encontrado en el archivo <arg:0> - La plantilla '<arg:1>' está usando un valor 'from' '<arg:2>' mayor que el valor 'to' '<arg:3>' en el argumento 'self_increase_int'.</yellow>"
|
||||
warning.config.template.argument.list.invalid_type: "<yellow>Problema encontrado en el archivo <arg:0> - La plantilla '<arg:1>' está usando un argumento 'list' que espera una 'List' como argumento, pero el argumento de entrada es de tipo '<arg:2>'.</yellow>"
|
||||
|
||||
@@ -134,7 +134,7 @@ warning.config.recipe.smithing_transform.post_processor.missing_type: "<yellow>
|
||||
warning.config.recipe.smithing_transform.post_processor.invalid_type: "<yellow>Проблема найдена в файле <arg:0> - Рецепт трансформации кузнечного дела '<arg:1>' использует недопустимый тип постпроцессора '<arg:2>'.</yellow>"
|
||||
warning.config.recipe.smithing_transform.post_processor.keep_component.missing_components: "<yellow>Проблема найдена в файле <arg:0> - В рецепте трансформации кузнечного дела '<arg:1>' отсутствует необходимый аргумент 'components' для постпроцессоров 'keep_components'.</yellow>"
|
||||
warning.config.recipe.smithing_transform.post_processor.keep_component.missing_tags: "<yellow>Проблема найдена в файле <arg:0> - В рецепте трансформации кузнечного дела '<arg:1>' отсутствует необходимый аргумент 'tags' для постпроцессоров 'keep_tags'.</yellow>"
|
||||
warning.config.i18n.unknown_locale: "<yellow>Проблема найдена в файле <arg:0> - Неизвестный locale '<arg:1>'.</yellow>"
|
||||
warning.config.translation.unknown_locale: "<yellow>Проблема найдена в файле <arg:0> - Неизвестный locale '<arg:1>'.</yellow>"
|
||||
warning.config.template.duplicate: "<yellow>Проблема найдена в файле <arg:0> - Дублированный шаблон '<arg:1>'. Проверьте, есть ли такая же конфигурация в других файлах.</yellow>"
|
||||
warning.config.template.invalid: "<yellow>Проблема найдена в файле <arg:0> - Конфигурация '<arg:1>' использует недействительный шаблон '<arg:2>'.</yellow>"
|
||||
warning.config.template.argument.self_increase_int.invalid_range: "<yellow>Проблема найдена в файле <arg:0> - Шаблон '<arg:1>' использует 'from' '<arg:2>' больше, чем 'to' '<arg:3>' в 'self_increase_int' аргументе.</yellow>"
|
||||
|
||||
@@ -97,7 +97,7 @@ warning.config.recipe.smithing_transform.post_processor.missing_type: "<yellow><
|
||||
warning.config.recipe.smithing_transform.post_processor.invalid_type: "<yellow><arg:0> dosyasında sorun bulundu - '<arg:1>' demircilik dönüşüm tarifi geçersiz bir işlem sonrası işleyici türü '<arg:2>' kullanıyor.</yellow>"
|
||||
warning.config.recipe.smithing_transform.post_processor.keep_component.missing_components: "<yellow><arg:0> dosyasında sorun bulundu - '<arg:1>' demircilik dönüşüm tarifi, 'keep_components' işlem sonrası işleyicisi için gerekli 'components' argümanı eksik.</yellow>"
|
||||
warning.config.recipe.smithing_transform.post_processor.keep_component.missing_tags: "<yellow><arg:0> dosyasında sorun bulundu - '<arg:1>' demircilik dönüşüm tarifi, 'keep_tags' işlem sonrası işleyicisi için gerekli 'tags' argümanı eksik.</yellow>"
|
||||
warning.config.i18n.unknown_locale: "<yellow><arg:0> dosyasında sorun bulundu - Bilinmeyen yerel ayar '<arg:1>'.</yellow>"
|
||||
warning.config.translation.unknown_locale: "<yellow><arg:0> dosyasında sorun bulundu - Bilinmeyen yerel ayar '<arg:1>'.</yellow>"
|
||||
warning.config.template.duplicate: "<yellow><arg:0> dosyasında sorun bulundu - Yinelenen şablon '<arg:1>'. Diğer dosyalarda aynı yapılandırmanın olup olmadığını kontrol edin.</yellow>"
|
||||
warning.config.template.argument.self_increase_int.invalid_range: "<yellow><arg:0> dosyasında sorun bulundu - '<arg:1>' şablonu, 'self_increase_int' argümanında 'to' '<arg:3>' değerinden daha büyük bir 'from' '<arg:2>' değeri kullanıyor.</yellow>"
|
||||
warning.config.template.argument.list.invalid_type: "<yellow><arg:0> dosyasında sorun bulundu - '<arg:1>' şablonu, argüman olarak bir 'List' bekleyen bir 'list' argümanı kullanıyor, ancak giriş argümanı bir '<arg:2>' türünde.</yellow>"
|
||||
|
||||
@@ -158,7 +158,7 @@ warning.config.recipe.brewing.missing_container: "<yellow>在文件 <arg:0> 发
|
||||
warning.config.recipe.brewing.missing_ingredient: "<yellow>在文件 <arg:0> 发现问题 - 酿造配方 '<arg:1>' 缺少必需的 'ingredient' 参数</yellow>"
|
||||
warning.config.recipe.result.post_processor.missing_type: "<yellow>在文件 <arg:0> 发现问题 - 配方 '<arg:1>' 缺少结果后处理器必需的 'type' 参数</yellow>"
|
||||
warning.config.recipe.result.post_processor.invalid_type: "<yellow>在文件 <arg:0> 发现问题 - 配方 '<arg:1>' 使用了无效结果后处理器类型 '<arg:2>'</yellow>"
|
||||
warning.config.i18n.unknown_locale: "<yellow>在文件 <arg:0> 发现问题 - 未知的语言环境 '<arg:1>'</yellow>"
|
||||
warning.config.translation.unknown_locale: "<yellow>在文件 <arg:0> 发现问题 - 未知的语言环境 '<arg:1>'</yellow>"
|
||||
warning.config.template.duplicate: "<yellow>在文件 <arg:0> 发现问题 - 重复的模板 '<arg:1>' 请检查其他文件中是否存在相同配置</yellow>"
|
||||
warning.config.template.invalid: "<yellow>在文件 <arg:0> 发现问题 - 配置 '<arg:1>' 使用了无效的模板 '<arg:2>'</yellow>"
|
||||
warning.config.template.argument.self_increase_int.invalid_range: "<yellow>在文件 <arg:0> 发现问题 - 模板 '<arg:1>' 在 'self_increase_int' 参数中使用了一个起始值 '<arg:2>' 大于终止值 '<arg:3>'</yellow>"
|
||||
|
||||
@@ -376,7 +376,7 @@ public abstract class AbstractPackManager implements PackManager {
|
||||
|
||||
// internal
|
||||
plugin.saveResource("resources/internal/pack.yml");
|
||||
plugin.saveResource("resources/internal/configuration/i18n.yml");
|
||||
plugin.saveResource("resources/internal/configuration/translations.yml");
|
||||
plugin.saveResource("resources/internal/configuration/fix_client_visual.yml");
|
||||
plugin.saveResource("resources/internal/configuration/offset_chars.yml");
|
||||
plugin.saveResource("resources/internal/configuration/gui.yml");
|
||||
@@ -413,7 +413,7 @@ public abstract class AbstractPackManager implements PackManager {
|
||||
plugin.saveResource("resources/default/configuration/templates.yml");
|
||||
plugin.saveResource("resources/default/configuration/categories.yml");
|
||||
plugin.saveResource("resources/default/configuration/emoji.yml");
|
||||
plugin.saveResource("resources/default/configuration/i18n.yml");
|
||||
plugin.saveResource("resources/default/configuration/translations.yml");
|
||||
plugin.saveResource("resources/default/configuration/items/cap.yml");
|
||||
plugin.saveResource("resources/default/configuration/items/flame_elytra.yml");
|
||||
plugin.saveResource("resources/default/configuration/items/gui_head.yml");
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.momirealms.craftengine.core.plugin;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
import net.momirealms.craftengine.core.world.World;
|
||||
import net.momirealms.craftengine.core.world.particle.ParticleType;
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package net.momirealms.craftengine.core.plugin.compatibility;
|
||||
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import net.momirealms.craftengine.core.entity.furniture.ExternalModel;
|
||||
import net.momirealms.craftengine.core.entity.player.Player;
|
||||
import net.momirealms.craftengine.core.plugin.context.Context;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -15,6 +17,8 @@ public interface CompatibilityManager {
|
||||
|
||||
void registerLevelerProvider(String plugin, LevelerProvider provider);
|
||||
|
||||
void registerTagResolverProvider(TagResolverProvider provider);
|
||||
|
||||
void addLevelerExp(Player player, String plugin, String target, double value);
|
||||
|
||||
int getLevel(Player player, String plugin, String target);
|
||||
@@ -36,4 +40,6 @@ public interface CompatibilityManager {
|
||||
int getPlayerProtocolVersion(UUID uuid);
|
||||
|
||||
void executeMMSkill(String skill, float power, Player player);
|
||||
|
||||
TagResolver[] createExternalTagResolvers(Context context);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package net.momirealms.craftengine.core.plugin.compatibility;
|
||||
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import net.momirealms.craftengine.core.plugin.context.Context;
|
||||
|
||||
public interface TagResolverProvider {
|
||||
|
||||
String name();
|
||||
|
||||
TagResolver getTagResolver(Context context);
|
||||
}
|
||||
@@ -1,8 +1,11 @@
|
||||
package net.momirealms.craftengine.core.plugin.context;
|
||||
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
||||
import net.momirealms.craftengine.core.plugin.text.minimessage.*;
|
||||
import net.momirealms.craftengine.core.util.ArrayUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
@@ -32,12 +35,27 @@ public abstract class AbstractCommonContext implements Context {
|
||||
@NotNull
|
||||
public TagResolver[] tagResolvers() {
|
||||
if (this.tagResolvers == null) {
|
||||
this.tagResolvers = new TagResolver[]{ShiftTag.INSTANCE, ImageTag.INSTANCE, new I18NTag(this), new NamedArgumentTag(this),
|
||||
new PlaceholderTag(this), new ExpressionTag(this), new GlobalVariableTag(this)};
|
||||
this.tagResolvers = getTagResolver();
|
||||
}
|
||||
return this.tagResolvers;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected TagResolver[] getTagResolver() {
|
||||
return ArrayUtils.mergeNoCopy(getExternalTagResolvers(), getInternalTagResolvers());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected TagResolver[] getExternalTagResolvers() {
|
||||
return CraftEngine.instance().compatibilityManager().createExternalTagResolvers(this);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected TagResolver[] getInternalTagResolvers() {
|
||||
return new TagResolver[]{ShiftTag.INSTANCE, ImageTag.INSTANCE, new I18NTag(this), new NamedArgumentTag(this),
|
||||
new PlaceholderTag(this), new ExpressionTag(this), new GlobalVariableTag(this)};
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Optional<T> getOptionalParameter(ContextKey<T> parameter) {
|
||||
if (!this.additionalParameterProviders.isEmpty()) {
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package net.momirealms.craftengine.core.plugin.context;
|
||||
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import net.momirealms.craftengine.core.entity.player.Player;
|
||||
import net.momirealms.craftengine.core.plugin.context.parameter.DirectContextParameters;
|
||||
import net.momirealms.craftengine.core.plugin.text.minimessage.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -22,13 +20,4 @@ public final class NetworkTextReplaceContext extends PlayerOptionalContext imple
|
||||
public Player player() {
|
||||
return super.player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TagResolver[] tagResolvers() {
|
||||
if (this.tagResolvers == null) {
|
||||
this.tagResolvers = new TagResolver[]{ShiftTag.INSTANCE, ImageTag.INSTANCE, new PlaceholderTag(this), new I18NTag(this),
|
||||
new NamedArgumentTag(this), new ExpressionTag(this), new GlobalVariableTag(this)};
|
||||
}
|
||||
return this.tagResolvers;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package net.momirealms.craftengine.core.plugin.context;
|
||||
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import net.momirealms.craftengine.core.entity.player.Player;
|
||||
import net.momirealms.craftengine.core.plugin.context.parameter.DirectContextParameters;
|
||||
import net.momirealms.craftengine.core.plugin.text.minimessage.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -63,14 +61,4 @@ public class PlayerOptionalContext extends AbstractChainParameterContext impleme
|
||||
public boolean isPlayerPresent() {
|
||||
return this.player != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public TagResolver[] tagResolvers() {
|
||||
if (this.tagResolvers == null) {
|
||||
this.tagResolvers = new TagResolver[]{ShiftTag.INSTANCE, ImageTag.INSTANCE, new PlaceholderTag(this), new I18NTag(this),
|
||||
new NamedArgumentTag(this), new ExpressionTag(this), new GlobalVariableTag(this)};
|
||||
}
|
||||
return this.tagResolvers;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ public class LangData {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "I18NData{" + translations + "}";
|
||||
return "LangData{" + translations + "}";
|
||||
}
|
||||
|
||||
public static void merge(Map<String, LangData> target, Map<String, LangData> source) {
|
||||
|
||||
@@ -276,7 +276,7 @@ public class TranslationManagerImpl implements TranslationManager {
|
||||
}
|
||||
|
||||
public class TranslationParser extends IdSectionConfigParser {
|
||||
public static final String[] CONFIG_SECTION_NAME = new String[] {"translations", "translation", "l10n", "localization", "i18n", "internationalization", };
|
||||
public static final String[] CONFIG_SECTION_NAME = new String[] {"translations", "translation", "l10n", "localization", "i18n", "internationalization"};
|
||||
|
||||
@Override
|
||||
public int loadingSequence() {
|
||||
@@ -292,7 +292,7 @@ public class TranslationManagerImpl implements TranslationManager {
|
||||
public void parseSection(Pack pack, Path path, String node, net.momirealms.craftengine.core.util.Key id, Map<String, Object> section) {
|
||||
Locale locale = TranslationManager.parseLocale(id.value());
|
||||
if (locale == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.i18n.unknown_locale");
|
||||
throw new LocalizedResourceConfigException("warning.config.translation.unknown_locale");
|
||||
}
|
||||
|
||||
Map<String, String> bundle = new HashMap<>();
|
||||
|
||||
@@ -10,6 +10,8 @@ import net.momirealms.craftengine.core.util.AdventureHelper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface FormattedLine {
|
||||
TagResolver[] CUSTOM_RESOLVERS = new TagResolver[]{
|
||||
createDummyResolvers("expr"),
|
||||
@@ -22,6 +24,19 @@ public interface FormattedLine {
|
||||
createDummyResolvers("rel_papi")
|
||||
};
|
||||
|
||||
class Companion {
|
||||
public static TagResolver[] LATEST_RESOLVERS = CUSTOM_RESOLVERS;
|
||||
|
||||
public static void resetWithCustomResolvers(List<String> customResolvers) {
|
||||
TagResolver[] resolvers = new TagResolver[customResolvers.size() + CUSTOM_RESOLVERS.length];
|
||||
System.arraycopy(CUSTOM_RESOLVERS, 0, resolvers, 0, CUSTOM_RESOLVERS.length);
|
||||
for (int i = 0; i < customResolvers.size(); i++) {
|
||||
resolvers[CUSTOM_RESOLVERS.length + i] = createDummyResolvers(customResolvers.get(i));
|
||||
}
|
||||
LATEST_RESOLVERS = resolvers;
|
||||
}
|
||||
}
|
||||
|
||||
Component parse(net.momirealms.craftengine.core.plugin.context.Context context);
|
||||
|
||||
private static TagResolver createDummyResolvers(String tag) {
|
||||
@@ -39,7 +54,7 @@ public interface FormattedLine {
|
||||
}
|
||||
|
||||
static FormattedLine create(String line) {
|
||||
if (line.equals(AdventureHelper.customMiniMessage().stripTags(line, CUSTOM_RESOLVERS))) {
|
||||
if (line.equals(AdventureHelper.customMiniMessage().stripTags(line, Companion.LATEST_RESOLVERS))) {
|
||||
return new PreParsedLine(AdventureHelper.miniMessage().deserialize(line));
|
||||
} else {
|
||||
return new DynamicLine(line);
|
||||
|
||||
@@ -12,6 +12,7 @@ import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.kyori.adventure.text.serializer.json.JSONOptions;
|
||||
import net.kyori.adventure.text.serializer.json.legacyimpl.NBTLegacyHoverEventSerializer;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
||||
import net.momirealms.craftengine.core.plugin.context.Context;
|
||||
import net.momirealms.craftengine.core.plugin.text.component.ComponentProvider;
|
||||
import net.momirealms.sparrow.nbt.Tag;
|
||||
|
||||
@@ -42,6 +42,26 @@ public class ArrayUtils {
|
||||
return mergedArray;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T[] mergeNoCopy(T[] array1, T[] array2) {
|
||||
if (array1 == null && array2 == null) {
|
||||
return null;
|
||||
}
|
||||
if (array1 == null) {
|
||||
return array2;
|
||||
}
|
||||
if (array2 == null) {
|
||||
return array1;
|
||||
}
|
||||
T[] mergedArray = (T[]) Array.newInstance(
|
||||
array1.getClass().getComponentType(),
|
||||
array1.length + array2.length
|
||||
);
|
||||
System.arraycopy(array1, 0, mergedArray, 0, array1.length);
|
||||
System.arraycopy(array2, 0, mergedArray, array1.length, array2.length);
|
||||
return mergedArray;
|
||||
}
|
||||
|
||||
public static <T> List<T[]> splitArray(T[] array, int chunkSize) {
|
||||
List<T[]> result = new ArrayList<>();
|
||||
for (int i = 0; i < array.length; i += chunkSize) {
|
||||
|
||||
@@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx1G
|
||||
|
||||
# Project settings
|
||||
# Rule: [major update].[feature update].[bug fix]
|
||||
project_version=0.0.64.14
|
||||
project_version=0.0.64.15
|
||||
config_version=49
|
||||
lang_version=35
|
||||
project_group=net.momirealms
|
||||
|
||||
Reference in New Issue
Block a user