API ​
WARNING
This page is outdated; it will be updated as soon as possible.
ChatPlugin comes with a rich and complete API available since version 1.8.0. The possibilities are endless: from sending a simple message translated in a player's language to creating custom interactive scoreboards that update automatically. Keep reading to discover how to do that.
TODO FIX FOLLOWING LINKS:
Introduction ​
ChatPlugin's JAR is composed of the loader which contains the API (and is common to both free and paid version) and the implementation's JAR which contains the real stuff. Because of this structure, you cannot interact with the implementation's classes as they are loaded through a class loader that is child of the one used to load other plugins. You can use reflection methods to do that, but it is not recommended (and it is useless: the API should cover every need).
As always, feel free to suggest new features and additions through our Discord server or here on GitHub.
Package organization ​
There are three main packages in me.remigio07.chatplugin.api
:
common
: contains code that run on both the server and the proxy implementationsserver
: features and modules only available on Bukkit/Sponge environmentsproxy
: features and modules only available on BungeeCord/Velocity environments
You must not interact with the other plugin's implementation's package. For example, calling a method from server.util.TPSManager
on a Velocity proxy may throw ClassNotFoundException
s as its classes may not even be loaded by the class loader. Instead, classes inside of the common
package are available and safe to use on both implementations.
Features availability ​
As stated above, some features are not available/do not work the same way on both implementations. They are treated separately, so you should refer to the interested module's wiki page.
Note that even on the server implementation (Bukkit and Sponge environments) not all features are always available. Every module's wiki page presents a table which signals noteworthy information about its availability.
Managers ​
Every feature or module in the plugin has its own manager class. For example, IP lookup is handled by the IPLookupManager
class; to interact with anything you first need to obtain its manager's instance. Every manager implements the interface ChatPluginManager
, that contains some methods:
load()
: initializes the manager; do not call if the manager is already loadedunload()
: unloads the manager and disables its modulesreload()
: unloads the manager, then loads it againisEnabled()
: checks if the manager and its modules are enabledisReloadable()
: checks if the manager will be reloaded on a plugin reloadcheckAvailability(boolean)
: checks if the manager may run on the current environment
Getting a manager's instance ​
Additionally to the methods mentioned above, every (built-in) manager has a static method getInstance()
that allows you to obtain the current manager's implementation's instance that you may interact with. Short example:
import me.remigio07.chatplugin.api.server.chat.ChatManager;
// ...
ChatManager.getInstance();
...will return you the active chat manager's implementation's instance.
Interacting with a manager ​
Getting managers' instances is all you need to interact with them. Here is an example on how to globally mute or unmute the chat using ChatManager
:
import me.remigio07.chatplugin.api.server.chat.ChatManager;
// ...
public void setChatMuted(boolean chatMuted) {
ChatManager.getInstance().setChatMuted(chatMuted);
}
Super easy, isn't it?
Managers list ​
These lists represent the managers available on the proxy and the server implementations on the plugin. They follow this order when enabled (click one of the spoilers):
Server (Bukkit/Sponge) environments
LogManager
ConfigurationManager
TaskManager
StorageManager
ProxyManager
IPLookupManager
LanguageManager
RankManager
EventManager
IntegrationManager
AnticheatManager
VanishManager
JoinMessageManager
QuitMessageManager
SwitchMessageManager
JoinTitleManager
WelcomeMessageManager
AccountCheckManager
PlayerManager
BanManager
BanwaveManager
WarningManager
KickManager
MuteManager
PlaceholderManager
SuggestedVersionManager
TPSManager
PingManager
ChatManager
FormattedChatManager
AntispamManager
PlayerPingManager
HoverInfoManager
InstantEmojisManager
StaffChatManager
ChatLogManager
PlayerIgnoreManager
PrivateMessagesManager
ScoreboardManager
TablistManager
CustomSuffixManager
BossbarManager
ActionbarManager
AdManager
F3ServerNameManager
GUIManager
MoTDManager
DiscordIntegrationManager
TelegramIntegrationManager
Proxy (BungeeCord/Velocity) environments
Adding a custom manager ​
It is possible to add custom managers to the plugin to add new features through other plugins. To do it, create your manager's class and simply obtain the current instance of ChatPluginManagers
to add it to the loaded managers' map. Note that it must implement the interface ChatPluginManager
and override load()
and isEnabled()
. Here's an example:
package me.remigio07.chatplugin.example;
import me.remigio07.chatplugin.api.common.util.manager.ChatPluginManager;
import me.remigio07.chatplugin.api.common.util.manager.ChatPluginManagerException;
public class CustomChatPluginManager implements ChatPluginManager {
private boolean enabled;
@Override
public void load() throws ChatPluginManagerException {
enabled = true;
// additional code to load the manager
}
@Override
public void unload() throws ChatPluginManagerException {
enabled = false;
// additional code to unload the manager
}
@Override
public void isEnabled() {
return enabled;
}
}
Then, add it to the loaded managers and load it:
import me.remigio07.chatplugin.api.common.util.manager.ChatPluginManagers;
// ...
public void initialize() {
ChatPluginManagers.getInstance().addManager(CustomChatPluginManager.class, new CustomChatPluginManager());
}
Now the manager will reload automatically along with the plugin, unless you override isReloadable()
(which defaults to true
) and make it return false
. In this case the manager will not be unloaded until the server is closed (or you do it manually through unload()
).
Events ​
ChatPlugin offers a lot of custom events through the ones you can interact with it and customize their outcome.
Listening to events ​
TODO
Plugin reload event ​
ChatPlugin - Un plugin completo ma leggero che gestisce semplicemente troppe funzionalità !
Questa wiki è attualmente aggiornata alla versione 1.9.10.
© 2024  Remigio07
Si prega di segnalare imprecisioni ed errori di ortografia come descritto a Home/Reporting issues.