Skip to content

Commit 904daae

Browse files
Fixed dough imports and fully support MC 1.18 and SF RC28+
1 parent cbf737e commit 904daae

File tree

106 files changed

+285
-236
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+285
-236
lines changed

pom.xml

+18-17
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,15 @@
114114
<relocations>
115115
<relocation>
116116
<pattern>org.bstats</pattern>
117-
<shadedPattern>io.github.thebusybiscuit.sensibletoolbox.bstats</shadedPattern>
117+
<shadedPattern>io.github.thebusybiscuit.sensibletoolbox.libraries.bstats</shadedPattern>
118118
</relocation>
119119
<relocation>
120120
<pattern>io.papermc.lib</pattern>
121-
<shadedPattern>io.github.thebusybiscuit.sensibletoolbox.paperlib</shadedPattern>
121+
<shadedPattern>io.github.thebusybiscuit.sensibletoolbox.libraries.paperlib</shadedPattern>
122122
</relocation>
123123
<relocation>
124-
<pattern>io.github.thebusybiscuit.cscorelib2</pattern>
125-
<shadedPattern>io.github.thebusybiscuit.sensibletoolbox.cscorelib2</shadedPattern>
124+
<pattern>io.github.bakedlibs.dough</pattern>
125+
<shadedPattern>io.github.thebusybiscuit.sensibletoolbox.libraries.dough</shadedPattern>
126126
</relocation>
127127
</relocations>
128128

@@ -199,19 +199,6 @@
199199
<scope>provided</scope>
200200
</dependency>
201201

202-
<dependency>
203-
<groupId>com.github.TheBusyBiscuit</groupId>
204-
<artifactId>Slimefun4</artifactId>
205-
<version>RC-27</version>
206-
<scope>provided</scope>
207-
<exclusions>
208-
<exclusion>
209-
<groupId>io.github.bakedlibs</groupId>
210-
<artifactId>dough-api</artifactId>
211-
</exclusion>
212-
</exclusions>
213-
</dependency>
214-
215202
<dependency>
216203
<groupId>com.google.code.findbugs</groupId>
217204
<artifactId>jsr305</artifactId>
@@ -233,6 +220,20 @@
233220
<scope>provided</scope>
234221
</dependency>
235222

223+
<dependency>
224+
<groupId>com.github.TheBusyBiscuit</groupId>
225+
<artifactId>Slimefun4</artifactId>
226+
<version>RC-30</version>
227+
<scope>provided</scope>
228+
</dependency>
229+
230+
<dependency>
231+
<groupId>io.github.baked-libs</groupId>
232+
<artifactId>dough-api</artifactId>
233+
<version>1.1.1</version>
234+
<scope>compile</scope>
235+
</dependency>
236+
236237
<dependency>
237238
<groupId>io.papermc</groupId>
238239
<artifactId>paperlib</artifactId>

src/main/java/io/github/thebusybiscuit/sensibletoolbox/SensibleToolboxPlugin.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222

2323
import com.comphenix.protocol.ProtocolLib;
2424

25+
import io.github.bakedlibs.dough.protection.ProtectionManager;
26+
import io.github.bakedlibs.dough.updater.GitHubBuildsUpdater;
27+
import io.github.bakedlibs.dough.updater.PluginUpdater;
28+
import io.github.bakedlibs.dough.versions.PrefixedVersion;
2529
import io.github.thebusybiscuit.sensibletoolbox.api.AccessControl;
2630
import io.github.thebusybiscuit.sensibletoolbox.api.FriendManager;
2731
import io.github.thebusybiscuit.sensibletoolbox.api.MinecraftVersion;
@@ -151,10 +155,6 @@
151155
import io.github.thebusybiscuit.sensibletoolbox.slimefun.SlimefunBridge;
152156
import io.github.thebusybiscuit.sensibletoolbox.utils.ItemGlow;
153157
import io.github.thebusybiscuit.sensibletoolbox.utils.STBUtil;
154-
import io.github.thebusybiscuit.slimefun4.libraries.dough.protection.ProtectionManager;
155-
import io.github.thebusybiscuit.slimefun4.libraries.dough.updater.GitHubBuildsUpdater;
156-
import io.github.thebusybiscuit.slimefun4.libraries.dough.updater.PluginUpdater;
157-
import io.github.thebusybiscuit.slimefun4.libraries.dough.versions.PrefixedVersion;
158158
import io.papermc.lib.PaperLib;
159159

160160
import me.desht.dhutils.DHUtilsException;

src/main/java/io/github/thebusybiscuit/sensibletoolbox/api/MinecraftVersion.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public enum MinecraftVersion {
4343
*
4444
*/
4545
MINECRAFT_1_17(17, "1.17.x"),
46-
46+
4747
/**
4848
* This constant represents Minecraft (Java Edition) Version 1.18
4949
* (The "Caves and Cliffs: Part II" Update)

src/main/java/io/github/thebusybiscuit/sensibletoolbox/api/SensibleToolbox.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
import org.bukkit.Location;
55
import org.bukkit.block.Block;
66

7+
import io.github.bakedlibs.dough.protection.ProtectionManager;
78
import io.github.thebusybiscuit.sensibletoolbox.SensibleToolboxPlugin;
89
import io.github.thebusybiscuit.sensibletoolbox.api.energy.EnergyNet;
910
import io.github.thebusybiscuit.sensibletoolbox.api.items.BaseSTBBlock;
1011
import io.github.thebusybiscuit.sensibletoolbox.core.storage.LocationManager;
11-
import io.github.thebusybiscuit.slimefun4.libraries.dough.protection.ProtectionManager;
1212

1313
/**
1414
* Top-level collection of utility methods for Sensible Toolbox.

src/main/java/io/github/thebusybiscuit/sensibletoolbox/api/items/AbstractProcessingMachine.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public abstract class AbstractProcessingMachine extends BaseSTBMachine {
3030
private ItemStack processing;
3131
// try to eject every tick by default
3232
private int ejectionInterval = 1;
33-
33+
3434
protected AbstractProcessingMachine() {
3535
super();
3636
}

src/main/java/io/github/thebusybiscuit/sensibletoolbox/api/items/BaseSTBItem.java

+6-5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import java.util.concurrent.ThreadLocalRandom;
88

99
import javax.annotation.Nonnull;
10+
import javax.annotation.Nullable;
1011
import javax.annotation.ParametersAreNonnullByDefault;
1112

1213
import org.apache.commons.lang.Validate;
@@ -34,14 +35,14 @@
3435
import org.bukkit.permissions.Permissible;
3536
import org.bukkit.plugin.Plugin;
3637

38+
import io.github.bakedlibs.dough.data.persistent.PersistentDataAPI;
3739
import io.github.thebusybiscuit.sensibletoolbox.SensibleToolboxPlugin;
3840
import io.github.thebusybiscuit.sensibletoolbox.api.SensibleToolbox;
3941
import io.github.thebusybiscuit.sensibletoolbox.api.energy.Chargeable;
4042
import io.github.thebusybiscuit.sensibletoolbox.api.gui.InventoryGUIListener;
4143
import io.github.thebusybiscuit.sensibletoolbox.core.STBItemRegistry;
4244
import io.github.thebusybiscuit.sensibletoolbox.utils.ItemGlow;
4345
import io.github.thebusybiscuit.sensibletoolbox.utils.STBUtil;
44-
import io.github.thebusybiscuit.slimefun4.libraries.dough.data.persistent.PersistentDataAPI;
4546

4647
/**
4748
* Represents an STB item. This is the superclass for all STB items.
@@ -183,7 +184,7 @@ public final boolean isIngredientFor(ItemStack result) {
183184
*
184185
* @return the display suffix, or null for no suffix
185186
*/
186-
public String getDisplaySuffix() {
187+
public @Nullable String getDisplaySuffix() {
187188
return null;
188189
}
189190

@@ -194,7 +195,7 @@ public String getDisplaySuffix() {
194195
*
195196
* @return the extra item lore
196197
*/
197-
public String[] getExtraLore() {
198+
public @Nonnull String[] getExtraLore() {
198199
return new String[0];
199200
}
200201

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

208209
/**
209210
* Define any alternative vanilla crafting recipes used to create the item.
210211
*
211212
* @return an array of recipes
212213
*/
213-
public Recipe[] getExtraRecipes() {
214+
public @Nonnull Recipe[] getExtraRecipes() {
214215
return new Recipe[0];
215216
}
216217

src/main/java/io/github/thebusybiscuit/sensibletoolbox/api/recipes/RecipeUtil.java

+41-19
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,19 @@
88
import java.util.List;
99
import java.util.Map;
1010
import java.util.Set;
11+
import java.util.logging.Level;
1112

1213
import javax.annotation.Nonnull;
1314
import javax.annotation.Nullable;
1415

1516
import org.bukkit.Bukkit;
1617
import org.bukkit.Material;
18+
import org.bukkit.NamespacedKey;
1719
import org.bukkit.inventory.FurnaceRecipe;
1820
import org.bukkit.inventory.ItemStack;
1921
import org.bukkit.inventory.Recipe;
2022

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

3841
public static void setupRecipes() {
39-
for (String key : SensibleToolbox.getItemRegistry().getItemIds()) {
40-
// add custom workbench recipes
41-
BaseSTBItem item = SensibleToolbox.getItemRegistry().getItemById(key);
42-
Recipe r = item.getRecipe();
43-
if (r != null) {
44-
Bukkit.addRecipe(r);
45-
}
46-
for (Recipe r2 : item.getExtraRecipes()) {
47-
Bukkit.addRecipe(r2);
48-
}
42+
for (String itemId : SensibleToolbox.getItemRegistry().getItemIds()) {
43+
try {
44+
BaseSTBItem item = SensibleToolbox.getItemRegistry().getItemById(itemId);
4945

50-
// add custom furnace recipes
51-
ItemStack stack = item.getSmeltingResult();
46+
addWorkbenchRecipes(item);
47+
addFurnaceRecipes(item);
48+
addCustomMachineRecipes(item);
5249

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

58-
// add custom processing recipes for any machine items
59-
if (item instanceof BaseSTBMachine) {
60-
((BaseSTBMachine) item).addCustomRecipes(CustomRecipeManager.getManager());
61-
}
56+
private static void addWorkbenchRecipes(@Nonnull BaseSTBItem item) {
57+
// add custom workbench recipes
58+
Recipe mainRecipe = item.getMainRecipe();
59+
60+
if (mainRecipe != null) {
61+
Bukkit.addRecipe(mainRecipe);
62+
}
63+
64+
for (Recipe extraRecipe : item.getExtraRecipes()) {
65+
Bukkit.addRecipe(extraRecipe);
66+
}
67+
}
68+
69+
private static void addFurnaceRecipes(@Nonnull BaseSTBItem item) {
70+
// add custom furnace recipes
71+
ItemStack stack = item.getSmeltingResult();
72+
73+
if (stack != null) {
74+
NamespacedKey key = new NamespacedKey(SensibleToolboxPlugin.getInstance(), item.getItemTypeID() + "_furnacerecipe");
75+
Bukkit.addRecipe(new FurnaceRecipe(key, stack, item.getMaterial(), 0, 200));
76+
recordReverseSmelt(stack, item.toItemStack());
77+
}
78+
}
79+
80+
private static void addCustomMachineRecipes(@Nonnull BaseSTBItem item) {
81+
// add custom processing recipes for any machine items
82+
if (item instanceof BaseSTBMachine) {
83+
((BaseSTBMachine) item).addCustomRecipes(CustomRecipeManager.getManager());
6284
}
6385
}
6486

src/main/java/io/github/thebusybiscuit/sensibletoolbox/blocks/AngelicBlock.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package io.github.thebusybiscuit.sensibletoolbox.blocks;
22

3-
import io.github.thebusybiscuit.sensibletoolbox.SensibleToolboxPlugin;
4-
import io.github.thebusybiscuit.sensibletoolbox.api.MinecraftVersion;
5-
import io.github.thebusybiscuit.slimefun4.libraries.dough.protection.Interaction;
3+
import javax.annotation.Nonnull;
4+
65
import org.bukkit.ChatColor;
76
import org.bukkit.Effect;
87
import org.bukkit.Location;
@@ -20,12 +19,13 @@
2019
import org.bukkit.inventory.ShapedRecipe;
2120
import org.bukkit.util.Vector;
2221

22+
import io.github.bakedlibs.dough.protection.Interaction;
23+
import io.github.thebusybiscuit.sensibletoolbox.SensibleToolboxPlugin;
24+
import io.github.thebusybiscuit.sensibletoolbox.api.MinecraftVersion;
2325
import io.github.thebusybiscuit.sensibletoolbox.api.SensibleToolbox;
2426
import io.github.thebusybiscuit.sensibletoolbox.api.items.BaseSTBBlock;
2527
import io.github.thebusybiscuit.sensibletoolbox.utils.STBUtil;
2628

27-
import javax.annotation.Nonnull;
28-
2929
public class AngelicBlock extends BaseSTBBlock {
3030

3131
public AngelicBlock() {}
@@ -50,7 +50,7 @@ public String[] getLore() {
5050
}
5151

5252
@Override
53-
public Recipe getRecipe() {
53+
public Recipe getMainRecipe() {
5454
ShapedRecipe recipe = new ShapedRecipe(getKey(), this.toItemStack());
5555
recipe.shape(" G ", "FOF");
5656
recipe.setIngredient('G', Material.GOLD_INGOT);

src/main/java/io/github/thebusybiscuit/sensibletoolbox/blocks/BlockUpdateDetector.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public String[] getExtraLore() {
8888
}
8989

9090
@Override
91-
public Recipe getRecipe() {
91+
public Recipe getMainRecipe() {
9292
ShapedRecipe res = new ShapedRecipe(getKey(), toItemStack());
9393
res.shape("SRS", "SPS", "STS");
9494
res.setIngredient('S', Material.STONE);

src/main/java/io/github/thebusybiscuit/sensibletoolbox/blocks/Elevator.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public String[] getLore() {
6363
}
6464

6565
@Override
66-
public Recipe getRecipe() {
66+
public Recipe getMainRecipe() {
6767
ShapedRecipe recipe = new ShapedRecipe(getKey(), toItemStack());
6868
recipe.shape("WWW", "WPW", "WWW");
6969
recipe.setIngredient('W', Material.WHITE_WOOL);

src/main/java/io/github/thebusybiscuit/sensibletoolbox/blocks/EnderBox.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ protected String[] getSignLabel(BlockFace face) {
104104
}
105105

106106
@Override
107-
public Recipe getRecipe() {
107+
public Recipe getMainRecipe() {
108108
ShapedRecipe recipe = new ShapedRecipe(getKey(), toItemStack(1));
109109
recipe.shape("GDG", "GEG", "GGG");
110110
recipe.setIngredient('G', Material.GOLD_INGOT);

src/main/java/io/github/thebusybiscuit/sensibletoolbox/blocks/PaintCan.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public String[] getLore() {
135135
}
136136

137137
@Override
138-
public Recipe getRecipe() {
138+
public Recipe getMainRecipe() {
139139
ShapedRecipe recipe = new ShapedRecipe(getKey(), toItemStack());
140140
recipe.shape("GSG", "G G", "III");
141141
recipe.setIngredient('S', new MaterialChoice(Tag.WOODEN_SLABS));

src/main/java/io/github/thebusybiscuit/sensibletoolbox/blocks/RedstoneClock.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public String[] getLore() {
111111
}
112112

113113
@Override
114-
public Recipe getRecipe() {
114+
public Recipe getMainRecipe() {
115115
ShapedRecipe res = new ShapedRecipe(getKey(), toItemStack());
116116
res.shape("RSR", "STS", "RSR");
117117
res.setIngredient('R', Material.REDSTONE);

src/main/java/io/github/thebusybiscuit/sensibletoolbox/blocks/SoundMuffler.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public String[] getLore() {
9191
}
9292

9393
@Override
94-
public Recipe getRecipe() {
94+
public Recipe getMainRecipe() {
9595
ShapedRecipe recipe = new ShapedRecipe(getKey(), toItemStack());
9696
recipe.shape("WWW", "WNW", "WWW");
9797
recipe.setIngredient('W', Material.WHITE_WOOL);

src/main/java/io/github/thebusybiscuit/sensibletoolbox/blocks/TrashCan.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public String[] getLore() {
5656
}
5757

5858
@Override
59-
public Recipe getRecipe() {
59+
public Recipe getMainRecipe() {
6060
ShapedRecipe recipe = new ShapedRecipe(getKey(), toItemStack());
6161
recipe.shape("SSS", "OCO", "OOO");
6262
recipe.setIngredient('S', Material.STONE);

src/main/java/io/github/thebusybiscuit/sensibletoolbox/blocks/machines/AutoBuilder.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.bukkit.inventory.Recipe;
2222
import org.bukkit.inventory.ShapedRecipe;
2323

24+
import io.github.bakedlibs.dough.protection.Interaction;
2425
import io.github.thebusybiscuit.sensibletoolbox.api.SensibleToolbox;
2526
import io.github.thebusybiscuit.sensibletoolbox.api.gui.InventoryGUI;
2627
import io.github.thebusybiscuit.sensibletoolbox.api.gui.SlotType;
@@ -34,7 +35,7 @@
3435
import io.github.thebusybiscuit.sensibletoolbox.items.components.ToughMachineFrame;
3536
import io.github.thebusybiscuit.sensibletoolbox.utils.ColoredMaterial;
3637
import io.github.thebusybiscuit.sensibletoolbox.utils.STBUtil;
37-
import io.github.thebusybiscuit.slimefun4.libraries.dough.protection.Interaction;
38+
3839
import me.desht.dhutils.MiscUtil;
3940
import me.desht.dhutils.cuboid.Cuboid;
4041
import me.desht.dhutils.cuboid.CuboidDirection;
@@ -127,7 +128,7 @@ public String[] getLore() {
127128
}
128129

129130
@Override
130-
public Recipe getRecipe() {
131+
public Recipe getMainRecipe() {
131132
ShapedRecipe recipe = new ShapedRecipe(getKey(), toItemStack());
132133
ToughMachineFrame mf = new ToughMachineFrame();
133134
IntegratedCircuit ic = new IntegratedCircuit();

0 commit comments

Comments
 (0)