⚠️ StarItems 目前是一个作为开发者工具使用的插件。它不像其他物品插件那样允许你通过命令或文件来配置物品。我正在随着我在其他项目中处理物品的经验,逐步完善这一功能。
自 StarItems v0.3.0 起,它已成为一个独立插件,不应再与 StarCore 一起使用,因为现在 StarCore v0.13.0 已内置了 StarItems。如果你是一名开发者并使用 StarCore,在更新后你就不需要这个插件了。
这使得开发者拥有更大的灵活性,无需同时依赖 StarCore 和 StarItems。
总共有三种构建产物(Artifacts):
- 依赖包 Artifact:这是基础产物,也是用于发布 Maven 依赖的版本。请使用此版本进行开发对接。
- 插件包 Artifact:这是一个插件产物,但它不包含所有必需的依赖项,需与其他库插件(如 StarMCLib)配合使用。此版本仅包含 StarItems 代码和 StarDevLLC ItemBuilder 库。
- 独立包 Artifact:这就是你在 SpigotMC 上下载的产物,是一个完全独立的版本,将所有必需的依赖项打包进了插件中。
必需依赖
Java 21
NBT-API 2.15.3
不兼容项(适用于从 Modrinth 下载的版本)
- StarMCLib
- StarCore
- StarEvents
版本信息
本插件仍在开发中且非常不稳定。我正在不断地向本插件中添加、更改和移除内容。这些改动基于我在其他项目中的需求,而那些项目也处于持续开发和演变的过程中。随着时间的推移,情况预计会逐渐稳定下来。
基本信息
StarItems 是一个提供自定义物品底层支持的插件。它使用 NBT 标签来检测物品是自定义物品还是普通物品。
这不是面向服务器管理员的插件,而是面向开发者的。随着时间的推移,它将提供一些面向服务器管理员的默认功能。
安装 - 服务器管理员
下载插件并将其放入你的 plugins 文件夹,然后重启服务器以应用所有更改。
安装 - 插件开发者
强烈建议使用 Gradle 或 Maven 等构建工具。你可以在构建工具中找到填写所需配置的详细信息。
- 仓库地址:
- Group ID: com.github.StarDevelopmentLLC
- Artifact ID: StarItems
- Version: 0.5.0
对于 Gradle,应设置为 compileOnly;对于 Maven,应设置为 provided 作用域,因为它是一个插件。
命令 - /staritems
这是 StarItems 的主要管理命令。目前它的功能很少,但随着功能的增加,会有更多命令加入。
权限:staritems.admin
/staritems list
此命令列出当前注册到 StarItems 的所有物品,以及拥有这些物品的插件。
权限:staritems.admin.list
/staritems give <name> [amount]
此命令允许你给自己发放一个自定义物品。<name> 是 list 命令中列出的名称,[amount] 是一个可选参数,默认为 1。
权限:staritems.admin.give
用法 - 插件开发者
ItemBuilder 类用于构建物品并提供物品配置。
ItemBuilder itemBuilder = ItemBuilder.of(XMaterial.DIAMOND);
接下来,我们要创建一个自定义物品实例,传入插件、名称和 itembuilder。
物品的名称即为其“ID”,插件会自动重新格式化名称以使其正常工作。
CustomItem customItem = new CustomItem(plugin, "custom_diamond", itemBuilder);
然后,我们需要获取 ItemRegistry 并将自定义物品注册到其中。
注意:每个自定义物品只注册一次。最好将其存储在某种静态字段中,或者使用注册表来获取该物品。
ItemRegistry itemRegistry = StarItems.getItemRegistry();
itemRegistry.register(customItem);
我们可以使用 toItemStack 方法将自定义物品添加到玩家的背包中。
player.getInventory().addItem(customItem.toItemStack());
不要使用 ItemBuilder 实例直接添加物品。toItemStack 方法会将名称作为 NBT 字符串添加到物品堆栈中。如果不存在该名称,库将无法通过消费者检测到它。
StarItems 提供了根据特定操作向物品附加消费者的能力。请查看 CustomItems 类中的消费者字段。
StarItems 会自动处理这些逻辑,并将事件/玩家传递给消费者。
基于事件的消费者仅在物品匹配且事件发生时调用。
非事件类的消费者每秒检查一次。建议将药水效果等内容的设置值调低,我发现测试中将它们设置为 2 秒(40 tick)是可以正常工作的。
由于夜视效果有闪烁现象,你需要将此值设置得更高一些。
本插件免费提供给用户,并在 MIT 开源许可证下发布。我绝不会在任何地方出售此库。如果你发现有人在售卖,那不是我本人所为,请直接向我报告此类情况。本库仅在 GitHub Release 和 SpigotMC 上发布,其他来源的使用风险自负。
⚠️ 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. 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
Incompatible (For Version Downloaded from Modrinth)
- StarMCLib
- StarCore
- StarEvents
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:
- Group: com.github.StarDevelopmentLLC
- Artifact: StarItems
- Version: 0.5.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 Developers
The ItemBuilder class is used to build the items and provide item configuration.
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
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.
ItemRegistry itemRegistry = StarItems.getItemRegistry();
itemRegistry.register(customItem);
We can add a custom item to a player's inventory by using the toItemStack method
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.
评论 0
登录后参与评分
还没有评论,来抢沙发吧