diff --git a/common/common-core/src/main/java/com/iohao/game/action/skeleton/core/ActionCommandRegions.java b/common/common-core/src/main/java/com/iohao/game/action/skeleton/core/ActionCommandRegions.java index 99295dd4..942882d4 100644 --- a/common/common-core/src/main/java/com/iohao/game/action/skeleton/core/ActionCommandRegions.java +++ b/common/common-core/src/main/java/com/iohao/game/action/skeleton/core/ActionCommandRegions.java @@ -18,6 +18,8 @@ */ package com.iohao.game.action.skeleton.core; +import com.iohao.game.action.skeleton.i18n.Bundle; +import com.iohao.game.action.skeleton.i18n.MessageKey; import com.iohao.game.action.skeleton.toy.IoGameBanner; import com.iohao.game.common.kit.MoreKit; import lombok.AccessLevel; @@ -177,15 +179,19 @@ private ActionCommand[][] convertArray(BarSkeletonSetting barSkeletonSetting) { private int getMaxCmd(BarSkeletonSetting barSkeletonSetting) { // 获取最大的路由数字 并且+1 int max = this.regionMap - .keySet() - .stream() - .max(Integer::compareTo) - .orElse(0) + 1; + .keySet() + .stream() + .max(Integer::compareTo) + .orElse(0) + 1; if (max > barSkeletonSetting.getCmdMaxLen()) { - - String info = String.format("cmd 超过最大默认值! 如果有需要, 请手动设置容量! 默认最大容量 %s. 当前容量 %s" - , barSkeletonSetting.getCmdMaxLen(), max + /* + * %s exceeds the maximum default value. + * Please set the capacity manually if necessary. + * Default maximum capacity %d, current capacity %d + */ + var info = Bundle.getMessage(MessageKey.cmdMergeLimit).formatted( + "cmd", barSkeletonSetting.getCmdMaxLen(), max ); IoGameBanner.me().ofRuntimeException(info); @@ -193,12 +199,12 @@ private int getMaxCmd(BarSkeletonSetting barSkeletonSetting) { // subCmd for (ActionCommandRegion actionCommandRegion : this.regionMap.values()) { + int subCmdMax = actionCommandRegion.getMaxSubCmd() + 1; if (subCmdMax > barSkeletonSetting.getSubCmdMaxLen()) { - - String info = String.format("subCmd 超过最大默认值! 如果有需要, 请手动设置容量! 默认最大容量 %s. 当前容量 %s" - , barSkeletonSetting.getSubCmdMaxLen(), subCmdMax + var info = Bundle.getMessage(MessageKey.cmdMergeLimit).formatted( + "subCmd", barSkeletonSetting.getSubCmdMaxLen(), subCmdMax ); IoGameBanner.me().ofRuntimeException(info); diff --git a/common/common-core/src/main/java/com/iohao/game/action/skeleton/core/ActionParserListenerAbout.java b/common/common-core/src/main/java/com/iohao/game/action/skeleton/core/ActionParserListenerAbout.java index 4e4fa6eb..3a47fa0e 100644 --- a/common/common-core/src/main/java/com/iohao/game/action/skeleton/core/ActionParserListenerAbout.java +++ b/common/common-core/src/main/java/com/iohao/game/action/skeleton/core/ActionParserListenerAbout.java @@ -21,6 +21,8 @@ import com.baidu.bjf.remoting.protobuf.annotation.ProtobufClass; import com.iohao.game.action.skeleton.core.action.parser.ActionParserContext; import com.iohao.game.action.skeleton.core.action.parser.ActionParserListener; +import com.iohao.game.action.skeleton.i18n.Bundle; +import com.iohao.game.action.skeleton.i18n.MessageKey; import com.iohao.game.action.skeleton.protocol.wrapper.*; import com.iohao.game.common.kit.ProtoKit; import lombok.AccessLevel; @@ -127,7 +129,7 @@ public void onAfter(BarSkeleton barSkeleton) { return; } - log.error("======== 注意,协议类没有添加 ProtobufClass 注解 ========"); + log.error(Bundle.getMessage(MessageKey.protobufAnnotationCheck)); for (Class protoClass : protoSet) { log.error(protoClass.toString()); } diff --git a/common/common-core/src/main/java/com/iohao/game/action/skeleton/i18n/Bundle.java b/common/common-core/src/main/java/com/iohao/game/action/skeleton/i18n/Bundle.java index 3cf0f278..b3ad4c45 100644 --- a/common/common-core/src/main/java/com/iohao/game/action/skeleton/i18n/Bundle.java +++ b/common/common-core/src/main/java/com/iohao/game/action/skeleton/i18n/Bundle.java @@ -20,7 +20,6 @@ import lombok.experimental.UtilityClass; -import java.text.MessageFormat; import java.util.Locale; import java.util.Objects; import java.util.ResourceBundle; @@ -46,9 +45,4 @@ ResourceBundle getBundle() { public String getMessage(String key) { return getBundle().getString(key); } - - String getMessage(String key, Object... args) { - var keyPattern = getBundle().getString(key); - return MessageFormat.format(keyPattern, args); - } } diff --git a/common/common-core/src/main/java/com/iohao/game/action/skeleton/i18n/MessageKey.java b/common/common-core/src/main/java/com/iohao/game/action/skeleton/i18n/MessageKey.java index fde5696e..764a0127 100644 --- a/common/common-core/src/main/java/com/iohao/game/action/skeleton/i18n/MessageKey.java +++ b/common/common-core/src/main/java/com/iohao/game/action/skeleton/i18n/MessageKey.java @@ -66,4 +66,8 @@ public interface MessageKey { String timeRangeInOutDayTitle = "timeRangeInOutDayTitle"; String timeRangeInOutHourTitle = "timeRangeInOutHourTitle"; String timeRangeInOutMinuteTitle = "timeRangeInOutMinuteTitle"; + /* see ActionCommandRegions.java */ + String cmdMergeLimit = "cmdMergeLimit"; + /* see ProtobufCheckActionParserListener.java */ + String protobufAnnotationCheck = "protobufAnnotationCheck"; } diff --git a/common/common-core/src/main/resources/iohao.properties b/common/common-core/src/main/resources/iohao.properties index c5e5c9fb..c055c0b4 100644 --- a/common/common-core/src/main/resources/iohao.properties +++ b/common/common-core/src/main/resources/iohao.properties @@ -35,3 +35,8 @@ threadMonitorInOutThreadMonitor=thread[%s], execute[%d], avgTime[%d]ms, remainTa timeRangeInOutDayTitle=action execution times[%d] timeRangeInOutHourTitle=%d:00 execute[%s]; timeRangeInOutMinuteTitle=[%d~%d minutes, execute:%d] +# see ActionCommandRegions.java +cmdMergeLimit=%s exceeds the maximum default value. Please set the capacity manually if necessary. Default maximum capacity %d, current capacity %d +# see ProtobufCheckActionParserListener +protobufAnnotationCheck=Note that the protocol class does not have the ProtobufClass annotation added + diff --git a/common/common-core/src/main/resources/iohao_zh_CN.properties b/common/common-core/src/main/resources/iohao_zh_CN.properties index 42fd5e30..cea8f66b 100644 --- a/common/common-core/src/main/resources/iohao_zh_CN.properties +++ b/common/common-core/src/main/resources/iohao_zh_CN.properties @@ -35,3 +35,7 @@ threadMonitorInOutThreadMonitor=业务线程[%s],共执行了[%d]次业务, timeRangeInOutDayTitle=action 执行次数 共 [%d] 次 timeRangeInOutHourTitle=%d:00 共 %s 次; timeRangeInOutMinuteTitle=[%d~%d分钟,%d 次] +# see ActionCommandRegions.java +cmdMergeLimit=%s 超过最大默认值,如有需要请手动设置容量。默认最大容量 %d. 当前容量 %d +# see ProtobufCheckActionParserListener +protobufAnnotationCheck=注意,协议类没有添加 ProtobufClass 注解