145 lines
4.5 KiB
Markdown
145 lines
4.5 KiB
Markdown
[](https://github.com/oskar3123/StaffChat/releases/latest)
|
|
|
|
[](https://github.com/oskar3123/StaffChat/releases/latest)
|
|
[](https://github.com/oskar3123/StaffChat/commits/master)
|
|
[](https://github.com/oskar3123/StaffChat/releases)
|
|
[](https://github.com/oskar3123/StaffChat/commits/master)
|
|
|
|
[](https://github.com/oskar3123/StaffChat/issues?q=is%3Aopen+is%3Aissue)
|
|
[](https://github.com/oskar3123/StaffChat/issues?q=is%3Aissue+is%3Aclosed)
|
|
[](https://github.com/oskar3123/StaffChat/pulls?q=is%3Aopen+is%3Apr)
|
|
[](https://github.com/oskar3123/StaffChat/pulls?q=is%3Apr+is%3Aclosed)
|
|
|
|
# [StaffChat](https://oskar3123.github.io/StaffChat)
|
|
|
|
Simple and highly configurable staff chat.
|
|
|
|
## Download
|
|
|
|
You can download the plugin from
|
|
the [Spigot resource page](https://www.spigotmc.org/resources/37804/) or via
|
|
the [GitHub releases](https://github.com/oskar3123/StaffChat/releases).
|
|
|
|
## License
|
|
|
|
This plugin is licensed with the MIT License, for more information see
|
|
the [LICENSE file](https://github.com/oskar3123/StaffChat/blob/master/LICENSE).
|
|
|
|
## Building
|
|
|
|
To build this yourself just clone the repository and run the `shadowJar` task with the Gradle
|
|
Wrapper.
|
|
|
|
### Windows
|
|
|
|
```bat
|
|
git clone git@github.com:oskar3123/StaffChat.git
|
|
cd StaffChat
|
|
gradlew.bat shadowJar
|
|
```
|
|
|
|
### *nix (Linux, FreeBSD, macOS, ...)
|
|
|
|
```bash
|
|
git clone git@github.com:oskar3123/StaffChat.git
|
|
cd StaffChat
|
|
./gradlew shadowJar
|
|
```
|
|
|
|
## Event API (For developers)
|
|
|
|
### Bukkit/Spigot
|
|
|
|
Because the event API in 1.14+ is now strict between sync and async events you should check whether
|
|
this was called synchronously or asynchronously by using `event.isAsynchronous()`.
|
|
|
|
```java
|
|
public class StaffChatListener implements Listener {
|
|
|
|
@EventHandler
|
|
public void onStaffChat(StaffChatEvent event) {
|
|
// String format = event.getFormat();
|
|
// event.setFormat("&b{NAME} >> {MESSAGE}");
|
|
// String message = event.getMessage();
|
|
// Player player = event.getPlayer();
|
|
// event.setCancelled(true);
|
|
}
|
|
}
|
|
```
|
|
|
|
Register the listener with
|
|
|
|
```java
|
|
getServer().getPluginManager().registerEvents(new StaffChatListener(), this);
|
|
```
|
|
|
|
in your plugin onEnable.
|
|
|
|
### BungeeCord
|
|
|
|
```java
|
|
public class StaffChatListener implements Listener {
|
|
|
|
@EventHandler
|
|
public void onStaffChat(BungeeStaffChatEvent event) {
|
|
// String format = event.getFormat();
|
|
// event.setFormat("&b{NAME} >> {MESSAGE}");
|
|
// String message = event.getMessage();
|
|
// Player player = event.getPlayer();
|
|
// event.setCancelled(true);
|
|
}
|
|
}
|
|
```
|
|
|
|
Register the listener with
|
|
|
|
```java
|
|
getProxy().getPluginManager().registerListener(this, new StaffChatListener());
|
|
```
|
|
|
|
in your plugin onEnable.
|
|
|
|
### Velocity
|
|
|
|
```java
|
|
public class StaffChatListener {
|
|
|
|
@Subscribe
|
|
public void onStaffChat(VelocityStaffChatEvent event) {
|
|
// Player player = event.getPlayer();
|
|
// String format = event.getFormat();
|
|
// String message = event.getMessage();
|
|
// StaffChatResult result = StaffChatResult.denied();
|
|
// StaffChatResult result = StaffChatResult.format("&b{NAME} >> {MESSAGE}");
|
|
// StaffChatResult result = StaffChatResult.message(filterMessage(message));
|
|
// StaffChatResult result = StaffChatResult.formatAndMessage("&b{NAME} >> {MESSAGE}", filterMessage(message));
|
|
// event.setResult(result);
|
|
}
|
|
|
|
private static String filterMessage(String message) {
|
|
// ...
|
|
return message;
|
|
}
|
|
}
|
|
```
|
|
|
|
Register the listener on the `ProxyInitializeEvent` in your plugin.
|
|
|
|
```java
|
|
@Plugin
|
|
public class Plugin {
|
|
|
|
private final ProxyServer server;
|
|
|
|
@Inject
|
|
public Plugin(ProxyServer server) {
|
|
this.server = server;
|
|
}
|
|
|
|
@Subscribe
|
|
public void onProxyInitialization(ProxyInitializeEvent event) {
|
|
server.getEventManager().register(this, new StaffChatListener());
|
|
}
|
|
}
|
|
```
|