Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added shout filter and ability to make shouts orange #18

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/java/tk/avicia/avomod/Avomod.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ public class Avomod {
new ConfigToggle("General", "Notify for avomod BETA Version (may have bugs)", "Disabled", "betaNotification"),
new ConfigToggle("Guild", "Filter Out Bank Messages", "Disabled", "filterBankMessages"),
new ConfigToggle("Guild", "Filter Out All Resource Messages", "Disabled", "filterResourceMessages"),
new ConfigToggle("Chat", "Filter Out All Shouts", "Disabled", "filterShoutMessages"),
new ConfigToggle("Chat", "Make Shouts Orange", "Enabled", "makeShoutsOrange"),
new ConfigToggle("Chat", "Reveal Nicknames", "Enabled", "revealNicks"),
new ConfigToggle("Chat", "Auto Skip Quest Dialogue", "Disabled", "skipDialogue"),
new ConfigToggle("Chat", "Click to Say Congrats Message", "Enabled", "clickToSayCongrats"),
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/tk/avicia/avomod/features/EventHandlerClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import net.minecraftforge.fml.common.gameevent.TickEvent;
import tk.avicia.avomod.Avomod;

import java.util.Arrays;

public class EventHandlerClass {
private int tick = 0;

Expand Down Expand Up @@ -50,6 +52,18 @@ public void onChatEvent(ClientChatReceivedEvent event) {
event.setCanceled(true);
}

// shout management
if (message.contains(":") && message.split(":")[0].endsWith("shouts") && !message.split(":")[0].startsWith("[")) {
if (Avomod.getConfigBoolean("filterShoutMessages"))
event.setCanceled(true);

if (Avomod.getConfigBoolean("makeShoutsOrange")) {
String start = event.getMessage().getUnformattedText().split(":")[0] + ":";
String end = String.join(":", Arrays.copyOfRange(event.getMessage().getUnformattedText().split(":"), 1, event.getMessage().getUnformattedText().split(":").length));
event.setMessage(new TextComponentString(TextFormatting.GOLD + start + TextFormatting.YELLOW + end));
}
}

if (message.trim().startsWith("Loading Resource Pack...")) {
new Thread(() -> {
UpdateChecker.checkStableUpdate();
Expand Down