Skip to content

Commit 2579c72

Browse files
author
Lee Zheng Han
committed
Add loadRecipe for separation of concerns
1 parent a9b0932 commit 2579c72

File tree

1 file changed

+13
-20
lines changed

1 file changed

+13
-20
lines changed

src/main/java/com/paratopiamc/colorbundles/ColorBundles.java

+13-20
Original file line numberDiff line numberDiff line change
@@ -91,17 +91,8 @@ public void onEnable() {
9191
ChatColor.WHITE + WordUtils.capitalize(dye.toString().replaceAll("_", " ")) + " Bundle");
9292
item.setItemMeta(meta);
9393

94-
NamespacedKey key = new NamespacedKey(this, dye + "_bundle");
95-
ShapelessRecipe recipe = new ShapelessRecipe(key, item);
96-
recipe.addIngredient(Material.BUNDLE);
97-
recipe.addIngredient(dye.getDye());
98-
99-
Bukkit.addRecipe(recipe);
100-
94+
loadRecipe(dye, item);
10195
recipeKeys.add(dye + "_bundle");
102-
103-
getServer().getConsoleSender()
104-
.sendMessage(ChatColor.GREEN + "[ColorBundles] Loaded recipes: " + dye + "_bundle");
10596
}
10697
}
10798
}
@@ -111,20 +102,22 @@ public void onItemsLoadEvent(ItemsAdderFirstLoadEvent evt) {
111102
for (Dyes dye : Dyes.values()) {
112103
ItemStack item = CustomStack.getInstance("colorbundles:" + dye + "_bundle").getItemStack();
113104

114-
NamespacedKey key = new NamespacedKey(this, dye + "_bundle");
115-
ShapelessRecipe recipe = new ShapelessRecipe(key, item);
116-
recipe.addIngredient(Material.BUNDLE);
117-
recipe.addIngredient(dye.getDye());
118-
119-
Bukkit.addRecipe(recipe);
120-
105+
loadRecipe(dye, item);
121106
recipeKeys.add(dye + "_bundle");
122-
123-
getServer().getConsoleSender()
124-
.sendMessage(ChatColor.GREEN + "[ColorBundles] Loaded recipes: " + dye + "_bundle");
125107
}
126108
}
127109

110+
private void loadRecipe(Dyes dye, ItemStack result) {
111+
NamespacedKey key = new NamespacedKey(this, dye + "_bundle");
112+
ShapelessRecipe recipe = new ShapelessRecipe(key, result);
113+
recipe.addIngredient(Material.BUNDLE);
114+
recipe.addIngredient(dye.getDye());
115+
116+
Bukkit.addRecipe(recipe);
117+
getServer().getConsoleSender()
118+
.sendMessage(ChatColor.GREEN + "[ColorBundles] Loaded recipes: " + dye + "_bundle");
119+
}
120+
128121
public List<String> getRecipeKeys() {
129122
return this.recipeKeys;
130123
}

0 commit comments

Comments
 (0)