Skip to content

Commit

Permalink
Fixed dough imports and fully support MC 1.18 and SF RC28+
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBusyBiscuit committed Jan 10, 2022
1 parent cbf737e commit 904daae
Show file tree
Hide file tree
Showing 106 changed files with 285 additions and 236 deletions.
35 changes: 18 additions & 17 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,15 @@
<relocations>
<relocation>
<pattern>org.bstats</pattern>
<shadedPattern>io.github.thebusybiscuit.sensibletoolbox.bstats</shadedPattern>
<shadedPattern>io.github.thebusybiscuit.sensibletoolbox.libraries.bstats</shadedPattern>
</relocation>
<relocation>
<pattern>io.papermc.lib</pattern>
<shadedPattern>io.github.thebusybiscuit.sensibletoolbox.paperlib</shadedPattern>
<shadedPattern>io.github.thebusybiscuit.sensibletoolbox.libraries.paperlib</shadedPattern>
</relocation>
<relocation>
<pattern>io.github.thebusybiscuit.cscorelib2</pattern>
<shadedPattern>io.github.thebusybiscuit.sensibletoolbox.cscorelib2</shadedPattern>
<pattern>io.github.bakedlibs.dough</pattern>
<shadedPattern>io.github.thebusybiscuit.sensibletoolbox.libraries.dough</shadedPattern>
</relocation>
</relocations>

Expand Down Expand Up @@ -199,19 +199,6 @@
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.github.TheBusyBiscuit</groupId>
<artifactId>Slimefun4</artifactId>
<version>RC-27</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>io.github.bakedlibs</groupId>
<artifactId>dough-api</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
Expand All @@ -233,6 +220,20 @@
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.github.TheBusyBiscuit</groupId>
<artifactId>Slimefun4</artifactId>
<version>RC-30</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>io.github.baked-libs</groupId>
<artifactId>dough-api</artifactId>
<version>1.1.1</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>io.papermc</groupId>
<artifactId>paperlib</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@

import com.comphenix.protocol.ProtocolLib;

import io.github.bakedlibs.dough.protection.ProtectionManager;
import io.github.bakedlibs.dough.updater.GitHubBuildsUpdater;
import io.github.bakedlibs.dough.updater.PluginUpdater;
import io.github.bakedlibs.dough.versions.PrefixedVersion;
import io.github.thebusybiscuit.sensibletoolbox.api.AccessControl;
import io.github.thebusybiscuit.sensibletoolbox.api.FriendManager;
import io.github.thebusybiscuit.sensibletoolbox.api.MinecraftVersion;
Expand Down Expand Up @@ -151,10 +155,6 @@
import io.github.thebusybiscuit.sensibletoolbox.slimefun.SlimefunBridge;
import io.github.thebusybiscuit.sensibletoolbox.utils.ItemGlow;
import io.github.thebusybiscuit.sensibletoolbox.utils.STBUtil;
import io.github.thebusybiscuit.slimefun4.libraries.dough.protection.ProtectionManager;
import io.github.thebusybiscuit.slimefun4.libraries.dough.updater.GitHubBuildsUpdater;
import io.github.thebusybiscuit.slimefun4.libraries.dough.updater.PluginUpdater;
import io.github.thebusybiscuit.slimefun4.libraries.dough.versions.PrefixedVersion;
import io.papermc.lib.PaperLib;

import me.desht.dhutils.DHUtilsException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public enum MinecraftVersion {
*
*/
MINECRAFT_1_17(17, "1.17.x"),

/**
* This constant represents Minecraft (Java Edition) Version 1.18
* (The "Caves and Cliffs: Part II" Update)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import org.bukkit.Location;
import org.bukkit.block.Block;

import io.github.bakedlibs.dough.protection.ProtectionManager;
import io.github.thebusybiscuit.sensibletoolbox.SensibleToolboxPlugin;
import io.github.thebusybiscuit.sensibletoolbox.api.energy.EnergyNet;
import io.github.thebusybiscuit.sensibletoolbox.api.items.BaseSTBBlock;
import io.github.thebusybiscuit.sensibletoolbox.core.storage.LocationManager;
import io.github.thebusybiscuit.slimefun4.libraries.dough.protection.ProtectionManager;

/**
* Top-level collection of utility methods for Sensible Toolbox.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public abstract class AbstractProcessingMachine extends BaseSTBMachine {
private ItemStack processing;
// try to eject every tick by default
private int ejectionInterval = 1;

protected AbstractProcessingMachine() {
super();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.concurrent.ThreadLocalRandom;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;

import org.apache.commons.lang.Validate;
Expand Down Expand Up @@ -34,14 +35,14 @@
import org.bukkit.permissions.Permissible;
import org.bukkit.plugin.Plugin;

import io.github.bakedlibs.dough.data.persistent.PersistentDataAPI;
import io.github.thebusybiscuit.sensibletoolbox.SensibleToolboxPlugin;
import io.github.thebusybiscuit.sensibletoolbox.api.SensibleToolbox;
import io.github.thebusybiscuit.sensibletoolbox.api.energy.Chargeable;
import io.github.thebusybiscuit.sensibletoolbox.api.gui.InventoryGUIListener;
import io.github.thebusybiscuit.sensibletoolbox.core.STBItemRegistry;
import io.github.thebusybiscuit.sensibletoolbox.utils.ItemGlow;
import io.github.thebusybiscuit.sensibletoolbox.utils.STBUtil;
import io.github.thebusybiscuit.slimefun4.libraries.dough.data.persistent.PersistentDataAPI;

/**
* Represents an STB item. This is the superclass for all STB items.
Expand Down Expand Up @@ -183,7 +184,7 @@ public final boolean isIngredientFor(ItemStack result) {
*
* @return the display suffix, or null for no suffix
*/
public String getDisplaySuffix() {
public @Nullable String getDisplaySuffix() {
return null;
}

Expand All @@ -194,7 +195,7 @@ public String getDisplaySuffix() {
*
* @return the extra item lore
*/
public String[] getExtraLore() {
public @Nonnull String[] getExtraLore() {
return new String[0];
}

Expand All @@ -203,14 +204,14 @@ public String[] getExtraLore() {
*
* @return the recipe, or null if the item does not have a vanilla crafting recipe
*/
public abstract Recipe getRecipe();
public abstract @Nullable Recipe getMainRecipe();

/**
* Define any alternative vanilla crafting recipes used to create the item.
*
* @return an array of recipes
*/
public Recipe[] getExtraRecipes() {
public @Nonnull Recipe[] getExtraRecipes() {
return new Recipe[0];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,19 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.inventory.FurnaceRecipe;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.Recipe;

import io.github.thebusybiscuit.sensibletoolbox.SensibleToolboxPlugin;
import io.github.thebusybiscuit.sensibletoolbox.api.SensibleToolbox;
import io.github.thebusybiscuit.sensibletoolbox.api.items.BaseSTBItem;
import io.github.thebusybiscuit.sensibletoolbox.api.items.BaseSTBMachine;
Expand All @@ -36,29 +39,48 @@ private RecipeUtil() {}
private static final Map<ItemStack, List<ItemStack>> reverseCustomSmelts = new HashMap<>();

public static void setupRecipes() {
for (String key : SensibleToolbox.getItemRegistry().getItemIds()) {
// add custom workbench recipes
BaseSTBItem item = SensibleToolbox.getItemRegistry().getItemById(key);
Recipe r = item.getRecipe();
if (r != null) {
Bukkit.addRecipe(r);
}
for (Recipe r2 : item.getExtraRecipes()) {
Bukkit.addRecipe(r2);
}
for (String itemId : SensibleToolbox.getItemRegistry().getItemIds()) {
try {
BaseSTBItem item = SensibleToolbox.getItemRegistry().getItemById(itemId);

// add custom furnace recipes
ItemStack stack = item.getSmeltingResult();
addWorkbenchRecipes(item);
addFurnaceRecipes(item);
addCustomMachineRecipes(item);

if (stack != null) {
Bukkit.addRecipe(new FurnaceRecipe(item.getKey(), stack, item.getMaterial(), 0, 200));
recordReverseSmelt(stack, item.toItemStack());
} catch (Exception x) {
SensibleToolboxPlugin.getInstance().getLogger().log(Level.SEVERE, x, () -> "Could not register recipe for item: " + itemId);
}
}
}

// add custom processing recipes for any machine items
if (item instanceof BaseSTBMachine) {
((BaseSTBMachine) item).addCustomRecipes(CustomRecipeManager.getManager());
}
private static void addWorkbenchRecipes(@Nonnull BaseSTBItem item) {
// add custom workbench recipes
Recipe mainRecipe = item.getMainRecipe();

if (mainRecipe != null) {
Bukkit.addRecipe(mainRecipe);
}

for (Recipe extraRecipe : item.getExtraRecipes()) {
Bukkit.addRecipe(extraRecipe);
}
}

private static void addFurnaceRecipes(@Nonnull BaseSTBItem item) {
// add custom furnace recipes
ItemStack stack = item.getSmeltingResult();

if (stack != null) {
NamespacedKey key = new NamespacedKey(SensibleToolboxPlugin.getInstance(), item.getItemTypeID() + "_furnacerecipe");
Bukkit.addRecipe(new FurnaceRecipe(key, stack, item.getMaterial(), 0, 200));
recordReverseSmelt(stack, item.toItemStack());
}
}

private static void addCustomMachineRecipes(@Nonnull BaseSTBItem item) {
// add custom processing recipes for any machine items
if (item instanceof BaseSTBMachine) {
((BaseSTBMachine) item).addCustomRecipes(CustomRecipeManager.getManager());
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package io.github.thebusybiscuit.sensibletoolbox.blocks;

import io.github.thebusybiscuit.sensibletoolbox.SensibleToolboxPlugin;
import io.github.thebusybiscuit.sensibletoolbox.api.MinecraftVersion;
import io.github.thebusybiscuit.slimefun4.libraries.dough.protection.Interaction;
import javax.annotation.Nonnull;

import org.bukkit.ChatColor;
import org.bukkit.Effect;
import org.bukkit.Location;
Expand All @@ -20,12 +19,13 @@
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.util.Vector;

import io.github.bakedlibs.dough.protection.Interaction;
import io.github.thebusybiscuit.sensibletoolbox.SensibleToolboxPlugin;
import io.github.thebusybiscuit.sensibletoolbox.api.MinecraftVersion;
import io.github.thebusybiscuit.sensibletoolbox.api.SensibleToolbox;
import io.github.thebusybiscuit.sensibletoolbox.api.items.BaseSTBBlock;
import io.github.thebusybiscuit.sensibletoolbox.utils.STBUtil;

import javax.annotation.Nonnull;

public class AngelicBlock extends BaseSTBBlock {

public AngelicBlock() {}
Expand All @@ -50,7 +50,7 @@ public String[] getLore() {
}

@Override
public Recipe getRecipe() {
public Recipe getMainRecipe() {
ShapedRecipe recipe = new ShapedRecipe(getKey(), this.toItemStack());
recipe.shape(" G ", "FOF");
recipe.setIngredient('G', Material.GOLD_INGOT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public String[] getExtraLore() {
}

@Override
public Recipe getRecipe() {
public Recipe getMainRecipe() {
ShapedRecipe res = new ShapedRecipe(getKey(), toItemStack());
res.shape("SRS", "SPS", "STS");
res.setIngredient('S', Material.STONE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public String[] getLore() {
}

@Override
public Recipe getRecipe() {
public Recipe getMainRecipe() {
ShapedRecipe recipe = new ShapedRecipe(getKey(), toItemStack());
recipe.shape("WWW", "WPW", "WWW");
recipe.setIngredient('W', Material.WHITE_WOOL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ protected String[] getSignLabel(BlockFace face) {
}

@Override
public Recipe getRecipe() {
public Recipe getMainRecipe() {
ShapedRecipe recipe = new ShapedRecipe(getKey(), toItemStack(1));
recipe.shape("GDG", "GEG", "GGG");
recipe.setIngredient('G', Material.GOLD_INGOT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public String[] getLore() {
}

@Override
public Recipe getRecipe() {
public Recipe getMainRecipe() {
ShapedRecipe recipe = new ShapedRecipe(getKey(), toItemStack());
recipe.shape("GSG", "G G", "III");
recipe.setIngredient('S', new MaterialChoice(Tag.WOODEN_SLABS));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public String[] getLore() {
}

@Override
public Recipe getRecipe() {
public Recipe getMainRecipe() {
ShapedRecipe res = new ShapedRecipe(getKey(), toItemStack());
res.shape("RSR", "STS", "RSR");
res.setIngredient('R', Material.REDSTONE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public String[] getLore() {
}

@Override
public Recipe getRecipe() {
public Recipe getMainRecipe() {
ShapedRecipe recipe = new ShapedRecipe(getKey(), toItemStack());
recipe.shape("WWW", "WNW", "WWW");
recipe.setIngredient('W', Material.WHITE_WOOL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public String[] getLore() {
}

@Override
public Recipe getRecipe() {
public Recipe getMainRecipe() {
ShapedRecipe recipe = new ShapedRecipe(getKey(), toItemStack());
recipe.shape("SSS", "OCO", "OOO");
recipe.setIngredient('S', Material.STONE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.bukkit.inventory.Recipe;
import org.bukkit.inventory.ShapedRecipe;

import io.github.bakedlibs.dough.protection.Interaction;
import io.github.thebusybiscuit.sensibletoolbox.api.SensibleToolbox;
import io.github.thebusybiscuit.sensibletoolbox.api.gui.InventoryGUI;
import io.github.thebusybiscuit.sensibletoolbox.api.gui.SlotType;
Expand All @@ -34,7 +35,7 @@
import io.github.thebusybiscuit.sensibletoolbox.items.components.ToughMachineFrame;
import io.github.thebusybiscuit.sensibletoolbox.utils.ColoredMaterial;
import io.github.thebusybiscuit.sensibletoolbox.utils.STBUtil;
import io.github.thebusybiscuit.slimefun4.libraries.dough.protection.Interaction;

import me.desht.dhutils.MiscUtil;
import me.desht.dhutils.cuboid.Cuboid;
import me.desht.dhutils.cuboid.CuboidDirection;
Expand Down Expand Up @@ -127,7 +128,7 @@ public String[] getLore() {
}

@Override
public Recipe getRecipe() {
public Recipe getMainRecipe() {
ShapedRecipe recipe = new ShapedRecipe(getKey(), toItemStack());
ToughMachineFrame mf = new ToughMachineFrame();
IntegratedCircuit ic = new IntegratedCircuit();
Expand Down
Loading

0 comments on commit 904daae

Please sign in to comment.