diff --git a/pom.xml b/pom.xml index 04bf3a3..63b8f20 100644 --- a/pom.xml +++ b/pom.xml @@ -44,11 +44,12 @@ 2.11.2 provided - - org.xerial - sqlite-jdbc - 3.39.3.0 - + + + + + + club.minnced discord-webhooks diff --git a/src/main/java/uranium/Main.java b/src/main/java/uranium/Main.java index 530d724..a183ea8 100644 --- a/src/main/java/uranium/Main.java +++ b/src/main/java/uranium/Main.java @@ -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") diff --git a/src/main/java/uranium/listeners/ChatListener.java b/src/main/java/uranium/listeners/ChatListener.java index 6dddd8a..319af22 100644 --- a/src/main/java/uranium/listeners/ChatListener.java +++ b/src/main/java/uranium/listeners/ChatListener.java @@ -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); diff --git a/src/main/java/uranium/listeners/CommandListener.java b/src/main/java/uranium/listeners/CommandListener.java index 9be4f11..305a5eb 100644 --- a/src/main/java/uranium/listeners/CommandListener.java +++ b/src/main/java/uranium/listeners/CommandListener.java @@ -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(); diff --git a/src/main/java/uranium/tasks/IPCheck.java b/src/main/java/uranium/tasks/IPCheck.java new file mode 100644 index 0000000..01b473c --- /dev/null +++ b/src/main/java/uranium/tasks/IPCheck.java @@ -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() { + + } + +} \ No newline at end of file diff --git a/src/main/java/uranium/util/StringUtil.java b/src/main/java/uranium/util/StringUtil.java index d3b96f8..324c71c 100644 --- a/src/main/java/uranium/util/StringUtil.java +++ b/src/main/java/uranium/util/StringUtil.java @@ -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) { diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index ffa4122..a45e3d9 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -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? diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index f759901..daa06e4 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -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