!Small cleanup

This commit is contained in:
Jules 2020-07-30 10:00:46 +02:00
parent 9727bacb5c
commit 5213383819
2 changed files with 13 additions and 11 deletions

View File

@ -16,20 +16,20 @@ import net.mmogroup.mmolib.api.util.SmartGive;
public class CraftingRecipe extends Recipe { public class CraftingRecipe extends Recipe {
private final ConfigMMOItem output; private final ConfigMMOItem output;
private final boolean itemRecipe, silent;
private final ConfigurationSection config;
/* /*
* there can't be any crafting time for upgrading recipes since there is no * there can't be any crafting time for upgrading recipes since there is no way
* way to save an MMOItem in the config file TODO save as ItemStack * to save an MMOItem in the config file TODO save as ItemStack
*/ */
private final double craftingTime; private final double craftingTime;
public CraftingRecipe(ConfigurationSection config) { public CraftingRecipe(ConfigurationSection config) {
super(config); super(config);
this.config = config;
craftingTime = config.getDouble("crafting-time"); craftingTime = config.getDouble("crafting-time");
itemRecipe = config.getBoolean("options.output-item", true);
silent = config.getBoolean("options.silent-craft");
/* /*
* load recipe output * load recipe output
@ -47,14 +47,14 @@ public class CraftingRecipe extends Recipe {
/* /*
* this determines whether or not to give an item whenever an item is crafted * this determines whether or not to give an item whenever an item is crafted
* yaml format is 'output-item: false' under options * yaml format is 'output-item: false' under options
*/ */
public boolean isItemRecipe() { public boolean isItemRecipe() {
return config.getBoolean("options.output-item", true); return itemRecipe;
} }
public boolean isSilent() { public boolean isSilent() {
return config.getBoolean("options.silent-craft", false); return silent;
} }
public ConfigMMOItem getOutput() { public ConfigMMOItem getOutput() {
@ -74,8 +74,8 @@ public class CraftingRecipe extends Recipe {
if (!isSilent()) if (!isSilent())
data.getPlayer().playSound(data.getPlayer().getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1); data.getPlayer().playSound(data.getPlayer().getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1);
/* /*
* if recipe not instant, add item to crafting queue, either way * if recipe not instant, add item to crafting queue, either way RELOAD
* RELOAD inventory data and reopen inventory! * inventory data and reopen inventory!
*/ */
} else } else
data.getCrafting().getQueue(station).add(this); data.getCrafting().getQueue(station).add(this);

View File

@ -33,7 +33,9 @@ recipes:
# Recipe options # Recipe options
options: options:
hide-when-locked: false output-item: true # Set to false to give no item
silent-craft: false # No sound when clicking
hide-when-locked: false # Hide in the GUI when conditions are not met
# Conditions to unlock the recipe # Conditions to unlock the recipe
conditions: conditions: