Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public void onEnable() {
@Override
public void onDisable() {
CustomFishingHook.cleanupAll();
BlightedPlayer.saveAllSync();
if (database != null) {
database.closeConnection();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,51 +14,55 @@ public class ThermalFuels implements RegistryModule<Consumer<BlightedItem>> {
public void register(Consumer<BlightedItem> registry) {
BlightedItem enchantedCoal = new BlightedItem("ENCHANTED_COAL", ItemType.MATERIAL, ItemRarity.UNCOMMON, Material.COAL);
enchantedCoal.setDisplayName("Enchanted Coal");
enchantedCoal.description(
enchantedCoal.addLore(
"§8Thermal Fuel",
"",
"Ultra-dense carbon radiating",
"with intense heat that adds",
"§6\uD83E\uDEA3 3,000mB §7to a refuelable",
"machine."
" §7Ultra-dense carbon radiating",
" §7with intense heat that adds",
" §6\uD83E\uDEA3 3,000mB §7to a refuelable",
" §7machine.",
""
);
enchantedCoal.glow();

BlightedItem enchantedLavaBucket = new BlightedItem("ENCHANTED_LAVA_BUCKET", ItemType.UNCATEGORIZED, ItemRarity.RARE, Material.LAVA_BUCKET);
enchantedLavaBucket.setDisplayName("Enchanted Lava Bucket");
enchantedLavaBucket.description(
enchantedLavaBucket.addLore(
"§8Thermal Fuel",
"",
"Enriched lava capable of",
"prolonged burning that adds",
"§6\uD83E\uDEA3 10,000mB §7to a refuelable",
"machine."
" §7Enriched lava capable of",
" §7prolonged burning that adds",
" §6\uD83E\uDEA3 10,000mB §7to a refuelable",
" §7machine.",
""
);
enchantedLavaBucket.glow();
enchantedLavaBucket.preventBucketInteractions();

BlightedItem magmaBucket = new BlightedItem("MAGMA_BUCKET", ItemType.UNCATEGORIZED, ItemRarity.EPIC, Material.LAVA_BUCKET);
magmaBucket.setDisplayName("Magma Bucket");
magmaBucket.description(
magmaBucket.addLore(
"§8Thermal Fuel",
"",
"A superheated amalgam of",
"compressed magma that adds",
"§6\uD83E\uDEA3 20,000mB §7to a refuelable",
"machine."
" §7A superheated amalgam of",
" §7compressed magma that adds",
" §6\uD83E\uDEA3 20,000mB §7to a refuelable",
" §7machine.",
""
);
magmaBucket.glow();
magmaBucket.preventBucketInteractions();

BlightedItem plasmaBucket = new BlightedItem("PLASMA_BUCKET", ItemType.UNCATEGORIZED, ItemRarity.LEGENDARY, Material.LAVA_BUCKET);
plasmaBucket.setDisplayName("Plasma Bucket");
plasmaBucket.description(
plasmaBucket.addLore(
"§8Thermal Fuel",
"",
"Stable ionized matter containing",
"stellar-grade heat that adds",
"§6\uD83E\uDEA3 50,000mB §7to a refuelable",
"machine."
" §7Stable ionized matter containing",
" §7stellar-grade heat that adds",
" §6\uD83E\uDEA3 50,000mB §7to a refuelable",
" §7machine.",
""
);
plasmaBucket.glow();
plasmaBucket.preventBucketInteractions();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package fr.moussax.blightedSMP.content.recipes;

import fr.moussax.blightedSMP.engine.recipes.CraftingObject;
import fr.moussax.blightedSMP.engine.recipes.RecipeIngredient;
import fr.moussax.blightedSMP.engine.recipes.forging.ForgeRecipe;
import fr.moussax.blightedSMP.engine.items.registry.ItemRegistry;
import fr.moussax.blightedSMP.registry.RegistryModule;
import java.util.function.Consumer;
import org.bukkit.Material;
Expand All @@ -13,9 +12,9 @@ public void register(Consumer<ForgeRecipe> registry) {
var plasmaBucket = ForgeRecipe.Builder.of("PLASMA_BUCKET", 1)
.fuelCost(10000)
.ingredients(
new CraftingObject(ItemRegistry.get("MAGMA_BUCKET"), 1),
new CraftingObject(ItemRegistry.get("MAGMA_BUCKET"), 1),
new CraftingObject(Material.NETHER_STAR, 1)
RecipeIngredient.of("MAGMA_BUCKET", 1),
RecipeIngredient.of("MAGMA_BUCKET", 1),
RecipeIngredient.of(Material.NETHER_STAR, 1)
)
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import fr.moussax.bedrock.utils.ItemBuilder;
import fr.moussax.blightedSMP.engine.items.BlightedItem;
import fr.moussax.blightedSMP.engine.recipes.CraftingObject;
import fr.moussax.blightedSMP.engine.recipes.RecipeIngredient;
import fr.moussax.blightedSMP.engine.items.registry.ItemRegistry;
import lombok.Getter;
import org.bukkit.Material;
Expand All @@ -23,14 +23,14 @@
public final class AncientRitual {

private final AncientCreature summonedCreature;
private final List<CraftingObject> offerings;
private final List<RecipeIngredient> offerings;
private final ItemStack displayedItem;
private final int gemsCost;
private final int levelCost;

private AncientRitual(
AncientCreature summonedCreature,
List<CraftingObject> offerings,
List<RecipeIngredient> offerings,
ItemStack displayedItem,
int gemsCost,
int levelCost
Expand All @@ -51,7 +51,7 @@ private AncientRitual(
public static final class Builder {

private final AncientCreature summonedCreature;
private final List<CraftingObject> offerings = new ArrayList<>();
private final List<RecipeIngredient> offerings = new ArrayList<>();
private ItemStack displayedItem;
private int gemsCost;
private int levelCost;
Expand Down Expand Up @@ -96,7 +96,7 @@ public Builder displayedItem(
* @param offering required offering
* @return this builder
*/
public Builder addOffering(CraftingObject offering) {
public Builder addOffering(RecipeIngredient offering) {
this.offerings.add(offering);
return this;
}
Expand All @@ -109,7 +109,7 @@ public Builder addOffering(CraftingObject offering) {
* @return this builder
*/
public Builder addOffering(Material material, int amount) {
return addOffering(new CraftingObject(material, amount));
return addOffering(RecipeIngredient.of(material, amount));
}

/**
Expand All @@ -120,7 +120,7 @@ public Builder addOffering(Material material, int amount) {
* @return this builder
*/
public Builder addOffering(BlightedItem item, int amount) {
return addOffering(new CraftingObject(item, amount));
return addOffering(RecipeIngredient.of(item, amount));
}

/**
Expand All @@ -131,7 +131,7 @@ public Builder addOffering(BlightedItem item, int amount) {
* @return this builder
*/
public Builder addOffering(String itemId, int amount) {
return addOffering(ItemRegistry.get(itemId), amount);
return addOffering(RecipeIngredient.of(itemId, amount));
}

/**
Expand All @@ -140,7 +140,7 @@ public Builder addOffering(String itemId, int amount) {
* @param offerings offerings required by the ritual
* @return this builder
*/
public Builder offerings(CraftingObject... offerings) {
public Builder offerings(RecipeIngredient... offerings) {
this.offerings.addAll(List.of(offerings));
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import fr.moussax.bedrock.utils.ItemBuilder;
import fr.moussax.blightedSMP.engine.entities.rituals.AncientRitual;
import fr.moussax.blightedSMP.engine.entities.rituals.registry.RitualRegistry;
import fr.moussax.blightedSMP.engine.recipes.CraftingObject;
import fr.moussax.blightedSMP.engine.recipes.RecipeIngredient;
import fr.moussax.blightedSMP.utils.Utilities;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
Expand Down Expand Up @@ -88,7 +88,7 @@ private ItemStack buildRiteDisplayItem(AncientRitual ritual) {
}

builder.addLore(" §7Offerings required: ");
for (CraftingObject offering : ritual.getOfferings()) {
for (RecipeIngredient offering : ritual.getOfferings()) {
builder.addLore(" §8‣ " + Utilities.extractIngredientName(offering) + " §8x" + offering.getAmount());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import fr.moussax.blightedSMP.engine.entities.rituals.AncientCreature;
import fr.moussax.blightedSMP.engine.entities.rituals.AncientRitual;
import fr.moussax.blightedSMP.engine.entities.rituals.RitualAnimations;
import fr.moussax.blightedSMP.engine.recipes.CraftingObject;
import fr.moussax.blightedSMP.engine.recipes.RecipeIngredient;
import fr.moussax.blightedSMP.engine.player.BlightedPlayer;
import fr.moussax.blightedSMP.utils.Utilities;
import org.bukkit.Bukkit;
Expand Down Expand Up @@ -156,25 +156,21 @@ private Map<String, Integer> aggregateRequirements() {
Map<String, Integer> counts = new HashMap<>();
if (ritual == null) return counts;

for (CraftingObject ingredient : ritual.getOfferings()) {
for (RecipeIngredient ingredient : ritual.getOfferings()) {
counts.merge(ingredient.getId(), ingredient.getAmount(), Integer::sum);
}
return counts;
}

private void displayRequiredIngredients() {
for (int i = 0; i < ritual.getOfferings().size() && i < GRID_SLOTS.length; i++) {
CraftingObject ingredient = ritual.getOfferings().get(i);
RecipeIngredient ingredient = ritual.getOfferings().get(i);
setItem(GRID_SLOTS[i], createDisplayItem(ingredient));
}
}

private ItemStack createDisplayItem(CraftingObject ingredient) {
ItemStack item = ingredient.isCustom()
? Objects.requireNonNull(ingredient.getManager()).toItemStack().clone()
: Objects.requireNonNull(ingredient.getVanillaItem()).clone();
item.setAmount(ingredient.getAmount());
return item;
private ItemStack createDisplayItem(RecipeIngredient ingredient) {
return ingredient.toItemStack();
}

private void setupStatusPanes() {
Expand Down Expand Up @@ -223,7 +219,7 @@ private void setupInvokeButton() {
builder.setDisplayName("§5Invoke " + creatureName)
.addLore("", " §7Offerings required:");

for (CraftingObject ingredient : ritual.getOfferings()) {
for (RecipeIngredient ingredient : ritual.getOfferings()) {
builder.addLore(" §8‣ " + Utilities.extractIngredientName(ingredient) + " §8x" + ingredient.getAmount());
}

Expand Down Expand Up @@ -277,7 +273,7 @@ private void setupNavigationButtons() {
}

private void consumeIngredients(Player player) {
for (CraftingObject ingredient : ritual.getOfferings()) {
for (RecipeIngredient ingredient : ritual.getOfferings()) {
Utilities.consumeItemsFromInventory(player, ingredient);
}
BlightedPlayer.get(player).removeGems(ritual.getGemsCost());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static List<String> render(BlightedItem item) {
if (!description.isEmpty()) {
lore.add("");
for (String line : description) {
lore.add("§7 " + line);
lore.add(line.isEmpty() ? "" : "§7 " + line);
}
}

Expand All @@ -44,7 +44,7 @@ public static List<String> render(BlightedItem item) {
lore.add("§5 Ability: " + ability.getName() + " " + ability.getTrigger().getDisplayName());

for (String line : ability.getDescription()) {
lore.add("§7 " + line);
lore.add(line.isEmpty() ? "" : "§7 " + line);
}

int mana = ability.getManaCost();
Expand Down Expand Up @@ -76,7 +76,6 @@ public static List<String> render(BlightedItem item) {
ItemType type = item.getItemType();
String typeSuffix = (type != null && type != ItemType.UNCATEGORIZED) ? " " + type.name() : "";

lore.add("");
lore.add(rarity.getName() + typeSuffix);

return lore;
Expand Down
Loading
Loading