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

More refactoring

This commit is contained in:
TheBusyBiscuit 2021-04-30 11:22:18 +02:00
parent 2382b940f1
commit 8c0fbfb295
16 changed files with 96 additions and 13 deletions

View File

@ -1,5 +1,7 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.armor;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.block.data.type.Farmland;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -18,6 +20,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
*/
public class FarmerShoes extends SlimefunItem {
@ParametersAreNonnullByDefault
public FarmerShoes(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe);
}

View File

@ -1,5 +1,7 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.armor;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.NamespacedKey;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
@ -26,6 +28,7 @@ public class HazmatArmorPiece extends SlimefunArmorPiece implements ProtectiveAr
private final NamespacedKey namespacedKey;
private final ProtectionType[] types;
@ParametersAreNonnullByDefault
public HazmatArmorPiece(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, PotionEffect[] effects) {
super(category, item, recipeType, recipe, effects);

View File

@ -1,5 +1,8 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.armor;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
@ -13,7 +16,8 @@ public class SlimefunArmorPiece extends SlimefunItem {
private final PotionEffect[] effects;
public SlimefunArmorPiece(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, PotionEffect[] effects) {
@ParametersAreNonnullByDefault
public SlimefunArmorPiece(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, @Nullable PotionEffect[] effects) {
super(category, item, recipeType, recipe);
this.effects = effects == null ? new PotionEffect[0] : effects;

View File

@ -1,6 +1,7 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.armor;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Bukkit;
import org.bukkit.Effect;
@ -33,6 +34,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
*/
public class StomperBoots extends SlimefunItem {
@ParametersAreNonnullByDefault
public StomperBoots(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe);
}
@ -43,7 +45,7 @@ public class StomperBoots extends SlimefunItem {
* @param fallDamageEvent
* The {@link EntityDamageEvent} in which the {@link Player} has taken fall damage
*/
public void stomp(EntityDamageEvent fallDamageEvent) {
public void stomp(@Nonnull EntityDamageEvent fallDamageEvent) {
Player player = (Player) fallDamageEvent.getEntity();
player.getWorld().playSound(player.getLocation(), Sound.ENTITY_ZOMBIE_BREAK_WOODEN_DOOR, 1F, 2F);
player.setVelocity(new Vector(0, 0.7, 0));
@ -81,7 +83,8 @@ public class StomperBoots extends SlimefunItem {
*
* @return A {@link Vector} to determine the velocity for our {@link Entity}
*/
private Vector getShockwave(@Nonnull Location origin, @Nonnull Location target) {
@Nonnull
protected Vector getShockwave(@Nonnull Location origin, @Nonnull Location target) {
// As the distance approaches zero we might slip into a "division by zero" when normalizing
if (origin.distanceSquared(target) < 0.05) {
return new Vector(0, 1, 0);

View File

@ -1,5 +1,7 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.backpacks;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -23,6 +25,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
*/
public class Cooler extends SlimefunBackpack {
@ParametersAreNonnullByDefault
public Cooler(int size, Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(size, category, item, recipeType, recipe);
}

View File

@ -1,5 +1,7 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.backpacks;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Sound;
import org.bukkit.block.EnderChest;
import org.bukkit.entity.Player;
@ -22,6 +24,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
*/
public class EnderBackpack extends SimpleSlimefunItem<ItemUseHandler> implements NotPlaceable {
@ParametersAreNonnullByDefault
public EnderBackpack(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe);
}

View File

@ -5,6 +5,9 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
@ -17,6 +20,7 @@ import org.bukkit.inventory.ItemStack;
*
* @author Sfiguz7
*
* @see SlimefunBackpack
* @see PlayerBackpack
*/
public class RestoredBackpack extends SlimefunBackpack {
@ -27,7 +31,8 @@ public class RestoredBackpack extends SlimefunBackpack {
* @param category
* the category to bind this {@link SlimefunBackpack} to
*/
public RestoredBackpack(Category category) {
@ParametersAreNonnullByDefault
public RestoredBackpack(@Nonnull Category category) {
super(54, category, SlimefunItems.RESTORED_BACKPACK, RecipeType.NULL, new ItemStack[9]);
this.hidden = true;

View File

@ -1,5 +1,7 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.backpacks;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.slimefun4.core.attributes.Soulbound;
@ -15,6 +17,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
*/
public class SoulboundBackpack extends SlimefunBackpack implements Soulbound {
@ParametersAreNonnullByDefault
public SoulboundBackpack(int size, Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(size, category, item, recipeType, recipe);
}

View File

@ -0,0 +1,35 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.magical.runes;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientAltar;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
/**
* An {@link ElementalRune} is a very simple and basic crafting component
* used to craft various magical gadgets.
* <p>
* These runes are crafted using an {@link AncientAltar}.
*
* @author TheBusyBiscuit
*
*/
public class ElementalRune extends SlimefunItem {
@ParametersAreNonnullByDefault
public ElementalRune(Category category, SlimefunItemStack item, ItemStack[] recipe) {
this(category, item, recipe, null);
}
@ParametersAreNonnullByDefault
public ElementalRune(Category category, SlimefunItemStack item, ItemStack[] recipe, @Nullable ItemStack recipeResult) {
super(category, item, RecipeType.ANCIENT_ALTAR, recipe, recipeResult);
}
}

View File

@ -1,5 +1,7 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.misc;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.entity.Villager;
import org.bukkit.inventory.ItemStack;
@ -20,6 +22,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
*/
public class SyntheticEmerald extends SlimefunItem {
@ParametersAreNonnullByDefault
public SyntheticEmerald(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe);

View File

@ -1,5 +1,7 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.tools;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.block.Block;
import org.bukkit.inventory.ItemStack;
@ -19,6 +21,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
*/
public class ExplosivePickaxe extends ExplosiveTool {
@ParametersAreNonnullByDefault
public ExplosivePickaxe(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe);
}

View File

@ -1,5 +1,7 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.tools;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -23,6 +25,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
*/
public class ExplosiveShovel extends ExplosiveTool {
@ParametersAreNonnullByDefault
public ExplosiveShovel(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe);
}

View File

@ -1,5 +1,7 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.tools;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
@ -7,12 +9,14 @@ import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
import io.github.thebusybiscuit.slimefun4.core.handlers.ToolUseHandler;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
public class HerculesPickaxe extends SimpleSlimefunItem<ToolUseHandler> {
@ParametersAreNonnullByDefault
public HerculesPickaxe(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe);
}
@ -20,7 +24,7 @@ public class HerculesPickaxe extends SimpleSlimefunItem<ToolUseHandler> {
@Override
public ToolUseHandler getItemHandler() {
return (e, tool, fortune, drops) -> {
if (e.getBlock().getType().toString().endsWith("_ORE")) {
if (SlimefunTag.ORES.isTagged(e.getBlock().getType())) {
if (e.getBlock().getType() == Material.IRON_ORE) {
drops.add(new CustomItem(SlimefunItems.IRON_DUST, 2));
} else if (e.getBlock().getType() == Material.GOLD_ORE) {

View File

@ -1,6 +1,7 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.tools;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Material;
import org.bukkit.block.Block;
@ -34,6 +35,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
*/
public class PickaxeOfContainment extends SimpleSlimefunItem<ToolUseHandler> {
@ParametersAreNonnullByDefault
public PickaxeOfContainment(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe);
}

View File

@ -1,5 +1,7 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.tools;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Sound;
@ -15,6 +17,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
public class PortableDustbin extends SimpleSlimefunItem<ItemUseHandler> implements NotPlaceable {
@ParametersAreNonnullByDefault
public PortableDustbin(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe);
}

View File

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
@ -141,6 +142,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.magical.MagicEyeO
import io.github.thebusybiscuit.slimefun4.implementation.items.magical.MagicalZombiePills;
import io.github.thebusybiscuit.slimefun4.implementation.items.magical.SoulboundItem;
import io.github.thebusybiscuit.slimefun4.implementation.items.magical.TelepositionScroll;
import io.github.thebusybiscuit.slimefun4.implementation.items.magical.runes.ElementalRune;
import io.github.thebusybiscuit.slimefun4.implementation.items.magical.runes.EnchantmentRune;
import io.github.thebusybiscuit.slimefun4.implementation.items.magical.runes.SoulboundRune;
import io.github.thebusybiscuit.slimefun4.implementation.items.magical.runes.VillagerRune;
@ -1952,41 +1954,41 @@ public final class SlimefunItemSetup {
new ItemStack[] {null, SlimefunItems.GPS_TRANSMITTER_3, null, new ItemStack(Material.DIAMOND_SWORD), SlimefunItems.PROGRAMMABLE_ANDROID_3, new ItemStack(Material.DIAMOND_SWORD), null, SlimefunItems.ELECTRIC_MOTOR, null})
.register(plugin);
new SlimefunItem(categories.magicalResources, SlimefunItems.BLANK_RUNE, RecipeType.ANCIENT_ALTAR,
new ElementalRune(categories.magicalResources, SlimefunItems.BLANK_RUNE,
new ItemStack[] {new ItemStack(Material.STONE), SlimefunItems.MAGIC_LUMP_1, new ItemStack(Material.STONE), SlimefunItems.MAGIC_LUMP_1, new ItemStack(Material.OBSIDIAN), SlimefunItems.MAGIC_LUMP_1, new ItemStack(Material.STONE), SlimefunItems.MAGIC_LUMP_1, new ItemStack(Material.STONE)})
.register(plugin);
new SlimefunItem(categories.magicalResources, SlimefunItems.AIR_RUNE, RecipeType.ANCIENT_ALTAR,
new ElementalRune(categories.magicalResources, SlimefunItems.AIR_RUNE,
new ItemStack[] {new ItemStack(Material.FEATHER), SlimefunItems.MAGIC_LUMP_1, new ItemStack(Material.FEATHER), new ItemStack(Material.GHAST_TEAR), SlimefunItems.BLANK_RUNE, new ItemStack(Material.GHAST_TEAR), new ItemStack(Material.FEATHER), SlimefunItems.MAGIC_LUMP_1, new ItemStack(Material.FEATHER)},
new SlimefunItemStack(SlimefunItems.AIR_RUNE, 4))
.register(plugin);
new SlimefunItem(categories.magicalResources, SlimefunItems.EARTH_RUNE, RecipeType.ANCIENT_ALTAR,
new ElementalRune(categories.magicalResources, SlimefunItems.EARTH_RUNE,
new ItemStack[] {new ItemStack(Material.DIRT), SlimefunItems.MAGIC_LUMP_1, new ItemStack(Material.STONE), new ItemStack(Material.OBSIDIAN), SlimefunItems.BLANK_RUNE, new ItemStack(Material.OBSIDIAN), new ItemStack(Material.STONE), SlimefunItems.MAGIC_LUMP_1, new ItemStack(Material.DIRT)},
new SlimefunItemStack(SlimefunItems.EARTH_RUNE, 4))
.register(plugin);
new SlimefunItem(categories.magicalResources, SlimefunItems.FIRE_RUNE, RecipeType.ANCIENT_ALTAR,
new ElementalRune(categories.magicalResources, SlimefunItems.FIRE_RUNE,
new ItemStack[] {new ItemStack(Material.FIRE_CHARGE), SlimefunItems.MAGIC_LUMP_2, new ItemStack(Material.FIRE_CHARGE), new ItemStack(Material.BLAZE_POWDER), SlimefunItems.EARTH_RUNE, new ItemStack(Material.FLINT_AND_STEEL), new ItemStack(Material.FIRE_CHARGE), SlimefunItems.MAGIC_LUMP_2, new ItemStack(Material.FIRE_CHARGE)},
new SlimefunItemStack(SlimefunItems.FIRE_RUNE, 4))
.register(plugin);
new SlimefunItem(categories.magicalResources, SlimefunItems.WATER_RUNE, RecipeType.ANCIENT_ALTAR,
new ElementalRune(categories.magicalResources, SlimefunItems.WATER_RUNE,
new ItemStack[] {new ItemStack(Material.SALMON), SlimefunItems.MAGIC_LUMP_2, new ItemStack(Material.WATER_BUCKET), new ItemStack(Material.SAND), SlimefunItems.BLANK_RUNE, new ItemStack(Material.SAND), new ItemStack(Material.WATER_BUCKET), SlimefunItems.MAGIC_LUMP_2, new ItemStack(Material.COD)},
new SlimefunItemStack(SlimefunItems.WATER_RUNE, 4))
.register(plugin);
new SlimefunItem(categories.magicalResources, SlimefunItems.ENDER_RUNE, RecipeType.ANCIENT_ALTAR,
new ElementalRune(categories.magicalResources, SlimefunItems.ENDER_RUNE,
new ItemStack[] {new ItemStack(Material.ENDER_PEARL), SlimefunItems.ENDER_LUMP_3, new ItemStack(Material.ENDER_PEARL), new ItemStack(Material.ENDER_EYE), SlimefunItems.BLANK_RUNE, new ItemStack(Material.ENDER_EYE), new ItemStack(Material.ENDER_PEARL), SlimefunItems.ENDER_LUMP_3, new ItemStack(Material.ENDER_PEARL)},
new SlimefunItemStack(SlimefunItems.ENDER_RUNE, 6))
.register(plugin);
new SlimefunItem(categories.magicalResources, SlimefunItems.LIGHTNING_RUNE, RecipeType.ANCIENT_ALTAR,
new ElementalRune(categories.magicalResources, SlimefunItems.LIGHTNING_RUNE,
new ItemStack[] {new ItemStack(Material.IRON_INGOT), SlimefunItems.MAGIC_LUMP_3, new ItemStack(Material.IRON_INGOT), SlimefunItems.AIR_RUNE, new ItemStack(Material.PHANTOM_MEMBRANE), SlimefunItems.WATER_RUNE, new ItemStack(Material.IRON_INGOT), SlimefunItems.MAGIC_LUMP_3, new ItemStack(Material.IRON_INGOT)},
new SlimefunItemStack(SlimefunItems.LIGHTNING_RUNE, 4))
.register(plugin);
new SlimefunItem(categories.magicalResources, SlimefunItems.RAINBOW_RUNE, RecipeType.ANCIENT_ALTAR,
new ElementalRune(categories.magicalResources, SlimefunItems.RAINBOW_RUNE,
new ItemStack[] {new ItemStack(Material.RED_DYE), SlimefunItems.MAGIC_LUMP_3, new ItemStack(Material.CYAN_DYE), new ItemStack(Material.WHITE_WOOL), SlimefunItems.ENDER_RUNE, new ItemStack(Material.WHITE_WOOL), new ItemStack(Material.YELLOW_DYE), SlimefunItems.ENDER_LUMP_3, new ItemStack(Material.MAGENTA_DYE)})
.register(plugin);
@ -2621,6 +2623,7 @@ public final class SlimefunItemSetup {
// @formatter:on
}
@ParametersAreNonnullByDefault
private static void registerArmorSet(Category category, ItemStack baseComponent, ItemStack[] items, String idSyntax, boolean vanilla, PotionEffect[][] effects, SlimefunAddon addon) {
String[] components = new String[] { "_HELMET", "_CHESTPLATE", "_LEGGINGS", "_BOOTS" };
List<ItemStack[]> recipes = new ArrayList<>();