mirror of
https://github.com/darverdevs/Uranium.git
synced 2024-12-21 22:54:10 -08:00
feat(config): add option to check commands with the chat filter
This commit is contained in:
parent
97ebb635a7
commit
98ee42ad48
11
pom.xml
11
pom.xml
|
@ -44,11 +44,12 @@
|
|||
<version>2.11.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.xerial</groupId>
|
||||
<artifactId>sqlite-jdbc</artifactId>
|
||||
<version>3.39.3.0</version>
|
||||
</dependency>
|
||||
<!-- Unused until a future release -->
|
||||
<!--<dependency>-->
|
||||
<!-- <groupId>org.xerial</groupId>-->
|
||||
<!-- <artifactId>sqlite-jdbc</artifactId>-->
|
||||
<!-- <version>3.39.3.0</version>-->
|
||||
<!--</dependency>-->
|
||||
<dependency>
|
||||
<groupId>club.minnced</groupId>
|
||||
<artifactId>discord-webhooks</artifactId>
|
||||
|
|
|
@ -17,6 +17,7 @@ public class Main extends JavaPlugin implements PluginMessageListener {
|
|||
setupCommands();
|
||||
setupTasks();
|
||||
setupPluginChannels();
|
||||
getLogger().info("Initialization is complete.");
|
||||
}
|
||||
|
||||
public void onDisable() {
|
||||
|
@ -25,6 +26,7 @@ public class Main extends JavaPlugin implements PluginMessageListener {
|
|||
}
|
||||
|
||||
private void setupListeners() {
|
||||
getLogger().info("Initializing events...");
|
||||
getServer().getPluginManager().registerEvents(new PlayerListener(this), this);
|
||||
getServer().getPluginManager().registerEvents(new ChatListener(this), this);
|
||||
getServer().getPluginManager().registerEvents(new CommandListener(this), this);
|
||||
|
@ -40,6 +42,7 @@ public class Main extends JavaPlugin implements PluginMessageListener {
|
|||
}
|
||||
|
||||
private void setupPluginChannels() {
|
||||
getLogger().info("Initializing plugin channels...");
|
||||
getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
||||
getServer().getMessenger().registerIncomingPluginChannel(this, "BungeeCord", this);
|
||||
}
|
||||
|
@ -48,7 +51,6 @@ public class Main extends JavaPlugin implements PluginMessageListener {
|
|||
getLogger().info("Initializing config...");
|
||||
getConfig().options().copyDefaults(true);
|
||||
saveConfig();
|
||||
getLogger().info("Done!");
|
||||
}
|
||||
|
||||
@SuppressWarnings("UnstableApiUsage")
|
||||
|
|
|
@ -19,6 +19,7 @@ public class ChatListener implements Listener {
|
|||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||
public void onPlayerChat(AsyncPlayerChatEvent event) {
|
||||
if (!plugin.getConfig().getBoolean("chat-filter.enabled")) return;
|
||||
User user = UserManager.getUser(event.getPlayer());
|
||||
String message = event.getMessage();
|
||||
if (user.hasPermission("uranium.bypass")) return;
|
||||
|
@ -45,9 +46,9 @@ public class ChatListener implements Listener {
|
|||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
|
||||
public void onPlayerChat2(AsyncPlayerChatEvent event) {
|
||||
if (!plugin.getConfig().getBoolean("chat-filter.enabled")) return;
|
||||
User user = UserManager.getUser(event.getPlayer());
|
||||
String message = event.getMessage();
|
||||
if (!plugin.getConfig().getBoolean("chat-filter.enabled")) return;
|
||||
|
||||
if (!StringUtil.validateMessage(message)) {
|
||||
event.setCancelled(true);
|
||||
|
|
|
@ -33,6 +33,8 @@ public class CommandListener implements Listener {
|
|||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
|
||||
public void onPlayerPreprocessCommand2(PlayerCommandPreprocessEvent event) {
|
||||
if (!plugin.getConfig().getBoolean("chat-filter.enabled")) return;
|
||||
if (!plugin.getConfig().getBoolean("chat-filter.check-commands")) return;
|
||||
User user = UserManager.getUser(event.getPlayer());
|
||||
String message = event.getMessage();
|
||||
|
||||
|
|
17
src/main/java/uranium/tasks/IPCheck.java
Normal file
17
src/main/java/uranium/tasks/IPCheck.java
Normal file
|
@ -0,0 +1,17 @@
|
|||
package uranium.tasks;
|
||||
|
||||
import uranium.Main;
|
||||
|
||||
public class IPCheck implements Runnable {
|
||||
|
||||
private final Main plugin;
|
||||
|
||||
public IPCheck(Main plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -23,12 +23,7 @@ public class StringUtil {
|
|||
}
|
||||
|
||||
private static String removeCrap(String s) {
|
||||
return s
|
||||
.replace(" ", "")
|
||||
.replace("_", "")
|
||||
.replace("*", "")
|
||||
.replace(".", "")
|
||||
.replace("/", ""); // TODO: Replace with regex
|
||||
return s.replaceAll("[^a-zA-Z0-9]", "");
|
||||
}
|
||||
|
||||
public static boolean validateUsername(String username) {
|
||||
|
|
|
@ -3,6 +3,8 @@ chat-filter:
|
|||
enabled: true
|
||||
# Should usernames be checked on join?
|
||||
check-usernames: true
|
||||
# Should we also check the contents of commands?
|
||||
check-commands: true
|
||||
# Should posting the same message twice in a row be allowed?
|
||||
double-posting: false
|
||||
# Should there be an enforced delay between messages?
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
name: Uranium
|
||||
version: 1.0.0-LITE
|
||||
version: 1.0-LITE
|
||||
main: uranium.Main
|
||||
description: A moderation utility for Eaglercraft 1.8 servers.
|
||||
author: Cold
|
||||
|
|
Loading…
Reference in New Issue
Block a user