14 Commits
9 changed files with 83 additions and 24 deletions
+1
View File
@@ -0,0 +1 @@
repo_token: $COVERALLS_REPO_TOKEN
+2
View File
@@ -9,3 +9,5 @@ deploy:
skip_cleanup: true
on:
tags: true
after_success:
- mvn clean test jacoco:report coveralls:report
+51
View File
@@ -2,6 +2,7 @@
[![All Release](https://img.shields.io/github/downloads/oskar3123/StaffChat/total.svg?style=flat)](https://github.com/oskar3123/StaffChat/releases/latest)
[![Latest Release](https://img.shields.io/github/release/oskar3123/StaffChat.svg?style=flat)](https://github.com/oskar3123/StaffChat/releases/latest)
[![Github commits (since latest release)](https://img.shields.io/github/commits-since/oskar3123/StaffChat/latest.svg?style=flat)](https://github.com/oskar3123/StaffChat/commits/master)
[![Coverage Status](https://coveralls.io/repos/github/oskar3123/StaffChat/badge.svg?branch=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.
+8 -4
View File
@@ -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 -1
View File
@@ -1,4 +1,4 @@
name: StaffChat
authors: [oskar3123]
main: me.oskar3123.staffchat.bungee.BungeeMain
version: 1.1.3
version: 1.1.5
+1 -1
View File
@@ -1,7 +1,7 @@
name: StaffChat
authors: [oskar3123]
main: me.oskar3123.staffchat.spigot.Main
version: 1.1.3
version: 1.1.5
commands:
staffchat: