From ee78ebbbe5c9f445bb8a5fd540540524b931833e Mon Sep 17 00:00:00 2001 From: zeruth Date: Thu, 16 May 2019 00:31:55 -0400 Subject: [PATCH] Remove Emojis plugin It's merged upstream so useless here atm. --- .../runelite/client/plugins/emojis/Emoji.java | 109 ------------ .../client/plugins/emojis/EmojiPlugin.java | 161 ------------------ 2 files changed, 270 deletions(-) delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/emojis/Emoji.java delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/emojis/EmojiPlugin.java diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/emojis/Emoji.java b/runelite-client/src/main/java/net/runelite/client/plugins/emojis/Emoji.java deleted file mode 100644 index 5318d58ecb..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/emojis/Emoji.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2019, Lotto - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.client.plugins.emojis; - -import java.awt.image.BufferedImage; -import java.util.HashMap; -import java.util.Map; -import net.runelite.client.util.ImageUtil; - -public enum Emoji -{ - SLIGHT_SMILE(":)"), - JOY("=')"), - COWBOY("3:)"), - BLUSH("^_^"), - SMILE(":D"), - GRINNING("=D"), - WINK(";)"), - STUCK_OUT_TONGUE_CLOSED_EYES("X-P"), - STUCK_OUT_TONGUE(":P"), - YUM("=P~"), - HUGGING(":D"), // >:D< - TRIUMPH(":"), // :> - THINKING(":-?"), - CONFUSED(":/"), - NEUTRAL_FACE("=|"), - EXPRESSIONLESS(":|"), - UNAMUSED(":-|"), - SLIGHT_FROWN(":("), - FROWNING2("=("), - CRY(":'("), - SOB(":_("), - FLUSHED(":$"), - ZIPPER_MOUTH(":-#"), - PERSEVERE("_"), // >_< - SUNGLASSES("8-)"), - INNOCENT("O:)"), - SMILING_IMP(":)"), // >:) - RAGE(":("), // >:( - HUSHED(":-O"), - OPEN_MOUTH(":O"), - SCREAM(":-@"), - SEE_NO_EVIL("X_X"), - DANCER("\\:D/"), - OK_HAND("(Ok)"), - THUMBSUP("(Y)"), - THUMBSDOWN("(N)"), - HEARTS("3"), // <3 - BROKEN_HEART("/3"), // "), // <>< - CAT(":3"), - DOG("=3"), - CRAB("V(;,;)V"), - FORK_AND_KNIFE("--E"), - COOKING("--(o)"), - PARTY_POPPER("@@@"); - - private static final Map emojiMap = new HashMap<>(); - - private final String trigger; - - static - { - final Emoji[] emojis = values(); - - for (final Emoji emoji : emojis) - { - emojiMap.put(emoji.trigger, emoji); - } - } - - Emoji(String trigger) - { - this.trigger = trigger; - } - - public static Emoji getEmoji(String trigger) - { - return emojiMap.get(trigger); - } - - public BufferedImage loadImage() - { - return ImageUtil.getResourceStreamFromClass(getClass(), this.name().toLowerCase() + ".png"); - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/emojis/EmojiPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/emojis/EmojiPlugin.java deleted file mode 100644 index a04bb443db..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/emojis/EmojiPlugin.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright (c) 2019, Lotto - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.client.plugins.emojis; - -import java.awt.image.BufferedImage; -import java.util.Arrays; -import javax.inject.Inject; -import joptsimple.internal.Strings; -import lombok.extern.slf4j.Slf4j; -import net.runelite.api.Client; -import net.runelite.api.GameState; -import net.runelite.api.IndexedSprite; -import net.runelite.api.MessageNode; -import net.runelite.api.events.ChatMessage; -import net.runelite.api.events.GameStateChanged; -import net.runelite.client.chat.ChatMessageManager; -import net.runelite.client.eventbus.Subscribe; -import net.runelite.client.plugins.Plugin; -import net.runelite.client.plugins.PluginDescriptor; -import net.runelite.client.plugins.PluginType; -import net.runelite.client.util.ImageUtil; - -@PluginDescriptor( - name = "Emojis", - description = "Replaces common emoticons such as :) with their corresponding emoji in the chat", - enabledByDefault = false, - type = PluginType.UTILITY -) -@Slf4j -public class EmojiPlugin extends Plugin -{ - @Inject - private Client client; - - @Inject - private ChatMessageManager chatMessageManager; - - private int modIconsStart = -1; - - @Override - protected void startUp() - { - } - - @Override - protected void shutDown() - { - } - - @Subscribe - public void onGameStateChanged(GameStateChanged gameStateChanged) - { - if (gameStateChanged.getGameState() == GameState.LOGGED_IN - && modIconsStart == -1) - { - loadEmojiIcons(); - } - } - - private void loadEmojiIcons() - { - final Emoji[] emojis = Emoji.values(); - - final IndexedSprite[] modIcons = client.getModIcons(); - final IndexedSprite[] newModIcons = Arrays.copyOf(modIcons, modIcons.length + emojis.length); - modIconsStart = modIcons.length; - - for (int i = 0; i < emojis.length; i++) - { - final Emoji emoji = emojis[i]; - - try - { - final BufferedImage image = emoji.loadImage(); - final IndexedSprite sprite = ImageUtil.getImageIndexedSprite(image, client); - newModIcons[modIconsStart + i] = sprite; - } - catch (Exception ex) - { - log.warn("Failed to load the sprite for emoji " + emoji, ex); - } - } - - client.setModIcons(newModIcons); - } - - @Subscribe - public void onChatMessage(ChatMessage chatMessage) - { - if (client.getGameState() != GameState.LOGGED_IN) - { - return; - } - - switch (chatMessage.getType()) - { - case PUBLICCHAT: - case MODCHAT: - case FRIENDSCHAT: - case PRIVATECHAT: - case PRIVATECHATOUT: - break; - default: - return; - } - - final String message = chatMessage.getMessage(); - final String[] messageWords = message.split(" "); - - boolean editedMessage = false; - for (int i = 0; i < messageWords.length; i++) - { - final Emoji emoji = Emoji.getEmoji(messageWords[i]); - - if (emoji == null) - { - continue; - } - - final int emojiId = modIconsStart + emoji.ordinal(); - - messageWords[i] = ""; - editedMessage = true; - } - - // If we haven't edited the message any, don't update it. - if (!editedMessage) - { - return; - } - - final String newMessage = Strings.join(messageWords, " "); - - final MessageNode messageNode = chatMessage.getMessageNode(); - messageNode.setRuneLiteFormatMessage(newMessage); - chatMessageManager.update(messageNode); - client.refreshChat(); - } -}