StarItems is a plugin that is meant as a developer utility for the time being. This is not like other items plugins where you can configure items via a command or a file. I am working on this functionality as I work with items in my other projects.
As of StarItems v0.3.0 it is now a standalone plugin and should not be used with StarCore as now StarCore v0.13.0 provides StarItems. If you are a developer and use StarCore and update it, you do not need this plugin.
This allows for much greater flexibility for developers so that they don't have to depend on StarCore in addition to StarItems.
There are a total of three artifacts
-
Dependency Artifact: This is the base artifact and is what is used for the published maven dependency. Use this to develop against
-
Plugin Artifact: This artifact is a plugin, however it does not have all of the required dependencies and is to be used with the other library plugins like StarMCLib (Not yet published to Spigot). This only contains the StarItems code and the StarDevLLC ItemBuilder library
-
Standalone Artifact: This artifact is what you download here on SpigotMC and is a completely standalone version that has all the dependencies that it requires bundled into the plugin
Required Dependencies
Java 21
NBT API 2.15.3
Version Information
This plugin is a work in progress and very unstable. I am constantly adding, changing and removing things within this plugin. This is based on need in my other projects, of which are also works in progress and constantly changing and evolving. I expect things to stabilize as time goes on.
Basic Information
StarItems is a plugin to provide the backbone of having custom items. It uses NBT to detect if an item is a custom item or a regular item.
This is not a plugin for server owners, but for developers. Over time, it will provide some default functionality for server owners.
Installation - Server Owners
Download the plugin and place it in your plugins folder and
restart the server to apply everything.
Installation - Plugin Developers
I strongly encourage the use of a build tool like Gradle or Maven. You can find the details needed to fill in what you need in your build tool.
Repository:
https://www.jitpack.io
Group: com.github.StarDevelopmentLLC
Artifact: StarItems
Version: 0.3.0
This should be compileOnly for Gradle and provided scope for Maven, its a plugin.
Command - /staritems
This is the main admin command for StarItems. Currently it does very little, but more will be added as more features are added.
Permission: staritems.admin
/staritems list
This command lists all items currently registered to StarItems, and which plugin that owns those items.
Permission: staritems.admin.list
/staritems give <name> [amount]
This command allows you to give yourself a custom item. The <name> is what is listed in the list command and [amount] is an optional argument that defaults to 1
Permission: staritems.admin.give
Usage - Plugin Develoeprs
The ItemBuilder class is used to build the items and provide item configuration.
Code (Java):
ItemBuilder itemBuilder
= ItemBuilder.
of
(XMaterial.
DIAMOND
)
;
Then we want to create a custom item instance, passing in a plugin, the name, and the itembuilder
The name of the item is the "id" of it, the plugin will automatically reformat the name to work
Code (Java):
CustomItem customItem
=
new CustomItem
(plugin,
"custom_diamond", itemBuilder
)
;
Then we want to obtain the ItemRegistry and register the custom item to it.
Note: Only register each custom item once. It is best to store this in a static field of some kind, or use the registry to obtain the item.
Code (Java):
ItemRegistry itemRegistry
= StarItems.
getItemRegistry
(
)
;
itemRegistry.
register
(customItem
)
;
We can add a custom item to a player's inventory by using the toItemStack method
Code (Java):
player.
getInventory
(
).
addItem
(customItem.
toItemStack
(
)
)
;
Do not add items using the ItemBuilder instance. The toItemStack method adds the name as an NBT String to the item stack. If this does not exist, then the library will not detect it with the consumers.
StarItems provides the ability to attach consumers to items based on certain actions. Take a look at the
CustomItems class at the consumer fields.
StarItems handles these automatically and will pass the event/player to the consumer.
The event based ones will be called only if the item matches, when the event occurs
The non-event ones are checked every second, It is recommended to keep things like potion effects at a lower value, I found in testing putting them at 2 seconds (40 ticks) works fine.
Night vision is a bit weird due to the flashing effect, you will need to set this higher.
This plugin is provided free of charge and under the MIT Open Source License. I will never sell this library anywhere. If you see it being sold, it is not by me and please report any of these cases to me directly. This library is only published as a GitHub Release and on SpigotMC, other sources are to be considered use at your own risk.