mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-19 15:09:15 +00:00
添加多语言日志
This commit is contained in:
@@ -37,6 +37,7 @@ import net.momirealms.craftengine.core.plugin.config.Config;
|
|||||||
import net.momirealms.craftengine.core.plugin.context.Context;
|
import net.momirealms.craftengine.core.plugin.context.Context;
|
||||||
import net.momirealms.craftengine.core.plugin.context.condition.AlwaysFalseCondition;
|
import net.momirealms.craftengine.core.plugin.context.condition.AlwaysFalseCondition;
|
||||||
import net.momirealms.craftengine.core.plugin.context.event.EventConditions;
|
import net.momirealms.craftengine.core.plugin.context.event.EventConditions;
|
||||||
|
import net.momirealms.craftengine.core.plugin.locale.TranslationManager;
|
||||||
import net.momirealms.craftengine.core.plugin.text.minimessage.FormattedLine;
|
import net.momirealms.craftengine.core.plugin.text.minimessage.FormattedLine;
|
||||||
import net.momirealms.craftengine.core.util.Key;
|
import net.momirealms.craftengine.core.util.Key;
|
||||||
import net.momirealms.craftengine.core.util.VersionHelper;
|
import net.momirealms.craftengine.core.util.VersionHelper;
|
||||||
@@ -181,7 +182,7 @@ public class BukkitCompatibilityManager implements CompatibilityManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void logHook(String plugin) {
|
private void logHook(String plugin) {
|
||||||
this.plugin.logger().info("[Compatibility] " + plugin + " hooked");
|
this.plugin.logger().info(TranslationManager.instance().translateLog("info.compatibility", plugin));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -252,8 +253,8 @@ public class BukkitCompatibilityManager implements CompatibilityManager {
|
|||||||
if (VersionHelper.isOrAbove1_20_3()) {
|
if (VersionHelper.isOrAbove1_20_3()) {
|
||||||
this.plugin.logger().severe("");
|
this.plugin.logger().severe("");
|
||||||
if (Locale.getDefault() == Locale.SIMPLIFIED_CHINESE) {
|
if (Locale.getDefault() == Locale.SIMPLIFIED_CHINESE) {
|
||||||
this.plugin.logger().severe("[Compatibility] 插件需要更新 FastAsyncWorldEdit 到 2.13.0 或更高版本,以获得更好的兼容性。(当前版本: " + version + ")");
|
this.plugin.logger().severe("[兼容性] 插件需要更新 FastAsyncWorldEdit 到 2.13.0 或更高版本,以获得更好的兼容性。(当前版本: " + version + ")");
|
||||||
this.plugin.logger().severe("[Compatibility] 请前往 https://ci.athion.net/job/FastAsyncWorldEdit/ 下载最新版本");
|
this.plugin.logger().severe("[兼容性] 请前往 https://ci.athion.net/job/FastAsyncWorldEdit/ 下载最新版本");
|
||||||
} else {
|
} else {
|
||||||
this.plugin.logger().severe("[Compatibility] Update FastAsyncWorldEdit to v2.13.0+ for better compatibility (Current: " + version + ")");
|
this.plugin.logger().severe("[Compatibility] Update FastAsyncWorldEdit to v2.13.0+ for better compatibility (Current: " + version + ")");
|
||||||
this.plugin.logger().severe("[Compatibility] Download latest version: https://ci.athion.net/job/FastAsyncWorldEdit/");
|
this.plugin.logger().severe("[Compatibility] Download latest version: https://ci.athion.net/job/FastAsyncWorldEdit/");
|
||||||
|
|||||||
@@ -119,6 +119,11 @@ public final class BukkitAdvancementManager extends AbstractAdvancementManager {
|
|||||||
return LoadingSequence.ADVANCEMENT;
|
return LoadingSequence.ADVANCEMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int count() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void parseSection(Pack pack, Path path, String node, Key id, Map<String, Object> section) {
|
public void parseSection(Pack pack, Path path, String node, Key id, Map<String, Object> section) {
|
||||||
if (advancements.containsKey(id)) {
|
if (advancements.containsKey(id)) {
|
||||||
|
|||||||
@@ -7,13 +7,11 @@ import net.momirealms.craftengine.bukkit.nms.FastNMS;
|
|||||||
import net.momirealms.craftengine.bukkit.plugin.BukkitCraftEngine;
|
import net.momirealms.craftengine.bukkit.plugin.BukkitCraftEngine;
|
||||||
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.CoreReflections;
|
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.CoreReflections;
|
||||||
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.MEntityTypes;
|
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.MEntityTypes;
|
||||||
import net.momirealms.craftengine.bukkit.plugin.user.BukkitServerPlayer;
|
|
||||||
import net.momirealms.craftengine.bukkit.util.EntityUtils;
|
import net.momirealms.craftengine.bukkit.util.EntityUtils;
|
||||||
import net.momirealms.craftengine.bukkit.util.KeyUtils;
|
import net.momirealms.craftengine.bukkit.util.KeyUtils;
|
||||||
import net.momirealms.craftengine.bukkit.util.LocationUtils;
|
import net.momirealms.craftengine.bukkit.util.LocationUtils;
|
||||||
import net.momirealms.craftengine.core.entity.furniture.*;
|
import net.momirealms.craftengine.core.entity.furniture.*;
|
||||||
import net.momirealms.craftengine.core.entity.furniture.hitbox.FurnitureHitBoxConfig;
|
import net.momirealms.craftengine.core.entity.furniture.hitbox.FurnitureHitBoxConfig;
|
||||||
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
|
||||||
import net.momirealms.craftengine.core.plugin.config.Config;
|
import net.momirealms.craftengine.core.plugin.config.Config;
|
||||||
import net.momirealms.craftengine.core.sound.SoundData;
|
import net.momirealms.craftengine.core.sound.SoundData;
|
||||||
import net.momirealms.craftengine.core.util.Key;
|
import net.momirealms.craftengine.core.util.Key;
|
||||||
@@ -33,7 +31,6 @@ import java.util.Map;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
public class BukkitFurnitureManager extends AbstractFurnitureManager {
|
public class BukkitFurnitureManager extends AbstractFurnitureManager {
|
||||||
public static final NamespacedKey FURNITURE_KEY = KeyUtils.toNamespacedKey(FurnitureManager.FURNITURE_KEY);
|
public static final NamespacedKey FURNITURE_KEY = KeyUtils.toNamespacedKey(FurnitureManager.FURNITURE_KEY);
|
||||||
|
|||||||
@@ -17,7 +17,10 @@ import net.momirealms.craftengine.core.world.WorldPosition;
|
|||||||
import org.joml.Quaternionf;
|
import org.joml.Quaternionf;
|
||||||
import org.joml.Vector3f;
|
import org.joml.Vector3f;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ public class BukkitVanillaLootManager extends AbstractVanillaLootManager impleme
|
|||||||
|
|
||||||
public class VanillaLootParser extends IdSectionConfigParser {
|
public class VanillaLootParser extends IdSectionConfigParser {
|
||||||
public static final String[] CONFIG_SECTION_NAME = new String[] {"vanilla-loots", "vanilla-loot"};
|
public static final String[] CONFIG_SECTION_NAME = new String[] {"vanilla-loots", "vanilla-loot"};
|
||||||
|
private int count;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int loadingSequence() {
|
public int loadingSequence() {
|
||||||
@@ -104,6 +105,16 @@ public class BukkitVanillaLootManager extends AbstractVanillaLootManager impleme
|
|||||||
return CONFIG_SECTION_NAME;
|
return CONFIG_SECTION_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int count() {
|
||||||
|
return this.count;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void preProcess() {
|
||||||
|
this.count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void parseSection(Pack pack, Path path, String node, Key id, Map<String, Object> section) {
|
public void parseSection(Pack pack, Path path, String node, Key id, Map<String, Object> section) {
|
||||||
String type = ResourceConfigUtils.requireNonEmptyStringOrThrow(section.get("type"), "warning.config.vanilla_loot.missing_type");
|
String type = ResourceConfigUtils.requireNonEmptyStringOrThrow(section.get("type"), "warning.config.vanilla_loot.missing_type");
|
||||||
@@ -147,6 +158,7 @@ public class BukkitVanillaLootManager extends AbstractVanillaLootManager impleme
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ import net.momirealms.craftengine.core.pack.host.ResourcePackDownloadData;
|
|||||||
import net.momirealms.craftengine.core.pack.obfuscation.ObfA;
|
import net.momirealms.craftengine.core.pack.obfuscation.ObfA;
|
||||||
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
||||||
import net.momirealms.craftengine.core.plugin.config.Config;
|
import net.momirealms.craftengine.core.plugin.config.Config;
|
||||||
|
import net.momirealms.craftengine.core.plugin.locale.TranslationManager;
|
||||||
|
import net.momirealms.craftengine.core.plugin.locale.TranslationManagerImpl;
|
||||||
import net.momirealms.craftengine.core.util.Base64Utils;
|
import net.momirealms.craftengine.core.util.Base64Utils;
|
||||||
import net.momirealms.craftengine.core.util.VersionHelper;
|
import net.momirealms.craftengine.core.util.VersionHelper;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@@ -94,7 +96,7 @@ public class BukkitPackManager extends AbstractPackManager implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!Config.sendPackOnUpload()) return;
|
if (!Config.sendPackOnUpload()) return;
|
||||||
CraftEngine.instance().logger().info("Completed uploading resource pack");
|
CraftEngine.instance().logger().info(TranslationManager.instance().translateLog("info.resource_pack.upload"));
|
||||||
for (BukkitServerPlayer player : this.plugin.networkManager().onlineUsers()) {
|
for (BukkitServerPlayer player : this.plugin.networkManager().onlineUsers()) {
|
||||||
sendResourcePack(player);
|
sendResourcePack(player);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,20 @@ argument.parse.failure.aggregate.missing: "<red>Missing component '<arg:0>'</red
|
|||||||
argument.parse.failure.aggregate.failure: "<red>Invalid component '<arg:0>': <arg:1></red>"
|
argument.parse.failure.aggregate.failure: "<red>Invalid component '<arg:0>': <arg:1></red>"
|
||||||
argument.parse.failure.either: "<red>Could not resolve <arg:1> or <arg:2> from '<arg:0>'</red>"
|
argument.parse.failure.either: "<red>Could not resolve <arg:1> or <arg:2> from '<arg:0>'</red>"
|
||||||
argument.parse.failure.namedtextcolor: "<red>'<arg:0>' is not a named text color</red>"
|
argument.parse.failure.namedtextcolor: "<red>'<arg:0>' is not a named text color</red>"
|
||||||
|
info.pack.load: "Loaded pack: <arg:0>. Default namespace: <arg:1>"
|
||||||
|
info.resource.load: "Loaded <arg:0> in <arg:1>ms (<arg:2>)"
|
||||||
|
info.resource_pack.start: "Generating resource pack..."
|
||||||
|
info.resource_pack.generate: "Generated resource pack in <arg:0>ms"
|
||||||
|
info.resource_pack.validate: "Validated resource pack in <arg:0>ms"
|
||||||
|
info.resource_pack.optimize: "Optimized resource pack in <arg:0>ms"
|
||||||
|
info.resource_pack.optimize.json: "> Optimizing json files..."
|
||||||
|
info.resource_pack.optimize.texture: "> Optimizing textures..."
|
||||||
|
info.resource_pack.optimize.result: "□ Before/After/Ratio: <arg:0> KB/<arg:1> KB/<arg:2>%"
|
||||||
|
info.resource_pack.create: "Created resource pack zip in <arg:0>ms"
|
||||||
|
info.resource_pack.upload: "Completed uploading resource pack"
|
||||||
|
info.host.self.netty_server: "Netty HTTP server started on port: <arg:0>"
|
||||||
|
info.host.cache.load: "[<arg:0>] Loaded cached resource pack metadata"
|
||||||
|
info.compatibility: "[Compatibility] <arg:0> hooked"
|
||||||
command.reload.config.success: "<white>Configs reloaded in <green><arg:0></green> ms.</white> <gray>(Async: <arg:1>ms | Sync: <arg:2>ms)</gray>"
|
command.reload.config.success: "<white>Configs reloaded in <green><arg:0></green> ms.</white> <gray>(Async: <arg:1>ms | Sync: <arg:2>ms)</gray>"
|
||||||
command.reload.config.failure: "<red>Config reload failed. Check console logs.</red>"
|
command.reload.config.failure: "<red>Config reload failed. Check console logs.</red>"
|
||||||
command.reload.pack.success: "<white>Resource pack reloaded in <green><arg:0></green> ms.</white>"
|
command.reload.pack.success: "<white>Resource pack reloaded in <green><arg:0></green> ms.</white>"
|
||||||
|
|||||||
@@ -38,6 +38,20 @@ argument.parse.failure.aggregate.missing: "<red>缺少组件 '<arg:0>'</red>"
|
|||||||
argument.parse.failure.aggregate.failure: "<red>无效的组件 '<arg:0>': <arg:1></red>"
|
argument.parse.failure.aggregate.failure: "<red>无效的组件 '<arg:0>': <arg:1></red>"
|
||||||
argument.parse.failure.either: "<red>无法从 '<arg:0>' 解析 <arg:1> 或 <arg:2></red>"
|
argument.parse.failure.either: "<red>无法从 '<arg:0>' 解析 <arg:1> 或 <arg:2></red>"
|
||||||
argument.parse.failure.namedtextcolor: "<red>'<arg:0>' 不是颜色代码</red>"
|
argument.parse.failure.namedtextcolor: "<red>'<arg:0>' 不是颜色代码</red>"
|
||||||
|
info.pack.load: "已加载包: <arg:0>. 默认命名空间: <arg:1>"
|
||||||
|
info.resource.load: "加载 <arg:0> 耗时 <arg:1>ms (<arg:2>)"
|
||||||
|
info.resource_pack.start: "正在开始生成资源包..."
|
||||||
|
info.resource_pack.generate: "生成资源包耗时 <arg:0>ms"
|
||||||
|
info.resource_pack.validate: "验证资源包耗时 <arg:0>ms"
|
||||||
|
info.resource_pack.optimize: "优化资源包耗时 <arg:0>ms"
|
||||||
|
info.resource_pack.optimize.json: "> 正在优化json文件..."
|
||||||
|
info.resource_pack.optimize.texture: "> 正在优化贴图文件..."
|
||||||
|
info.resource_pack.optimize.result: "□ 优化前/优化后/比例: <arg:0> KB/<arg:1> KB/<arg:2>%"
|
||||||
|
info.resource_pack.create: "创建资源包文件耗时 <arg:0>ms"
|
||||||
|
info.resource_pack.upload: "资源包上传完成"
|
||||||
|
info.host.self.netty_server: "Netty HTTP 服务已在端口 <arg:0> 开启"
|
||||||
|
info.host.cache.load: "[<arg:0>] 已加载缓存的资源包元数据"
|
||||||
|
info.compatibility: "[兼容性] 已挂钩 <arg:0>"
|
||||||
command.reload.config.success: "<white>重新加载配置完成. 耗时 <green><arg:0></green> 毫秒</white> <gray>(异步: <arg:1>ms | 同步: <arg:2>ms)</gray>"
|
command.reload.config.success: "<white>重新加载配置完成. 耗时 <green><arg:0></green> 毫秒</white> <gray>(异步: <arg:1>ms | 同步: <arg:2>ms)</gray>"
|
||||||
command.reload.config.failure: "<red>重新加载配置失败, 请检查控制台日志</red>"
|
command.reload.config.failure: "<red>重新加载配置失败, 请检查控制台日志</red>"
|
||||||
command.reload.pack.success: "<white>资源包重新加载完成. 耗时 <green><arg:0></green> 毫秒</white>"
|
command.reload.pack.success: "<white>资源包重新加载完成. 耗时 <green><arg:0></green> 毫秒</white>"
|
||||||
|
|||||||
@@ -261,6 +261,7 @@ public abstract class AbstractBlockManager extends AbstractModelGenerator implem
|
|||||||
|
|
||||||
public class BlockStateMappingParser extends SectionConfigParser {
|
public class BlockStateMappingParser extends SectionConfigParser {
|
||||||
public static final String[] CONFIG_SECTION_NAME = new String[]{"block-state-mappings", "block-state-mapping"};
|
public static final String[] CONFIG_SECTION_NAME = new String[]{"block-state-mappings", "block-state-mapping"};
|
||||||
|
private int count;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] sectionId() {
|
public String[] sectionId() {
|
||||||
@@ -272,6 +273,16 @@ public abstract class AbstractBlockManager extends AbstractModelGenerator implem
|
|||||||
return LoadingSequence.BLOCK_STATE_MAPPING;
|
return LoadingSequence.BLOCK_STATE_MAPPING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int count() {
|
||||||
|
return this.count;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void preProcess() {
|
||||||
|
this.count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void parseSection(Pack pack, Path path, Map<String, Object> section) throws LocalizedException {
|
public void parseSection(Pack pack, Path path, Map<String, Object> section) throws LocalizedException {
|
||||||
ExceptionCollector<LocalizedResourceConfigException> exceptionCollector = new ExceptionCollector<>();
|
ExceptionCollector<LocalizedResourceConfigException> exceptionCollector = new ExceptionCollector<>();
|
||||||
@@ -302,6 +313,7 @@ public abstract class AbstractBlockManager extends AbstractModelGenerator implem
|
|||||||
List<BlockStateWrapper> blockStateWrappers = AbstractBlockManager.this.blockStateArranger.computeIfAbsent(blockOwnerId, k -> new ArrayList<>());
|
List<BlockStateWrapper> blockStateWrappers = AbstractBlockManager.this.blockStateArranger.computeIfAbsent(blockOwnerId, k -> new ArrayList<>());
|
||||||
blockStateWrappers.add(beforeState);
|
blockStateWrappers.add(beforeState);
|
||||||
AbstractBlockManager.this.autoVisualBlockStateCandidates[beforeState.registryId()] = createVisualBlockCandidate(beforeState);
|
AbstractBlockManager.this.autoVisualBlockStateCandidates[beforeState.registryId()] = createVisualBlockCandidate(beforeState);
|
||||||
|
this.count++;
|
||||||
}
|
}
|
||||||
exceptionCollector.throwIfPresent();
|
exceptionCollector.throwIfPresent();
|
||||||
}
|
}
|
||||||
@@ -331,6 +343,11 @@ public abstract class AbstractBlockManager extends AbstractModelGenerator implem
|
|||||||
this.visualBlockStateAllocator = new VisualBlockStateAllocator(AbstractBlockManager.this.plugin.dataFolderPath().resolve("cache").resolve("visual-block-states.json"), candidates, AbstractBlockManager.this::createVanillaBlockState);
|
this.visualBlockStateAllocator = new VisualBlockStateAllocator(AbstractBlockManager.this.plugin.dataFolderPath().resolve("cache").resolve("visual-block-states.json"), candidates, AbstractBlockManager.this::createVanillaBlockState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int count() {
|
||||||
|
return AbstractBlockManager.this.byId.size();
|
||||||
|
}
|
||||||
|
|
||||||
public void addPendingConfigSection(PendingConfigSection section) {
|
public void addPendingConfigSection(PendingConfigSection section) {
|
||||||
this.pendingConfigSections.add(section);
|
this.pendingConfigSections.add(section);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package net.momirealms.craftengine.core.entity.furniture;
|
|||||||
|
|
||||||
import net.momirealms.craftengine.core.entity.furniture.element.FurnitureElementConfig;
|
import net.momirealms.craftengine.core.entity.furniture.element.FurnitureElementConfig;
|
||||||
import net.momirealms.craftengine.core.entity.furniture.element.FurnitureElementConfigs;
|
import net.momirealms.craftengine.core.entity.furniture.element.FurnitureElementConfigs;
|
||||||
import net.momirealms.craftengine.core.entity.furniture.hitbox.FurnitureHitBox;
|
|
||||||
import net.momirealms.craftengine.core.entity.furniture.hitbox.FurnitureHitBoxConfig;
|
import net.momirealms.craftengine.core.entity.furniture.hitbox.FurnitureHitBoxConfig;
|
||||||
import net.momirealms.craftengine.core.entity.furniture.hitbox.FurnitureHitBoxTypes;
|
import net.momirealms.craftengine.core.entity.furniture.hitbox.FurnitureHitBoxTypes;
|
||||||
import net.momirealms.craftengine.core.loot.LootTable;
|
import net.momirealms.craftengine.core.loot.LootTable;
|
||||||
@@ -109,6 +108,11 @@ public abstract class AbstractFurnitureManager implements FurnitureManager {
|
|||||||
return LoadingSequence.FURNITURE;
|
return LoadingSequence.FURNITURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int count() {
|
||||||
|
return AbstractFurnitureManager.this.byId.size();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void parseSection(Pack pack, Path path, String node, Key id, Map<String, Object> section) {
|
public void parseSection(Pack pack, Path path, String node, Key id, Map<String, Object> section) {
|
||||||
if (AbstractFurnitureManager.this.byId.containsKey(id)) {
|
if (AbstractFurnitureManager.this.byId.containsKey(id)) {
|
||||||
|
|||||||
@@ -442,9 +442,14 @@ public abstract class AbstractFontManager implements FontManager {
|
|||||||
return LoadingSequence.EMOJI;
|
return LoadingSequence.EMOJI;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int count() {
|
||||||
|
return AbstractFontManager.this.emojis.size();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void parseSection(Pack pack, Path path, String node, Key id, Map<String, Object> section) {
|
public void parseSection(Pack pack, Path path, String node, Key id, Map<String, Object> section) {
|
||||||
if (emojis.containsKey(id)) {
|
if (AbstractFontManager.this.emojis.containsKey(id)) {
|
||||||
throw new LocalizedResourceConfigException("warning.config.emoji.duplicate");
|
throw new LocalizedResourceConfigException("warning.config.emoji.duplicate");
|
||||||
}
|
}
|
||||||
String permission = (String) section.get("permission");
|
String permission = (String) section.get("permission");
|
||||||
@@ -510,6 +515,11 @@ public abstract class AbstractFontManager implements FontManager {
|
|||||||
return LoadingSequence.IMAGE;
|
return LoadingSequence.IMAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int count() {
|
||||||
|
return AbstractFontManager.this.images.size();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postProcess() {
|
public void postProcess() {
|
||||||
for (Map.Entry<Key, IdAllocator> entry : this.idAllocators.entrySet()) {
|
for (Map.Entry<Key, IdAllocator> entry : this.idAllocators.entrySet()) {
|
||||||
|
|||||||
@@ -351,6 +351,11 @@ public abstract class AbstractItemManager<I> extends AbstractModelGenerator impl
|
|||||||
.toList();
|
.toList();
|
||||||
registerArmorTrimPattern(trims);
|
registerArmorTrimPattern(trims);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int count() {
|
||||||
|
return AbstractItemManager.this.equipments.size();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addOrMergeEquipment(ComponentBasedEquipment equipment) {
|
public void addOrMergeEquipment(ComponentBasedEquipment equipment) {
|
||||||
@@ -368,6 +373,11 @@ public abstract class AbstractItemManager<I> extends AbstractModelGenerator impl
|
|||||||
public static final String[] CONFIG_SECTION_NAME = new String[] {"items", "item"};
|
public static final String[] CONFIG_SECTION_NAME = new String[] {"items", "item"};
|
||||||
private final Map<Key, IdAllocator> idAllocators = new HashMap<>();
|
private final Map<Key, IdAllocator> idAllocators = new HashMap<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int count() {
|
||||||
|
return AbstractItemManager.this.customItemsById.size();
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isModernFormatRequired() {
|
private boolean isModernFormatRequired() {
|
||||||
return Config.packMaxVersion().isAtOrAbove(MinecraftVersions.V1_21_4);
|
return Config.packMaxVersion().isAtOrAbove(MinecraftVersions.V1_21_4);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,6 +134,11 @@ public abstract class AbstractRecipeManager<T> implements RecipeManager<T> {
|
|||||||
return CONFIG_SECTION_NAME;
|
return CONFIG_SECTION_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int count() {
|
||||||
|
return Math.max(0, AbstractRecipeManager.this.byId.size() - AbstractRecipeManager.this.dataPackRecipes.size());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void parseSection(Pack pack, Path path, String node, Key id, Map<String, Object> section) {
|
public void parseSection(Pack pack, Path path, String node, Key id, Map<String, Object> section) {
|
||||||
if (!Config.enableRecipeSystem()) return;
|
if (!Config.enableRecipeSystem()) return;
|
||||||
|
|||||||
@@ -19,7 +19,10 @@ import net.momirealms.craftengine.core.util.*;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
|||||||
@@ -31,10 +31,7 @@ import net.momirealms.craftengine.core.plugin.config.Config;
|
|||||||
import net.momirealms.craftengine.core.plugin.config.ConfigParser;
|
import net.momirealms.craftengine.core.plugin.config.ConfigParser;
|
||||||
import net.momirealms.craftengine.core.plugin.config.SectionConfigParser;
|
import net.momirealms.craftengine.core.plugin.config.SectionConfigParser;
|
||||||
import net.momirealms.craftengine.core.plugin.config.StringKeyConstructor;
|
import net.momirealms.craftengine.core.plugin.config.StringKeyConstructor;
|
||||||
import net.momirealms.craftengine.core.plugin.locale.LangData;
|
import net.momirealms.craftengine.core.plugin.locale.*;
|
||||||
import net.momirealms.craftengine.core.plugin.locale.LocalizedException;
|
|
||||||
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
|
|
||||||
import net.momirealms.craftengine.core.plugin.locale.TranslationManager;
|
|
||||||
import net.momirealms.craftengine.core.plugin.logger.Debugger;
|
import net.momirealms.craftengine.core.plugin.logger.Debugger;
|
||||||
import net.momirealms.craftengine.core.sound.AbstractSoundManager;
|
import net.momirealms.craftengine.core.sound.AbstractSoundManager;
|
||||||
import net.momirealms.craftengine.core.sound.SoundEvent;
|
import net.momirealms.craftengine.core.sound.SoundEvent;
|
||||||
@@ -407,7 +404,7 @@ public abstract class AbstractPackManager implements PackManager {
|
|||||||
}
|
}
|
||||||
Pack pack = new Pack(path, new PackMeta(author, description, version, namespace), enable);
|
Pack pack = new Pack(path, new PackMeta(author, description, version, namespace), enable);
|
||||||
this.loadedPacks.put(path.getFileName().toString(), pack);
|
this.loadedPacks.put(path.getFileName().toString(), pack);
|
||||||
this.plugin.logger().info("Loaded pack: " + pack.folder().getFileName() + ". Default namespace: " + namespace);
|
this.plugin.logger().info(TranslationManager.instance().translateLog("info.pack.load", pack.folder().getFileName().toString(), namespace));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@@ -695,7 +692,12 @@ public abstract class AbstractPackManager implements PackManager {
|
|||||||
parser.loadAll();
|
parser.loadAll();
|
||||||
parser.postProcess();
|
parser.postProcess();
|
||||||
long t2 = System.nanoTime();
|
long t2 = System.nanoTime();
|
||||||
this.plugin.logger().info("Loaded " + parser.sectionId()[0] + " in " + String.format("%.2f", ((t2 - t1) / 1_000_000.0)) + " ms");
|
int count = parser.count();
|
||||||
|
if (parser.silentIfNotExists() && count == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
this.plugin.logger().info(TranslationManager.instance().translateLog("info.resource.load",
|
||||||
|
parser.sectionId()[0], String.format("%.2f", ((t2 - t1) / 1_000_000.0)), String.valueOf(count)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -720,7 +722,7 @@ public abstract class AbstractPackManager implements PackManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateResourcePack() throws IOException {
|
public void generateResourcePack() throws IOException {
|
||||||
this.plugin.logger().info("Generating resource pack...");
|
this.plugin.logger().info(TranslationManager.instance().translateLog("info.resource_pack.start"));
|
||||||
long time1 = System.currentTimeMillis();
|
long time1 = System.currentTimeMillis();
|
||||||
|
|
||||||
// Create cache data
|
// Create cache data
|
||||||
@@ -768,17 +770,17 @@ public abstract class AbstractPackManager implements PackManager {
|
|||||||
this.removeAllShaders(generatedPackPath);
|
this.removeAllShaders(generatedPackPath);
|
||||||
}
|
}
|
||||||
long time2 = System.currentTimeMillis();
|
long time2 = System.currentTimeMillis();
|
||||||
this.plugin.logger().info("Generated resource pack in " + (time2 - time1) + "ms");
|
this.plugin.logger().info(TranslationManager.instance().translateLog("info.resource_pack.generate", String.valueOf(time2 - time1)));
|
||||||
if (Config.validateResourcePack()) {
|
if (Config.validateResourcePack()) {
|
||||||
this.validateResourcePack(generatedPackPath);
|
this.validateResourcePack(generatedPackPath);
|
||||||
}
|
}
|
||||||
long time3 = System.currentTimeMillis();
|
long time3 = System.currentTimeMillis();
|
||||||
this.plugin.logger().info("Validated resource pack in " + (time3 - time2) + "ms");
|
this.plugin.logger().info(TranslationManager.instance().translateLog("info.resource_pack.validate", String.valueOf(time3 - time2)));
|
||||||
if (Config.optimizeResourcePack()) {
|
if (Config.optimizeResourcePack()) {
|
||||||
this.optimizeResourcePack(generatedPackPath);
|
this.optimizeResourcePack(generatedPackPath);
|
||||||
}
|
}
|
||||||
long time4 = System.currentTimeMillis();
|
long time4 = System.currentTimeMillis();
|
||||||
this.plugin.logger().info("Optimized resource pack in " + (time4 - time3) + "ms");
|
this.plugin.logger().info(TranslationManager.instance().translateLog("info.resource_pack.optimize", String.valueOf(time4 - time3)));
|
||||||
Path finalPath = resourcePackPath();
|
Path finalPath = resourcePackPath();
|
||||||
Files.createDirectories(finalPath.getParent());
|
Files.createDirectories(finalPath.getParent());
|
||||||
try {
|
try {
|
||||||
@@ -787,7 +789,7 @@ public abstract class AbstractPackManager implements PackManager {
|
|||||||
this.plugin.logger().severe("Error zipping resource pack", e);
|
this.plugin.logger().severe("Error zipping resource pack", e);
|
||||||
}
|
}
|
||||||
long time5 = System.currentTimeMillis();
|
long time5 = System.currentTimeMillis();
|
||||||
this.plugin.logger().info("Created resource pack zip file in " + (time5 - time4) + "ms");
|
this.plugin.logger().info(TranslationManager.instance().translateLog("info.resource_pack.create", String.valueOf(time5 - time4)));
|
||||||
this.generationEventDispatcher.accept(generatedPackPath, finalPath);
|
this.generationEventDispatcher.accept(generatedPackPath, finalPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1042,7 +1044,7 @@ public abstract class AbstractPackManager implements PackManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Config.optimizeJson()) {
|
if (Config.optimizeJson()) {
|
||||||
this.plugin.logger().info("> Optimizing json files...");
|
this.plugin.logger().info(TranslationManager.instance().translateLog("info.resource_pack.optimize.json"));
|
||||||
AtomicLong previousBytes = new AtomicLong(0L);
|
AtomicLong previousBytes = new AtomicLong(0L);
|
||||||
AtomicLong afterBytes = new AtomicLong(0L);
|
AtomicLong afterBytes = new AtomicLong(0L);
|
||||||
List<CompletableFuture<Void>> futures = new ArrayList<>();
|
List<CompletableFuture<Void>> futures = new ArrayList<>();
|
||||||
@@ -1109,11 +1111,11 @@ public abstract class AbstractPackManager implements PackManager {
|
|||||||
long originalSize = previousBytes.get();
|
long originalSize = previousBytes.get();
|
||||||
long optimizedSize = afterBytes.get();
|
long optimizedSize = afterBytes.get();
|
||||||
double compressionRatio = ((double) optimizedSize / originalSize) * 100;
|
double compressionRatio = ((double) optimizedSize / originalSize) * 100;
|
||||||
this.plugin.logger().info("□ Before/After/Ratio: " + formatSize(originalSize) + "/" + formatSize(optimizedSize) + "/" + String.format("%.2f%%", compressionRatio));
|
this.plugin.logger().info(TranslationManager.instance().translateLog("info.resource_pack.optimize.result", formatSize(originalSize), formatSize(optimizedSize), String.format("%.2f%%", compressionRatio)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.optimizeTexture()) {
|
if (Config.optimizeTexture()) {
|
||||||
this.plugin.logger().info("> Optimizing textures...");
|
this.plugin.logger().info(TranslationManager.instance().translateLog("info.resource_pack.optimize.texture"));
|
||||||
AtomicLong previousBytes = new AtomicLong(0L);
|
AtomicLong previousBytes = new AtomicLong(0L);
|
||||||
AtomicLong afterBytes = new AtomicLong(0L);
|
AtomicLong afterBytes = new AtomicLong(0L);
|
||||||
List<CompletableFuture<Void>> futures = new ArrayList<>();
|
List<CompletableFuture<Void>> futures = new ArrayList<>();
|
||||||
@@ -1155,7 +1157,7 @@ public abstract class AbstractPackManager implements PackManager {
|
|||||||
long originalSize = previousBytes.get();
|
long originalSize = previousBytes.get();
|
||||||
long optimizedSize = afterBytes.get();
|
long optimizedSize = afterBytes.get();
|
||||||
double compressionRatio = ((double) optimizedSize / originalSize) * 100;
|
double compressionRatio = ((double) optimizedSize / originalSize) * 100;
|
||||||
this.plugin.logger().info("□ Before/After/Ratio: " + formatSize(originalSize) + "/" + formatSize(optimizedSize) + "/" + String.format("%.2f%%", compressionRatio));
|
this.plugin.logger().info(TranslationManager.instance().translateLog("info.resource_pack.optimize.result", formatSize(originalSize), formatSize(optimizedSize), String.format("%.2f%%", compressionRatio)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1170,7 +1172,7 @@ public abstract class AbstractPackManager implements PackManager {
|
|||||||
" ".repeat(Math.max(0, emptyLength)) +
|
" ".repeat(Math.max(0, emptyLength)) +
|
||||||
"]";
|
"]";
|
||||||
return String.format(
|
return String.format(
|
||||||
"%s %d/%d (%.1f%%) | Time: %ss",
|
"%s %d/%d (%.1f%%) | %ss",
|
||||||
progressBar,
|
progressBar,
|
||||||
current,
|
current,
|
||||||
total,
|
total,
|
||||||
@@ -2854,6 +2856,11 @@ public abstract class AbstractPackManager implements PackManager {
|
|||||||
this.excludeJson.clear();
|
this.excludeJson.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int count() {
|
||||||
|
return this.excludeJson.size() + this.excludeTexture.size();
|
||||||
|
}
|
||||||
|
|
||||||
public Set<String> excludeTexture() {
|
public Set<String> excludeTexture() {
|
||||||
return excludeTexture;
|
return excludeTexture;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import net.momirealms.craftengine.core.pack.host.ResourcePackHostFactory;
|
|||||||
import net.momirealms.craftengine.core.pack.host.ResourcePackHosts;
|
import net.momirealms.craftengine.core.pack.host.ResourcePackHosts;
|
||||||
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
||||||
import net.momirealms.craftengine.core.plugin.locale.LocalizedException;
|
import net.momirealms.craftengine.core.plugin.locale.LocalizedException;
|
||||||
|
import net.momirealms.craftengine.core.plugin.locale.TranslationManager;
|
||||||
import net.momirealms.craftengine.core.util.*;
|
import net.momirealms.craftengine.core.util.*;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@@ -85,7 +86,7 @@ public class AlistHost implements ResourcePackHost {
|
|||||||
new TypeToken<Map<String, String>>(){}.getType()
|
new TypeToken<Map<String, String>>(){}.getType()
|
||||||
);
|
);
|
||||||
this.cachedSha1 = cache.get("sha1");
|
this.cachedSha1 = cache.get("sha1");
|
||||||
CraftEngine.instance().logger().info("[Alist] Loaded cached resource pack metadata");
|
CraftEngine.instance().logger().info(TranslationManager.instance().translateLog("info.host.cache.load", "Alist"));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
CraftEngine.instance().logger().warn("[Alist] Failed to load cache " + cachePath, e);
|
CraftEngine.instance().logger().warn("[Alist] Failed to load cache " + cachePath, e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import net.momirealms.craftengine.core.pack.host.ResourcePackHostFactory;
|
|||||||
import net.momirealms.craftengine.core.pack.host.ResourcePackHosts;
|
import net.momirealms.craftengine.core.pack.host.ResourcePackHosts;
|
||||||
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
||||||
import net.momirealms.craftengine.core.plugin.locale.LocalizedException;
|
import net.momirealms.craftengine.core.plugin.locale.LocalizedException;
|
||||||
|
import net.momirealms.craftengine.core.plugin.locale.TranslationManager;
|
||||||
import net.momirealms.craftengine.core.util.*;
|
import net.momirealms.craftengine.core.util.*;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -58,7 +59,7 @@ public class DropboxHost implements ResourcePackHost {
|
|||||||
this.refreshToken = getString(cache, "refresh_token");
|
this.refreshToken = getString(cache, "refresh_token");
|
||||||
this.accessToken = getString(cache, "access_token");
|
this.accessToken = getString(cache, "access_token");
|
||||||
this.expiresAt = getLong(cache, "expires_at");
|
this.expiresAt = getLong(cache, "expires_at");
|
||||||
CraftEngine.instance().logger().info("[Dropbox] Loaded cached resource pack info");
|
CraftEngine.instance().logger().info(TranslationManager.instance().translateLog("info.host.cache.load", "Dropbox"));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
CraftEngine.instance().logger().warn("[Dropbox] Failed to load cache " + cachePath, e);
|
CraftEngine.instance().logger().warn("[Dropbox] Failed to load cache " + cachePath, e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import net.momirealms.craftengine.core.pack.host.ResourcePackHostFactory;
|
|||||||
import net.momirealms.craftengine.core.pack.host.ResourcePackHosts;
|
import net.momirealms.craftengine.core.pack.host.ResourcePackHosts;
|
||||||
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
||||||
import net.momirealms.craftengine.core.plugin.locale.LocalizedException;
|
import net.momirealms.craftengine.core.plugin.locale.LocalizedException;
|
||||||
|
import net.momirealms.craftengine.core.plugin.locale.TranslationManager;
|
||||||
import net.momirealms.craftengine.core.util.*;
|
import net.momirealms.craftengine.core.util.*;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -58,7 +59,7 @@ public class GitLabHost implements ResourcePackHost {
|
|||||||
if (uuidString != null && !uuidString.isEmpty()) {
|
if (uuidString != null && !uuidString.isEmpty()) {
|
||||||
this.uuid = UUID.fromString(uuidString);
|
this.uuid = UUID.fromString(uuidString);
|
||||||
}
|
}
|
||||||
CraftEngine.instance().logger().info("[GitLab] Loaded cached resource pack info");
|
CraftEngine.instance().logger().info(TranslationManager.instance().translateLog("info.host.cache.load", "GitLab"));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
CraftEngine.instance().logger().warn(
|
CraftEngine.instance().logger().warn(
|
||||||
"[GitLab] Failed to read cache file: " + cachePath, e);
|
"[GitLab] Failed to read cache file: " + cachePath, e);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import net.momirealms.craftengine.core.pack.host.ResourcePackHostFactory;
|
|||||||
import net.momirealms.craftengine.core.pack.host.ResourcePackHosts;
|
import net.momirealms.craftengine.core.pack.host.ResourcePackHosts;
|
||||||
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
||||||
import net.momirealms.craftengine.core.plugin.locale.LocalizedException;
|
import net.momirealms.craftengine.core.plugin.locale.LocalizedException;
|
||||||
|
import net.momirealms.craftengine.core.plugin.locale.TranslationManager;
|
||||||
import net.momirealms.craftengine.core.util.GsonHelper;
|
import net.momirealms.craftengine.core.util.GsonHelper;
|
||||||
import net.momirealms.craftengine.core.util.Key;
|
import net.momirealms.craftengine.core.util.Key;
|
||||||
import net.momirealms.craftengine.core.util.MiscUtils;
|
import net.momirealms.craftengine.core.util.MiscUtils;
|
||||||
@@ -70,7 +71,7 @@ public class LobFileHost implements ResourcePackHost {
|
|||||||
if (uuidString != null && !uuidString.isEmpty()) {
|
if (uuidString != null && !uuidString.isEmpty()) {
|
||||||
this.uuid = UUID.fromString(uuidString);
|
this.uuid = UUID.fromString(uuidString);
|
||||||
}
|
}
|
||||||
CraftEngine.instance().logger().info("[LobFile] Loaded cached resource pack info");
|
CraftEngine.instance().logger().info(TranslationManager.instance().translateLog("info.host.cache.load", "LobFile"));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
CraftEngine.instance().logger().warn(
|
CraftEngine.instance().logger().warn(
|
||||||
"[LobFile] Failed to read cache file: " + e.getMessage());
|
"[LobFile] Failed to read cache file: " + e.getMessage());
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import net.momirealms.craftengine.core.pack.host.ResourcePackHostFactory;
|
|||||||
import net.momirealms.craftengine.core.pack.host.ResourcePackHosts;
|
import net.momirealms.craftengine.core.pack.host.ResourcePackHosts;
|
||||||
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
||||||
import net.momirealms.craftengine.core.plugin.locale.LocalizedException;
|
import net.momirealms.craftengine.core.plugin.locale.LocalizedException;
|
||||||
|
import net.momirealms.craftengine.core.plugin.locale.TranslationManager;
|
||||||
import net.momirealms.craftengine.core.util.*;
|
import net.momirealms.craftengine.core.util.*;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
@@ -76,7 +77,7 @@ public class OneDriveHost implements ResourcePackHost {
|
|||||||
this.sha1 = cache.get("sha1");
|
this.sha1 = cache.get("sha1");
|
||||||
this.fileId = cache.get("file-id");
|
this.fileId = cache.get("file-id");
|
||||||
|
|
||||||
CraftEngine.instance().logger().info("[OneDrive] Loaded cached resource pack info");
|
CraftEngine.instance().logger().info(TranslationManager.instance().translateLog("info.host.cache.load", "OneDrive"));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
CraftEngine.instance().logger().warn(
|
CraftEngine.instance().logger().warn(
|
||||||
"[OneDrive] Failed to load cache" + cachePath, e);
|
"[OneDrive] Failed to load cache" + cachePath, e);
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import io.netty.util.CharsetUtil;
|
|||||||
import io.netty.util.concurrent.GlobalEventExecutor;
|
import io.netty.util.concurrent.GlobalEventExecutor;
|
||||||
import net.momirealms.craftengine.core.pack.host.ResourcePackDownloadData;
|
import net.momirealms.craftengine.core.pack.host.ResourcePackDownloadData;
|
||||||
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
||||||
|
import net.momirealms.craftengine.core.plugin.locale.TranslationManager;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
@@ -166,7 +167,7 @@ public class SelfHostHttpServer {
|
|||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
serverChannel = b.bind(port).sync().channel();
|
serverChannel = b.bind(port).sync().channel();
|
||||||
CraftEngine.instance().logger().info("Netty HTTP server started on port: " + port);
|
CraftEngine.instance().logger().info(TranslationManager.instance().translateLog("info.host.self.netty_server", String.valueOf(port)));
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
CraftEngine.instance().logger().warn("Failed to start Netty server", e);
|
CraftEngine.instance().logger().warn("Failed to start Netty server", e);
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
|
|||||||
@@ -25,4 +25,12 @@ public interface ConfigParser extends Comparable<ConfigParser> {
|
|||||||
void loadAll();
|
void loadAll();
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
|
default int count() {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
default boolean silentIfNotExists() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,6 +51,11 @@ public class TemplateManagerImpl implements TemplateManager {
|
|||||||
return LoadingSequence.TEMPLATE;
|
return LoadingSequence.TEMPLATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int count() {
|
||||||
|
return TemplateManagerImpl.this.templates.size();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void parseObject(Pack pack, Path path, String node, Key id, Object obj) {
|
public void parseObject(Pack pack, Path path, String node, Key id, Object obj) {
|
||||||
if (TemplateManagerImpl.this.templates.containsKey(id)) {
|
if (TemplateManagerImpl.this.templates.containsKey(id)) {
|
||||||
|
|||||||
@@ -49,6 +49,11 @@ public class GlobalVariableManager implements Manageable {
|
|||||||
return CONFIG_SECTION_NAME;
|
return CONFIG_SECTION_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int count() {
|
||||||
|
return GlobalVariableManager.this.globalVariables.size();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void parseObject(Pack pack, Path path, String node, Key id, Object object) throws LocalizedException {
|
public void parseObject(Pack pack, Path path, String node, Key id, Object object) throws LocalizedException {
|
||||||
if (object != null) {
|
if (object != null) {
|
||||||
|
|||||||
@@ -109,6 +109,11 @@ public class ItemBrowserManagerImpl implements ItemBrowserManager {
|
|||||||
return LoadingSequence.CATEGORY;
|
return LoadingSequence.CATEGORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int count() {
|
||||||
|
return ItemBrowserManagerImpl.this.byId.size();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void parseSection(Pack pack, Path path, String node, Key id, Map<String, Object> section) {
|
public void parseSection(Pack pack, Path path, String node, Key id, Map<String, Object> section) {
|
||||||
String name = section.getOrDefault("name", id).toString();
|
String name = section.getOrDefault("name", id).toString();
|
||||||
|
|||||||
@@ -4,13 +4,12 @@ import net.kyori.adventure.text.Component;
|
|||||||
import net.kyori.adventure.translation.Translator;
|
import net.kyori.adventure.translation.Translator;
|
||||||
import net.momirealms.craftengine.core.plugin.Manageable;
|
import net.momirealms.craftengine.core.plugin.Manageable;
|
||||||
import net.momirealms.craftengine.core.plugin.config.ConfigParser;
|
import net.momirealms.craftengine.core.plugin.config.ConfigParser;
|
||||||
|
import net.momirealms.craftengine.core.plugin.text.minimessage.IndexedArgumentTag;
|
||||||
|
import net.momirealms.craftengine.core.util.AdventureHelper;
|
||||||
import org.incendo.cloud.suggestion.Suggestion;
|
import org.incendo.cloud.suggestion.Suggestion;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public interface TranslationManager extends Manageable {
|
public interface TranslationManager extends Manageable {
|
||||||
@@ -74,6 +73,15 @@ public interface TranslationManager extends Manageable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default String translateLog(String id, String... arguments) {
|
||||||
|
String translation = miniMessageTranslation(id);
|
||||||
|
if (translation == null) {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
Component deserialize = AdventureHelper.customMiniMessage().deserialize(translation, new IndexedArgumentTag(Arrays.stream(arguments).map(Component::text).toList()));
|
||||||
|
return AdventureHelper.plainTextContent(deserialize);
|
||||||
|
}
|
||||||
|
|
||||||
Set<String> translationKeys();
|
Set<String> translationKeys();
|
||||||
|
|
||||||
void log(String id, String... args);
|
void log(String id, String... args);
|
||||||
|
|||||||
@@ -277,6 +277,7 @@ public class TranslationManagerImpl implements TranslationManager {
|
|||||||
|
|
||||||
public class TranslationParser extends IdSectionConfigParser {
|
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"};
|
||||||
|
private int count;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int loadingSequence() {
|
public int loadingSequence() {
|
||||||
@@ -288,6 +289,16 @@ public class TranslationManagerImpl implements TranslationManager {
|
|||||||
return CONFIG_SECTION_NAME;
|
return CONFIG_SECTION_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int count() {
|
||||||
|
return this.count;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void preProcess() {
|
||||||
|
this.count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void parseSection(Pack pack, Path path, String node, net.momirealms.craftengine.core.util.Key id, Map<String, Object> section) {
|
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());
|
Locale locale = TranslationManager.parseLocale(id.value());
|
||||||
@@ -300,6 +311,7 @@ public class TranslationManagerImpl implements TranslationManager {
|
|||||||
String key = entry.getKey();
|
String key = entry.getKey();
|
||||||
bundle.put(key, entry.getValue().toString());
|
bundle.put(key, entry.getValue().toString());
|
||||||
TranslationManagerImpl.this.translationKeys.add(key);
|
TranslationManagerImpl.this.translationKeys.add(key);
|
||||||
|
this.count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
TranslationManagerImpl.this.registry.registerAll(locale, bundle);
|
TranslationManagerImpl.this.registry.registerAll(locale, bundle);
|
||||||
@@ -313,6 +325,7 @@ public class TranslationManagerImpl implements TranslationManager {
|
|||||||
Component deserialize = AdventureHelper.miniMessage().deserialize(AdventureHelper.legacyToMiniMessage(s), ShiftTag.INSTANCE, ImageTag.INSTANCE);
|
Component deserialize = AdventureHelper.miniMessage().deserialize(AdventureHelper.legacyToMiniMessage(s), ShiftTag.INSTANCE, ImageTag.INSTANCE);
|
||||||
return AdventureHelper.getLegacy().serialize(deserialize);
|
return AdventureHelper.getLegacy().serialize(deserialize);
|
||||||
};
|
};
|
||||||
|
private int count;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int loadingSequence() {
|
public int loadingSequence() {
|
||||||
@@ -324,6 +337,16 @@ public class TranslationManagerImpl implements TranslationManager {
|
|||||||
return CONFIG_SECTION_NAME;
|
return CONFIG_SECTION_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int count() {
|
||||||
|
return this.count;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void preProcess() {
|
||||||
|
this.count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void parseSection(Pack pack, Path path, String node, net.momirealms.craftengine.core.util.Key id, Map<String, Object> section) {
|
public void parseSection(Pack pack, Path path, String node, net.momirealms.craftengine.core.util.Key id, Map<String, Object> section) {
|
||||||
String langId = id.value().toLowerCase(Locale.ENGLISH);
|
String langId = id.value().toLowerCase(Locale.ENGLISH);
|
||||||
@@ -333,6 +356,7 @@ public class TranslationManagerImpl implements TranslationManager {
|
|||||||
entry -> this.langProcessor.apply(String.valueOf(entry.getValue()))
|
entry -> this.langProcessor.apply(String.valueOf(entry.getValue()))
|
||||||
));
|
));
|
||||||
TranslationManagerImpl.this.addClientTranslation(langId, sectionData);
|
TranslationManagerImpl.this.addClientTranslation(langId, sectionData);
|
||||||
|
this.count += sectionData.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -97,6 +97,11 @@ public abstract class AbstractSoundManager implements SoundManager {
|
|||||||
return CONFIG_SECTION_NAME;
|
return CONFIG_SECTION_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int count() {
|
||||||
|
return AbstractSoundManager.this.songs.size();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void parseSection(Pack pack, Path path, String node, Key id, Map<String, Object> section) {
|
public void parseSection(Pack pack, Path path, String node, Key id, Map<String, Object> section) {
|
||||||
if (AbstractSoundManager.this.songs.containsKey(id)) {
|
if (AbstractSoundManager.this.songs.containsKey(id)) {
|
||||||
@@ -124,6 +129,11 @@ public abstract class AbstractSoundManager implements SoundManager {
|
|||||||
return CONFIG_SECTION_NAME;
|
return CONFIG_SECTION_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int count() {
|
||||||
|
return AbstractSoundManager.this.byId.size();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void parseSection(Pack pack, Path path, String node, Key id, Map<String, Object> section) {
|
public void parseSection(Pack pack, Path path, String node, Key id, Map<String, Object> section) {
|
||||||
if (AbstractSoundManager.this.byId.containsKey(id)) {
|
if (AbstractSoundManager.this.byId.containsKey(id)) {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx1G
|
|||||||
# Project settings
|
# Project settings
|
||||||
project_version=0.0.65.16
|
project_version=0.0.65.16
|
||||||
config_version=60
|
config_version=60
|
||||||
lang_version=41
|
lang_version=43
|
||||||
project_group=net.momirealms
|
project_group=net.momirealms
|
||||||
latest_supported_version=1.21.10
|
latest_supported_version=1.21.10
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user