Finished SkibidiBlocker and added AntiSpam
This commit is contained in:
parent
aeeaa83745
commit
6fc6fb67cf
11 changed files with 67 additions and 18 deletions
|
|
@ -7,6 +7,6 @@
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="src" path="src"/>
|
<classpathentry kind="src" path="src"/>
|
||||||
<classpathentry combineaccessrules="false" kind="src" path="/tenkumaLib"/>
|
<classpathentry combineaccessrules="false" kind="src" path="/tenkumaLib"/>
|
||||||
<classpathentry kind="lib" path="/home/adrian/Downloads/craftbukkit-1060.jar"/>
|
<classpathentry kind="lib" path="E:/craftbukkit-1060.jar"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
|
||||||
1
bin/.gitignore
vendored
Normal file
1
bin/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
/gd/
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -1,6 +1,15 @@
|
||||||
|
# Blocks duplicated messages
|
||||||
|
antiSpam: true
|
||||||
|
antiSpamLightning: false
|
||||||
|
|
||||||
|
# Adds color code for rainbow
|
||||||
|
rainbowChat: true
|
||||||
|
rainbowChatModifier: 'z' # Single word you need to put after & to use the rainbow
|
||||||
|
|
||||||
# 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
|
||||||
|
skibidiBlockerVerboseMessage: "This is a bad word."
|
||||||
skibidiBlockerWords:
|
skibidiBlockerWords:
|
||||||
- 'skibidi'
|
- 'skibidi'
|
||||||
|
|
|
||||||
|
|
@ -3,4 +3,4 @@ database: false
|
||||||
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: '1.0'
|
version: '1.1'
|
||||||
30
src/gd/rf/adrianvictor/stuff/AntiSpam.java
Normal file
30
src/gd/rf/adrianvictor/stuff/AntiSpam.java
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
package gd.rf.adrianvictor.stuff;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.event.player.PlayerChatEvent;
|
||||||
|
import org.bukkit.event.player.PlayerListener;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import gd.rf.adrianvictor.lib.PlayerEx;
|
||||||
|
|
||||||
|
public class AntiSpam extends PlayerListener {
|
||||||
|
private final Map<UUID, String> lastMessages = new HashMap<>();
|
||||||
|
private JavaPlugin plugin;
|
||||||
|
|
||||||
|
public AntiSpam(JavaPlugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onPlayerChat(PlayerChatEvent event) {
|
||||||
|
if (lastMessages.containsKey(event.getPlayer().getUniqueId()) && lastMessages.get(event.getPlayer().getUniqueId()).contains(event.getMessage())) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
event.getPlayer().sendMessage("Stop spamming.");
|
||||||
|
|
||||||
|
if (plugin.getConfiguration().getBoolean("antiSpamLightning", false)) PlayerEx.strikeLightning(event.getPlayer());
|
||||||
|
}
|
||||||
|
lastMessages.put(event.getPlayer().getUniqueId(), event.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -28,15 +28,24 @@ public class GhostsAndStuff extends JavaPlugin {
|
||||||
loadModules();
|
loadModules();
|
||||||
logger.info("is starting.");
|
logger.info("is starting.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadModules() {
|
public void loadModules() {
|
||||||
|
|
||||||
|
// AntiSpam
|
||||||
|
if (this.getConfiguration().getBoolean("antiSpam", true)) {
|
||||||
|
PlayerListener antiSpam = new AntiSpam(this);
|
||||||
|
pm.registerEvent(Type.PLAYER_CHAT, antiSpam, Priority.High, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
// RainbowChat
|
||||||
|
if (this.getConfiguration().getBoolean("rainbowChat", true)) {
|
||||||
PlayerListener rainbowChat = new RainbowChat(this);
|
PlayerListener rainbowChat = new RainbowChat(this);
|
||||||
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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 == null || words.isEmpty()) {
|
||||||
logger.warning("SkibidiBlocker is enabled, but no words were provided. Disabling.");
|
logger.warning("SkibidiBlocker is enabled, but no words were provided. Disabling.");
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ public class RainbowChat extends PlayerListener {
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
||||||
while (index < message.length()) {
|
while (index < message.length()) {
|
||||||
int startIndex = message.indexOf("§z", index);
|
int startIndex = message.indexOf("§" + plugin.getConfiguration().getString("rainbowChatModifier", "z"), index);
|
||||||
if (startIndex == -1) {
|
if (startIndex == -1) {
|
||||||
result.append(message.substring(index));
|
result.append(message.substring(index));
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@ import java.util.List;
|
||||||
import org.bukkit.event.player.PlayerChatEvent;
|
import org.bukkit.event.player.PlayerChatEvent;
|
||||||
import org.bukkit.event.player.PlayerListener;
|
import org.bukkit.event.player.PlayerListener;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import gd.rf.adrianvictor.lib.Color;
|
||||||
import gd.rf.adrianvictor.lib.Log;
|
import gd.rf.adrianvictor.lib.Log;
|
||||||
|
|
||||||
public class SkibidiBlocker extends PlayerListener {
|
public class SkibidiBlocker extends PlayerListener {
|
||||||
|
|
@ -29,20 +31,18 @@ public class SkibidiBlocker extends PlayerListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean caseSensitive = plugin.getConfiguration().getBoolean("skibidiBlockerCaseSensitive", true);
|
boolean caseSensitive = plugin.getConfiguration().getBoolean("skibidiBlockerCaseSensitive", true);
|
||||||
|
|
||||||
for (String blockedWord : blockedWords) {
|
for (String blockedWord : blockedWords) {
|
||||||
|
String finalMessage;
|
||||||
if (!caseSensitive) {
|
if (!caseSensitive) {
|
||||||
if (message.toLowerCase().contains(blockedWord.toLowerCase())) {
|
finalMessage = message.toLowerCase();
|
||||||
logger.info(event.getPlayer().getDisplayName() + " said a blocked word (case insensitive).");
|
|
||||||
event.getPlayer().getWorld().strikeLightning(event.getPlayer().getLocation()); // Ensure it works
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (message.contains(blockedWord)) {
|
finalMessage = message;
|
||||||
logger.info(event.getPlayer().getDisplayName() + " said a blocked word (case sensitive).");
|
}
|
||||||
|
if (message.contains(blockedWord.toLowerCase())) {
|
||||||
|
if (plugin.getConfiguration().getBoolean("skibidiBlockerVerbose", true)) {
|
||||||
|
event.getPlayer().sendMessage(Color.formatColors(plugin.getConfiguration().getString("skibidiBlockerVerboseMessage", "This is a bad word.")));
|
||||||
|
}
|
||||||
event.getPlayer().getWorld().strikeLightning(event.getPlayer().getLocation());
|
event.getPlayer().getWorld().strikeLightning(event.getPlayer().getLocation());
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue