1010import org .bukkit .inventory .ShapedRecipe ;
1111import org .bukkit .inventory .ShapelessRecipe ;
1212import org .bukkit .Bukkit ;
13+ import me .rubix327 .itemslangapi .ItemsLangAPI ;
14+ import me .rubix327 .itemslangapi .Lang ;
1315
1416import javax .annotation .Nonnull ;
1517import javax .annotation .Nullable ;
1618import java .util .*;
1719import java .util .stream .Collectors ;
1820
21+
1922public class CalculateCommand implements TabExecutor {
2023
2124 private final CalcStackPlugin plugin ;
@@ -79,7 +82,7 @@ public boolean onCommand(@Nullable CommandSender sender, @Nullable Command comma
7982
8083 Bukkit .getScheduler ().runTask (plugin , () -> {
8184 sender .sendMessage (getLangMessage ("result.header" ));
82- sender .sendMessage (getLangMessage ("result.item" ).replace ("{item}" , material .name ().toLowerCase ()));
85+ sender .sendMessage (getLangMessage ("result.item" ).replace ("{item}" , material .name ().toLowerCase ()). replace ( "{translated_name}" , getTranslatedItemName ( material )) );
8386 sender .sendMessage (getLangMessage ("result.quantity" ).replace ("{quantity}" , String .valueOf (quantity )));
8487 sender .sendMessage (getLangMessage ("result.stacks" ).replace ("{stacks}" , String .valueOf (totalStacks ))
8588 .replace ("{stack_size}" , String .valueOf (maxStackSize )));
@@ -131,7 +134,7 @@ private String formatMaterialDetail(Material material, int quantity, int maxStac
131134 int chests = calculateChests (totalStacks , remainingItems , chestSize );
132135
133136 return getLangMessage ("result.ingredients.item" )
134- .replace ("{ingredient}" , material .name ().toLowerCase ())
137+ .replace ("{ingredient}" , material .name ().toLowerCase ()). replace ( "{translated_name}" , getTranslatedItemName ( material ))
135138 .replace ("{quantity}" , String .valueOf (quantity ))
136139 + "\n " + getLangMessage ("result.ingredients.stacks" )
137140 .replace ("{stacks}" , String .valueOf (totalStacks ))
@@ -178,4 +181,11 @@ private String getLangMessage(@Nonnull String path) {
178181 String message = plugin .getLangConfig ().getString (path );
179182 return message != null ? message : "§c配置错误: 未找到语言文件内容 (" + path + ")!" ;
180183 }
184+
185+ private String getTranslatedItemName (Material material ) {
186+ String translatedName = ItemsLangAPI .getApi ().translate (material , Lang .ZH_CN );
187+ return translatedName != null ? translatedName : material .name ().toLowerCase ();
188+ }
189+
190+
181191}
0 commit comments