Skip to content

Commit

Permalink
Merge pull request #72 from Noogear/master
Browse files Browse the repository at this point in the history
shaped生成配置文件调整,重复项合并
  • Loading branch information
YufiriaMazenta authored Aug 19, 2024
2 parents 30b9d86 + e0259fe commit 1f2ea1d
Showing 1 changed file with 19 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,24 +77,29 @@ public CraftingRecipeCreator(@NotNull Player player, RecipeType recipeType, @Not
ConfigWrapper recipeConfig = createRecipeConfig(recipeName);
switch (recipeType()) {
case SHAPED:
List<String> shape = new ArrayList<>(Arrays.asList("abc", "def", "ghi"));
Map<String, Character> itemRepeatMap = new HashMap<>();
List<String> shape = new ArrayList<>();
Map<Character, String> itemNameMap = new HashMap<>();
char[] tmp = "abcdefghi".toCharArray();
for (int i = 0; i < sourceList.size(); i++) {
if (sourceList.get(i).isEmpty()) {
char[] tmp = " ".toCharArray(); //9个空格
char c = 'a';
for(int i = 0; i < sourceList.size(); i++){
String sourceItem = sourceList.get(i);
if (sourceItem.isEmpty()) {
continue;
}
itemNameMap.put(tmp[i], sourceList.get(i));
}
//删除无映射的字符
for (int i = 0; i < shape.size(); i++) {
String s = shape.get(i);
for (char c : s.toCharArray()) {
if (!itemNameMap.containsKey(c)) {
s = s.replace(c, ' ');
}
if (!itemRepeatMap.containsKey(sourceItem)){
itemRepeatMap.put(sourceList.get(i),c);
c++;
}
shape.set(i, s);
tmp[i] = itemRepeatMap.get(sourceItem);
}
for (int i = 0; i < 9; i += 3) {
shape.add(new String(tmp,i,3));
}
c = 'a';
for (String key : itemRepeatMap.keySet()){
itemNameMap.put(c,key);
c++;
}
shape.removeIf(s -> s.trim().isEmpty());
removeEmptyColumn(shape);
Expand Down

0 comments on commit 1f2ea1d

Please sign in to comment.