
AnhyLibAPI
AnhyLibAPI is a library designed for integration into Minecraft plugins, developed to enhance their capabilities on servers running on Spigot, Paper, Purpur, and other Spigot forks
- Загрузки
- 855
- Подписчики
- 3
- Обновлён
- 2 августа 2024 г.
- Лицензия
- MIT
Опубликован 17 декабря 2023 г.
AnhyLibAPI: For Minecraft Plugins
AnhyLibAPI is a library designed for integration into Minecraft plugins, developed to enhance their capabilities on servers running on Spigot, Paper, Purpur, and other Spigot forks
ProtocolLib plugin version 5.0.0 or higher is required for operation.
AnhyLibAPI must be loaded on the server as a plugin. It's crucial to understand that AnhyLibAPI, in its role as a plugin, does not monitor any events, have timers, or interact with the world or players, ensuring no additional load on the server's operation and performance. The primary purpose of AnhyLibAPI is to provide its API to other plugins, serving as a robust foundation for extending their functionality. This design ensures that AnhyLibAPI enhances plugin capabilities without compromising server efficiency.
Key Features:
- Multilingual Support: Easy integration of language packs for plugins.
- NBT Tags Handling: Advanced management of NBT tags for flexible data interaction.
- Player Persistent Data: Efficient use of persistent data for players.
- Customizing Messages: Individual customization of message delivery to players.
- Logging: Unique methods for event logging.
Key Features of AnhyLibAPI
1. Multilingual Support
AnhyLibAPI implements a unified standard for multilingual support by checking "Player Persistent Data" for the player's selected language. If a selected language is not found, the player's Minecraft client language is used by default. Additionally, it supports the inclusion of a list of preferred languages, enhancing flexibility in localization.
2. NBT Tags Handling
AnhyLibAPI simplifies the addition, modification, and deletion of NBT tags in items, enabling developers to effortlessly manage key item data within the game.
3. Player Persistent Data
This feature allows for the storage, retrieval, and modification of players' personal data, such as settings, statuses, and achievements, providing deep personalization and preservation of individual player details.
4. Customizing Messages and Logging
These functionalities offer message customization and color-coded logging for various message types. They enhance communication between plugins and players and facilitate more effective tracking and analysis of events within plugins.
Documentation:
JavaDoc for AnhyLibAPI are available at the following link: AnhyLibAPI Documentation.
Integration with Gradle and Maven:
Gradle:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.AnhyDev:AnhyLibAPI:v1.4.0'
}
Maven:
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependency>
<groupId>com.github.AnhyDev</groupId>
<artifactId>AnhyLibAPI</artifactId>
<version>v1.4.0</version>
</dependency>
Plugin Writing Examples:
For a comprehensive, ready-to-use plugin example that implements AnhyLibAPI, visit the following link: AnhyLibAPI Plugin Examples. This example is more than just sample code; it is a fully functional plugin featuring multilingual support, configurable settings, and player commands. Developers can use this plugin as a foundation, renaming and repackaging as needed, while also adding their own code to extend its functionality. It serves as an excellent starting point for understanding and applying AnhyLibAPI in a practical, real-world plugin project.
See below for some examples from this code:
package ink.anh.example;
import java.io.File;
import java.io.IOException;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.Plugin;
import ink.anh.api.LibraryManager;
import ink.anh.api.lingo.Translator;
import ink.anh.api.lingo.lang.LanguageManager;
import ink.anh.api.messages.Logger;
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import net.md_5.bungee.api.ChatColor;
public class GlobalManager extends LibraryManager {
private static GlobalManager instance;
private ExampleLangPlugin plugin;
private LanguageManager langManager;
private String pluginName;
private String defaultLang;
private static BukkitAudiences bukkitAudiences;
private boolean debug;
private GlobalManager(ExampleLangPlugin plugin) {
super(plugin);
this.plugin = plugin;
this.saveDefaultConfig();
this.loadFields(plugin);
}
public static synchronized GlobalManager getManager(ExampleLangPlugin plugin) {
if (instance == null) {
instance = new GlobalManager(plugin);
}
return instance;
}
@Override
public Plugin getPlugin() {
return plugin;
}
@Override
public String getPluginName() {
return pluginName;
}
@Override
public BukkitAudiences getBukkitAudiences() {
return bukkitAudiences;
}
@Override
public LanguageManager getLanguageManager() {
return this.langManager;
}
@Override
public String getDefaultLang() {
return defaultLang;
}
@Override
public boolean isDebug() {
return debug;
}
private void loadFields(ExampleLangPlugin plugin) {
bukkitAudiences = BukkitAudiences.create(plugin);
defaultLang = plugin.getConfig().getString("language", "en");
pluginName = ChatColor.translateAlternateColorCodes('&',plugin.getConfig().getString("plugin_name", "ExampleLangPlugin"));
debug = plugin.getConfig().getBoolean("debug", false);
setLanguageManager();
}
private void saveDefaultConfig() {
File configFile = new File(plugin.getDataFolder(), "config.yml");
if (!configFile.exists()) {
YamlConfiguration defaultConfig = new YamlConfiguration();
defaultConfig.set("plugin_name", "ExampleLangPlugin");
defaultConfig.set("language", "en");
defaultConfig.set("debug", false);
try {
defaultConfig.save(configFile);
Logger.warn(plugin, "Default configuration created. ");
} catch (IOException e) {
e.printStackTrace();
}
}
}
private void setLanguageManager() {
if (this.langManager == null) {
this.langManager = LangMessage.getInstance(this);;
} else {
this.langManager.reloadLanguages();
}
}
public boolean reload() {
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
try {
saveDefaultConfig();
plugin.reloadConfig();
loadFields(plugin);
Logger.info(plugin, Translator.translateKyeWorld(instance, "configuration_reloaded" , new String[] {defaultLang}));
} catch (Exception e) {
e.printStackTrace();
Logger.error(plugin, Translator.translateKyeWorld(instance, "err_reloading_configuration ", new String[] {defaultLang}));
}
});
return true;
}
}
package ink.anh.example;
import ink.anh.api.lingo.lang.LanguageManager;
public class LangMessage extends LanguageManager {
private static LangMessage instance = null;
private static final Object LOCK = new Object();
private LangMessage(GlobalManager manager) {
super(manager, "lang");
}
public static LangMessage getInstance(GlobalManager manager) {
if (instance == null) {
synchronized (LOCK) {
if (instance == null) {
instance = new LangMessage(manager);
}
}
}
return instance;
}
}
Ченджлог
1.7.0Релиз1.20.5, 1.20.6, 1.21 · 2 августа 2024 г.
We are excited to announce that AnhyLibAPI has been updated to version 1.7.0! This latest release brings full compatibility with Minecraft servers running version 1.21.
What's New:
- Updated Compatibility: Ensures seamless integration and functionality with Minecraft 1.21 servers.
- Bug Fixes and Improvements: Enhanced performance and stability.
Make sure to update to version 1.7.0 to take advantage of the latest features and improvements. As always, if you encounter any issues or need assistance, feel free to reach out!
Thank you for your continued support!
1.5.2Релиз1.20.2, 1.20.3, 1.20.4 · 24 апреля 2024 г.
AnhyLibAPI Update 1.5.2 Released!
- Enhanced Messaging Capabilities: We've significantly expanded the functionality for sending messages with text components. This allows for more dynamic and customizable text in your server's communications.
- New Message Variants: To enhance your server's interaction, we've introduced additional message types that can be used in various contexts and scenarios.
- Code Optimization: The codebase has been optimized to improve performance and reliability. These enhancements help ensure smoother operation and less overhead on your server.
1.4.0Релиз1.20.2, 1.20.3, 1.20.4 · 10 февраля 2024 г.
🎉 AnhyLibAPI Update! Version for Minecraft 1.20.4 Available Now!
We are excited to announce the release of the updated AnhyLibAPI, now fully compatible with Minecraft version 1.20.4! This update includes not only support for the latest Minecraft version but also a series of exciting improvements and new features:
✨ New Capabilities for Text Component Formation: We've expanded our text handling tools, adding new functions that allow for the creation of even more dynamic and expressive text components for your server.
🚀 Code Optimization: We've conducted thorough code optimization to ensure better performance and stability for your server. Thanks to these changes, AnhyLibAPI now operates faster and more efficiently, minimizing the load on your server.
We strive to provide you with the best experience using our products and thank you for your unwavering support. Please do not hesitate to contact us if you have any questions or suggestions!
1.3.5Релиз1.20.2, 1.20.3, 1.20.4 · 20 декабря 2023 г.
Fixed bug with sending messages in old versions. Removed some redundant methods and optimized the code.
Комментарии
Загружаем…