- Notifications
You must be signed in to change notification settings - Fork3
A library for Minecraft server plugin development.
License
UltiKits/UltiTools-Reborn
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
I hope my plugin can help with your plugin development! XD
UltiTools-API has changed the way plugin development is done. By introducing advanced syntax like annotations, it makes your plugin development much more efficient.
With UltiTools-API, you no longer need to manually register commands and listeners. Simply add annotations to your command classes and listener classes, and UltiTools-API will automatically register them for you.
You can also write your commands like a controller. You no longer need to make tedious judgments for a command. Just add annotations to your command methods, and UltiTools-API will automatically match the commands to the corresponding methods.
@CmdTarget(CmdTarget.CmdTargetType.PLAYER)@CmdExecutor(alias = {"lore"},manualRegister =true,permission ="ultikits.tools.command.lore",description ="Lore edit function")publicclassLoreCommandsextendsAbstractCommendExecutor {@CmdMapping(format ="add <lore...>")publicvoidaddLore(@CmdSenderPlayerplayer,@CmdParam("lore...")String[]lore) { ... }@CmdMapping(format ="delete <position>")publicvoiddeleteLore(@CmdSenderPlayerplayer,@CmdParam("position")intposition) { ... }@CmdMapping(format ="edit <position> <lore...>")publicvoideditLore(@CmdSenderPlayerplayer,@CmdParam("position")intposition,@CmdParam("lore...")String[]lore) { ... }@OverrideprotectedvoidhandleHelp(CommandSendersender) {sender.sendMessage(ChatColor.RED +"lore add <content>" +ChatColor.GRAY +" - " +BasicFunctions.getInstance().i18n("Add Lore"));sender.sendMessage(ChatColor.RED +"lore delete <lineNum>" +ChatColor.GRAY +" - " +BasicFunctions.getInstance().i18n("Delete Lore"));sender.sendMessage(ChatColor.RED +"lore edit <linNum> <content>" +ChatColor.GRAY +" - " +BasicFunctions.getInstance().i18n("Edit Lore")); }}
In terms of data storage, UltiTools provides wrapped APIs for both MySQL and JSON, allowing you not to worry about which data storage method the users will choose.
For example
@Data@Builder@NoArgsConstructor@AllArgsConstructor@EqualsAndHashCode(callSuper =true)@Table("economy_accounts")publicclassAccountEntityextendsAbstractDataEntity {@Column("name")privateStringname;@Column(value ="balance",type ="FLOAT")privatedoublebalance;@Column("owner")privateStringowner;}
// check if the player account existspublicbooleanplayerHasAccount(UUIDplayer,Stringname) {DataOperator<AccountEntity>dataOperator =UltiEconomy.getInstance().getDataOperator(AccountEntity.class);returndataOperator.exist(WhereCondition.builder().column("name").value(name).build(),WhereCondition.builder().column("owner").value(player.toString()).build() );}
Regarding configuration files, UltiTools allows you to read the configuration files as if you were manipulating objects.
For example
@Getter@Setter@ConfigEntity(path ="config/config.yml")publicclassEcoConfigextendsAbstractConfigEntity {@ConfigEntry(path ="useThirdPartEconomy",comment ="Whether to use another economy plugin as a base (i.e., only use the bank function of this plugin)")privatebooleanuseThirdPartEconomy =false;@ConfigEntry(path ="enableInterest",comment ="Whether to enable interest")privatebooleanenableInterest =true;@ConfigEntry(path ="interestRate",comment ="Interest rate, interest = interest rate × principal")privatedoubleinterestRate =0.0003;@ConfigEntry(path ="interestTime",comment ="Interval for interest distribution (minutes)")privateintinterestTime =30;@ConfigEntry(path ="initial_money",comment ="Initial amount of currency for players")privatedoubleinitMoney =1000;@ConfigEntry(path ="op_operate_money",comment ="Whether the server administrator can increase or decrease player currency")privatebooleanopOperateMoney =false;@ConfigEntry(path ="currency_name",comment ="Name of the currency")privateStringcurrencyName ="Gold Coin";@ConfigEntry(path ="server_trade_log",comment ="Whether to enable server trade log")privatebooleanenableTradeLog =false;publicEcoConfig(StringconfigFilePath) {super(configFilePath); }}
// Get the configuration file of the economy plugin and read the interest rateEcoConfigconfig =UltiEconomy.getInstance().getConfig(EcoConfig.class);doubleinterestRate =config.getInterestRate();
UltiTools-API provides a Spring IOC container, which can manage all the Beans in your plugin and automatically inject dependencies.
// @Service marks the type as a Bean, and UltiTools-API will automatically scan and register it@ServicepublicclassBanPlayerService { ...publicvoidunBanPlayer(OfflinePlayerplayer) {DataOperator<BanedUserData>dataOperator =BasicFunctions.getInstance().getDataOperator(BanedUserData.class);dataOperator.delById(player.getUniqueId().toString()); }}
@CmdTarget(CmdTarget.CmdTargetType.BOTH)@CmdExecutor(permission ="ultikits.ban.command.all",description ="Ban function",alias = {"uban"},manualRegister =true)publicclassBanCommandsextendsAbstractCommendExecutor {// Using the @Autowired annotation, UltiTools-API will automatically inject the dependency@AutowiredprivateBanPlayerServicebanPlayerService;@CmdMapping(format ="unban <player>")publicvoidunBanPlayer(@CmdSenderCommandSendersender,@CmdParam("player")Stringplayer) {banPlayerService.unBanPlayer(Bukkit.getOfflinePlayer(player));sender.sendMessage(BasicFunctions.getInstance().i18n("§aUnban successful")); } ...}
If you don't like automatic injection, or can't use automatic injection, you can also manually obtain the Bean.
BanPlayerServicebanPlayerService =getContext().getBean(BanPlayerService.class);
UltiTools-API offers some functionalities of Hutool, including a large number of utility classes.
Hutool Documentation
In terms of GUI interfaces, UltiTools provides the obliviate-invs API, facilitating rapid GUI development.
ObliviateInvs — Highly efficient modular GUI library
UltiTools also offers the Adventure API.
For more detailed documentation, please refer toUltiTools API Documentation
Below is a simple quick start guide.
First, add the UltiTools-API dependency to your project.
Using Maven
<dependency> <groupId>com.ultikits</groupId> <artifactId>UltiTools-API</artifactId> <version>{VERSION}</version></dependency>
Using Gradle
implementation'com.ultikits:UltiTools-API:{VERSION}'
Before starting, please create a plugin.yml file in the resources folder with the following content:
# Plugin namename:TestPlugin# Plugin versionversion:'${project.version}'# Plugin main classmain:com.test.plugin.MyPlugin# UltiTools-API version used by the plugin, for example, 6.0.0 is 600api-version:600# Plugin authorsauthors:[ wisdomme ]
Create a config folder, where you can put your plugin configuration files according to your needs. These configuration files will be placed unmodified in the collective configuration folder of the UltiTools plugin for display to users.
Create a main class extendingUltiToolsPlugin
. Similar to traditional Spigot plugins, UltiTools plugins also need to override the start and stop methods. However,UltiToolsPlugin
adds an optionalUltiToolsPlugin#reloadSelf()
method for use during plugin reload.
publicclassMyPluginextendsUltiToolsPlugin {@OverridepublicbooleanregisterSelf() {// Executes when the plugin startsreturntrue; }@OverridepublicvoidunregisterSelf() {// Executes when the plugin shuts down }@OverridepublicvoidreloadSelf() {// Executes when the plugin is reloaded }}
With this, you've completed an UltiTools plugin that does nothing. Then, you can register your listeners and commands in theUltiToolsPlugin#registerSelf()
method.
publicclassMyPluginextendsUltiToolsPlugin {@OverridepublicbooleanregisterSelf() {// Register a Test command, with permission 'permission.test', and command 'test'// No need to register the command in Plugin.ymlgetCommandManager().register(newTestCommands(),"permission.test","Sample Function","test");// Register listenersgetListenerManager().register(this,newTestListener());returntrue; }}
Then, you can add your configuration file in the main class, and UltiTools will automatically load the configuration file.
publicclassMyPluginextendsUltiToolsPlugin {@OverridepublicbooleanregisterSelf() {// Register a Test command, with permission 'permission.test', and command 'test'// No need to register the command in Plugin.ymlgetCommandManager().register(newTestCommands(),"permission.test","Sample Function","test");// Register listenersgetListenerManager().register(this,newTestListener());// Register configuration filegetConfigManager().register(this,newTestConfig("config/config.yml"));returntrue; }}
Alternatively, you can override theUltiToolsPlugin#getAllConfigs()
method to register all configuration files here.
@OverridepublicList<AbstractConfigEntity>getAllConfigs() {returnArrays.asList(newTestConfig("config/config.yml") );}
Contributor | Description |
---|---|
@wisdommen | Founder, UltiKits Author |
@qianmo2233 | UltiTools Developer, Main Maintainer of UltiKits Development Documentation |
@Shpries | UltiTools Developer |
@JueChenChen | Feedback on UltiKits Issues, Bugs & Suggestions |
拾柒 | Graphic Designer |
Click here to submit an Issue!
About
A library for Minecraft server plugin development.