In order to use UltraStaffChatPro's API, you must declare UltraStaffChatPro as a dependency of your plugin. This causes UltraStaffChatPro to be loaded before your plugin, making it possible for your plugin to use UltraStaffChatPro's API.
If you don't declare UltraStaffChatPro as a dependency of your plugin, errors are likely to occur when you attempt to use the API.
Declare UltraStaffChatPro as a dependency in your paper-plugin.yml file.
PaperMC Documentation
paper-plugin.yml
dependencies:
server:
UltraStaffChatPro:
load: BEFORE
required: true # Set to `false` if your plugin does not require UltraStaffChatPro.
join-classpath: true
Declare UltraStaffChatPro as a dependency in your plugin.yml file.
plugin.yml
depend: ["UltraStaffChatPro"]
# If your plugin does not require UltraStaffChatPro,
# use 'softdepend' instead of 'depend':
softdepend: ["UltraStaffChatPro"]
Declare ultrastaffchatpro as a dependency in your @Plugin annotation.
Velocity documentation
@Plugin(
id = "myplugin",
name = "My Plugin",
version = "0.1.0",
dependencies = {
// Add `optional = true` if your plugin does not require UltraStaffChatPro.
@Dependency(id = "ultrastaffchatpro")
}
)
Declare UltraStaffChatPro as a dependency in your bungee.yml (or plugin.yml) file.
bungee.yml
depends: ["UltraStaffChatPro"]
# If your plugin does not require UltraStaffChatPro, use 'softDepends' instead of 'depends':
softDepends: ["UltraStaffChatPro"]
Examples
MyPlugin.java
public final class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
// Register your plugin with UltraStaffChatPro's API.
APIPlugin plugin = UltraStaffChatProAPI.getInstance()
.registerPlugin("MyPlugin", "0.1.0-SNAPSHOT", "Me, Myself and I");
// Register an event listener
UltraStaffChatProAPI.getInstance().registerListener(plugin, new MyListener());
}
}
MyListener.java
public final class MyListener implements UltraStaffChatProListener {
@USCPEventHandler
public void onMessage(UltraStaffChatProMessageEvent event) {
// Do something with the message...
}
@USCPEventHandler
public void onJoinMessage(UltraStaffChatProJoinMessageEvent event) {
if (event.getUser().getName().equalsIgnoreCase("Steve")) {
event.setCancelled(true);
}
}
}
// Send a message
UltraStaffChatProAPI.getInstance().getMessageManager()
.sendMessage(MessageBuilder.create(
UserBuilder.create("Steve", UUID.randomUUID()).build(),
"Hi, my name is Steve."
).build());
// Toggle global mute in StaffChat
UltraStaffChatProAPI.getInstance().getStateManager().toggleGlobalMute(null);