Added CommandTypoBlocker
This commit is contained in:
parent
023106b3bc
commit
3e6087e60c
5 changed files with 73 additions and 3 deletions
Binary file not shown.
11
config.yml
11
config.yml
|
|
@ -6,10 +6,19 @@ antiSpamLightning: false
|
||||||
rainbowChat: true
|
rainbowChat: true
|
||||||
rainbowChatModifier: 'z' # Single word you need to put after & to use the rainbow
|
rainbowChatModifier: 'z' # Single word you need to put after & to use the rainbow
|
||||||
|
|
||||||
|
# Prevents users from broadcasting sensitive commands by forgetting the /
|
||||||
|
commandTypoBlocker: true
|
||||||
|
commandTypoBlockerCaseSensitive: false
|
||||||
|
commandTypoBlockerVerbose: true
|
||||||
|
commandTypoBlockerVerboseMessage: "&cYour message begins with a sensitive command, you may be leaking something sensitive by forgetting the slash!"
|
||||||
|
commandTypoBlockerWords:
|
||||||
|
- 'login'
|
||||||
|
- 'register'
|
||||||
|
|
||||||
# Strikes a lightning to the player who says specific words
|
# Strikes a lightning to the player who says specific words
|
||||||
skibidiBlocker: true
|
skibidiBlocker: true
|
||||||
skibidiBlockerCaseSensitive: false
|
skibidiBlockerCaseSensitive: false
|
||||||
skibidiBlockerVerbose: true
|
skibidiBlockerVerbose: true
|
||||||
skibidiBlockerVerboseMessage: "This is a bad word."
|
skibidiBlockerVerboseMessage: "This is a bad word."
|
||||||
skibidiBlockerWords:
|
skibidiBlockerWords:
|
||||||
- 'skibidi'
|
- 'skibidi'
|
||||||
|
|
@ -2,7 +2,7 @@ author: tenkuma
|
||||||
main: gd.rf.adrianvictor.stuff.GhostsAndStuff
|
main: gd.rf.adrianvictor.stuff.GhostsAndStuff
|
||||||
name: GhostsAndStuff
|
name: GhostsAndStuff
|
||||||
url: https://adrianvictor.rf.gd
|
url: https://adrianvictor.rf.gd
|
||||||
version: '0.5'
|
version: '0.6'
|
||||||
commands:
|
commands:
|
||||||
gettime:
|
gettime:
|
||||||
description: Prints the time for the current world.
|
description: Prints the time for the current world.
|
||||||
|
|
|
||||||
49
src/gd/rf/adrianvictor/stuff/CommandTypoBlocker.java
Normal file
49
src/gd/rf/adrianvictor/stuff/CommandTypoBlocker.java
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
package gd.rf.adrianvictor.stuff;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import org.bukkit.event.player.PlayerChatEvent;
|
||||||
|
import org.bukkit.event.player.PlayerListener;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import gd.rf.adrianvictor.lib.Color;
|
||||||
|
import gd.rf.adrianvictor.lib.Log;
|
||||||
|
|
||||||
|
public class CommandTypoBlocker extends PlayerListener {
|
||||||
|
JavaPlugin plugin;
|
||||||
|
Log logger;
|
||||||
|
|
||||||
|
public CommandTypoBlocker(JavaPlugin _plugin, Log _logger) {
|
||||||
|
plugin = _plugin;
|
||||||
|
logger = _logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onPlayerChat(PlayerChatEvent event) {
|
||||||
|
String message = event.getMessage();
|
||||||
|
List<String> protectedCommands = plugin.getConfiguration().getStringList("commandTypoBlockerWords", null);
|
||||||
|
|
||||||
|
if (protectedCommands == null) {
|
||||||
|
logger.warning("Commands list is null!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (protectedCommands.isEmpty()) {
|
||||||
|
logger.warning("Commands list is empty!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean caseSensitive = plugin.getConfiguration().getBoolean("commandTypoBlockerCaseSensitive", true);
|
||||||
|
for (String protectedWord : protectedCommands) {
|
||||||
|
String finalMessage;
|
||||||
|
if (!caseSensitive) {
|
||||||
|
finalMessage = message.toLowerCase();
|
||||||
|
} else {
|
||||||
|
finalMessage = message;
|
||||||
|
}
|
||||||
|
if (message.startsWith(protectedWord.toLowerCase()) || message.startsWith(protectedWord.toLowerCase(), 1)) {
|
||||||
|
if (plugin.getConfiguration().getBoolean("commandTypoBlockerVerbose", true)) {
|
||||||
|
event.getPlayer().sendMessage(Color.formatColors(plugin.getConfiguration().getString("commandTypoBlockerVerboseMessage", "&cYour message begins with a sensitive command, you may be leaking something sensitive by forgetting the slash!")));
|
||||||
|
}
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -44,12 +44,24 @@ public class GhostsAndStuff extends JavaPlugin {
|
||||||
logger.info("Loading module RainbowChat");
|
logger.info("Loading module RainbowChat");
|
||||||
pm.registerEvent(Type.PLAYER_CHAT, rainbowChat, Priority.High, this);
|
pm.registerEvent(Type.PLAYER_CHAT, rainbowChat, Priority.High, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CommandTypoBlocker
|
||||||
|
if (this.getConfiguration().getBoolean("commandTypoBlocker", true)) {
|
||||||
|
logger.info("Loading module CommandTypoBlocker");
|
||||||
|
List<String> words = this.getConfiguration().getStringList("commandTypoBlockerWords", null);
|
||||||
|
if (words.isEmpty()) {
|
||||||
|
logger.warning("CommandTypoBlocker is enabled, but no words were provided. Disabling.");
|
||||||
|
} else {
|
||||||
|
PlayerListener commandTypoBlocker = new CommandTypoBlocker(this, logger);
|
||||||
|
pm.registerEvent(Type.PLAYER_CHAT, commandTypoBlocker, Priority.High, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// SkibidiBlocker
|
// SkibidiBlocker
|
||||||
if (this.getConfiguration().getBoolean("skibidiBlocker", true)) {
|
if (this.getConfiguration().getBoolean("skibidiBlocker", true)) {
|
||||||
logger.info("Loading module SkibidiBlocker");
|
logger.info("Loading module SkibidiBlocker");
|
||||||
List<String> words = this.getConfiguration().getStringList("skibidiBlockerWords", null);
|
List<String> words = this.getConfiguration().getStringList("skibidiBlockerWords", null);
|
||||||
if (words == null || words.isEmpty()) {
|
if (words.isEmpty()) {
|
||||||
logger.warning("SkibidiBlocker is enabled, but no words were provided. Disabling.");
|
logger.warning("SkibidiBlocker is enabled, but no words were provided. Disabling.");
|
||||||
} else {
|
} else {
|
||||||
PlayerListener verboseWorldChange = new SkibidiBlocker(this, logger);
|
PlayerListener verboseWorldChange = new SkibidiBlocker(this, logger);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue