1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-20 11:45:51 +00:00

[CI skip] Added Slimefun Guide and Recipe Types to custom item model

service
This commit is contained in:
TheBusyBiscuit 2019-11-22 14:57:04 +01:00
parent 8a605404c1
commit 7ad4d92a14
3 changed files with 46 additions and 21 deletions

View File

@ -6,45 +6,50 @@ import java.util.List;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
import io.github.thebusybiscuit.cscorelib2.recipes.MinecraftRecipe; import io.github.thebusybiscuit.cscorelib2.recipes.MinecraftRecipe;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunGadget; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunGadget;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunMachine; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunMachine;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
import me.mrCookieSlime.Slimefun.api.SlimefunRecipes; import me.mrCookieSlime.Slimefun.api.SlimefunRecipes;
public class RecipeType { public class RecipeType {
public static final RecipeType MULTIBLOCK = new RecipeType(new CustomItem(Material.BRICKS, "&bMultiBlock", "", "&a&oBuild it in the World")); public static final RecipeType MULTIBLOCK = new RecipeType(new CustomItem(Material.BRICKS, "&bMultiBlock", "", "&a&oBuild it in the World"));
public static final RecipeType ARMOR_FORGE = new RecipeType(new CustomItem(Material.ANVIL, "&bArmor Forge", "", "&a&oCraft it in an Armor Forge"), "ARMOR_FORGE"); public static final RecipeType ARMOR_FORGE = new RecipeType((SlimefunItemStack) SlimefunItems.ARMOR_FORGE, "", "&a&oCraft it in an Armor Forge");
public static final RecipeType GRIND_STONE = new RecipeType(new CustomItem(Material.DISPENSER, "&bGrind Stone", "", "&a&oGrind it using the Grind Stone"), "GRIND_STONE"); public static final RecipeType GRIND_STONE = new RecipeType((SlimefunItemStack) SlimefunItems.GRIND_STONE, "", "&a&oGrind it using the Grind Stone");
public static final RecipeType MOB_DROP = new RecipeType(new CustomItem(Material.IRON_SWORD, "&bMob Drop", "", "&a&oKill the specified Mob to obtain this Item")); public static final RecipeType MOB_DROP = new RecipeType(new CustomItem(Material.IRON_SWORD, "&bMob Drop", "", "&a&oKill the specified Mob to obtain this Item"));
public static final RecipeType SMELTERY = new RecipeType(new CustomItem(Material.FURNACE, "&6Smeltery", "", "&a&oSmelt it using a Smeltery"), "SMELTERY"); public static final RecipeType SMELTERY = new RecipeType((SlimefunItemStack) SlimefunItems.SMELTERY, "", "&a&oSmelt it using a Smeltery");
public static final RecipeType ORE_CRUSHER = new RecipeType(new CustomItem(Material.DISPENSER, "&bOre Crusher", "", "&a&oCrush it using the Ore Crusher"), "ORE_CRUSHER"); public static final RecipeType ORE_CRUSHER = new RecipeType((SlimefunItemStack) SlimefunItems.ORE_CRUSHER, "", "&a&oCrush it using the Ore Crusher");
public static final RecipeType GOLD_PAN = new RecipeType(new CustomItem(Material.BOWL, "&bGold Pan", "", "&a&oUse a Gold Pan on Gravel to obtain this Item")); public static final RecipeType GOLD_PAN = new RecipeType((SlimefunItemStack) SlimefunItems.GOLD_PAN, "", "&a&oUse a Gold Pan on Gravel to obtain this Item");
public static final RecipeType COMPRESSOR = new RecipeType(new CustomItem(Material.PISTON, "&bCompressor", "", "&a&oCompress it using the Compressor"), "COMPRESSOR"); public static final RecipeType COMPRESSOR = new RecipeType((SlimefunItemStack) SlimefunItems.COMPRESSOR, "", "&a&oCompress it using the Compressor");
public static final RecipeType PRESSURE_CHAMBER = new RecipeType(new CustomItem(Material.GLASS, "&bPressure Chamber", "", "&a&oCompress it using the Pressure Chamber"), "PRESSURE_CHAMBER"); public static final RecipeType PRESSURE_CHAMBER = new RecipeType((SlimefunItemStack) SlimefunItems.PRESSURE_CHAMBER, "", "&a&oCompress it using the Pressure Chamber");
public static final RecipeType OVEN = new RecipeType(new CustomItem(Material.FURNACE, "&bOven", "", "&a&oSmelt it in an Oven"), "OVEN"); public static final RecipeType MAGIC_WORKBENCH = new RecipeType((SlimefunItemStack) SlimefunItems.MAGIC_WORKBENCH, "", "&a&oCraft it in a Magic Workbench");
public static final RecipeType MAGIC_WORKBENCH = new RecipeType(new CustomItem(Material.BOOKSHELF, "&6Magic Workbench", "", "&a&oCraft it in a Magic Workbench"), "MAGIC_WORKBENCH"); public static final RecipeType ORE_WASHER = new RecipeType((SlimefunItemStack) SlimefunItems.ORE_WASHER, "", "&a&oWash it in an Ore Washer");
public static final RecipeType ORE_WASHER = new RecipeType(new CustomItem(Material.CAULDRON, "&6Ore Washer", "", "&a&oWash it in an Ore Washer"), "ORE_WASHER"); public static final RecipeType ENHANCED_CRAFTING_TABLE = new RecipeType((SlimefunItemStack) SlimefunItems.ENHANCED_CRAFTING_TABLE, "", "&a&oA regular Crafting Table cannot", "&a&ohold this massive Amount of Power...");
public static final RecipeType ENHANCED_CRAFTING_TABLE = new RecipeType(new CustomItem(Material.CRAFTING_TABLE, "&eEnhanced Crafting Table", "", "&a&oA regular Crafting Table cannot", "&a&ohold this massive Amount of Power..."), "ENHANCED_CRAFTING_TABLE"); public static final RecipeType JUICER = new RecipeType((SlimefunItemStack) SlimefunItems.JUICER, "", "&a&oUsed for Juice Creation");
public static final RecipeType JUICER = new RecipeType(new CustomItem(Material.GLASS_BOTTLE, "&eJuicer", "", "&a&oUsed for Juice Creation"), "JUICER"); public static final RecipeType ANCIENT_ALTAR = new RecipeType((SlimefunItemStack) SlimefunItems.ANCIENT_ALTAR, "", "&dYou will need to craft this Item", "&dby performing an Ancient Altar Ritual");
public static final RecipeType ANCIENT_ALTAR = new RecipeType(new CustomItem(Material.ENCHANTING_TABLE, "&4Ancient Altar", "", "&dYou will need to craft this Item", "&dby performing an Ancient Altar Ritual")); public static final RecipeType HEATED_PRESSURE_CHAMBER = new RecipeType((SlimefunItemStack) SlimefunItems.HEATED_PRESSURE_CHAMBER, "", "&a&oCraft this Item in a", "&a&oHeated Pressure Chamber");
public static final RecipeType HEATED_PRESSURE_CHAMBER = new RecipeType(new CustomItem(new ItemStack(Material.GRAY_STAINED_GLASS), "&cHeated Pressure Chamber", "", "&a&oCraft this Item in a", "&a&oHeated Pressure Chamber"), "HEATED_PRESSURE_CHAMBER");
public static final RecipeType SHAPED_RECIPE = new RecipeType(new CustomItem(Material.CRAFTING_TABLE, "&eShaped Recipe", "", "&a&oJust a standard Recipe in the Workbench...")); public static final RecipeType SHAPED_RECIPE = new RecipeType(new CustomItem(Material.CRAFTING_TABLE, "&eShaped Recipe", "", "&a&oJust a standard Recipe in the Workbench..."));
public static final RecipeType SHAPELESS_RECIPE = new RecipeType(new CustomItem(Material.CRAFTING_TABLE, "&eShapeless Recipe", "", "&a&oJust a standard Recipe in the Workbench...")); public static final RecipeType SHAPELESS_RECIPE = new RecipeType(new CustomItem(Material.CRAFTING_TABLE, "&eShapeless Recipe", "", "&a&oJust a standard Recipe in the Workbench..."));
public static final RecipeType FURNACE = new RecipeType(new CustomItem(Material.FURNACE, "&eFurnace Recipe", "", "&a&oJust smelt it in a regular Furnace")); public static final RecipeType FURNACE = new RecipeType(new CustomItem(Material.FURNACE, "&eFurnace Recipe", "", "&a&oJust smelt it in a regular Furnace"));
public static final RecipeType NULL = new RecipeType((ItemStack) null); public static final RecipeType NULL = new RecipeType((ItemStack) null);
private ItemStack item; private final ItemStack item;
private String machine; private final String machine;
public RecipeType(ItemStack item, String machine) { public RecipeType(ItemStack item, String machine) {
this.item = item; this.item = item;
this.machine = machine; this.machine = machine;
} }
public RecipeType(SlimefunItemStack slimefunItem, String... lore) {
this.item = new CustomItem(slimefunItem, null, lore);
this.machine = slimefunItem.getItemID();
}
public RecipeType(ItemStack item) { public RecipeType(ItemStack item) {
this(item, ""); this(item, "");
} }

View File

@ -1,6 +1,8 @@
package me.mrCookieSlime.Slimefun; package me.mrCookieSlime.Slimefun;
import java.util.Arrays; import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.logging.Level; import java.util.logging.Level;
@ -10,6 +12,7 @@ import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.inventory.meta.SkullMeta;
import io.github.thebusybiscuit.cscorelib2.math.DoubleHandler; import io.github.thebusybiscuit.cscorelib2.math.DoubleHandler;
@ -48,16 +51,31 @@ public final class SlimefunGuide {
} }
public static ItemStack getItem(SlimefunGuideLayout design) { public static ItemStack getItem(SlimefunGuideLayout design) {
ItemStack item = new ItemStack(Material.ENCHANTED_BOOK);
ItemMeta meta = item.getItemMeta();
List<String> lore = new LinkedList<>();
lore.addAll(Arrays.asList("&eRight Click &8\u21E8 &7Browse Items", "&eShift + Right Click &8\u21E8 &7Open Settings / Credits"));
switch (design) { switch (design) {
case BOOK: case BOOK:
return new CustomItem(new ItemStack(Material.ENCHANTED_BOOK), "&aSlimefun Guide &7(Book GUI)", "", "&eRight Click &8\u21E8 &7Browse Items", "&eShift + Right Click &8\u21E8 &7Open Settings / Credits"); meta.setDisplayName("&aSlimefun Guide &7(Book GUI)");
break;
case CHEAT_SHEET: case CHEAT_SHEET:
return new CustomItem(new ItemStack(Material.ENCHANTED_BOOK), "&cSlimefun Guide &4(Cheat Sheet)", "", "&4&lOnly openable by Admins", "", "&eRight Click &8\u21E8 &7Browse Items", "&eShift + Right Click &8\u21E8 &7Open Settings / Credits"); meta.setDisplayName("&cSlimefun Guide &4(Cheat Sheet)");
lore.add(0, "&4&lOnly openable by Admins");
lore.add(0, "");
break;
case CHEST: case CHEST:
return new CustomItem(new ItemStack(Material.ENCHANTED_BOOK), "&aSlimefun Guide &7(Chest GUI)", "", "&eRight Click &8\u21E8 &7Browse Items", "&eShift + Right Click &8\u21E8 &7Open Settings / Credits"); meta.setDisplayName("&aSlimefun Guide &7(Chest GUI)");
break;
default: default:
return null; return null;
} }
meta.setLore(lore);
SlimefunPlugin.getItemTextureService().setTexture(meta, "SLIMEFUN_GUIDE");
item.setItemMeta(meta);
return item;
} }
@Deprecated @Deprecated

View File

@ -18,6 +18,8 @@ public class CustomTextureService {
} }
public void setup(Collection<SlimefunItem> items) { public void setup(Collection<SlimefunItem> items) {
config.setDefaultValue("SLIMEFUN_GUIDE", 0);
for (SlimefunItem item : items) { for (SlimefunItem item : items) {
if (item != null && item.getID() != null) { if (item != null && item.getID() != null) {
config.setDefaultValue(item.getID(), 0); config.setDefaultValue(item.getID(), 0);