ContentAPI is a Paper plugin for fixing custom item conflicts.
- Add the ContentAPI JitPack dependency:
repositories {
maven { url "https://jitpack.io" }
}
dependencies {
compileOnly "com.github.c-128:contentapi:latest_commit"
}
- Add the plugin as a dependency in your
paper-plugin.yaml
:
dependencies:
server:
ContentAPI:
load: 'BEFORE'
required: true
join-classpath: true
RegisteredServiceProvider<ContentAPI> serviceProvider = servicesManager.getRegistration(ContentAPI.class);
if (serviceProvider == null) {
// ContentAPI is not loaded
return;
}
ContentAPI api = serviceProvider.getProvider();
ContentRegistry<ItemStack> itemRegistry = api.getItemRegistry();
// Register a custom item
itemRegistry.register(Key.key("example", "example_item"), item -> {
// Here you can check if the ItemStack is your custom item.
// Here you can for example check for a NBT tag or similar metadata.
ItemMeta meta = item.getItemMeta();
if (meta == null) {
return false;
}
if (meta.getCustomModelData() != 1) {
return false;
}
return true;
});
// You can also check if an ItemStack is a custom item, registered by another plugin.
// If so, you can deal with it accordingly.
ItemStack stack = new ItemStack(Material.AIR);
boolean isCustom = itemRegistry.isCustomContent(stack);
This plugin integrates with Oraxen by default. I plan on adding more plugins later.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.