Skip to content

Commit 2813710

Browse files
committed
new ItemStack => ItemStack.of
1 parent af2d6f6 commit 2813710

File tree

119 files changed

+867
-867
lines changed

Some content is hidden

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

119 files changed

+867
-867
lines changed

src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerRightClickEvent.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,13 @@ public PlayerInteractEvent getInteractEvent() {
9292
/**
9393
* This method returns the {@link ItemStack} that was held in the hand of the {@link Player}.
9494
* It will never return null, should there be no {@link ItemStack} then it will return
95-
* {@code new ItemStack(Material.AIR)}.
95+
* {@code ItemStack.of(Material.AIR)}.
9696
*
9797
* @return The {@link ItemStack} that the {@link Player} right clicked with
9898
*/
9999
@Nonnull
100100
public ItemStack getItem() {
101-
return itemStack.orElse(new ItemStack(Material.AIR));
101+
return itemStack.orElse(ItemStack.of(Material.AIR));
102102
}
103103

104104
/**

src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItemStack.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public SlimefunItemStack(@Nonnull String id, @Nonnull ItemStack item, @Nonnull C
7878
}
7979

8080
public SlimefunItemStack(@Nonnull String id, @Nonnull Material type, @Nonnull Consumer<ItemMeta> consumer) {
81-
this(id, new ItemStack(type), consumer);
81+
this(id, ItemStack.of(type), consumer);
8282
}
8383

8484
public SlimefunItemStack(@Nonnull String id, @Nonnull Material type, @Nullable String name, @Nonnull Consumer<ItemMeta> consumer) {
@@ -109,7 +109,7 @@ public SlimefunItemStack(@Nonnull String id, @Nonnull ItemStack item, @Nullable
109109
}
110110

111111
public SlimefunItemStack(@Nonnull String id, @Nonnull Material type, @Nullable String name, String... lore) {
112-
this(id, new ItemStack(type), name, lore);
112+
this(id, ItemStack.of(type), name, lore);
113113
}
114114

115115
public SlimefunItemStack(@Nonnull String id, @Nonnull Material type, @Nonnull Color color, @Nullable String name, String... lore) {
@@ -284,7 +284,7 @@ public void lock() {
284284

285285
private static @Nonnull ItemStack getSkull(@Nonnull String id, @Nonnull String texture) {
286286
if (Slimefun.getMinecraftVersion() == MinecraftVersion.UNIT_TEST) {
287-
return new ItemStack(Material.PLAYER_HEAD);
287+
return ItemStack.of(Material.PLAYER_HEAD);
288288
}
289289

290290
PlayerSkin skin = PlayerSkin.fromBase64(getTexture(id, texture));

src/main/java/io/github/thebusybiscuit/slimefun4/api/recipes/RecipeType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public RecipeType(NamespacedKey key, ItemStack item) {
113113
}
114114

115115
public RecipeType(MinecraftRecipe<?> recipe) {
116-
this.item = new ItemStack(recipe.getMachine());
116+
this.item = ItemStack.of(recipe.getMachine());
117117
this.machine = "";
118118
this.key = NamespacedKey.minecraft(recipe.getRecipeClass().getSimpleName().toLowerCase(Locale.ROOT).replace("recipe", ""));
119119
}

src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/GuideModeOption.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public Optional<ItemStack> getDisplayItem(Player p, ItemStack guide) {
4747

4848
if (current.isPresent()) {
4949
SlimefunGuideMode selectedMode = current.get();
50-
ItemStack item = new ItemStack(Material.AIR);
50+
ItemStack item = ItemStack.of(Material.AIR);
5151

5252
if (selectedMode == SlimefunGuideMode.SURVIVAL_MODE) {
5353
item.setType(Material.CHEST);

src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ItemStackAndInteger.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public void add(int amount) {
4242

4343
private void initializeItem() {
4444
if (this.item instanceof ItemStackWrapper) {
45-
ItemStack copy = new ItemStack(item.getType(), item.getAmount());
45+
ItemStack copy = ItemStack.of(item.getType(), item.getAmount());
4646
if (this.item.hasItemMeta()) {
4747
copy.setItemMeta(this.item.getItemMeta());
4848
}

src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/SlimefunLocalization.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ protected void loadEmbeddedLanguages() {
315315

316316
if (item == null) {
317317
// Fixes #3088
318-
return new ItemStack(Material.AIR);
318+
return ItemStack.of(Material.AIR);
319319
}
320320

321321
Language language = getLanguage(p);

src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,15 +484,15 @@ private <T extends Recipe> void showRecipeChoices(T recipe, ItemStack[] recipeIt
484484
RecipeChoice[] choices = Slimefun.getMinecraftRecipeService().getRecipeShape(recipe);
485485

486486
if (choices.length == 1 && choices[0] instanceof MaterialChoice materialChoice) {
487-
recipeItems[4] = new ItemStack(materialChoice.getChoices().get(0));
487+
recipeItems[4] = ItemStack.of(materialChoice.getChoices().get(0));
488488

489489
if (materialChoice.getChoices().size() > 1) {
490490
task.add(recipeSlots[4], materialChoice);
491491
}
492492
} else {
493493
for (int i = 0; i < choices.length; i++) {
494494
if (choices[i] instanceof MaterialChoice materialChoice) {
495-
recipeItems[i] = new ItemStack(materialChoice.getChoices().get(0));
495+
recipeItems[i] = ItemStack.of(materialChoice.getChoices().get(0));
496496

497497
if (materialChoice.getChoices().size() > 1) {
498498
task.add(recipeSlots[i], materialChoice);

src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/FarmerAndroid.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ private ItemStack getDropFromCrop(Material crop) {
6969
Random random = ThreadLocalRandom.current();
7070

7171
return switch (crop) {
72-
case WHEAT -> new ItemStack(Material.WHEAT, random.nextInt(2) + 1);
73-
case POTATOES -> new ItemStack(Material.POTATO, random.nextInt(3) + 1);
74-
case CARROTS -> new ItemStack(Material.CARROT, random.nextInt(3) + 1);
75-
case BEETROOTS -> new ItemStack(Material.BEETROOT, random.nextInt(3) + 1);
76-
case COCOA -> new ItemStack(Material.COCOA_BEANS, random.nextInt(3) + 1);
77-
case NETHER_WART -> new ItemStack(Material.NETHER_WART, random.nextInt(3) + 1);
78-
case SWEET_BERRY_BUSH -> new ItemStack(Material.SWEET_BERRIES, random.nextInt(3) + 1);
72+
case WHEAT -> ItemStack.of(Material.WHEAT, random.nextInt(2) + 1);
73+
case POTATOES -> ItemStack.of(Material.POTATO, random.nextInt(3) + 1);
74+
case CARROTS -> ItemStack.of(Material.CARROT, random.nextInt(3) + 1);
75+
case BEETROOTS -> ItemStack.of(Material.BEETROOT, random.nextInt(3) + 1);
76+
case COCOA -> ItemStack.of(Material.COCOA_BEANS, random.nextInt(3) + 1);
77+
case NETHER_WART -> ItemStack.of(Material.NETHER_WART, random.nextInt(3) + 1);
78+
case SWEET_BERRY_BUSH -> ItemStack.of(Material.SWEET_BERRIES, random.nextInt(3) + 1);
7979
default -> null;
8080
};
8181
}

src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/FishermanAndroid.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,23 @@ public FishermanAndroid(ItemGroup itemGroup, int tier, SlimefunItemStack item, R
2828

2929
// Fish
3030
for (Material fish : Tag.ITEMS_FISHES.getValues()) {
31-
fishingLoot.add(new ItemStack(fish), 25);
31+
fishingLoot.add(ItemStack.of(fish), 25);
3232
}
3333

3434
// Junk
35-
fishingLoot.add(new ItemStack(Material.BONE), 10);
36-
fishingLoot.add(new ItemStack(Material.STRING), 10);
37-
fishingLoot.add(new ItemStack(Material.INK_SAC), 8);
38-
fishingLoot.add(new ItemStack(Material.KELP), 6);
39-
fishingLoot.add(new ItemStack(Material.STICK), 5);
40-
fishingLoot.add(new ItemStack(Material.ROTTEN_FLESH), 3);
41-
fishingLoot.add(new ItemStack(Material.LEATHER), 2);
42-
fishingLoot.add(new ItemStack(Material.BAMBOO), 3);
35+
fishingLoot.add(ItemStack.of(Material.BONE), 10);
36+
fishingLoot.add(ItemStack.of(Material.STRING), 10);
37+
fishingLoot.add(ItemStack.of(Material.INK_SAC), 8);
38+
fishingLoot.add(ItemStack.of(Material.KELP), 6);
39+
fishingLoot.add(ItemStack.of(Material.STICK), 5);
40+
fishingLoot.add(ItemStack.of(Material.ROTTEN_FLESH), 3);
41+
fishingLoot.add(ItemStack.of(Material.LEATHER), 2);
42+
fishingLoot.add(ItemStack.of(Material.BAMBOO), 3);
4343

4444
// "loot"
45-
fishingLoot.add(new ItemStack(Material.SADDLE), 1);
46-
fishingLoot.add(new ItemStack(Material.NAME_TAG), 1);
47-
fishingLoot.add(new ItemStack(Material.NAUTILUS_SHELL), 1);
45+
fishingLoot.add(ItemStack.of(Material.SADDLE), 1);
46+
fishingLoot.add(ItemStack.of(Material.NAME_TAG), 1);
47+
fishingLoot.add(ItemStack.of(Material.NAUTILUS_SHELL), 1);
4848
}
4949

5050
@Override

src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/MinerAndroid.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
public class MinerAndroid extends ProgrammableAndroid {
5353

5454
// Determines the drops a miner android will get
55-
private final ItemStack effectivePickaxe = new ItemStack(Material.DIAMOND_PICKAXE);
55+
private final ItemStack effectivePickaxe = ItemStack.of(Material.DIAMOND_PICKAXE);
5656

5757
private final ItemSetting<Boolean> firesEvent = new ItemSetting<>(this, "trigger-event-for-generators", false);
5858
private final ItemSetting<Boolean> applyOptimizations = new ItemSetting<>(this, "reduced-block-updates", true);

0 commit comments

Comments
 (0)