add missing nullability annotations to data providers

This commit is contained in:
Julian Krings 2024-12-14 16:42:01 +01:00
parent d7a991b9b3
commit 8c7c9f89e1
No known key found for this signature in database
GPG Key ID: 208C6E08C3B718D2
8 changed files with 60 additions and 34 deletions

View File

@ -9,6 +9,7 @@ import com.willfp.ecoitems.items.EcoItems;
import org.bukkit.NamespacedKey;
import org.bukkit.block.data.BlockData;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import java.util.MissingResourceException;
@ -33,23 +34,27 @@ public class EcoItemsDataProvider extends ExternalDataProvider {
}
}
@NotNull
@Override
public BlockData getBlockData(Identifier blockId, KMap<String, String> state) throws MissingResourceException {
public BlockData getBlockData(@NotNull Identifier blockId, @NotNull KMap<String, String> state) throws MissingResourceException {
throw new MissingResourceException("Failed to find BlockData!", blockId.namespace(), blockId.key());
}
@NotNull
@Override
public ItemStack getItemStack(Identifier itemId, KMap<String, Object> customNbt) throws MissingResourceException {
public ItemStack getItemStack(@NotNull Identifier itemId, @NotNull KMap<String, Object> customNbt) throws MissingResourceException {
EcoItem item = EcoItems.INSTANCE.getByID(itemId.key());
if (item == null) throw new MissingResourceException("Failed to find Item!", itemId.namespace(), itemId.key());
return itemStack.get(item).clone();
}
@NotNull
@Override
public Identifier[] getBlockTypes() {
return new Identifier[0];
}
@NotNull
@Override
public Identifier[] getItemTypes() {
KList<Identifier> names = new KList<>();
@ -66,7 +71,7 @@ public class EcoItemsDataProvider extends ExternalDataProvider {
}
@Override
public boolean isValidProvider(Identifier id, boolean isItem) {
public boolean isValidProvider(@NotNull Identifier id, boolean isItem) {
return id.namespace().equalsIgnoreCase("ecoitems") && isItem;
}
}

View File

@ -6,6 +6,7 @@ import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap;
import org.bukkit.block.data.BlockData;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import java.util.MissingResourceException;
import java.util.Optional;
@ -20,23 +21,27 @@ public class ExecutableItemsDataProvider extends ExternalDataProvider {
Iris.info("Setting up ExecutableItems Link...");
}
@NotNull
@Override
public BlockData getBlockData(Identifier blockId, KMap<String, String> state) throws MissingResourceException {
public BlockData getBlockData(@NotNull Identifier blockId, @NotNull KMap<String, String> state) throws MissingResourceException {
throw new MissingResourceException("Failed to find BlockData!", blockId.namespace(), blockId.key());
}
@NotNull
@Override
public ItemStack getItemStack(Identifier itemId, KMap<String, Object> customNbt) throws MissingResourceException {
public ItemStack getItemStack(@NotNull Identifier itemId, @NotNull KMap<String, Object> customNbt) throws MissingResourceException {
return ExecutableItemsAPI.getExecutableItemsManager().getExecutableItem(itemId.key())
.map(item -> item.buildItem(1, Optional.empty()))
.orElseThrow(() -> new MissingResourceException("Failed to find ItemData!", itemId.namespace(), itemId.key()));
}
@NotNull
@Override
public Identifier[] getBlockTypes() {
return new Identifier[0];
}
@NotNull
@Override
public Identifier[] getItemTypes() {
KList<Identifier> names = new KList<>();
@ -53,7 +58,7 @@ public class ExecutableItemsDataProvider extends ExternalDataProvider {
}
@Override
public boolean isValidProvider(Identifier key, boolean isItem) {
public boolean isValidProvider(@NotNull Identifier key, boolean isItem) {
return key.namespace().equalsIgnoreCase("executable_items") && isItem;
}
}

View File

@ -16,6 +16,7 @@ import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.type.Leaves;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import java.util.Map;
import java.util.MissingResourceException;
@ -51,8 +52,9 @@ public class HMCLeavesDataProvider extends ExternalDataProvider {
}
}
@NotNull
@Override
public BlockData getBlockData(Identifier blockId, KMap<String, String> state) throws MissingResourceException {
public BlockData getBlockData(@NotNull Identifier blockId, @NotNull KMap<String, String> state) throws MissingResourceException {
Object o = blockDataMap.get(blockId.key());
if (o == null)
throw new MissingResourceException("Failed to find BlockData!", blockId.namespace(), blockId.key());
@ -65,15 +67,16 @@ public class HMCLeavesDataProvider extends ExternalDataProvider {
return new IrisBlockData(blockData, ExternalDataSVC.buildState(blockId, state));
}
@NotNull
@Override
public ItemStack getItemStack(Identifier itemId, KMap<String, Object> customNbt) throws MissingResourceException {
public ItemStack getItemStack(@NotNull Identifier itemId, @NotNull KMap<String, Object> customNbt) throws MissingResourceException {
if (!itemDataField.containsKey(itemId.key()))
throw new MissingResourceException("Failed to find ItemData!", itemId.namespace(), itemId.key());
return itemDataField.get(itemId.key()).get();
}
@Override
public void processUpdate(Engine engine, Block block, Identifier blockId) {
public void processUpdate(@NotNull Engine engine, @NotNull Block block, @NotNull Identifier blockId) {
var pair = ExternalDataSVC.parseState(blockId);
blockId = pair.getA();
Boolean result = setCustomBlock.invoke(apiInstance, new Object[]{block.getLocation(), blockId.key(), false});
@ -86,6 +89,7 @@ public class HMCLeavesDataProvider extends ExternalDataProvider {
}
}
@NotNull
@Override
public Identifier[] getBlockTypes() {
KList<Identifier> names = new KList<>();
@ -101,6 +105,7 @@ public class HMCLeavesDataProvider extends ExternalDataProvider {
return names.toArray(new Identifier[0]);
}
@NotNull
@Override
public Identifier[] getItemTypes() {
KList<Identifier> names = new KList<>();
@ -117,7 +122,7 @@ public class HMCLeavesDataProvider extends ExternalDataProvider {
}
@Override
public boolean isValidProvider(Identifier id, boolean isItem) {
public boolean isValidProvider(@NotNull Identifier id, boolean isItem) {
return (isItem ? itemDataField.keySet() : blockDataMap.keySet()).contains(id.key());
}

View File

@ -7,6 +7,7 @@ import dev.lone.itemsadder.api.CustomBlock;
import dev.lone.itemsadder.api.CustomStack;
import org.bukkit.block.data.BlockData;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import java.util.MissingResourceException;
@ -32,13 +33,15 @@ public class ItemAdderDataProvider extends ExternalDataProvider {
}
}
@NotNull
@Override
public BlockData getBlockData(Identifier blockId, KMap<String, String> state) throws MissingResourceException {
public BlockData getBlockData(@NotNull Identifier blockId, @NotNull KMap<String, String> state) throws MissingResourceException {
return CustomBlock.getBaseBlockData(blockId.toString());
}
@NotNull
@Override
public ItemStack getItemStack(Identifier itemId, KMap<String, Object> customNbt) throws MissingResourceException {
public ItemStack getItemStack(@NotNull Identifier itemId, @NotNull KMap<String, Object> customNbt) throws MissingResourceException {
CustomStack stack = CustomStack.getInstance(itemId.toString());
if (stack == null) {
throw new MissingResourceException("Failed to find ItemData!", itemId.namespace(), itemId.key());
@ -46,6 +49,7 @@ public class ItemAdderDataProvider extends ExternalDataProvider {
return stack.getItemStack();
}
@NotNull
@Override
public Identifier[] getBlockTypes() {
KList<Identifier> keys = new KList<>();
@ -55,6 +59,7 @@ public class ItemAdderDataProvider extends ExternalDataProvider {
return keys.toArray(new Identifier[0]);
}
@NotNull
@Override
public Identifier[] getItemTypes() {
KList<Identifier> keys = new KList<>();
@ -65,7 +70,7 @@ public class ItemAdderDataProvider extends ExternalDataProvider {
}
@Override
public boolean isValidProvider(Identifier id, boolean isItem) {
public boolean isValidProvider(@NotNull Identifier id, boolean isItem) {
return isItem ? this.itemNamespaces.contains(id.namespace()) : this.blockNamespaces.contains(id.namespace());
}
}

View File

@ -11,6 +11,7 @@ import net.Indyuce.mmoitems.api.block.CustomBlock;
import org.bukkit.Bukkit;
import org.bukkit.block.data.BlockData;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import java.util.MissingResourceException;
import java.util.concurrent.CompletableFuture;
@ -27,8 +28,9 @@ public class MMOItemsDataProvider extends ExternalDataProvider {
Iris.info("Setting up MMOItems Link...");
}
@NotNull
@Override
public BlockData getBlockData(Identifier blockId, KMap<String, String> state) throws MissingResourceException {
public BlockData getBlockData(@NotNull Identifier blockId, @NotNull KMap<String, String> state) throws MissingResourceException {
int id = -1;
try {
id = Integer.parseInt(blockId.key());
@ -38,8 +40,9 @@ public class MMOItemsDataProvider extends ExternalDataProvider {
return block.getState().getBlockData();
}
@NotNull
@Override
public ItemStack getItemStack(Identifier itemId, KMap<String, Object> customNbt) throws MissingResourceException {
public ItemStack getItemStack(@NotNull Identifier itemId, @NotNull KMap<String, Object> customNbt) throws MissingResourceException {
String[] parts = itemId.namespace().split("_", 2);
if (parts.length != 2)
throw new MissingResourceException("Failed to find ItemData!", itemId.namespace(), itemId.key());
@ -82,6 +85,7 @@ public class MMOItemsDataProvider extends ExternalDataProvider {
return item;
}
@NotNull
@Override
public Identifier[] getBlockTypes() {
KList<Identifier> names = new KList<>();
@ -96,6 +100,7 @@ public class MMOItemsDataProvider extends ExternalDataProvider {
return names.toArray(new Identifier[0]);
}
@NotNull
@Override
public Identifier[] getItemTypes() {
KList<Identifier> names = new KList<>();
@ -124,7 +129,7 @@ public class MMOItemsDataProvider extends ExternalDataProvider {
}
@Override
public boolean isValidProvider(Identifier id, boolean isItem) {
public boolean isValidProvider(@NotNull Identifier id, boolean isItem) {
return isItem ? id.namespace().split("_", 2).length == 2 : id.namespace().equals("mmoitems");
}

View File

@ -40,6 +40,7 @@ import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.BlockData;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import java.util.MissingResourceException;
import java.util.Optional;
@ -62,8 +63,9 @@ public class MythicCrucibleDataProvider extends ExternalDataProvider {
}
}
@NotNull
@Override
public BlockData getBlockData(Identifier blockId, KMap<String, String> state) throws MissingResourceException {
public BlockData getBlockData(@NotNull Identifier blockId, @NotNull KMap<String, String> state) throws MissingResourceException {
CrucibleItem crucibleItem = this.itemManager.getItem(blockId.key())
.orElseThrow(() -> new MissingResourceException("Failed to find BlockData!", blockId.namespace(), blockId.key()));
CustomBlockItemContext blockItemContext = crucibleItem.getBlockData();
@ -76,8 +78,9 @@ public class MythicCrucibleDataProvider extends ExternalDataProvider {
throw new MissingResourceException("Failed to find BlockData!", blockId.namespace(), blockId.key());
}
@NotNull
@Override
public ItemStack getItemStack(Identifier itemId, KMap<String, Object> customNbt) throws MissingResourceException {
public ItemStack getItemStack(@NotNull Identifier itemId, @NotNull KMap<String, Object> customNbt) throws MissingResourceException {
Optional<CrucibleItem> opt = this.itemManager.getItem(itemId.key());
return BukkitAdapter.adapt(opt.orElseThrow(() ->
new MissingResourceException("Failed to find ItemData!", itemId.namespace(), itemId.key()))
@ -85,6 +88,7 @@ public class MythicCrucibleDataProvider extends ExternalDataProvider {
.generateItemStack(1));
}
@NotNull
@Override
public Identifier[] getBlockTypes() {
KList<Identifier> names = new KList<>();
@ -101,6 +105,7 @@ public class MythicCrucibleDataProvider extends ExternalDataProvider {
return names.toArray(new Identifier[0]);
}
@NotNull
@Override
public Identifier[] getItemTypes() {
KList<Identifier> names = new KList<>();
@ -117,7 +122,7 @@ public class MythicCrucibleDataProvider extends ExternalDataProvider {
}
@Override
public void processUpdate(Engine engine, Block block, Identifier blockId) {
public void processUpdate(@NotNull Engine engine, @NotNull Block block, @NotNull Identifier blockId) {
var pair = ExternalDataSVC.parseState(blockId);
var state = pair.getB();
blockId = pair.getA();
@ -160,7 +165,7 @@ public class MythicCrucibleDataProvider extends ExternalDataProvider {
}
@Override
public boolean isValidProvider(Identifier key, boolean isItem) {
public boolean isValidProvider(@NotNull Identifier key, boolean isItem) {
return key.namespace().equalsIgnoreCase("crucible");
}
}

View File

@ -4,10 +4,8 @@ import com.nexomc.nexo.api.NexoBlocks;
import com.nexomc.nexo.api.NexoFurniture;
import com.nexomc.nexo.api.NexoItems;
import com.nexomc.nexo.items.ItemBuilder;
import com.volmit.iris.Iris;
import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.core.nms.container.BiomeColor;
import com.volmit.iris.core.nms.container.Pair;
import com.volmit.iris.core.service.ExternalDataSVC;
import com.volmit.iris.engine.data.cache.Cache;
import com.volmit.iris.engine.framework.Engine;
@ -15,24 +13,18 @@ import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.data.B;
import com.volmit.iris.util.data.IrisBlockData;
import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.reflect.WrappedReturningMethod;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.ItemDisplay;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.PotionMeta;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nullable;
import java.lang.reflect.Proxy;
import java.util.Arrays;
import java.util.MissingResourceException;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Function;
import java.util.stream.Collector;
import java.util.stream.Collectors;
public class NexoDataProvider extends ExternalDataProvider {
private final AtomicBoolean failed = new AtomicBoolean(false);
@ -45,8 +37,9 @@ public class NexoDataProvider extends ExternalDataProvider {
public void init() {
}
@NotNull
@Override
public BlockData getBlockData(Identifier blockId, KMap<String, String> state) throws MissingResourceException {
public BlockData getBlockData(@NotNull Identifier blockId, @NotNull KMap<String, String> state) throws MissingResourceException {
if (!NexoItems.exists(blockId.key())) {
throw new MissingResourceException("Failed to find BlockData!", blockId.namespace(), blockId.key());
}
@ -64,8 +57,9 @@ public class NexoDataProvider extends ExternalDataProvider {
throw new MissingResourceException("Failed to find BlockData!", blockId.namespace(), blockId.key());
}
@NotNull
@Override
public ItemStack getItemStack(Identifier itemId, KMap<String, Object> customNbt) throws MissingResourceException {
public ItemStack getItemStack(@NotNull Identifier itemId, @NotNull KMap<String, Object> customNbt) throws MissingResourceException {
ItemBuilder builder = NexoItems.itemFromId(itemId.key());
if (builder == null) {
throw new MissingResourceException("Failed to find ItemData!", itemId.namespace(), itemId.key());
@ -74,7 +68,7 @@ public class NexoDataProvider extends ExternalDataProvider {
}
@Override
public void processUpdate(Engine engine, Block block, Identifier blockId) {
public void processUpdate(@NotNull Engine engine, @NotNull Block block, @NotNull Identifier blockId) {
var pair = ExternalDataSVC.parseState(blockId);
var state = pair.getB();
blockId = pair.getA();
@ -128,6 +122,7 @@ public class NexoDataProvider extends ExternalDataProvider {
display.setItemStack(itemStack);
}
@NotNull
@Override
public Identifier[] getBlockTypes() {
return Arrays.stream(NexoItems.itemNames())
@ -142,6 +137,7 @@ public class NexoDataProvider extends ExternalDataProvider {
.toArray(Identifier[]::new);
}
@NotNull
@Override
public Identifier[] getItemTypes() {
return Arrays.stream(NexoItems.itemNames())
@ -157,7 +153,7 @@ public class NexoDataProvider extends ExternalDataProvider {
}
@Override
public boolean isValidProvider(Identifier id, boolean isItem) {
public boolean isValidProvider(@NotNull Identifier id, boolean isItem) {
return "nexo".equalsIgnoreCase(id.namespace());
}

View File

@ -37,7 +37,7 @@ public class UtilsSFG {
}
if (ServerBootSFG.unsuportedversion) {
Iris.safeguard(C.RED + "Server Version");
Iris.safeguard(C.RED + "- Iris only supports 1.19.2 > 1.21.1");
Iris.safeguard(C.RED + "- Iris only supports 1.19.2 > 1.21.3");
}
if (!ServerBootSFG.passedserversoftware) {
Iris.safeguard(C.YELLOW + "Unsupported Server Software");