Skip to content

Commit

Permalink
[6.1.2] 1.21, XSeries
Browse files Browse the repository at this point in the history
  • Loading branch information
Bkm016 committed Jun 15, 2024
1 parent 305332e commit 87b640a
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 97 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.material.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import javax.annotation.Nullable;
import java.util.*;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.*;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -146,7 +146,7 @@ public enum XEnchantment {
*
* @see NamespacedKey#getKey()
*/
XEnchantment(@Nonnull String... aliases) {
XEnchantment(@NotNull String... aliases) {
Enchantment enchantment = getBukkitEnchant(this.name());

Data.NAMES.put(this.name(), this);
Expand Down Expand Up @@ -205,8 +205,8 @@ public static boolean isArthropodsEffectiveAgainst(@Nullable EntityType type) {
* @return an enum name.
* @since 1.0.0
*/
@Nonnull
private static String format(@Nonnull String name) {
@NotNull
private static String format(@NotNull String name) {
int len = name.length();
char[] chs = new char[len];
int count = 0;
Expand Down Expand Up @@ -239,8 +239,8 @@ private static String format(@Nonnull String name) {
* @return an enchantment.
* @since 1.0.0
*/
@Nonnull
public static Optional<XEnchantment> matchXEnchantment(@Nonnull String enchantment) {
@NotNull
public static Optional<XEnchantment> matchXEnchantment(@NotNull String enchantment) {
if (enchantment == null || enchantment.isEmpty())
throw new IllegalArgumentException("Enchantment name cannot be null or empty");
return Optional.ofNullable(Data.NAMES.get(format(enchantment)));
Expand All @@ -255,9 +255,9 @@ public static Optional<XEnchantment> matchXEnchantment(@Nonnull String enchantme
* @throws IllegalArgumentException may be thrown as an unexpected exception.
* @since 1.0.0
*/
@Nonnull
@NotNull
@SuppressWarnings("deprecation")
public static XEnchantment matchXEnchantment(@Nonnull Enchantment enchantment) {
public static XEnchantment matchXEnchantment(@NotNull Enchantment enchantment) {
Objects.requireNonNull(enchantment, "Cannot parse XEnchantment of a null enchantment");
return Objects.requireNonNull(Data.NAMES.get(enchantment.getName()), () -> "Unsupported enchantment: " + enchantment.getName());
}
Expand All @@ -269,7 +269,7 @@ public static XEnchantment matchXEnchantment(@Nonnull Enchantment enchantment) {
* @return an enchanted book.
* @since 1.0.0
*/
@Nonnull
@NotNull
public ItemStack getBook(int level) {
ItemStack book = new ItemStack(Material.ENCHANTED_BOOK);
EnchantmentStorageMeta meta = (EnchantmentStorageMeta) book.getItemMeta();
Expand Down Expand Up @@ -327,7 +327,7 @@ public XEnchantment or(@Nullable XEnchantment alternateEnchantment) {
* @return a friendly readable string name.
*/
@Override
@Nonnull
@NotNull
public String toString() {
return Arrays.stream(name().split("_"))
.map(t -> t.charAt(0) + t.substring(1).toLowerCase())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@
import org.bukkit.material.SpawnEgg;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionType;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import taboolib.library.configuration.ConfigurationSection;
import taboolib.module.configuration.Configuration;
import taboolib.module.configuration.Type;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.*;
import java.util.function.BiPredicate;
import java.util.function.Consumer;
Expand Down Expand Up @@ -133,7 +133,7 @@ private static BlockState safeBlockState(BlockStateMeta meta) {
* @see #serialize(ItemStack, ConfigurationSection, Function)
* @since 1.0.0
*/
public static void serialize(@Nonnull ItemStack item, @Nonnull ConfigurationSection config) {
public static void serialize(@NotNull ItemStack item, @NotNull ConfigurationSection config) {
serialize(item, config, Function.identity());
}

Expand All @@ -147,8 +147,8 @@ public static void serialize(@Nonnull ItemStack item, @Nonnull ConfigurationSect
* @since 7.4.0
*/
@SuppressWarnings("deprecation")
public static void serialize(@Nonnull ItemStack item, @Nonnull ConfigurationSection config,
@Nonnull Function<String, String> translator) {
public static void serialize(@NotNull ItemStack item, @NotNull ConfigurationSection config,
@NotNull Function<String, String> translator) {
Objects.requireNonNull(item, "Cannot serialize a null item");
Objects.requireNonNull(config, "Cannot serialize item from a null configuration section.");

Expand Down Expand Up @@ -435,7 +435,7 @@ public static void serialize(@Nonnull ItemStack item, @Nonnull ConfigurationSect
* @param item the ItemStack to serialize.
* @return a Map containing the serialized ItemStack properties.
*/
public static Map<String, Object> serialize(@Nonnull ItemStack item) {
public static Map<String, Object> serialize(@NotNull ItemStack item) {
Objects.requireNonNull(item, "Cannot serialize a null item");
ConfigurationSection config = Configuration.Companion.empty(Type.YAML, false);
serialize(item, config);
Expand All @@ -449,8 +449,8 @@ public static Map<String, Object> serialize(@Nonnull ItemStack item) {
* @return a deserialized ItemStack.
* @since 1.0.0
*/
@Nonnull
public static ItemStack deserialize(@Nonnull ConfigurationSection config) {
@NotNull
public static ItemStack deserialize(@NotNull ConfigurationSection config) {
return edit(new ItemStack(DEFAULT_MATERIAL.parseMaterial()), config, Function.identity(), null);
}

Expand All @@ -461,15 +461,15 @@ public static ItemStack deserialize(@Nonnull ConfigurationSection config) {
* the ItemStack object from.
* @return a deserialized ItemStack.
*/
@Nonnull
public static ItemStack deserialize(@Nonnull Map<String, Object> serializedItem) {
@NotNull
public static ItemStack deserialize(@NotNull Map<String, Object> serializedItem) {
Objects.requireNonNull(serializedItem, "serializedItem cannot be null.");
return deserialize(mapToConfigSection(serializedItem));
}

@Nonnull
public static ItemStack deserialize(@Nonnull ConfigurationSection config,
@Nonnull Function<String, String> translator) {
@NotNull
public static ItemStack deserialize(@NotNull ConfigurationSection config,
@NotNull Function<String, String> translator) {
return deserialize(config, translator, null);
}

Expand All @@ -480,9 +480,9 @@ public static ItemStack deserialize(@Nonnull ConfigurationSection config,
* @return an edited ItemStack.
* @since 7.2.0
*/
@Nonnull
public static ItemStack deserialize(@Nonnull ConfigurationSection config,
@Nonnull Function<String, String> translator,
@NotNull
public static ItemStack deserialize(@NotNull ConfigurationSection config,
@NotNull Function<String, String> translator,
@Nullable Consumer<Exception> restart) {
return edit(new ItemStack(DEFAULT_MATERIAL.parseMaterial()), config, translator, restart);
}
Expand All @@ -496,8 +496,8 @@ public static ItemStack deserialize(@Nonnull ConfigurationSection config,
* @param translator the translator to use for translating the item's name.
* @return a deserialized ItemStack.
*/
@Nonnull
public static ItemStack deserialize(@Nonnull Map<String, Object> serializedItem, @Nonnull Function<String, String> translator) {
@NotNull
public static ItemStack deserialize(@NotNull Map<String, Object> serializedItem, @NotNull Function<String, String> translator) {
Objects.requireNonNull(serializedItem, "serializedItem cannot be null.");
Objects.requireNonNull(translator, "translator cannot be null.");
return deserialize(mapToConfigSection(serializedItem), translator);
Expand All @@ -511,7 +511,7 @@ private static int toInt(String str, @SuppressWarnings("SameParameterValue") int
}
}

private static List<String> split(@Nonnull String str, @SuppressWarnings("SameParameterValue") char separatorChar) {
private static List<String> split(@NotNull String str, @SuppressWarnings("SameParameterValue") char separatorChar) {
List<String> list = new ArrayList<>(5);
boolean match = false, lastMatch = false;
int len = str.length();
Expand Down Expand Up @@ -578,10 +578,10 @@ private static List<String> splitNewLine(String str) {
* @since 1.0.0
*/
@SuppressWarnings("deprecation")
@Nonnull
public static ItemStack edit(@Nonnull ItemStack item,
@Nonnull final ConfigurationSection config,
@Nonnull final Function<String, String> translator,
@NotNull
public static ItemStack edit(@NotNull ItemStack item,
@NotNull final ConfigurationSection config,
@NotNull final Function<String, String> translator,
@Nullable final Consumer<Exception> restart) {
Objects.requireNonNull(item, "Cannot operate on null ItemStack, considering using an AIR ItemStack instead");
Objects.requireNonNull(config, "Cannot deserialize item to a null configuration section.");
Expand Down Expand Up @@ -1076,8 +1076,8 @@ public static ItemStack edit(@Nonnull ItemStack item,
* @param map the map to convert.
* @return a {@code ConfigurationSection} containing the map values.
*/
@Nonnull
private static ConfigurationSection mapToConfigSection(@Nonnull Map<?, ?> map) {
@NotNull
private static ConfigurationSection mapToConfigSection(@NotNull Map<?, ?> map) {
ConfigurationSection config = Configuration.Companion.empty(Type.YAML, false);

for (Map.Entry<?, ?> entry : map.entrySet()) {
Expand All @@ -1101,8 +1101,8 @@ private static ConfigurationSection mapToConfigSection(@Nonnull Map<?, ?> map) {
* @param config the configuration section to convert.
* @return a {@code Map<String, Object>} containing the configuration section values.
*/
@Nonnull
private static Map<String, Object> configSectionToMap(@Nonnull ConfigurationSection config) {
@NotNull
private static Map<String, Object> configSectionToMap(@NotNull ConfigurationSection config) {
Map<String, Object> map = new LinkedHashMap<>();

for (String key : config.getKeys(false)) {
Expand All @@ -1127,7 +1127,7 @@ private static Map<String, Object> configSectionToMap(@Nonnull ConfigurationSect
* @return a color based on the RGB.
* @since 1.1.0
*/
@Nonnull
@NotNull
public static Color parseColor(@Nullable String str) {
if (Strings.isNullOrEmpty(str)) return Color.BLACK;
List<String> rgb = split(str.replace(" ", ""), ',');
Expand All @@ -1143,8 +1143,8 @@ public static Color parseColor(@Nullable String str) {
* @return the items that did not fit and were dropped.
* @since 2.0.1
*/
@Nonnull
public static List<ItemStack> giveOrDrop(@Nonnull Player player, @Nullable ItemStack... items) {
@NotNull
public static List<ItemStack> giveOrDrop(@NotNull Player player, @Nullable ItemStack... items) {
return giveOrDrop(player, false, items);
}

Expand All @@ -1157,8 +1157,8 @@ public static List<ItemStack> giveOrDrop(@Nonnull Player player, @Nullable ItemS
* @return the items that did not fit and were dropped.
* @since 2.0.1
*/
@Nonnull
public static List<ItemStack> giveOrDrop(@Nonnull Player player, boolean split, @Nullable ItemStack... items) {
@NotNull
public static List<ItemStack> giveOrDrop(@NotNull Player player, boolean split, @Nullable ItemStack... items) {
if (items == null || items.length == 0) return new ArrayList<>();
List<ItemStack> leftOvers = addItems(player.getInventory(), split, items);
World world = player.getWorld();
Expand All @@ -1168,7 +1168,7 @@ public static List<ItemStack> giveOrDrop(@Nonnull Player player, boolean split,
return leftOvers;
}

public static List<ItemStack> addItems(@Nonnull Inventory inventory, boolean split, @Nonnull ItemStack... items) {
public static List<ItemStack> addItems(@NotNull Inventory inventory, boolean split, @NotNull ItemStack... items) {
return addItems(inventory, split, null, items);
}

Expand All @@ -1185,9 +1185,9 @@ public static List<ItemStack> addItems(@Nonnull Inventory inventory, boolean spl
* @return items that didn't fit in the inventory.
* @since 4.0.0
*/
@Nonnull
public static List<ItemStack> addItems(@Nonnull Inventory inventory, boolean split,
@Nullable Predicate<Integer> modifiableSlots, @Nonnull ItemStack... items) {
@NotNull
public static List<ItemStack> addItems(@NotNull Inventory inventory, boolean split,
@Nullable Predicate<Integer> modifiableSlots, @NotNull ItemStack... items) {
Objects.requireNonNull(inventory, "Cannot add items to null inventory");
Objects.requireNonNull(items, "Cannot add null items to inventory");

Expand Down Expand Up @@ -1252,7 +1252,7 @@ public static List<ItemStack> addItems(@Nonnull Inventory inventory, boolean spl
return leftOvers;
}

public static int firstPartial(@Nonnull Inventory inventory, @Nullable ItemStack item, int beginIndex) {
public static int firstPartial(@NotNull Inventory inventory, @Nullable ItemStack item, int beginIndex) {
return firstPartial(inventory, item, beginIndex, null);
}

Expand All @@ -1269,7 +1269,7 @@ public static int firstPartial(@Nonnull Inventory inventory, @Nullable ItemStack
* @throws IndexOutOfBoundsException if the beginning index is less than 0 or greater than the inventory storage size.
* @since 4.0.0
*/
public static int firstPartial(@Nonnull Inventory inventory, @Nullable ItemStack item, int beginIndex, @Nullable Predicate<Integer> modifiableSlots) {
public static int firstPartial(@NotNull Inventory inventory, @Nullable ItemStack item, int beginIndex, @Nullable Predicate<Integer> modifiableSlots) {
if (item != null) {
ItemStack[] items = inventory.getStorageContents();
int invSize = items.length;
Expand All @@ -1286,7 +1286,7 @@ public static int firstPartial(@Nonnull Inventory inventory, @Nullable ItemStack
return -1;
}

public static List<ItemStack> stack(@Nonnull Collection<ItemStack> items) {
public static List<ItemStack> stack(@NotNull Collection<ItemStack> items) {
return stack(items, ItemStack::isSimilar);
}

Expand All @@ -1303,8 +1303,8 @@ public static List<ItemStack> stack(@Nonnull Collection<ItemStack> items) {
* @return stacked up items.
* @since 4.0.0
*/
@Nonnull
public static List<ItemStack> stack(@Nonnull Collection<ItemStack> items, @Nonnull BiPredicate<ItemStack, ItemStack> similarity) {
@NotNull
public static List<ItemStack> stack(@NotNull Collection<ItemStack> items, @NotNull BiPredicate<ItemStack, ItemStack> similarity) {
Objects.requireNonNull(items, "Cannot stack null items");
Objects.requireNonNull(similarity, "Similarity check cannot be null");
List<ItemStack> stacked = new ArrayList<>(items.size());
Expand All @@ -1326,7 +1326,7 @@ public static List<ItemStack> stack(@Nonnull Collection<ItemStack> items, @Nonnu
return stacked;
}

public static int firstEmpty(@Nonnull Inventory inventory, int beginIndex) {
public static int firstEmpty(@NotNull Inventory inventory, int beginIndex) {
return firstEmpty(inventory, beginIndex, null);
}

Expand All @@ -1342,7 +1342,7 @@ public static int firstEmpty(@Nonnull Inventory inventory, int beginIndex) {
* @throws IndexOutOfBoundsException if the beginning index is less than 0 or greater than the inventory storage size.
* @since 4.0.0
*/
public static int firstEmpty(@Nonnull Inventory inventory, int beginIndex, @Nullable Predicate<Integer> modifiableSlots) {
public static int firstEmpty(@NotNull Inventory inventory, int beginIndex, @Nullable Predicate<Integer> modifiableSlots) {
ItemStack[] items = inventory.getStorageContents();
int invSize = items.length;
if (beginIndex < 0 || beginIndex >= invSize)
Expand All @@ -1366,7 +1366,7 @@ public static int firstEmpty(@Nonnull Inventory inventory, int beginIndex, @Null
* @see #firstPartial(Inventory, ItemStack, int)
* @since 4.2.0
*/
public static int firstPartialOrEmpty(@Nonnull Inventory inventory, @Nullable ItemStack item, int beginIndex) {
public static int firstPartialOrEmpty(@NotNull Inventory inventory, @Nullable ItemStack item, int beginIndex) {
if (item != null) {
ItemStack[] items = inventory.getStorageContents();
int len = items.length;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import javax.annotation.Nullable;
import java.lang.reflect.Field;
import java.util.*;
import java.util.regex.Pattern;
Expand Down
Loading

0 comments on commit 87b640a

Please sign in to comment.