mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-02 06:28:54 +00:00
Begin (broken) modularization
This commit is contained in:
1 parent
b3a0d71ba8
commit
ad8089855c
56 files changed
+553
-369
No files matched your search
@@ -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>
|
||||
+24
@@ -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;
|
||||
}
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
package net.draycia.simplechatmoderation.commands;
|
||||
|
||||
import co.aikar.commands.BaseCommand;
|
||||
import co.aikar.commands.CommandIssuer;
|
||||
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;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandAlias("clearchat|cc")
|
||||
@CommandPermission("simplechat.clearchat.clear")
|
||||
public class ClearChatCommand extends BaseCommand {
|
||||
|
||||
private SimpleChatModeration moderation;
|
||||
|
||||
public ClearChatCommand(SimpleChatModeration moderation) {
|
||||
this.moderation = moderation;
|
||||
}
|
||||
|
||||
@Default
|
||||
public void baseCommand(CommandIssuer issuer) {
|
||||
String format = moderation.getConfig().getString("clear-chat.message", "");
|
||||
Component component = MiniMessage.get().parse(format, "br", "\n");
|
||||
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (player.hasPermission("simplechat.clearchat.exempt")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Audience audience = moderation.getSimpleChat().getAudiences().player(player);
|
||||
|
||||
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 = moderation.getConfig().getString("language.clear-notify");
|
||||
audience.sendMessage(MiniMessage.get().parse(message, "player", name));
|
||||
}
|
||||
|
||||
if (player.hasPermission("simplechat.clearchat.exempt")) {
|
||||
String message = moderation.getConfig().getString("language.clear-exempt");
|
||||
audience.sendMessage(MiniMessage.get().parse(message, "player", name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
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;
|
||||
|
||||
@CommandAlias("mute")
|
||||
@CommandPermission("simplechat.mute")
|
||||
public class MuteCommand extends BaseCommand {
|
||||
|
||||
private SimpleChatModeration moderation;
|
||||
|
||||
public MuteCommand(SimpleChatModeration moderation) {
|
||||
this.moderation = moderation;
|
||||
}
|
||||
|
||||
@Default
|
||||
@CommandCompletion("@players")
|
||||
public void baseCommand(CommandSender sender, ChatUser targetUser) {
|
||||
String format;
|
||||
|
||||
if (targetUser.isMuted()) {
|
||||
targetUser.setMuted(true);
|
||||
format = moderation.getConfig().getString("language.no-longer-muted");
|
||||
} else {
|
||||
targetUser.setMuted(false);
|
||||
format = moderation.getConfig().getString("language.is-now-muted");
|
||||
}
|
||||
|
||||
Component message = MiniMessage.get().parse(format, "br", "\n",
|
||||
"user", targetUser.asOfflinePlayer().getName());
|
||||
|
||||
moderation.getSimpleChat().getAudiences().audience(sender).sendMessage(message);
|
||||
}
|
||||
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
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.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;
|
||||
|
||||
@CommandAlias("shadowmute|sm|smute")
|
||||
@CommandPermission("simplechat.shadowmute")
|
||||
public class ShadowMuteCommand extends BaseCommand {
|
||||
|
||||
private SimpleChatModeration moderation;
|
||||
|
||||
public ShadowMuteCommand(SimpleChatModeration moderation) {
|
||||
this.moderation = moderation;
|
||||
}
|
||||
|
||||
@Default
|
||||
@CommandCompletion("@players")
|
||||
public void baseCommand(CommandSender sender, ChatUser targetUser) {
|
||||
String format;
|
||||
|
||||
if (targetUser.isShadowMuted()) {
|
||||
targetUser.setShadowMuted(false);
|
||||
format = moderation.getConfig().getString("language.no-longer-shadow-muted");
|
||||
} else {
|
||||
targetUser.setShadowMuted(true);
|
||||
format = moderation.getConfig().getString("language.is-now-shadow-muted");
|
||||
}
|
||||
|
||||
Component message = MiniMessage.get().parse(format, "br", "\n",
|
||||
"user", targetUser.asOfflinePlayer().getName());
|
||||
|
||||
moderation.getSimpleChat().getAudiences().audience(sender).sendMessage(message);
|
||||
}
|
||||
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
package net.draycia.simplechatmoderation.listeners;
|
||||
|
||||
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 SimpleChatModeration moderation;
|
||||
|
||||
public CapsHandler(SimpleChatModeration moderation) {
|
||||
this.moderation = moderation;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onMessage(ChatFormatEvent event) {
|
||||
if (!moderation.getConfig().getBoolean("caps-protection.enabled")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(event.getMessage().length() >= moderation.getConfig().getInt("caps-protection.minimum-length"))) {
|
||||
return;
|
||||
}
|
||||
|
||||
int amountOfCaps = 0;
|
||||
|
||||
for (char letter : event.getMessage().toCharArray()) {
|
||||
if (Character.isUpperCase(letter)) {
|
||||
amountOfCaps++;
|
||||
}
|
||||
}
|
||||
|
||||
double capsPercentage = (amountOfCaps * 100.0) / event.getMessage().length();
|
||||
|
||||
if (!(capsPercentage >= moderation.getConfig().getDouble("caps-protection.percent-caps"))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (moderation.getConfig().getBoolean("block-message")) {
|
||||
event.setCancelled(true);
|
||||
} else {
|
||||
event.setMessage(event.getMessage().toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+41
@@ -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]
|
||||
Reference in new issue
Block a user