From d3d8753ab80283d612d1edc186171a6a02cc33b2 Mon Sep 17 00:00:00 2001 From: DapperMickie Date: Tue, 18 Jun 2024 21:45:43 +0200 Subject: [PATCH] Add emotes setting (#66) * Added config for emotes * Add odaDap emote * Add OdaCap emote * Improve emote list and add ignore list --- .../dappermickie/odablock/OdablockConfig.java | 22 +++++- .../dappermickie/odablock/emotes/Emote.java | 5 ++ .../odablock/emotes/EmoteHandler.java | 71 +++++++++++++++++- .../dappermickie/odablock/emotes/cap.png | Bin 0 -> 536 bytes .../dappermickie/odablock/emotes/dap.png | Bin 0 -> 278 bytes 5 files changed, 96 insertions(+), 2 deletions(-) create mode 100644 src/main/resources/com/github/dappermickie/odablock/emotes/cap.png create mode 100644 src/main/resources/com/github/dappermickie/odablock/emotes/dap.png diff --git a/src/main/java/com/github/dappermickie/odablock/OdablockConfig.java b/src/main/java/com/github/dappermickie/odablock/OdablockConfig.java index 3bfbe9f..57f8fb7 100644 --- a/src/main/java/com/github/dappermickie/odablock/OdablockConfig.java +++ b/src/main/java/com/github/dappermickie/odablock/OdablockConfig.java @@ -380,14 +380,34 @@ default boolean snowballed() return true; } + @ConfigItem( + keyName = "emotes", + name = "Emotes", + description = "Configures whether or not some of the text in game gets replaced with Odablock's emotes.
type '::odaemotes' in chat to see a list of all available emotes.", + position = 32 + ) + default boolean emotes() + + @ConfigItem( + keyName = "emoteIgnoreList", + name = "Emote Ignore List", + description = "A comma separated list of emotes to ignore for example: \":p, :)\".
type '::odaemotes' in chat to see a list of all available emotes.", + position = 33 + ) + default String emoteIgnoreList() + { + return ""; + } + @ConfigItem( keyName = "warriors", name = "Odablock Warriors", description = "Should the '7th Realm' in-game sound be replaced with the Odablock Warriors song?", - position = 30, + position = 34, warning = "If you turn this off, you'll have to reload the client to be able to manually play '7th Realm' again." ) default boolean warriors() + { return true; } diff --git a/src/main/java/com/github/dappermickie/odablock/emotes/Emote.java b/src/main/java/com/github/dappermickie/odablock/emotes/Emote.java index 4d2759e..aa31e3f 100644 --- a/src/main/java/com/github/dappermickie/odablock/emotes/Emote.java +++ b/src/main/java/com/github/dappermickie/odablock/emotes/Emote.java @@ -4,6 +4,7 @@ import java.awt.image.BufferedImage; import java.util.Map; import lombok.AllArgsConstructor; +import lombok.Getter; import net.runelite.client.util.ImageUtil; @AllArgsConstructor @@ -24,6 +25,8 @@ public enum Emote SMILE(":)", EmoteType.GIF, new String[]{"smile"}), TUNE("tune", EmoteType.GIF), ODAWHAT("odawhat", EmoteType.PNG), + DAP("dap", EmoteType.PNG), + CAP("cap", EmoteType.PNG), WHENITREGISTERS("whenitregisters", EmoteType.GIF), WINK("wink", EmoteType.PNG); @@ -35,8 +38,10 @@ private enum EmoteType private static final Map emojiMap; + @Getter private final String trigger; private final EmoteType emoteType; + @Getter private final String[] altTriggers; Emote(final String trigger, EmoteType emoteType) diff --git a/src/main/java/com/github/dappermickie/odablock/emotes/EmoteHandler.java b/src/main/java/com/github/dappermickie/odablock/emotes/EmoteHandler.java index e7cb500..cc13af9 100644 --- a/src/main/java/com/github/dappermickie/odablock/emotes/EmoteHandler.java +++ b/src/main/java/com/github/dappermickie/odablock/emotes/EmoteHandler.java @@ -1,7 +1,11 @@ package com.github.dappermickie.odablock.emotes; +import com.github.dappermickie.odablock.OdablockConfig; import static com.github.dappermickie.odablock.OdablockPlugin.ODABLOCK; import java.awt.image.BufferedImage; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; import java.util.regex.Pattern; import javax.annotation.Nullable; import javax.inject.Inject; @@ -34,6 +38,9 @@ public class EmoteHandler @Inject private Client client; + @Inject + private OdablockConfig config; + private int[] iconIds; public void loadEmotes() @@ -56,6 +63,11 @@ public void loadEmotes() public void onChatMessage(ChatMessage chatMessage) { + if (!config.emotes()) + { + return; + } + if (iconIds == null) { return; @@ -91,6 +103,11 @@ public void onChatMessage(ChatMessage chatMessage) public void onOverheadTextChanged(final OverheadTextChanged event) { + if (!config.emotes()) + { + return; + } + if (!(event.getActor() instanceof Player)) { return; @@ -122,14 +139,51 @@ private void sendOdaEmotes() { final int emoteId = iconIds[emote.ordinal()]; final String emoteImage = ""; - client.addChatMessage(ChatMessageType.GAMEMESSAGE, ODABLOCK, emote.name() + " : " + emoteImage, null); + StringBuilder chatMessageSb = new StringBuilder(); + chatMessageSb.append(emote.getTrigger()); + chatMessageSb.append(" : "); + chatMessageSb.append(emoteImage); + List altTriggerOriginal = Arrays.asList(emote.getAltTriggers()); + List altTriggers = new ArrayList<>(altTriggerOriginal); + if (!emote.getTrigger().startsWith("oda") && !emote.getTrigger().startsWith(":")) + { + altTriggers.add("oda" + emote.getTrigger()); + } + for (int i = 0; i < altTriggers.size(); i++) + { + if (i == 0) + { + chatMessageSb.append(" (alt: "); + } + else + { + chatMessageSb.append(", "); + } + String altTrigger = altTriggers.get(i); + chatMessageSb.append(altTrigger); + if (!altTrigger.startsWith("oda") && !altTrigger.startsWith(":")) + { + chatMessageSb.append(", oda"); + chatMessageSb.append(altTrigger); + } + if (i == (altTriggers.size() - 1)) + { + chatMessageSb.append(" )"); + } + } + client.addChatMessage(ChatMessageType.GAMEMESSAGE, ODABLOCK, chatMessageSb.toString(), null); } + client.addChatMessage(ChatMessageType.GAMEMESSAGE, ODABLOCK, "Some emotes have an alternative trigger that will get translated into an emote.", null); + client.addChatMessage(ChatMessageType.GAMEMESSAGE, ODABLOCK, "For example: both \"cap\" and \"odacap\" work.", null); + client.addChatMessage(ChatMessageType.GAMEMESSAGE, ODABLOCK, "To disable an emote, you can add it to the \"Emote Ignore List\" in the plugin settings.", null); + client.addChatMessage(ChatMessageType.GAMEMESSAGE, ODABLOCK, "Add the emote and the alternative triggers to completely disable an emote.", null); } @Nullable String updateMessage(final String message) { final String[] messageWords = WHITESPACE_REGEXP.split(message); + final String[] ignoredEmotes = config.emoteIgnoreList().split(","); boolean editedMessage = false; for (int i = 0; i < messageWords.length; i++) @@ -144,6 +198,21 @@ String updateMessage(final String message) continue; } + boolean shouldSkip = false; + for (String ignored : ignoredEmotes) + { + if (ignored.strip().equalsIgnoreCase(trigger)) + { + shouldSkip = true; + break; + } + } + + if (shouldSkip) + { + break; + } + final int emoteId = iconIds[emote.ordinal()]; messageWords[i] = messageWords[i].replace(originalTrigger, ""); editedMessage = true; diff --git a/src/main/resources/com/github/dappermickie/odablock/emotes/cap.png b/src/main/resources/com/github/dappermickie/odablock/emotes/cap.png new file mode 100644 index 0000000000000000000000000000000000000000..8743942ed44ff18979f35dc94f2791ddb6638d53 GIT binary patch literal 536 zcmV+z0_XjSP)7bN-f;etbM$iKUbMrH;E2pAL@n@o6HIAc;gJgl&? z;nU47L{&H+FU7{iJyc>sN>M{RM*si%`TP5XgM%#`CNnQIOcNbE5*z>j<#Jn8-`>^u z;l_GQcseaE?98+E-NenWn@>|)p@@8VW?_(VX1kw`j!Sy}_ULRaP{6aSmz$m6+S6k$ zOOJYWYIT1G2@urA!T#mf_UzwjUR_NnL+s<=Z9HxI^zAl0NvoKX%D$~XE=p@|a8)BY zcUW`x-_vGYTW&v9`SUZOuw%a6=?`Xa? zNOGFfvd3@T1k1AH$a3$=`E*JL`&#p@#oxcXY5wSV5>;2d2=?{gFwO|^{7@_wZYA5Y zEJzVSTy1H)BpmW{yi}AB?=Ga1KxcqwhG{FxSI#NY6AEQ;faFsP^hef@AR}`WHFGkK a=J_9-u@>Uv@DL3E0000YY5jAo3GE|RuHI*{+FtBnqznVS`XhDgmi(?4K_1cr>LWdj#7!KO*f4)~( z=zsmP0Ktg{k=GgiY$?B-aVvDI0oR()mI*=npGB?S7p)A}BDc zem>{PH9ObzgmJ9c@&81jPAk(<^Y5C+=CLg`kVy8_lXRA6kw~{$XPL@jdw70cej{6u T)LVObp#2P~L! literal 0 HcmV?d00001