Begin (broken) modularization

This commit is contained in:
Draycia committed 2020-07-12 04:25:33 -07:00
1 parent b3a0d71ba8
commit ad8089855c
56 files changed
+553 -369

No files matched your search

+129
View File
@@ -0,0 +1,129 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>SimpleChatParent</artifactId>
<groupId>net.draycia</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>SimpleChatModeration</artifactId>
<packaging>jar</packaging>
<name>SimpleChatModeration</name>
<build>
<defaultGoal>clean package</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>
<relocations>
<relocation>
<pattern>co.aikar.commands</pattern>
<shadedPattern>net.draycia.simplechat.libs.acf</shadedPattern>
</relocation>
<relocation>
<pattern>co.aikar.locales</pattern>
<shadedPattern>net.draycia.simplechat.libs.locales</shadedPattern>
</relocation>
<relocation>
<pattern>co.aikar.idb</pattern>
<shadedPattern>net.draycia.simplechat.libs.idb</shadedPattern>
</relocation>
<relocation>
<pattern>net.kyori</pattern>
<shadedPattern>net.draycia.simplechat.libs.kyori</shadedPattern>
</relocation>
<relocation>
<pattern>io.papermc.lib</pattern>
<shadedPattern>net.draycia.simplechat.libs.paperlib</shadedPattern>
</relocation>
<relocation>
<pattern>com.fasterxml</pattern>
<shadedPattern>net.draycia.simplechat.libs.fasterxml</shadedPattern>
</relocation>
<relocation>
<pattern>com.neovisionaries</pattern>
<shadedPattern>net.draycia.simplechat.libs.neovisionaries</shadedPattern>
</relocation>
<relocation>
<pattern>okio</pattern>
<shadedPattern>net.draycia.simplechat.libs.okio</shadedPattern>
</relocation>
<relocation>
<pattern>okhttp3</pattern>
<shadedPattern>net.draycia.simplechat.libs.okhttp3</shadedPattern>
</relocation>
<relocation>
<pattern>org.checkerframework</pattern>
<shadedPattern>net.draycia.simplechat.libs.checkerframework</shadedPattern>
</relocation>
</relocations>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>testCompile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.draycia</groupId>
<artifactId>SimpleChat</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>provided</scope>
<classifier>shaded</classifier>
</dependency>
</dependencies>
</project>
@@ -0,0 +1,24 @@
package net.draycia.simplechatmoderation;
import net.draycia.simplechat.SimpleChat;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
public final class SimpleChatModeration extends JavaPlugin {
private SimpleChat simpleChat;
@Override
public void onEnable() {
simpleChat = (SimpleChat)Bukkit.getPluginManager().getPlugin("SimpleChat");
}
@Override
public void onDisable() {
}
public SimpleChat getSimpleChat() {
return simpleChat;
}
}
@@ -1,4 +1,4 @@
package net.draycia.simplechat.commands;
package net.draycia.simplechatmoderation.commands;
import co.aikar.commands.BaseCommand;
import co.aikar.commands.CommandIssuer;
@@ -6,6 +6,7 @@ import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Default;
import net.draycia.simplechat.SimpleChat;
import net.draycia.simplechatmoderation.SimpleChatModeration;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
@@ -16,15 +17,15 @@ import org.bukkit.entity.Player;
@CommandPermission("simplechat.clearchat.clear")
public class ClearChatCommand extends BaseCommand {
private SimpleChat simpleChat;
private SimpleChatModeration moderation;
public ClearChatCommand(SimpleChat simpleChat) {
this.simpleChat = simpleChat;
public ClearChatCommand(SimpleChatModeration moderation) {
this.moderation = moderation;
}
@Default
public void baseCommand(CommandIssuer issuer) {
String format = simpleChat.getConfig().getString("clear-chat-message", "");
String format = moderation.getConfig().getString("clear-chat.message", "");
Component component = MiniMessage.get().parse(format, "br", "\n");
for (Player player : Bukkit.getOnlinePlayers()) {
@@ -32,21 +33,21 @@ public class ClearChatCommand extends BaseCommand {
continue;
}
Audience audience = simpleChat.getAudiences().player(player);
Audience audience = moderation.getSimpleChat().getAudiences().player(player);
for (int i = 0; i < simpleChat.getConfig().getInt("clear-chat-amount", 100); i++) {
for (int i = 0; i < moderation.getConfig().getInt("clear-chat.message-count", 100); i++) {
audience.sendMessage(component);
}
String name = issuer.isPlayer() ? ((Player)issuer).getName() : "Console";
if (player.hasPermission("simplechat.clearchat.notify")) {
String message = simpleChat.getConfig().getString("language.clear-notify");
String message = moderation.getConfig().getString("language.clear-notify");
audience.sendMessage(MiniMessage.get().parse(message, "player", name));
}
if (player.hasPermission("simplechat.clearchat.exempt")) {
String message = simpleChat.getConfig().getString("language.clear-exempt");
String message = moderation.getConfig().getString("language.clear-exempt");
audience.sendMessage(MiniMessage.get().parse(message, "player", name));
}
}
@@ -1,4 +1,4 @@
package net.draycia.simplechat.commands;
package net.draycia.simplechatmoderation.commands;
import co.aikar.commands.BaseCommand;
import co.aikar.commands.annotation.CommandAlias;
@@ -7,6 +7,7 @@ import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Default;
import net.draycia.simplechat.SimpleChat;
import net.draycia.simplechat.storage.ChatUser;
import net.draycia.simplechatmoderation.SimpleChatModeration;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import org.bukkit.command.CommandSender;
@@ -15,10 +16,10 @@ import org.bukkit.command.CommandSender;
@CommandPermission("simplechat.mute")
public class MuteCommand extends BaseCommand {
private SimpleChat simpleChat;
private SimpleChatModeration moderation;
public MuteCommand(SimpleChat simpleChat) {
this.simpleChat = simpleChat;
public MuteCommand(SimpleChatModeration moderation) {
this.moderation = moderation;
}
@Default
@@ -28,16 +29,16 @@ public class MuteCommand extends BaseCommand {
if (targetUser.isMuted()) {
targetUser.setMuted(true);
format = simpleChat.getConfig().getString("language.no-longer-muted");
format = moderation.getConfig().getString("language.no-longer-muted");
} else {
targetUser.setMuted(false);
format = simpleChat.getConfig().getString("language.is-now-muted");
format = moderation.getConfig().getString("language.is-now-muted");
}
Component message = MiniMessage.get().parse(format, "br", "\n",
"user", targetUser.asOfflinePlayer().getName());
simpleChat.getAudiences().audience(sender).sendMessage(message);
moderation.getSimpleChat().getAudiences().audience(sender).sendMessage(message);
}
}
@@ -1,12 +1,12 @@
package net.draycia.simplechat.commands;
package net.draycia.simplechatmoderation.commands;
import co.aikar.commands.BaseCommand;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandCompletion;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Default;
import net.draycia.simplechat.SimpleChat;
import net.draycia.simplechat.storage.ChatUser;
import net.draycia.simplechatmoderation.SimpleChatModeration;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import org.bukkit.command.CommandSender;
@@ -15,10 +15,10 @@ import org.bukkit.command.CommandSender;
@CommandPermission("simplechat.shadowmute")
public class ShadowMuteCommand extends BaseCommand {
private SimpleChat simpleChat;
private SimpleChatModeration moderation;
public ShadowMuteCommand(SimpleChat simpleChat) {
this.simpleChat = simpleChat;
public ShadowMuteCommand(SimpleChatModeration moderation) {
this.moderation = moderation;
}
@Default
@@ -28,16 +28,16 @@ public class ShadowMuteCommand extends BaseCommand {
if (targetUser.isShadowMuted()) {
targetUser.setShadowMuted(false);
format = simpleChat.getConfig().getString("language.no-longer-shadow-muted");
format = moderation.getConfig().getString("language.no-longer-shadow-muted");
} else {
targetUser.setShadowMuted(true);
format = simpleChat.getConfig().getString("language.is-now-shadow-muted");
format = moderation.getConfig().getString("language.is-now-shadow-muted");
}
Component message = MiniMessage.get().parse(format, "br", "\n",
"user", targetUser.asOfflinePlayer().getName());
simpleChat.getAudiences().audience(sender).sendMessage(message);
moderation.getSimpleChat().getAudiences().audience(sender).sendMessage(message);
}
}
@@ -1,26 +1,26 @@
package net.draycia.simplechat.listeners;
package net.draycia.simplechatmoderation.listeners;
import net.draycia.simplechat.SimpleChat;
import net.draycia.simplechat.events.ChatFormatEvent;
import net.draycia.simplechatmoderation.SimpleChatModeration;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
public class CapsHandler implements Listener {
private SimpleChat simpleChat;
private SimpleChatModeration moderation;
public CapsHandler(SimpleChat simpleChat) {
this.simpleChat = simpleChat;
public CapsHandler(SimpleChatModeration moderation) {
this.moderation = moderation;
}
@EventHandler(priority = EventPriority.LOW)
public void onMessage(ChatFormatEvent event) {
if (!simpleChat.getConfig().getBoolean("caps-protection.enabled")) {
if (!moderation.getConfig().getBoolean("caps-protection.enabled")) {
return;
}
if (!(event.getMessage().length() >= simpleChat.getConfig().getInt("caps-protection.minimum-length"))) {
if (!(event.getMessage().length() >= moderation.getConfig().getInt("caps-protection.minimum-length"))) {
return;
}
@@ -34,11 +34,11 @@ public class CapsHandler implements Listener {
double capsPercentage = (amountOfCaps * 100.0) / event.getMessage().length();
if (!(capsPercentage >= simpleChat.getConfig().getDouble("caps-protection.percent-caps"))) {
if (!(capsPercentage >= moderation.getConfig().getDouble("caps-protection.percent-caps"))) {
return;
}
if (simpleChat.getConfig().getBoolean("block-message")) {
if (moderation.getConfig().getBoolean("block-message")) {
event.setCancelled(true);
} else {
event.setMessage(event.getMessage().toLowerCase());
@@ -0,0 +1,41 @@
package net.draycia.simplechatmoderation.listeners;
import net.draycia.simplechat.channels.ChatChannel;
import net.draycia.simplechat.events.ChatFormatEvent;
import net.draycia.simplechatmoderation.SimpleChatModeration;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import java.util.List;
public class FilterHandler implements Listener {
private SimpleChatModeration moderation;
public FilterHandler(SimpleChatModeration moderation) {
this.moderation = moderation;
}
@EventHandler(priority = EventPriority.LOWEST)
public void onFilter(ChatFormatEvent event) {
if (!moderation.getConfig().getBoolean("filters.enabled")) {
return;
}
String filterText = moderation.getConfig().getString("filters.filter-text", "****");
if (channelUsesFilter(event.getChatChannel())) {
for (String entry : moderation.getConfig().getStringList("filters.filtered-words")) {
event.setMessage(event.getMessage().replaceAll(entry, filterText));
}
}
}
private boolean channelUsesFilter(ChatChannel chatChannel) {
List<String> channels = moderation.getConfig().getStringList("filters.channels");
return channels.contains("*") || channels.contains(chatChannel.getKey());
}
}
@@ -0,0 +1,29 @@
caps-protection:
enabled: true
minimum-length: 10
percent-caps: 80
block-message: false
filters:
enabled: true
filter-text: '****'
filtered-words:
- 'lag'
- 'la[g]+'
channels:
- '*' # Use '*' to mean all channels
clear-chat:
# The message sent to clear chat, you probably want to leave this blank
message: ""
# How many messages will be sent in order to clear chat
message-count: 100
language:
is-now-shadow-muted: '<yellow>User <user> is now shadow muted!'
no-longer-shadow-muted: '<yellow>User <user> is no longer shadow muted!'
is-now-muted: '<yellow>User <user> is now muted!'
no-longer-muted: '<yellow>User <user> is no longer muted!'
reloaded: '<yellow>ChatModeration config has been reloaded!'
clear-notify: '<yellow>Chat has been cleared by <player>.'
clear-exempt: '<yellow>You were exempt from the clear due to your permissions!'
@@ -0,0 +1,5 @@
name: SimpleChatModeration
version: ${project.version}
main: net.draycia.simplechatmoderation.SimpleChatModeration
api-version: 1.16
depend: [SimpleChat]
+276
View File
@@ -0,0 +1,276 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>SimpleChatParent</artifactId>
<groupId>net.draycia</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>SimpleChat</artifactId>
<packaging>jar</packaging>
<name>SimpleChat</name>
<build>
<defaultGoal>clean package</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>
<relocations>
<relocation>
<pattern>co.aikar.commands</pattern>
<shadedPattern>net.draycia.simplechat.libs.acf</shadedPattern>
</relocation>
<relocation>
<pattern>co.aikar.locales</pattern>
<shadedPattern>net.draycia.simplechat.libs.locales</shadedPattern>
</relocation>
<relocation>
<pattern>co.aikar.idb</pattern>
<shadedPattern>net.draycia.simplechat.libs.idb</shadedPattern>
</relocation>
<relocation>
<pattern>net.kyori</pattern>
<shadedPattern>net.draycia.simplechat.libs.kyori</shadedPattern>
</relocation>
<relocation>
<pattern>io.papermc.lib</pattern>
<shadedPattern>net.draycia.simplechat.libs.paperlib</shadedPattern>
</relocation>
<relocation>
<pattern>com.fasterxml</pattern>
<shadedPattern>net.draycia.simplechat.libs.fasterxml</shadedPattern>
</relocation>
<relocation>
<pattern>com.neovisionaries</pattern>
<shadedPattern>net.draycia.simplechat.libs.neovisionaries</shadedPattern>
</relocation>
<relocation>
<pattern>okio</pattern>
<shadedPattern>net.draycia.simplechat.libs.okio</shadedPattern>
</relocation>
<relocation>
<pattern>okhttp3</pattern>
<shadedPattern>net.draycia.simplechat.libs.okhttp3</shadedPattern>
</relocation>
<relocation>
<pattern>org.checkerframework</pattern>
<shadedPattern>net.draycia.simplechat.libs.checkerframework</shadedPattern>
</relocation>
</relocations>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>testCompile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<repositories>
<!-- Spigot API -->
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<!-- Kyori -->
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
<!-- PlaceholderAPI -->
<repository>
<id>placeholderapi</id>
<url>http://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
<!-- Towny, VaultAPI -->
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<!-- ACF -->
<repository>
<id>aikar</id>
<url>https://repo.aikar.co/content/groups/aikar/</url>
</repository>
<!-- NuVotifier -->
<repository>
<id>bintray-repo</id>
<url>https://dl.bintray.com/ichbinjoe/public/</url>
</repository>
<!-- BungeeChannelAPI -->
<repository>
<id>codemc-repo</id>
<url>https://repo.codemc.org/repository/maven-public/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<!-- mcMMO and MiniMessage must be compiled locally -->
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- ACF - command framework -->
<dependency>
<groupId>co.aikar</groupId>
<artifactId>acf-bukkit</artifactId>
<version>0.5.0-SNAPSHOT</version>
</dependency>
<!-- Components and formatting -->
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-api</artifactId>
<version>4.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-nbt</artifactId>
<version>4.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-bukkit</artifactId>
<version>4.0.0-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Must be built locally for the time being -->
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-minimessage</artifactId>
<version>3.0.0-SNAPSHOT</version>
</dependency>
<!-- Placeholders -->
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.10.6</version>
<scope>provided</scope>
</dependency>
<!-- Towny chats - nation & town -->
<dependency>
<groupId>com.github.TownyAdvanced</groupId>
<artifactId>Towny</artifactId>
<version>0.96.1.11</version>
<scope>provided</scope>
</dependency>
<!-- mcMMO - no repository, add to maven local -->
<dependency>
<groupId>com.gmail.nossr50.mcMMO</groupId>
<artifactId>mcMMO</artifactId>
<version>2.1.130</version>
<scope>provided</scope>
</dependency>
<!-- Vault for permissions / groups -->
<dependency>
<groupId>com.github.MilkBowl</groupId>
<artifactId>VaultAPI</artifactId>
<version>1.7</version>
<scope>provided</scope>
</dependency>
<!-- NuVotifier for vote messages in discord bridge -->
<dependency>
<groupId>com.vexsoftware</groupId>
<artifactId>nuvotifier-universal</artifactId>
<version>2.6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>co.aikar</groupId>
<artifactId>idb-bukkit</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>2.4.1</version>
</dependency>
<!-- Easier bungee handling -->
<dependency>
<groupId>io.github.leonardosnt</groupId>
<artifactId>bungeechannelapi</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<!-- Redis -->
<dependency>
<groupId>io.lettuce</groupId>
<artifactId>lettuce-core</artifactId>
<version>6.0.0.M1</version>
</dependency>
</dependencies>
</project>
@@ -85,7 +85,6 @@ public final class SimpleChat extends JavaPlugin {
// Register chat listeners
pluginManager.registerEvents(new BukkitChatListener(this), this);
pluginManager.registerEvents(new FilterHandler(this), this);
pluginManager.registerEvents(new ItemLinkHandler(this), this);
pluginManager.registerEvents(new LegacyFormatHandler(), this);
pluginManager.registerEvents(new MuteHandler(), this);
@@ -94,7 +93,6 @@ public final class SimpleChat extends JavaPlugin {
pluginManager.registerEvents(new PlaceholderHandler(this), this);
pluginManager.registerEvents(new ShadowMuteHandler(), this);
pluginManager.registerEvents(new EmptyChatHandler(this), this);
pluginManager.registerEvents(new CapsHandler(this), this);
}
public void reloadPatterns() {
@@ -39,6 +39,8 @@ public abstract class ChatChannel {
*/
public abstract String getName();
public abstract String getKey();
/**
* @return The distance other players must be within to the sender to see messages in this channel.
*/
@@ -67,8 +69,6 @@ public abstract class ChatChannel {
public abstract String getToggleOtherOffMessage();
public abstract boolean filterEnabled();
/**
* @return If this channel is Towny's town chat.
*/
@@ -344,11 +344,6 @@ public class SimpleChatChannel extends ChatChannel {
return (Boolean) getSetting("forward-format");
}
@Override
public boolean filterEnabled() {
return (Boolean) getSetting("filter-enabled");
}
@Override
public boolean firstMatchingGroup() {
return (Boolean) getSetting("first-matching-group");
@@ -381,7 +376,8 @@ public class SimpleChatChannel extends ChatChannel {
return false;
}
private String getKey() {
@Override
public String getKey() {
return key;
}
@@ -100,13 +100,10 @@ public class CommandManager {
manager.registerCommand(new ToggleCommand(simpleChat));
manager.registerCommand(new ChannelCommand(simpleChat));
manager.registerCommand(new IgnoreCommand(simpleChat));
manager.registerCommand(new ClearChatCommand(simpleChat));
manager.registerCommand(new ShadowMuteCommand(simpleChat));
manager.registerCommand(new ChatReloadCommand(simpleChat));
manager.registerCommand(new MeCommand(simpleChat));
manager.registerCommand(new MessageCommand(simpleChat));
manager.registerCommand(new ReplyCommand(simpleChat));
manager.registerCommand(new MuteCommand(simpleChat));
manager.registerCommand(new SetColorCommand(simpleChat));
manager.registerCommand(new SpyChannelCommand(simpleChat));
}
@@ -34,8 +34,6 @@ default:
should-bungee: true
# Determines if this channel should use the highest matching vault group found for formatting
first-matching-group: false
# Determines if the chat filter is enabled for this channel
filter-enabled: true
# Towny, Nation, Alliance, Party, Normal
type: 'normal'
@@ -52,23 +50,13 @@ channels:
ignorable: false
should-bungee: false
filters:
- 'lag'
- 'la[g]+'
filter-text: '****'
replacements:
'%shrug%': '¯\_(ツ)_/¯'
language:
ignoring-user: '<green>You are now ignoring <gold><player><green>!'
not-ignoring-user: '<green>You are no longer ignoring <gold><player><green>!'
is-now-shadow-muted: '<yellow>User <user> is now shadow muted!'
no-longer-shadow-muted: '<yellow>User <user> is no longer shadow muted!'
is-now-muted: '<yellow>User <user> is now muted!'
no-longer-muted: '<yellow>User <user> is no longer muted!'
reloaded: '<yellow>Chat config has been reloaded! Note that this does not reload channel configs!'
reloaded: '<yellow>Chat config has been reloaded!'
me: '<italic><dark_purple>*%player_displayname% <pre><message></pre>*</dark_purple></italic>'
message-to-other: '<green>[<gray>Me <gold>-> <gray><target><green>] <message>'
message-from-other: '<green>[<gray><sender> <gold>-> <gray>Me<green>] <message>'
@@ -79,34 +67,21 @@ language:
channel-color-set: "<green>You have set <color><channel> <green>color to <hex>!"
spy-toggled-on: '<gray>You are now spying on <color><channel> <gray>chat!'
spy-toggled-off: '<gray>You are no longer spying on <color><channel> <gray>chat!'
clear-notify: '<yellow>Chat has been cleared by <player>.'
clear-exempt: '<yellow>You were exempt from the clear due to your permissions!'
empty-channel: '<green>Nobody is around to hear you!' #<channel>
# The following messages are not MiniMessage compatible
player-left: '%player_displayname% has left <server>!'
player-joined: '%player_displayname% has joined <server>!'
vote-received: '<name> has voted on <service>!'
cannot-use-channel: "You cannot use that channel!"
town-cannot-use: 'You are not in a town!'
nation-cannot-use: 'You are not in a nation!'
alliance-cannot-use: 'You do not have any alliances!'
party-cannot-use: 'You are not in a party!'
# Used for <server> placeholder in channel formats
server-name: 'Server'
clear-chat-message: ""
clear-chat-amount: 100
item-link-placeholders:
- '[item]' # cursed placeholder do not use
- '%item%'
caps-protection:
enabled: true
minimum-length: 10
percent-caps: 80
block-message: false
spy-prefix: '<color>[SPY] '
spy-prefix-nation: '<color>[SPY <nation>] '
spy-prefix-town: '<color>[SPY <town>] '
@@ -121,12 +96,6 @@ pings:
highlight: true # independent of the "enabled" option!
on-whisper: true # independent of the "enabled" option!
listeners:
join: true # sends join messages in discord
leave: true # sends leave messages in discord
death: true # sends death messages in discord
vote: false # sends vote messages in discord
storage:
type: JSON # JSON, MySQL
username: 'username'
File renamed without changes.
+8 -260
View File
@@ -5,9 +5,15 @@
<modelVersion>4.0.0</modelVersion>
<groupId>net.draycia</groupId>
<artifactId>SimpleChat</artifactId>
<artifactId>SimpleChatParent</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<modules>
<module>SimpleChatPlugin</module>
<module>SimpleChatModeration</module>
</modules>
<packaging>pom</packaging>
<name>SimpleChat</name>
@@ -15,262 +21,4 @@
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<defaultGoal>clean package</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>
<relocations>
<relocation>
<pattern>co.aikar.commands</pattern>
<shadedPattern>net.draycia.simplechat.libs.acf</shadedPattern>
</relocation>
<relocation>
<pattern>co.aikar.locales</pattern>
<shadedPattern>net.draycia.simplechat.libs.locales</shadedPattern>
</relocation>
<relocation>
<pattern>co.aikar.idb</pattern>
<shadedPattern>net.draycia.simplechat.libs.idb</shadedPattern>
</relocation>
<relocation>
<pattern>net.kyori</pattern>
<shadedPattern>net.draycia.simplechat.libs.kyori</shadedPattern>
</relocation>
<relocation>
<pattern>io.papermc.lib</pattern>
<shadedPattern>net.draycia.simplechat.libs.paperlib</shadedPattern>
</relocation>
<relocation>
<pattern>com.fasterxml</pattern>
<shadedPattern>net.draycia.simplechat.libs.fasterxml</shadedPattern>
</relocation>
<relocation>
<pattern>com.neovisionaries</pattern>
<shadedPattern>net.draycia.simplechat.libs.neovisionaries</shadedPattern>
</relocation>
<relocation>
<pattern>okio</pattern>
<shadedPattern>net.draycia.simplechat.libs.okio</shadedPattern>
</relocation>
<relocation>
<pattern>okhttp3</pattern>
<shadedPattern>net.draycia.simplechat.libs.okhttp3</shadedPattern>
</relocation>
<relocation>
<pattern>org.checkerframework</pattern>
<shadedPattern>net.draycia.simplechat.libs.checkerframework</shadedPattern>
</relocation>
</relocations>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>testCompile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<repositories>
<!-- Spigot API -->
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<!-- Kyori -->
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
<!-- PlaceholderAPI -->
<repository>
<id>placeholderapi</id>
<url>http://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
<!-- Towny, VaultAPI -->
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<!-- ACF -->
<repository>
<id>aikar</id>
<url>https://repo.aikar.co/content/groups/aikar/</url>
</repository>
<!-- NuVotifier -->
<repository>
<id>bintray-repo</id>
<url>https://dl.bintray.com/ichbinjoe/public/</url>
</repository>
<!-- BungeeChannelAPI -->
<repository>
<id>codemc-repo</id>
<url>https://repo.codemc.org/repository/maven-public/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<!-- mcMMO and MiniMessage must be compiled locally -->
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- ACF - command framework -->
<dependency>
<groupId>co.aikar</groupId>
<artifactId>acf-bukkit</artifactId>
<version>0.5.0-SNAPSHOT</version>
</dependency>
<!-- Components and formatting -->
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-api</artifactId>
<version>4.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-nbt</artifactId>
<version>4.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-bukkit</artifactId>
<version>4.0.0-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Must be built locally for the time being -->
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-minimessage</artifactId>
<version>3.0.0-SNAPSHOT</version>
</dependency>
<!-- Placeholders -->
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.10.6</version>
<scope>provided</scope>
</dependency>
<!-- Towny chats - nation & town -->
<dependency>
<groupId>com.github.TownyAdvanced</groupId>
<artifactId>Towny</artifactId>
<version>0.96.1.11</version>
<scope>provided</scope>
</dependency>
<!-- mcMMO - no repository, add to maven local -->
<dependency>
<groupId>com.gmail.nossr50.mcMMO</groupId>
<artifactId>mcMMO</artifactId>
<version>2.1.130</version>
<scope>provided</scope>
</dependency>
<!-- Vault for permissions / groups -->
<dependency>
<groupId>com.github.MilkBowl</groupId>
<artifactId>VaultAPI</artifactId>
<version>1.7</version>
<scope>provided</scope>
</dependency>
<!-- NuVotifier for vote messages in discord bridge -->
<dependency>
<groupId>com.vexsoftware</groupId>
<artifactId>nuvotifier-universal</artifactId>
<version>2.6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>co.aikar</groupId>
<artifactId>idb-bukkit</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>2.4.1</version>
</dependency>
<!-- Easier bungee handling -->
<dependency>
<groupId>io.github.leonardosnt</groupId>
<artifactId>bungeechannelapi</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<!-- Redis -->
<dependency>
<groupId>io.lettuce</groupId>
<artifactId>lettuce-core</artifactId>
<version>6.0.0.M1</version>
</dependency>
</dependencies>
</project>
@@ -1,30 +0,0 @@
package net.draycia.simplechat.listeners;
import net.draycia.simplechat.SimpleChat;
import net.draycia.simplechat.channels.ChatChannel;
import net.draycia.simplechat.events.ChatFormatEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
public class FilterHandler implements Listener {
private SimpleChat simpleChat;
public FilterHandler(SimpleChat simpleChat) {
this.simpleChat = simpleChat;
}
@EventHandler(priority = EventPriority.LOWEST)
public void onFilter(ChatFormatEvent event) {
ChatChannel channel = event.getChatChannel();
String filterText = simpleChat.getConfig().getString("filter-text", "****");
if (channel.filterEnabled() && simpleChat.getConfig().contains("filters")) {
for (String entry : simpleChat.getConfig().getStringList("filters")) {
event.setMessage(event.getMessage().replaceAll(entry, filterText));
}
}
}
}