Crafting stations minor refactor

This commit is contained in:
Jules 2023-10-01 00:23:34 +02:00
parent bab6b7c9d4
commit ece2213efb
10 changed files with 70 additions and 104 deletions

View File

@ -6,10 +6,7 @@ import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
import net.Indyuce.mmoitems.api.util.message.FFPMMOItems;
import net.Indyuce.mmoitems.gui.edition.EditionInventory;
import net.Indyuce.mmoitems.gui.edition.recipe.registry.*;
import net.Indyuce.mmoitems.gui.edition.recipe.registry.burninglegacy.RMGRR_LBBlast;
import net.Indyuce.mmoitems.gui.edition.recipe.registry.burninglegacy.RMGRR_LBCampfire;
import net.Indyuce.mmoitems.gui.edition.recipe.registry.burninglegacy.RMGRR_LBFurnace;
import net.Indyuce.mmoitems.gui.edition.recipe.registry.burninglegacy.RMGRR_LBSmoker;
import net.Indyuce.mmoitems.gui.edition.recipe.registry.burninglegacy.*;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryAction;
@ -225,10 +222,10 @@ public class RecipeTypeListGUI extends EditionInventory {
* sends the recipes back to RecipeManager.registerBurningRecipe)
* I have no clue what happens; barely even read that far.
*/
registerRecipe(new RMGRR_LBFurnace());
registerRecipe(new RMGRR_LBBlast());
registerRecipe(new RMGRR_LBSmoker());
registerRecipe(new RMGRR_LBCampfire());
registerRecipe(new RMGRR_LegacyBurning(CraftingType.FURNACE));
registerRecipe(new RMGRR_LegacyBurning(CraftingType.BLAST));
registerRecipe(new RMGRR_LegacyBurning(CraftingType.SMOKER));
registerRecipe(new RMGRR_LegacyBurning(CraftingType.CAMPFIRE));
}
@NotNull

View File

@ -1,7 +1,7 @@
package net.Indyuce.mmoitems.gui.edition.recipe.gui;
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
import net.Indyuce.mmoitems.gui.edition.recipe.interpreter.RMGRI_BurningLegacy;
import net.Indyuce.mmoitems.gui.edition.recipe.interpreter.RMGRI_LegacyBurning;
import net.Indyuce.mmoitems.gui.edition.recipe.interpreter.RMG_RecipeInterpreter;
import net.Indyuce.mmoitems.gui.edition.recipe.button.RBA_CookingTime;
import net.Indyuce.mmoitems.gui.edition.recipe.button.RBA_Experience;
@ -43,7 +43,7 @@ public class RMG_BurningLegacy extends RecipeEditorGUI {
if (!isShowingInput()) { switchInput(); }
// Get section and build interpreter
interpreter = new RMGRI_BurningLegacy(getNameSection());
interpreter = new RMGRI_LegacyBurning(getNameSection());
// Bind inputs - Furnace only has which item to smelt
inputLinks.put(40, 0);
@ -68,6 +68,6 @@ public class RMG_BurningLegacy extends RecipeEditorGUI {
return found != null ? found : -1;
}
@NotNull final RMGRI_BurningLegacy interpreter;
@NotNull final RMGRI_LegacyBurning interpreter;
@NotNull @Override public RMG_RecipeInterpreter getInterpreter() { return interpreter; }
}

View File

@ -12,7 +12,8 @@ import org.jetbrains.annotations.Nullable;
*
* @author Gunging
*/
public class RMGRI_BurningLegacy implements RMG_RecipeInterpreter{
@Deprecated
public class RMGRI_LegacyBurning implements RMG_RecipeInterpreter{
/**
* Interestingly enough, they onl require one input.
@ -43,7 +44,7 @@ public class RMGRI_BurningLegacy implements RMG_RecipeInterpreter{
*
* @param recipeNameSection <b><code>[ID].base.crafting.furnace.[name]</code></b> section
*/
public RMGRI_BurningLegacy(@NotNull ConfigurationSection recipeNameSection) {
public RMGRI_LegacyBurning(@NotNull ConfigurationSection recipeNameSection) {
// Save
section = recipeNameSection;

View File

@ -33,9 +33,18 @@ import org.jetbrains.annotations.NotNull;
*
* @author Gunging
*/
public abstract class RMGRR_LegacyBurning implements RecipeRegistry {
@Deprecated
public class RMGRR_LegacyBurning implements RecipeRegistry {
private final CraftingType craftingType;
@NotNull public abstract CraftingType getLegacyBurningType();
public RMGRR_LegacyBurning(CraftingType craftingType) {
this.craftingType = craftingType;
}
@NotNull
public CraftingType getLegacyBurningType() {
return craftingType;
}
@NotNull public static String capitalizeFirst(@NotNull String str) { return str.substring(0, 1).toUpperCase() + str.substring(1); }

View File

@ -8,14 +8,15 @@ import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.Nullable;
@Deprecated
public enum CraftingType {
SHAPED(21, "The C. Table Recipe (Shaped) for this item", VersionMaterial.CRAFTING_TABLE, null),
SHAPELESS(22, "The C. Table Recipe (Shapeless) for this item", VersionMaterial.CRAFTING_TABLE, null),
//SHAPED(21, "The C. Table Recipe (Shaped) for this item", VersionMaterial.CRAFTING_TABLE, null),
//SHAPELESS(22, "The C. Table Recipe (Shapeless) for this item", VersionMaterial.CRAFTING_TABLE, null),
FURNACE(23, "The Furnace Recipe for this item", Material.FURNACE, RecipeManager.BurningRecipeType.FURNACE),
BLAST(29, "The Blast Furnace Recipe for this item", VersionMaterial.BLAST_FURNACE, RecipeManager.BurningRecipeType.BLAST, 1, 14),
SMOKER(30, "The Smoker Recipe for this item", VersionMaterial.SMOKER, RecipeManager.BurningRecipeType.SMOKER, 1, 14),
CAMPFIRE(32, "The Campfire Recipe for this item", VersionMaterial.CAMPFIRE, RecipeManager.BurningRecipeType.CAMPFIRE, 1, 14),
SMITHING(33, "The Smithing Recipe for this item", VersionMaterial.SMITHING_TABLE, null, 1, 15);
CAMPFIRE(32, "The Campfire Recipe for this item", VersionMaterial.CAMPFIRE, RecipeManager.BurningRecipeType.CAMPFIRE, 1, 14);
//SMITHING(33, "The Smithing Recipe for this item", VersionMaterial.SMITHING_TABLE, null, 1, 15);
private final int slot;
private final String lore;
@ -50,7 +51,10 @@ public enum CraftingType {
public String getLore() {
return lore;
}
public RecipeManager.BurningRecipeType getBurningType() { return burning; }
public RecipeManager.BurningRecipeType getBurningType() {
return burning;
}
public boolean shouldAdd() {
return mustBeHigher.length == 0 || MythicLib.plugin.getVersion().isStrictlyHigher(mustBeHigher);
@ -58,8 +62,7 @@ public enum CraftingType {
public static CraftingType getBySlot(int slot) {
for (CraftingType type : values())
if (type.getSlot() == slot)
return type;
if (type.getSlot() == slot) return type;
return null;
}
}

View File

@ -1,11 +0,0 @@
package net.Indyuce.mmoitems.gui.edition.recipe.registry.burninglegacy;
import net.Indyuce.mmoitems.gui.edition.recipe.registry.RMGRR_LegacyBurning;
import org.jetbrains.annotations.NotNull;
/**
* The blast furnace yes
*/
public class RMGRR_LBBlast extends RMGRR_LegacyBurning {
@NotNull @Override public CraftingType getLegacyBurningType() { return CraftingType.BLAST; }
}

View File

@ -1,11 +0,0 @@
package net.Indyuce.mmoitems.gui.edition.recipe.registry.burninglegacy;
import net.Indyuce.mmoitems.gui.edition.recipe.registry.RMGRR_LegacyBurning;
import org.jetbrains.annotations.NotNull;
/**
* The campfire yes
*/
public class RMGRR_LBCampfire extends RMGRR_LegacyBurning {
@NotNull @Override public CraftingType getLegacyBurningType() { return CraftingType.CAMPFIRE; }
}

View File

@ -1,12 +0,0 @@
package net.Indyuce.mmoitems.gui.edition.recipe.registry.burninglegacy;
import net.Indyuce.mmoitems.gui.edition.recipe.registry.RMGRR_LegacyBurning;
import org.jetbrains.annotations.NotNull;
/**
* The furnace yes
*/
public class RMGRR_LBFurnace extends RMGRR_LegacyBurning {
@NotNull @Override public CraftingType getLegacyBurningType() { return CraftingType.FURNACE; }
}

View File

@ -1,11 +0,0 @@
package net.Indyuce.mmoitems.gui.edition.recipe.registry.burninglegacy;
import net.Indyuce.mmoitems.gui.edition.recipe.registry.RMGRR_LegacyBurning;
import org.jetbrains.annotations.NotNull;
/**
* The smoker yes
*/
public class RMGRR_LBSmoker extends RMGRR_LegacyBurning {
@NotNull @Override public CraftingType getLegacyBurningType() { return CraftingType.SMOKER; }
}

View File

@ -388,6 +388,7 @@ public class RecipeManager implements Reloadable {
*
* @author cympe
*/
@Deprecated
public enum BurningRecipeType {
FURNACE(FurnaceRecipe::new),
SMOKER(SmokingRecipe::new),