mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2025-01-04 06:47:34 +01:00
Station view fixed
This commit is contained in:
parent
ff3b195e2b
commit
b70bb270d0
@ -59,7 +59,6 @@ public class CheckedIngredient {
|
|||||||
* It most likely matches ingredient.getAmount()
|
* It most likely matches ingredient.getAmount()
|
||||||
*/
|
*/
|
||||||
public void reduceItem(int amount) {
|
public void reduceItem(int amount) {
|
||||||
|
|
||||||
Iterator<PlayerIngredient> iterator = found.iterator();
|
Iterator<PlayerIngredient> iterator = found.iterator();
|
||||||
while (iterator.hasNext() && amount > 0) {
|
while (iterator.hasNext() && amount > 0) {
|
||||||
ItemStack item = iterator.next().getItem();
|
ItemStack item = iterator.next().getItem();
|
||||||
|
@ -38,6 +38,7 @@ public class UpgradingRecipe extends TimedRecipe {
|
|||||||
// load item being upgraded.
|
// load item being upgraded.
|
||||||
item = new ConfigMMOItem(config.getConfigurationSection("item"));
|
item = new ConfigMMOItem(config.getConfigurationSection("item"));
|
||||||
ingredient = new MMOItemIngredient(item);
|
ingredient = new MMOItemIngredient(item);
|
||||||
|
this.addIngredient(new MMOItemIngredient(item));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -70,6 +71,8 @@ public class UpgradingRecipe extends TimedRecipe {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (isInstant()) {
|
if (isInstant()) {
|
||||||
|
recipe.getRecipe().whenClaimed().forEach(trigger -> trigger.whenCrafting(data));
|
||||||
|
|
||||||
// Update item
|
// Update item
|
||||||
recipe.getUpgradeData().upgrade(recipe.getMMOItem());
|
recipe.getUpgradeData().upgrade(recipe.getMMOItem());
|
||||||
recipe.getUpgraded().setItemMeta(recipe.getMMOItem().newBuilder().build().getItemMeta());
|
recipe.getUpgraded().setItemMeta(recipe.getMMOItem().newBuilder().build().getItemMeta());
|
||||||
@ -171,6 +174,7 @@ public class UpgradingRecipe extends TimedRecipe {
|
|||||||
super(recipe, data, inv);
|
super(recipe, data, inv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public UpgradeData getUpgradeData() {
|
public UpgradeData getUpgradeData() {
|
||||||
return upgradeData;
|
return upgradeData;
|
||||||
}
|
}
|
||||||
|
@ -3,11 +3,13 @@ package net.Indyuce.mmoitems.gui;
|
|||||||
import io.lumine.mythic.lib.MythicLib;
|
import io.lumine.mythic.lib.MythicLib;
|
||||||
import io.lumine.mythic.lib.api.item.NBTItem;
|
import io.lumine.mythic.lib.api.item.NBTItem;
|
||||||
import io.lumine.mythic.lib.api.util.SmartGive;
|
import io.lumine.mythic.lib.api.util.SmartGive;
|
||||||
|
import net.Indyuce.mmoitems.ItemStats;
|
||||||
import net.Indyuce.mmoitems.MMOItems;
|
import net.Indyuce.mmoitems.MMOItems;
|
||||||
import net.Indyuce.mmoitems.api.crafting.CraftingStation;
|
import net.Indyuce.mmoitems.api.crafting.CraftingStation;
|
||||||
import net.Indyuce.mmoitems.api.crafting.CraftingStatus.CraftingQueue;
|
import net.Indyuce.mmoitems.api.crafting.CraftingStatus.CraftingQueue;
|
||||||
import net.Indyuce.mmoitems.api.crafting.CraftingStatus.CraftingQueue.CraftingInfo;
|
import net.Indyuce.mmoitems.api.crafting.CraftingStatus.CraftingQueue.CraftingInfo;
|
||||||
import net.Indyuce.mmoitems.api.crafting.Layout;
|
import net.Indyuce.mmoitems.api.crafting.Layout;
|
||||||
|
import net.Indyuce.mmoitems.api.crafting.ingredient.CheckedIngredient;
|
||||||
import net.Indyuce.mmoitems.api.crafting.ingredient.Ingredient;
|
import net.Indyuce.mmoitems.api.crafting.ingredient.Ingredient;
|
||||||
import net.Indyuce.mmoitems.api.crafting.ingredient.inventory.IngredientInventory;
|
import net.Indyuce.mmoitems.api.crafting.ingredient.inventory.IngredientInventory;
|
||||||
import net.Indyuce.mmoitems.api.crafting.recipe.CheckedRecipe;
|
import net.Indyuce.mmoitems.api.crafting.recipe.CheckedRecipe;
|
||||||
@ -16,10 +18,10 @@ import net.Indyuce.mmoitems.api.crafting.recipe.TimedRecipe;
|
|||||||
import net.Indyuce.mmoitems.api.crafting.recipe.UpgradingRecipe;
|
import net.Indyuce.mmoitems.api.crafting.recipe.UpgradingRecipe;
|
||||||
import net.Indyuce.mmoitems.api.event.PlayerUseCraftingStationEvent;
|
import net.Indyuce.mmoitems.api.event.PlayerUseCraftingStationEvent;
|
||||||
import net.Indyuce.mmoitems.api.item.mmoitem.LiveMMOItem;
|
import net.Indyuce.mmoitems.api.item.mmoitem.LiveMMOItem;
|
||||||
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
|
|
||||||
import net.Indyuce.mmoitems.api.item.util.ConfigItems;
|
import net.Indyuce.mmoitems.api.item.util.ConfigItems;
|
||||||
import net.Indyuce.mmoitems.api.util.message.Message;
|
import net.Indyuce.mmoitems.api.util.message.Message;
|
||||||
import net.Indyuce.mmoitems.listener.CustomSoundListener;
|
import net.Indyuce.mmoitems.listener.CustomSoundListener;
|
||||||
|
import net.Indyuce.mmoitems.stat.data.UpgradeData;
|
||||||
import net.Indyuce.mmoitems.util.MMOUtils;
|
import net.Indyuce.mmoitems.util.MMOUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -174,6 +176,7 @@ public class CraftingStationView extends PluginInventory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!(tag = item.getString("queueId")).isEmpty()) {
|
if (!(tag = item.getString("queueId")).isEmpty()) {
|
||||||
CraftingInfo recipeInfo = playerData.getCrafting().getQueue(station).getCraft(UUID.fromString(tag));
|
CraftingInfo recipeInfo = playerData.getCrafting().getQueue(station).getCraft(UUID.fromString(tag));
|
||||||
TimedRecipe recipe = recipeInfo.getRecipe();
|
TimedRecipe recipe = recipeInfo.getRecipe();
|
||||||
@ -200,17 +203,11 @@ public class CraftingStationView extends PluginInventory {
|
|||||||
player.playSound(player.getLocation(), station.getSound(), 1, 1);
|
player.playSound(player.getLocation(), station.getSound(), 1, 1);
|
||||||
|
|
||||||
if (recipeInfo.getRecipe() instanceof UpgradingRecipe upgradingRecipe) {
|
if (recipeInfo.getRecipe() instanceof UpgradingRecipe upgradingRecipe) {
|
||||||
NBTItem item1 = MythicLib.plugin.getVersion().getWrapper().getNBTItem(event.getCurrentItem());
|
LiveMMOItem upgradedItem = new LiveMMOItem(item);
|
||||||
String tag1 = item.getString("recipeId");
|
((UpgradeData) upgradedItem.getData(ItemStats.UPGRADE)).upgrade(upgradedItem);
|
||||||
if (!tag.isEmpty()) {
|
|
||||||
UpgradingRecipe.CheckedUpgradingRecipe recipe1 = (UpgradingRecipe.CheckedUpgradingRecipe) getRecipe(tag);
|
upgradedItem.getNBT().getItem().setItemMeta(upgradedItem.newBuilder().getMeta());
|
||||||
MMOItem item2 = new LiveMMOItem(item1);
|
new SmartGive(player).give(upgradedItem.newBuilder().build());
|
||||||
recipe1.getUpgradeData().upgrade(item2);
|
|
||||||
recipe1.getUpgraded().setItemMeta(item2.newBuilder().build().getItemMeta());
|
|
||||||
new SmartGive(player).give(item2.newBuilder().build());
|
|
||||||
System.out.println("Upgraded item");
|
|
||||||
} else
|
|
||||||
System.out.println("No item");
|
|
||||||
} else if (result != null)
|
} else if (result != null)
|
||||||
new SmartGive(player).give(result);
|
new SmartGive(player).give(result);
|
||||||
|
|
||||||
@ -261,7 +258,7 @@ public class CraftingStationView extends PluginInventory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (recipe.getRecipe().whenUsed(playerData, ingredients, recipe, station)) {
|
if (recipe.getRecipe().whenUsed(playerData, ingredients, recipe, station)) {
|
||||||
recipe.getIngredients().forEach(ingredient -> ingredient.takeAway());
|
recipe.getIngredients().forEach(CheckedIngredient::takeAway);
|
||||||
recipe.getConditions().forEach(condition -> condition.getCondition().whenCrafting(playerData));
|
recipe.getConditions().forEach(condition -> condition.getCondition().whenCrafting(playerData));
|
||||||
recipe.getRecipe().whenUsed().forEach(trigger -> trigger.whenCrafting(playerData));
|
recipe.getRecipe().whenUsed().forEach(trigger -> trigger.whenCrafting(playerData));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user