警告
请勿将此插件与 StarCore 一起使用。两者互斥,且 StarCore 已包含 StarMCLib
此插件旨在避免依赖 StarCore 及其提供的重型组件。
要求
Java 21
功能
- Actors(角色):这是一种允许以更通用的方式引用玩家、控制台和插件等实体的功能。可根据需要对其进行扩展。
Actors 类是使用此功能的入口点
- CmdFlags(命令标志):提供了一种解析以“-”字符标记的标志的简便方法。支持存在型标志(即布尔值),也支持更复杂的类型,其后需跟有有效参数。详见下方“功能”部分以获取更多信息
- Mojang Profiles(Mojang 档案):提供从 Mojang API 获取玩家档案信息的方法,包括皮肤信息
- Enum Names(枚举名称):这些类将
EntityType、Material 和 PotionEffectType 等枚举的名称格式化为更易于人类阅读的形式。可以创建子类以添加自定义名称以保持一致性。默认实例不允许更改这些名称
- Plugin(插件):提供多项功能。包括一个与 StarLib 中更多实用工具接口的
ExtendedJavaPlugin,以及一个执行类似操作的 PluginEventBus 类型
- Cuboid(立方体):一个简单的类,用于定义立方体形状
- Position(位置):一个不与世界关联的位置对象。提供与
Location 相互转换的方法
- StarColorsV2:这是一个使用 Adventure Text API 的类
- StarThread:这是一个继承自
BukkitRunnable 的线程类,提供计时、性能跟踪和指标功能
CmdFlags
这些标志最好与命令配合使用。你可以通过创建新的标志类型实例(ComplexFlag 或 PresenceFlag)来定义每个标志,也可以创建实现 Flag 接口或扩展 AbstractFlag 类的自定义类。然后,通过传入你定义的标志来实例化 CmdFlags 类。当命令运行时,调用 CmdFlags#parse(String[]) 方法并传入命令的参数。该方法返回一个 FlagResult,其中包含移除了标志后的修改版参数数组,以及一个将 FlagValue 映射到其对应 Flag 的 Map。建议重新赋值 args 变量。FlagResult 允许你使用 addFrom(FlagResult) 方法链接结果,并提供两个辅助方法直接处理标志:isPresent 方法用于返回标志是否存在;getValue 方法用于返回标志的值
命令
基础命令为 /starmclib,基础权限节点为:
starmclib.command
/starmclib actors <args>
- 权限:starmclib.command.actors
/starmclib actors list [page]
- 权限:starmclib.command.actors.list
- 描述:列出所有已创建的演员(Actors)。这仅适用于调用了
Actors 中任一静态创建方法的情况,因此并非所有在线玩家或插件都会拥有 Actor 实例
/starmclib actors sendmessage <message>
- 权限:starmclib.command.actors.sendmessage
- 别名:sendmsg 和 sm
- 描述:允许你向任意选择的演员发送消息。此命令支持颜色代码
- ⚠️ 警告:仅将此权限授予你信任的人。这是一个强大的命令,因为如果你了解格式控制,几乎可以伪造任何消息。它主要用作调试命令以测试消息格式。你可能将其用作恶作剧功能,但请谨慎使用
/starmclib profiles <args>
- 权限:starmclib.command.profiles
/starmclib profiles list [page]
- 权限:starmclib.command.profiles.list
- 描述:列出自服务器启动以来从 MojangAPI 获取的所有档案
提供的库
本插件免费提供,并在 MIT 开源许可证下发布。我绝不会在任何地方出售此库。如果你发现有人在售卖,那并非由我所为,请直接向我报告此类情况。
Warning
Do not use this plugin with StarCore. They are mutually exclusive and StarCore already provides StarMCLib
This is a plugin meant solely for preventing to have to depend on StarCore and the heavier things that it provides.
Requirements
Java 21
Features
- Actors: This is a feature that allows for more of a generic way of referencing things like players, console and plugins. They can be expanded upon if desired. The Actors class is the entry-point to using this
- CmdFlags: This allows for an easy way to parse flags that are denoted with a "-" character. This supports both presence flags, where they are effectively booleans. Or a more complex type that can have a valid proved after it. See below the Features Section for more information
- Mojang Profiles: This provides a way to get player profile information from the Mojang API including skin information
- Enum Names: These are classes that format names of enums like EntityType, Material and PotionEffectType to be more human friendly. Child classes can be created to add custom names for consistency. The default instance does not allow changing these
- Plugin: This provides several things. An ExtendedJavaPlugin that interfaces with more of the utilities from StarLib and a PluginEventBus type that does similar things.
- Cuboid: A simple class that defines a cuboid shape.
- Position: A position that is not linked to a world. Provides methods to convert to and from Locations
- StarColorsV2: This is a class that uses the Adventure Text API
- StarThread: This is a thread class that extends from BukkitRunnable and provides timing and performance tracking and metrics
CmdFlags
These are best used in conjunction with commands. You define each flag by creating new instances of the Flag Types (ComplexFlag or PresenceFlag) or you can create your own class that either implements the Flag interface, or extends the AbstractFlag class. Then you instantiate the CmdFlags class providing the flags that you defined. Then when a command is run, you call the CmdFlags#parse(String[]) method passing in the arguments from the command. This returns a FlagResult which consists of the modified args that remove the flags and a Map of FlagValues to their Flag. It is recommended that you reassign the args variable. The FlagResult allows you to chain results together using the addFrom(FlagResult) method and has two helper methods to deal with the flags directly. An isPresent method to return if the flag is present. And a getValue method that returns the value of the flag
Command
The base command is /starmclib with the base permission node:
starmclib.command
/starmclib actors <args>
- Permission: starmclib.command.actors
/starmclib actors list [page]
- Permission: starmclib.command.actors.list
- Description: Lists all actors that have been created. This is only applies when any of the static creation methods in Actors is called for one. so not all online players or plugins will have an instance of an Actor
/starmclib actors sendmessage <message>
- Permission: starmclib.command.actors.sendmessage
- Aliases: sendmsg and sm
- Description: Allows you to send a message to an actor of your choosing. This does support colors.
- ⚠️ Warning: Only give those that you trust this permission. This is a powerful command as you can pretty much fake any message if you know the formatting. This is mainly used as a debug command to test message formatting. You could probably use it as a troll feature, but be careful with it
/starmclib profiles <args>
- Permission: starmclib.command.profiles
/starmclib profiles list [page]
- Permission: starmclib.command.profiles.list
- Description: Lists all profiles that have been fetched from the MojangAPI since the server started.
Provided Libraries
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.
评论 0
登录后参与评分
还没有评论,来抢沙发吧