This commit is contained in:
天クマ 2025-03-19 06:42:38 -03:00
commit aeeaa83745
12 changed files with 192 additions and 0 deletions

12
.classpath Normal file
View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src"/>
<classpathentry combineaccessrules="false" kind="src" path="/tenkumaLib"/>
<classpathentry kind="lib" path="/home/adrian/Downloads/craftbukkit-1060.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

17
.project Normal file
View file

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>GhostsAndStuff</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View file

@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8

View file

@ -0,0 +1,9 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=1.8

Binary file not shown.

Binary file not shown.

Binary file not shown.

6
config.yml Normal file
View file

@ -0,0 +1,6 @@
# Strikes a lightning to the player who says specific words
skibidiBlocker: true
skibidiBlockerCaseSensitive: false
skibidiBlockerWords:
- 'skibidi'

6
plugin.yml Normal file
View file

@ -0,0 +1,6 @@
author: tenkuma
database: false
main: gd.rf.adrianvictor.stuff.GhostsAndStuff
name: GhostsAndStuff
url: https://adrianvictor.rf.gd
version: '1.0'

View file

@ -0,0 +1,49 @@
package gd.rf.adrianvictor.stuff;
import gd.rf.adrianvictor.lib.ConfigurationEx;
import gd.rf.adrianvictor.lib.Log;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event.Type;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.List;
public class GhostsAndStuff extends JavaPlugin {
ConfigurationEx config;
PluginManager pm;
Log logger;
@Override
public void onDisable() {
logger.info("is being disabled.");
}
@Override
public void onEnable() {
logger = new Log(this);
pm = this.getServer().getPluginManager();
config = new ConfigurationEx(this, "config.yml", logger);
config.loadConfig();
loadModules();
logger.info("is starting.");
}
public void loadModules() {
PlayerListener rainbowChat = new RainbowChat(this);
logger.info("Loading module RainbowChat");
pm.registerEvent(Type.PLAYER_CHAT, rainbowChat, Priority.High, this);
if (this.getConfiguration().getBoolean("skibidiBlocker", true)) {
logger.info("Loading module SkibidiBlocker");
List<String> words = this.getConfiguration().getStringList("skibidiBlockerWords", null);
if (words == null || words.isEmpty()) {
logger.warning("SkibidiBlocker is enabled, but no words were provided. Disabling.");
} else {
PlayerListener verboseWorldChange = new SkibidiBlocker(this, logger);
pm.registerEvent(Type.PLAYER_CHAT, verboseWorldChange, Priority.High, this);
}
}
}
}

View file

@ -0,0 +1,42 @@
package gd.rf.adrianvictor.stuff;
import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.plugin.java.JavaPlugin;
import gd.rf.adrianvictor.lib.Color;
public class RainbowChat extends PlayerListener {
JavaPlugin plugin;
public RainbowChat(JavaPlugin _plugin) {
plugin = _plugin;
}
public void onPlayerChat(PlayerChatEvent event) {
StringBuilder result = new StringBuilder();
String message = Color.formatColors(event.getMessage());
int index = 0;
while (index < message.length()) {
int startIndex = message.indexOf("§z", index);
if (startIndex == -1) {
result.append(message.substring(index));
break;
}
result.append(message, index, startIndex);
int endIndex = startIndex + 2;
while (endIndex < message.length() && message.charAt(endIndex) != '§') {
endIndex++;
}
String textToColor = message.substring(startIndex + 2, endIndex);
result.append(Color.rainbow(textToColor));
index = endIndex;
}
event.setMessage(result.toString());
}
}

View 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.Log;
public class SkibidiBlocker extends PlayerListener {
JavaPlugin plugin;
Log logger;
public SkibidiBlocker(JavaPlugin _plugin, Log _logger) {
plugin = _plugin;
logger = _logger;
}
public void onPlayerChat(PlayerChatEvent event) {
String message = event.getMessage();
List<String> blockedWords = plugin.getConfiguration().getStringList("skibidiBlockerWords", null);
if (blockedWords == null) {
logger.warning("Blocked words list is null!");
return;
}
if (blockedWords.isEmpty()) {
logger.warning("Blocked words list is empty!");
return;
}
boolean caseSensitive = plugin.getConfiguration().getBoolean("skibidiBlockerCaseSensitive", true);
for (String blockedWord : blockedWords) {
if (!caseSensitive) {
if (message.toLowerCase().contains(blockedWord.toLowerCase())) {
logger.info(event.getPlayer().getDisplayName() + " said a blocked word (case insensitive).");
event.getPlayer().getWorld().strikeLightning(event.getPlayer().getLocation()); // Ensure it works
return;
}
} else {
if (message.contains(blockedWord)) {
logger.info(event.getPlayer().getDisplayName() + " said a blocked word (case sensitive).");
event.getPlayer().getWorld().strikeLightning(event.getPlayer().getLocation());
return;
}
}
}
}
}