Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9abaf55532
|
||
|
|
1136b7e33f
|
||
|
|
361d302b36
|
||
|
|
d6551b317f
|
||
|
|
5105e76dc5 | ||
|
|
82cfcb4862
|
||
|
|
671bb0d8b2
|
||
|
|
79fb7e84a5
|
||
|
|
bba628e3f2
|
||
|
|
b0951d7427
|
||
|
|
0e7a6e58e2
|
||
|
|
5850ff2009
|
||
|
|
f98a038e38 | ||
|
|
e927ca5f3c |
@@ -0,0 +1 @@
|
||||
repo_token: $COVERALLS_REPO_TOKEN
|
||||
@@ -9,3 +9,5 @@ deploy:
|
||||
skip_cleanup: true
|
||||
on:
|
||||
tags: true
|
||||
after_success:
|
||||
- mvn clean test jacoco:report coveralls:report
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
[](https://github.com/oskar3123/StaffChat/releases/latest)
|
||||
[](https://github.com/oskar3123/StaffChat/releases/latest)
|
||||
[](https://github.com/oskar3123/StaffChat/commits/master)
|
||||
[](https://coveralls.io/github/oskar3123/StaffChat?branch=master)
|
||||
|
||||
# [StaffChat](https://oskar3123.github.io/StaffChat)
|
||||
|
||||
@@ -9,3 +10,53 @@ Simple and highly configurable staffchat
|
||||
|
||||
## 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)
|
||||
|
||||
## Event API (For developers)
|
||||
|
||||
### Bukkit/Spigot
|
||||
|
||||
```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.
|
||||
|
||||
@@ -7,7 +7,11 @@
|
||||
|
||||
<groupId>me.oskar3123</groupId>
|
||||
<artifactId>staffchat</artifactId>
|
||||
<version>1.1.3-SNAPSHOT</version>
|
||||
<version>1.1.5-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
@@ -24,17 +28,17 @@
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.12.2-R0.1-SNAPSHOT</version>
|
||||
<version>1.13-R0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.12.2-R0.1-SNAPSHOT</version>
|
||||
<version>1.13-R0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-api</artifactId>
|
||||
<version>1.12-SNAPSHOT</version>
|
||||
<version>1.13-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package me.oskar3123.staffchat.bungee.listener;
|
||||
|
||||
import me.oskar3123.staffchat.bungee.BungeeMain;
|
||||
import me.oskar3123.staffchat.bungee.event.BungeeStaffChatEvent;
|
||||
import me.oskar3123.staffchat.util.StringUtils;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
@@ -53,8 +54,8 @@ public class BungeeChatListener implements Listener
|
||||
}
|
||||
format = chatEvent.getFormat();
|
||||
|
||||
format = format.replaceAll("\\{NAME\\}", sanitize(player.getName()));
|
||||
format = format.replaceAll("\\{MESSAGE\\}", sanitize(message));
|
||||
format = format.replaceAll("\\{NAME\\}", StringUtils.sanitize(player.getName()));
|
||||
format = format.replaceAll("\\{MESSAGE\\}", StringUtils.sanitize(message));
|
||||
final BaseComponent[] messageComponents = txt(format);
|
||||
|
||||
plugin.getProxy().getPlayers().stream()
|
||||
@@ -75,11 +76,4 @@ public class BungeeChatListener implements Listener
|
||||
return TextComponent.fromLegacyText(clr(text));
|
||||
}
|
||||
|
||||
private String sanitize(String string)
|
||||
{
|
||||
string = string.replaceAll("\\\\", "\\\\\\\\");
|
||||
string = string.replaceAll("\\$", "\\\\\\$");
|
||||
return string;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package me.oskar3123.staffchat.spigot.listener;
|
||||
|
||||
import me.oskar3123.staffchat.spigot.Main;
|
||||
import me.oskar3123.staffchat.spigot.event.StaffChatEvent;
|
||||
import me.oskar3123.staffchat.util.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
@@ -45,8 +46,8 @@ public class ChatListener implements Listener
|
||||
}
|
||||
format = chatEvent.getFormat();
|
||||
|
||||
format = format.replaceAll("\\{NAME\\}", sanitize(event.getPlayer().getName()));
|
||||
format = format.replaceAll("\\{MESSAGE\\}", sanitize(message));
|
||||
format = format.replaceAll("\\{NAME\\}", StringUtils.sanitize(event.getPlayer().getName()));
|
||||
format = format.replaceAll("\\{MESSAGE\\}", StringUtils.sanitize(message));
|
||||
format = ChatColor.translateAlternateColorCodes('&', format);
|
||||
final String finalMessage = format;
|
||||
|
||||
@@ -58,11 +59,4 @@ public class ChatListener implements Listener
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
private String sanitize(String string)
|
||||
{
|
||||
string = string.replaceAll("\\\\", "\\\\\\\\");
|
||||
string = string.replaceAll("\\$", "\\\\\\$");
|
||||
return string;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package me.oskar3123.staffchat.util;
|
||||
|
||||
public class StringUtils
|
||||
{
|
||||
|
||||
public static String sanitize(String string)
|
||||
{
|
||||
string = string.replaceAll("\\\\", "\\\\\\\\");
|
||||
string = string.replaceAll("\\$", "\\\\\\$");
|
||||
return string;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
name: StaffChat
|
||||
authors: [oskar3123]
|
||||
main: me.oskar3123.staffchat.bungee.BungeeMain
|
||||
version: 1.1.3
|
||||
version: 1.1.5
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
name: StaffChat
|
||||
authors: [oskar3123]
|
||||
main: me.oskar3123.staffchat.spigot.Main
|
||||
version: 1.1.3
|
||||
version: 1.1.5
|
||||
|
||||
commands:
|
||||
staffchat:
|
||||
|
||||
Reference in New Issue
Block a user