mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2025-01-03 06:37:47 +01:00
Merge branch 'master' of https://Indyuce@git.lumine.io/mmoteam/mmoitems.git
This commit is contained in:
commit
9727bacb5c
@ -17,6 +17,8 @@ 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 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 to save an MMOItem in the config file TODO save as ItemStack
|
* way to save an MMOItem in the config file TODO save as ItemStack
|
||||||
@ -25,6 +27,7 @@ public class CraftingRecipe extends Recipe {
|
|||||||
|
|
||||||
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");
|
||||||
|
|
||||||
@ -42,6 +45,18 @@ public class CraftingRecipe extends Recipe {
|
|||||||
return craftingTime <= 0;
|
return craftingTime <= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* this determines whether or not to give an item whenever an item is crafted
|
||||||
|
* yaml format is 'output-item: false' under options
|
||||||
|
*/
|
||||||
|
public boolean isItemRecipe() {
|
||||||
|
return config.getBoolean("options.output-item", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSilent() {
|
||||||
|
return config.getBoolean("options.silent-craft", false);
|
||||||
|
}
|
||||||
|
|
||||||
public ConfigMMOItem getOutput() {
|
public ConfigMMOItem getOutput() {
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
@ -53,9 +68,11 @@ public class CraftingRecipe extends Recipe {
|
|||||||
* directly add the ingredients to the player inventory
|
* directly add the ingredients to the player inventory
|
||||||
*/
|
*/
|
||||||
if (isInstant()) {
|
if (isInstant()) {
|
||||||
new SmartGive(data.getPlayer()).give(getOutput().generate());
|
if (isItemRecipe())
|
||||||
|
new SmartGive(data.getPlayer()).give(getOutput().generate());
|
||||||
recipe.getRecipe().getTriggers().forEach(trigger -> trigger.whenCrafting(data));
|
recipe.getRecipe().getTriggers().forEach(trigger -> trigger.whenCrafting(data));
|
||||||
|
if (!isSilent())
|
||||||
|
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 inventory data and reopen inventory!
|
* RELOAD inventory data and reopen inventory!
|
||||||
@ -63,7 +80,8 @@ public class CraftingRecipe extends Recipe {
|
|||||||
} else
|
} else
|
||||||
data.getCrafting().getQueue(station).add(this);
|
data.getCrafting().getQueue(station).add(this);
|
||||||
|
|
||||||
data.getPlayer().playSound(data.getPlayer().getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1);
|
if (!isInstant())
|
||||||
|
data.getPlayer().playSound(data.getPlayer().getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -12,7 +12,7 @@ public class CommandTrigger extends Trigger {
|
|||||||
super("command");
|
super("command");
|
||||||
|
|
||||||
config.validate("format");
|
config.validate("format");
|
||||||
player = config.getBoolean("player");
|
player = config.getBoolean("player", false);
|
||||||
command = config.getString("format");
|
command = config.getString("format");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,8 +178,6 @@ public class CraftingStationView extends PluginInventory {
|
|||||||
if (!(tag = item.getString("queueId")).equals("")) {
|
if (!(tag = item.getString("queueId")).equals("")) {
|
||||||
UUID uuid = UUID.fromString(tag);
|
UUID uuid = UUID.fromString(tag);
|
||||||
CraftingInfo craft = data.getCrafting().getQueue(station).getCraft(uuid);
|
CraftingInfo craft = data.getCrafting().getQueue(station).getCraft(uuid);
|
||||||
|
|
||||||
data.getPlayer().playSound(data.getPlayer().getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1);
|
|
||||||
data.getCrafting().getQueue(station).remove(craft);
|
data.getCrafting().getQueue(station).remove(craft);
|
||||||
|
|
||||||
if (craft.isReady()) {
|
if (craft.isReady()) {
|
||||||
@ -187,10 +185,16 @@ public class CraftingStationView extends PluginInventory {
|
|||||||
recipe.getTriggers().forEach(trigger -> trigger.whenCrafting(data));
|
recipe.getTriggers().forEach(trigger -> trigger.whenCrafting(data));
|
||||||
ItemStack craftedItem = recipe.getOutput().generate();
|
ItemStack craftedItem = recipe.getOutput().generate();
|
||||||
CustomSoundListener.stationCrafting(craftedItem, data.getPlayer());
|
CustomSoundListener.stationCrafting(craftedItem, data.getPlayer());
|
||||||
new SmartGive(data.getPlayer()).give(craftedItem);
|
if (!recipe.isSilent())
|
||||||
} else
|
data.getPlayer().playSound(data.getPlayer().getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1);
|
||||||
|
if (recipe.isItemRecipe())
|
||||||
|
new SmartGive(data.getPlayer()).give(craftedItem);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
data.getPlayer().playSound(data.getPlayer().getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1);
|
||||||
for (Ingredient ingredient : craft.getRecipe().getIngredients())
|
for (Ingredient ingredient : craft.getRecipe().getIngredients())
|
||||||
new SmartGive(data.getPlayer()).give(ingredient.generateItemStack());
|
new SmartGive(data.getPlayer()).give(ingredient.generateItemStack());
|
||||||
|
}
|
||||||
|
|
||||||
updateData();
|
updateData();
|
||||||
open();
|
open();
|
||||||
|
Loading…
Reference in New Issue
Block a user