-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2a8834a
commit 1a4eaf6
Showing
1 changed file
with
33 additions
and
50 deletions.
There are no files selected for viewing
83 changes: 33 additions & 50 deletions
83
src/main/java/me/ShermansWorld/AlathraExtras/chat/ChatListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,44 @@ | ||
package me.ShermansWorld.AlathraExtras.chat; | ||
|
||
import io.papermc.paper.event.player.AsyncChatEvent; | ||
import me.ShermansWorld.AlathraExtras.Helper; | ||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.player.AsyncPlayerChatEvent; | ||
|
||
public class ChatListener implements Listener { | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class ChatListener implements Listener { | ||
private static final PlainTextComponentSerializer plainText = PlainTextComponentSerializer.plainText(); | ||
private static final Map<String, String> replacements; | ||
static { | ||
replacements = new HashMap<>(); | ||
replacements.put("(?i)stoneworks", "rock function "); | ||
replacements.put("(?i)stone works", "rock function "); | ||
replacements.put("(?i)stonework", "rock function "); | ||
replacements.put("(?i)\\ssw\\s", "rock function "); | ||
replacements.put("(?i)shears", "✂"); | ||
replacements.put("(?i)o_o", Helper.color("&9&lO_O&r")); | ||
replacements.put("->", "➡"); | ||
replacements.put("<-", "⬅"); | ||
replacements.put(":\\)", "☺"); | ||
replacements.put(":\\(", "☹"); | ||
replacements.put("~~", "〰"); | ||
replacements.put("<3", Helper.color("&c❤&r")); | ||
replacements.put("(?i)\\^up", "⬆"); | ||
replacements.put("<>", Helper.color("&a♢&r")); | ||
replacements.put("(?i)o==", Helper.color("&b☄&r")); | ||
} | ||
|
||
@EventHandler | ||
public void chatReplace(AsyncPlayerChatEvent e) { | ||
if (e.getMessage().toLowerCase().contains("stoneworks")) { | ||
e.setMessage(e.getMessage().toLowerCase().replace("stoneworks", "rock function ")); | ||
} | ||
if (e.getMessage().toLowerCase().contains("stone works")) { | ||
e.setMessage(e.getMessage().toLowerCase().replace("stone works", "rock function ")); | ||
} | ||
if (e.getMessage().toLowerCase().contains("stonework")) { | ||
e.setMessage(e.getMessage().toLowerCase().replace("stonework", "rock function ")); | ||
} | ||
if (e.getMessage().toLowerCase().contains(" sw ")) { | ||
e.setMessage(e.getMessage().toLowerCase().replace(" sw ", "rock function ")); | ||
} | ||
if (e.getMessage().toLowerCase().contains("shears")) { | ||
e.setMessage(e.getMessage().toLowerCase().replace("shears", "✂")); | ||
} | ||
if (e.getMessage().toLowerCase().contains("o_o")) { | ||
e.setMessage(e.getMessage().replace("o_o", Helper.color("&9&lO_O&r"))); | ||
} | ||
if (e.getMessage().toLowerCase().contains("->")) { | ||
e.setMessage(e.getMessage().replace("->", "➡")); | ||
} | ||
if (e.getMessage().toLowerCase().contains("<-")) { | ||
e.setMessage(e.getMessage().replace("<-", "⬅")); | ||
} | ||
if (e.getMessage().toLowerCase().contains(":)")) { | ||
e.setMessage(e.getMessage().replace(":)", "☺")); | ||
} | ||
if (e.getMessage().toLowerCase().contains(":(")) { | ||
e.setMessage(e.getMessage().replace(":(", "☹")); | ||
} | ||
if (e.getMessage().toLowerCase().contains("~~")) { | ||
e.setMessage(e.getMessage().replace("~~", "〰")); | ||
} | ||
if (e.getMessage().toLowerCase().contains("<3")) { | ||
e.setMessage(e.getMessage().replace("<3", Helper.color("&c❤&r"))); | ||
} | ||
if (e.getMessage().toLowerCase().contains("<>")) { | ||
e.setMessage(e.getMessage().replace("<>", Helper.color("&a♢&r"))); | ||
} | ||
if (e.getMessage().toLowerCase().contains("^up")) { | ||
e.setMessage(e.getMessage().toLowerCase().replace("^up", "⬆")); | ||
} | ||
if (e.getMessage().toLowerCase().contains("<>")) { | ||
e.setMessage(e.getMessage().replace("<>", Helper.color("&a♢&r"))); | ||
} | ||
if (e.getMessage().toLowerCase().contains("o==")) { | ||
e.setMessage(e.getMessage().replace("o==", Helper.color("&b☄&r"))); | ||
public void chatReplace(AsyncChatEvent e) { | ||
String msg = plainText.serialize(e.message()); | ||
|
||
for (String s : replacements.keySet()) { | ||
msg = msg.replaceAll(s, replacements.get(s)); | ||
} | ||
|
||
e.message(plainText.deserialize(msg)); | ||
} | ||
} |