1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-19 19:25:48 +00:00

Merge branch 'chore/cleanup-deprecated-crafter'

This commit is contained in:
TheBusyBiscuit 2021-03-27 11:52:54 +01:00
commit 090a0f7791
15 changed files with 159 additions and 326 deletions

View File

@ -31,6 +31,7 @@
* Added "Netherite Ingot -> Netherite Block" recipe to Electric Press
#### Changes
* Removed all functionality from the old Automated Crafting Chamber
* Changed item order in guide for the Villager Rune and Nether Goo (All runes are now grouped together)
#### Fixes

View File

@ -50,6 +50,18 @@ public class ErrorReport<T extends Throwable> {
private T throwable;
private File file;
/**
* This is the base constructor for an {@link ErrorReport}. It will only
* print the necessary info and provides a {@link Consumer} for any more detailed
* needs.
*
* @param throwable
* The {@link Throwable} which caused this {@link ErrorReport}.
* @param addon
* The {@link SlimefunAddon} responsible.
* @param printer
* A custom {@link Consumer} to add more details.
*/
@ParametersAreNonnullByDefault
public ErrorReport(T throwable, SlimefunAddon addon, Consumer<PrintStream> printer) {
this.throwable = throwable;
@ -58,6 +70,17 @@ public class ErrorReport<T extends Throwable> {
SlimefunPlugin.runSync(() -> print(printer));
}
/**
* This constructs a new {@link ErrorReport} for the given {@link Location} and
* {@link SlimefunItem}.
*
* @param throwable
* The {@link Throwable} which caused this {@link ErrorReport}.
* @param l
* The {@link Location} at which the error was thrown.
* @param item
* The {@link SlimefunItem} responsible.
*/
@ParametersAreNonnullByDefault
public ErrorReport(T throwable, Location l, SlimefunItem item) {
this(throwable, item.getAddon(), stream -> {
@ -91,6 +114,14 @@ public class ErrorReport<T extends Throwable> {
});
}
/**
* This constructs a new {@link ErrorReport} for the given {@link SlimefunItem}.
*
* @param throwable
* The {@link Throwable} which caused this {@link ErrorReport}.
* @param item
* The {@link SlimefunItem} responsible.
*/
@ParametersAreNonnullByDefault
public ErrorReport(T throwable, SlimefunItem item) {
this(throwable, item.getAddon(), stream -> {

View File

@ -47,6 +47,12 @@ public class ResourceManager {
private final int[] backgroundSlots = { 0, 1, 2, 3, 5, 6, 7, 8, 9, 17, 18, 26, 27, 35, 36, 44, 45, 46, 48, 49, 50, 52, 53 };
private final Config config;
/**
* This will create a new {@link ResourceManager}.
*
* @param plugin
* Our {@link SlimefunPlugin} instance
*/
public ResourceManager(@Nonnull SlimefunPlugin plugin) {
config = new Config(plugin, "resources.yml");
}
@ -109,6 +115,20 @@ public class ResourceManager {
}
}
/**
* This method will set the supplies in a given {@link Chunk} to the specified value.
*
* @param resource
* The {@link GEOResource}
* @param world
* The {@link World}
* @param x
* The x coordinate of that {@link Chunk}
* @param z
* The z coordinate of that {@link Chunk}
* @param value
* The new supply value
*/
public void setSupplies(@Nonnull GEOResource resource, @Nonnull World world, int x, int z, int value) {
Validate.notNull(resource, "Cannot set supplies for null");
Validate.notNull(world, "World cannot be null");
@ -117,6 +137,24 @@ public class ResourceManager {
BlockStorage.setChunkInfo(world, x, z, key, String.valueOf(value));
}
/**
* This method will generate the default supplies for a given {@link GEOResource} at the
* given {@link Chunk}.
* <p>
* This method will invoke {@link #setSupplies(GEOResource, World, int, int, int)} and also calls a
* {@link GEOResourceGenerationEvent}.
*
* @param resource
* The {@link GEOResource} to generate
* @param world
* The {@link World}
* @param x
* The x coordinate of that {@link Chunk}
* @param z
* The z coordinate of that {@link Chunk}
*
* @return The new supply value
*/
private int generate(@Nonnull GEOResource resource, @Nonnull World world, int x, int z) {
Validate.notNull(resource, "Cannot generate resources for null");
Validate.notNull(world, "World cannot be null");
@ -166,7 +204,8 @@ public class ResourceManager {
int x = block.getX() >> 4;
int z = block.getZ() >> 4;
ChestMenu menu = new ChestMenu("&4" + SlimefunPlugin.getLocalization().getResourceString(p, "tooltips.results"));
String title = "&4" + SlimefunPlugin.getLocalization().getResourceString(p, "tooltips.results");
ChestMenu menu = new ChestMenu(title);
for (int slot : backgroundSlots) {
menu.addItem(slot, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler());

View File

@ -58,6 +58,13 @@ public class GPSNetwork {
private final TeleportationManager teleportation = new TeleportationManager();
private final ResourceManager resourceManager;
/**
* This constructs a new {@link GPSNetwork}.
* Note that this network is per {@link Server} and not per {@link Player}.
*
* @param plugin
* Our {@link SlimefunPlugin} instance
*/
public GPSNetwork(@Nonnull SlimefunPlugin plugin) {
resourceManager = new ResourceManager(plugin);
}
@ -125,6 +132,13 @@ public class GPSNetwork {
return locations == null ? 0 : locations.size();
}
/**
* This method opens the {@link GPSTransmitter} control panel to the given
* {@link Player}.
*
* @param p
* The {@link Player}
*/
public void openTransmitterControlPanel(@Nonnull Player p) {
ChestMenu menu = new ChestMenu(ChatColor.BLUE + SlimefunPlugin.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.title"));

View File

@ -7,6 +7,7 @@ import javax.annotation.ParametersAreNonnullByDefault;
import org.apache.commons.lang.Validate;
import org.bukkit.Location;
import org.bukkit.World.Environment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -34,53 +35,103 @@ public class Waypoint {
private final String name;
private final Location location;
/**
* This constructs a new {@link Waypoint} object.
*
* @param profile
* The owning {@link PlayerProfile}
* @param id
* The unique id for this {@link Waypoint}
* @param loc
* The {@link Location} of the {@link Waypoint}
* @param name
* The name of this {@link Waypoint}
*/
@ParametersAreNonnullByDefault
public Waypoint(PlayerProfile profile, String id, Location l, String name) {
public Waypoint(PlayerProfile profile, String id, Location loc, String name) {
Validate.notNull(profile, "Profile must never be null!");
Validate.notNull(id, "id must never be null!");
Validate.notNull(l, "Location must never be null!");
Validate.notNull(loc, "Location must never be null!");
Validate.notNull(name, "Name must never be null!");
this.profile = profile;
this.id = id;
this.location = l;
this.location = loc;
this.name = name;
}
/**
* This returns the owner of the {@link Waypoint}.
*
* @return The corresponding {@link PlayerProfile}
*/
@Nonnull
public PlayerProfile getOwner() {
return profile;
}
/**
* This method returns the unique identifier for this {@link Waypoint}.
*
* @return The {@link Waypoint} id
*/
@Nonnull
public String getId() {
return id;
}
/**
* This returns the name of this {@link Waypoint}.
*
* @return The name of this {@link Waypoint}
*/
@Nonnull
public String getName() {
return name;
}
/**
* This returns the {@link Location} of this {@link Waypoint}
*
* @return The {@link Waypoint} {@link Location}
*/
@Nonnull
public Location getLocation() {
return location;
}
/**
* This method returns whether this {@link Waypoint} is a Deathpoint.
*
* @return Whether this is a Deathpoint
*/
public boolean isDeathpoint() {
return name.startsWith("player:death ");
}
/**
* This method returns the {@link ItemStack} icon for this {@link Waypoint}.
* The icon is dependent on the {@link Environment} the {@link Waypoint} is in
* and whether it is a Deathpoint.
*
* @return The {@link ItemStack} icon for this {@link Waypoint}
*/
@Nonnull
public ItemStack getIcon() {
return SlimefunPlugin.getGPSNetwork().getIcon(name, location.getWorld().getEnvironment());
}
/**
* {@inheritDoc}
*/
@Override
public int hashCode() {
return Objects.hash(profile.getUUID(), id, name, location);
}
/**
* {@inheritDoc}
*/
@Override
public boolean equals(Object obj) {
if (!(obj instanceof Waypoint)) {

View File

@ -1,44 +0,0 @@
package io.github.thebusybiscuit.slimefun4.api.items;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
public interface ItemRestriction {
/**
* This method represents a check.
* The returned boolean will decide whether to allow the action.
*
* @param profile
* The Player's profile
* @param p
* The Player itself
* @param item
* The SlimefunItem that the {@link ItemStack} represents
* @param itemstack
* The ItemStack that is being tested.
*
* @return Whether the action was allowed
*/
boolean isAllowed(PlayerProfile profile, Player p, SlimefunItem item, ItemStack itemstack);
/**
* This method is executed if an ItemRestriction took affect.
* Override it to send a message to the Player telling them they cannot
* use that item, or do something else in there.
*
* @param profile
* The Player's profile
* @param p
* The Player to warn
* @param item
* The SlimefunItem that the {@link ItemStack} represents
* @param itemstack
* The ItemStack that was prevented from being used
*/
void warnPlayer(PlayerProfile profile, Player p, SlimefunItem item, ItemStack itemstack);
}

View File

@ -34,6 +34,7 @@ import io.github.thebusybiscuit.cscorelib2.protection.ProtectionManager;
import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
import io.github.thebusybiscuit.slimefun4.api.exceptions.TagMisconfigurationException;
import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource;
import io.github.thebusybiscuit.slimefun4.api.gps.GPSNetwork;
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
import io.github.thebusybiscuit.slimefun4.core.SlimefunRegistry;
@ -778,6 +779,13 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
return instance.items;
}
/**
* This returns our {@link GPSNetwork} instance.
* The {@link GPSNetwork} is responsible for handling any GPS-related
* operations and for managing any {@link GEOResource}.
*
* @return Our {@link GPSNetwork} instance
*/
@Nonnull
public static GPSNetwork getGPSNetwork() {
validateInstance();

View File

@ -153,7 +153,7 @@ public enum Instruction {
* ahead of them.
*/
ATTACK_MOBS(AndroidType.FIGHTER, HeadTexture.SCRIPT_ATTACK, (android, b, inv, face) -> {
Predicate<LivingEntity> predicate = e -> e instanceof Monster;
Predicate<LivingEntity> predicate = Monster.class::isInstance;
android.attack(b, face, predicate);
}),
@ -162,7 +162,7 @@ public enum Instruction {
* ahead of them.
*/
ATTACK_ANIMALS(AndroidType.FIGHTER, HeadTexture.SCRIPT_ATTACK, (android, b, inv, face) -> {
Predicate<LivingEntity> predicate = e -> e instanceof Animals;
Predicate<LivingEntity> predicate = Animals.class::isInstance;
android.attack(b, face, predicate);
}),

View File

@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.blocks;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.inventory.ItemStack;
@ -31,7 +32,7 @@ public class UnplaceableBlock extends SimpleSlimefunItem<ItemUseHandler> impleme
}
@ParametersAreNonnullByDefault
public UnplaceableBlock(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) {
public UnplaceableBlock(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, @Nullable ItemStack recipeOutput) {
super(category, item, recipeType, recipe, recipeOutput);
}

View File

@ -3,9 +3,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machine
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.ParametersAreNonnullByDefault;
@ -23,19 +21,14 @@ import io.github.thebusybiscuit.slimefun4.api.events.BlockPlacerPlaceEvent;
import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent;
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler;
import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.EnhancedCraftingTable;
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.auto_crafters.AbstractAutoCrafter;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.AdvancedMenuClickHandler;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItemSerializer;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItemSerializer.ItemFlag;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.interfaces.InventoryBlock;
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker;
import me.mrCookieSlime.Slimefun.api.BlockStorage;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
@ -47,7 +40,7 @@ import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
* This class needs to be rewritten VERY BADLY.
* But we should focus on rewriting the recipe system first.
*
* @deprecated This is horribly done. Someone needs to rewrite this.
* @deprecated This has been replaced by the {@link AbstractAutoCrafter}.
*
* @author TheBusyBiscuit
*
@ -58,13 +51,11 @@ public abstract class AutomatedCraftingChamber extends SlimefunItem implements I
private final int[] inputBorder = { 9, 10, 11, 12, 13, 18, 22, 27, 31, 36, 40, 45, 46, 47, 48, 49 };
private final int[] outputBorder = { 23, 24, 25, 26, 32, 35, 41, 42, 43, 44 };
private final Map<String, ItemStack> craftingRecipes = new HashMap<>();
@ParametersAreNonnullByDefault
public AutomatedCraftingChamber(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe);
new BlockMenuPreset(getId(), "&4Deprecated item. Do not use.") {
new BlockMenuPreset(getId(), "&4Machine is disabled.") {
@Override
public void init() {
@ -88,17 +79,11 @@ public abstract class AutomatedCraftingChamber extends SlimefunItem implements I
return false;
});
}
menu.replaceExistingItem(7, new CustomItem(Material.CRAFTING_TABLE, "&7Craft Last", "", "&e> Click to craft the last shaped recipe", "&cOnly works with the last one"));
menu.addMenuClickHandler(7, (p, slot, item, action) -> {
tick(b, true);
return false;
});
}
@Override
public boolean canOpen(Block b, Player p) {
p.sendMessage(ChatColor.DARK_RED + "This item has been deprecated. It will be removed soon!");
p.sendMessage(ChatColor.DARK_RED + "This item has been disabled and will be removed soon. Please switch over to the new Auto Crafters in the Cargo Category.");
return p.hasPermission("slimefun.inventory.bypass") || SlimefunPlugin.getProtectionManager().hasPermission(p, b.getLocation(), ProtectableAction.INTERACT_BLOCK);
}
@ -150,7 +135,7 @@ public abstract class AutomatedCraftingChamber extends SlimefunItem implements I
@Override
public void onPlayerPlace(BlockPlaceEvent e) {
e.getPlayer().sendMessage(ChatColor.DARK_RED + "This item has been deprecated. It will be removed soon!");
e.getPlayer().sendMessage(ChatColor.DARK_RED + "This item has been disabled and will be removed soon. Please switch over to the new Auto Crafters in the Cargo Category.");
BlockStorage.addBlockInfo(e.getBlock(), "enabled", String.valueOf(false));
}
@ -212,106 +197,4 @@ public abstract class AutomatedCraftingChamber extends SlimefunItem implements I
public EnergyNetComponentType getEnergyComponentType() {
return EnergyNetComponentType.CONSUMER;
}
@Override
public void preRegister() {
addItemHandler(new BlockTicker() {
@Override
public void tick(Block b, SlimefunItem sf, Config data) {
AutomatedCraftingChamber.this.tick(b, false);
}
@Override
public boolean isSynchronized() {
return false;
}
});
}
protected void tick(Block block, boolean craftLast) {
if (!craftLast && BlockStorage.getLocationInfo(block.getLocation(), "enabled").equals(String.valueOf(false))) {
return;
}
if (getCharge(block.getLocation()) < getEnergyConsumption()) {
return;
}
String input = getSerializedInput(block, craftLast);
testInputAgainstRecipes(block, input);
}
private String getSerializedInput(Block block, boolean craftLast) {
BlockMenu menu = BlockStorage.getInventory(block);
StringBuilder builder = new StringBuilder();
int i = 0;
boolean lastIteration = false;
for (int j = 0; j < 9; j++) {
if (i > 0) {
builder.append(" </slot> ");
}
ItemStack item = menu.getItemInSlot(getInputSlots()[j]);
if (item != null && item.getAmount() == 1) {
if (craftLast) {
lastIteration = true;
} else {
return "";
}
}
builder.append(CustomItemSerializer.serialize(item, ItemFlag.MATERIAL, ItemFlag.ITEMMETA_DISPLAY_NAME, ItemFlag.ITEMMETA_LORE));
i++;
}
// we're only executing the last possible shaped recipe
// we don't want to allow this to be pressed instead of the default timer-based
// execution to prevent abuse and auto clickers
if (craftLast && !lastIteration) {
return "";
}
return builder.toString();
}
private void testInputAgainstRecipes(Block block, String input) {
BlockMenu menu = BlockStorage.getInventory(block);
ItemStack output = craftingRecipes.get(input);
if (output != null && menu.fits(output, getOutputSlots())) {
menu.pushItem(output.clone(), getOutputSlots());
removeCharge(block.getLocation(), getEnergyConsumption());
for (int j = 0; j < 9; j++) {
if (menu.getItemInSlot(getInputSlots()[j]) != null) {
menu.consumeItem(getInputSlots()[j]);
}
}
}
}
public void loadRecipes() {
EnhancedCraftingTable machine = (EnhancedCraftingTable) SlimefunItems.ENHANCED_CRAFTING_TABLE.getItem();
for (ItemStack[] inputs : RecipeType.getRecipeInputList(machine)) {
StringBuilder builder = new StringBuilder();
int i = 0;
for (ItemStack item : inputs) {
if (i > 0) {
builder.append(" </slot> ");
}
builder.append(CustomItemSerializer.serialize(item, ItemFlag.MATERIAL, ItemFlag.ITEMMETA_DISPLAY_NAME, ItemFlag.ITEMMETA_LORE));
i++;
}
craftingRecipes.put(builder.toString(), RecipeType.getRecipeOutputList(machine, inputs));
}
}
}

View File

@ -27,7 +27,6 @@ import com.google.gson.JsonParser;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.AutomatedCraftingChamber;
import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.GrindStone;
import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.MakeshiftSmeltery;
import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.OreCrusher;
@ -78,7 +77,6 @@ public final class PostSetup {
}
}
loadAutomaticCraftingChamber();
loadOreGrinderRecipes();
loadSmelteryRecipes();
@ -128,14 +126,6 @@ public final class PostSetup {
// @formatter:on
}
private static void loadAutomaticCraftingChamber() {
AutomatedCraftingChamber crafter = (AutomatedCraftingChamber) SlimefunItems.AUTOMATED_CRAFTING_CHAMBER.getItem();
if (crafter != null) {
crafter.loadRecipes();
}
}
private static void loadOreGrinderRecipes() {
List<ItemStack[]> grinderRecipes = new ArrayList<>();

View File

@ -218,7 +218,6 @@ public final class ResearchSetup {
register("cargo_nodes", 206, "Cargo Setup", 30, SlimefunItems.CARGO_INPUT_NODE, SlimefunItems.CARGO_OUTPUT_NODE);
register("electric_ingot_machines", 207, "Electric Ingot Fabrication", 18, SlimefunItems.ELECTRIC_GOLD_PAN, SlimefunItems.ELECTRIC_DUST_WASHER, SlimefunItems.ELECTRIC_INGOT_FACTORY);
register("high_tier_electric_ingot_machines", 209, "Super Fast Ingot Fabrication", 32, SlimefunItems.ELECTRIC_GOLD_PAN_3, SlimefunItems.ELECTRIC_DUST_WASHER_3, SlimefunItems.ELECTRIC_INGOT_FACTORY_3, SlimefunItems.ELECTRIC_ORE_GRINDER_2, SlimefunItems.ELECTRIC_ORE_GRINDER_3);
register("automated_crafting_chamber", 210, "Automated Crafting", 20, SlimefunItems.AUTOMATED_CRAFTING_CHAMBER);
register("better_food_fabricator", 211, "Upgraded Food Fabrication", 28, SlimefunItems.FOOD_FABRICATOR_2, SlimefunItems.FOOD_COMPOSTER_2);
register("reactor_access_port", 212, "Reactor Interaction", 18, SlimefunItems.REACTOR_ACCESS_PORT);
register("fluid_pump", 213, "Fluid Pump", 28, SlimefunItems.FLUID_PUMP);

View File

@ -109,9 +109,9 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.enchanting.AutoDisenchanter;
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.enchanting.AutoEnchanter;
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.enchanting.BookBinder;
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.entities.ExpCollector;
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.entities.IronGolemAssembler;
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.entities.WitherAssembler;
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.entities.ExpCollector;
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.NetherStarReactor;
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.NuclearReactor;
import io.github.thebusybiscuit.slimefun4.implementation.items.elevator.ElevatorPlate;
@ -2476,7 +2476,7 @@ public final class SlimefunItemSetup {
.register(plugin);
new AutomatedCraftingChamber(categories.electricity, SlimefunItems.AUTOMATED_CRAFTING_CHAMBER, RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {null, new ItemStack(Material.CRAFTING_TABLE), null, SlimefunItems.CARGO_MOTOR, SlimefunItems.BLISTERING_INGOT_3, SlimefunItems.CARGO_MOTOR, null, SlimefunItems.ELECTRIC_MOTOR, null}) {
new ItemStack[] {null, null, null, null, new CustomItem(Material.BARRIER, "&4This Item has been disabled.", "&cIt will soon be removed!", "&cPlease switch over to the new", "&cAuto-Crafters from the Cargo Category."), null, null, null, null}) {
@Override
public int getEnergyConsumption() {

View File

@ -1,117 +0,0 @@
package me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
/**
* An old remnant of CS-CoreLib.
* This will be removed once we updated everything.
* Don't look at the code, it will be gone soon, don't worry.
*
* @deprecated This was a horrible idea. Don't use it.
*
*/
@Deprecated
public class CustomItemSerializer {
public enum ItemFlag {
MATERIAL(0),
DATA(1),
AMOUNT(2),
DURABILITY(3),
ENCHANTMENTS(4),
ITEMMETA_DISPLAY_NAME(5),
ITEMMETA_LORE(6);
private int weight;
ItemFlag(int weight) {
this.weight = weight;
}
public int getWeight() {
return this.weight;
}
}
private static ItemFlagComparator comparator = new ItemFlagComparator();
public static String serialize(ItemStack item, ItemFlag... flags) {
if (item == null)
return "NULL";
List<ItemFlag> flaglist = Arrays.asList(flags);
Collections.sort(flaglist, comparator);
StringBuilder builder = new StringBuilder();
int i = 0;
for (ItemFlag flag : flags) {
if (i > 0)
builder.append(" </sep> ");
builder.append(flag.toString() + "=");
switch (flag) {
case AMOUNT: {
builder.append(item.getAmount());
break;
}
case DATA: {
builder.append((int) item.getData().getData());
break;
}
case DURABILITY: {
builder.append((int) item.getDurability());
break;
}
case ENCHANTMENTS:
for (Enchantment enchantment : Enchantment.values()) {
if (item.getEnchantments().containsKey(enchantment)) {
builder.append(enchantment.getName() + ":" + item.getEnchantmentLevel(enchantment));
} else {
builder.append(enchantment.getName() + ":0");
}
}
break;
case ITEMMETA_DISPLAY_NAME: {
if (item.hasItemMeta() && item.getItemMeta().hasDisplayName()) {
builder.append(item.getItemMeta().getDisplayName().replaceAll("\\u00a7", "&"));
} else {
builder.append("NONE");
}
break;
}
case ITEMMETA_LORE: {
if (item.hasItemMeta() && item.getItemMeta().hasLore()) {
builder.append(item.getItemMeta().getLore().toString().replaceAll("\\u00a7", "&"));
} else {
builder.append("NONE");
}
break;
}
case MATERIAL: {
builder.append(item.getType().toString());
break;
}
default:
break;
}
i++;
}
return builder.toString();
}
public static boolean equals(ItemStack stack1, ItemStack stack2, ItemFlag... flags) {
return serialize(stack1, flags).equals(serialize(stack2, flags));
}
}

View File

@ -1,23 +0,0 @@
package me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item;
import java.util.Comparator;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItemSerializer.ItemFlag;
/**
* An old remnant of CS-CoreLib.
* This will be removed once we updated everything.
* Don't look at the code, it will be gone soon, don't worry.
*
* @deprecated This was a horrible idea. Don't use it.
*
*/
@Deprecated
public class ItemFlagComparator implements Comparator<ItemFlag> {
@Override
public int compare(ItemFlag flag1, ItemFlag flag2) {
return flag1.getWeight() - flag2.getWeight();
}
}