party: add party chat messages
Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
@@ -34,6 +34,7 @@ import net.runelite.http.api.ws.messages.Handshake;
|
||||
import net.runelite.http.api.ws.messages.LoginResponse;
|
||||
import net.runelite.http.api.ws.messages.party.Join;
|
||||
import net.runelite.http.api.ws.messages.party.Part;
|
||||
import net.runelite.http.api.ws.messages.party.PartyChatMessage;
|
||||
import net.runelite.http.api.ws.messages.party.UserJoin;
|
||||
import net.runelite.http.api.ws.messages.party.UserPart;
|
||||
import net.runelite.http.api.ws.messages.party.UserSync;
|
||||
@@ -52,6 +53,7 @@ public class WebsocketGsonFactory
|
||||
messages.add(UserJoin.class);
|
||||
messages.add(UserPart.class);
|
||||
messages.add(UserSync.class);
|
||||
messages.add(PartyChatMessage.class);
|
||||
MESSAGES = messages;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 2019, Tomas Slusny <slusnucky@gmail.com>
|
||||
* 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.http.api.ws.messages.party;
|
||||
|
||||
import lombok.Value;
|
||||
|
||||
@Value
|
||||
public class PartyChatMessage extends PartyMemberMessage
|
||||
{
|
||||
private final String value;
|
||||
}
|
||||
@@ -112,7 +112,7 @@ public class RuneLite
|
||||
private OverlayManager overlayManager;
|
||||
|
||||
@Inject
|
||||
private PartyService partyService;
|
||||
private Provider<PartyService> partyService;
|
||||
|
||||
@Inject
|
||||
private Provider<ItemManager> itemManager;
|
||||
@@ -276,13 +276,13 @@ public class RuneLite
|
||||
eventBus.register(overlayManager);
|
||||
eventBus.register(drawManager);
|
||||
eventBus.register(infoBoxManager);
|
||||
eventBus.register(partyService);
|
||||
|
||||
if (!isOutdated)
|
||||
{
|
||||
// Initialize chat colors
|
||||
chatMessageManager.get().loadColors();
|
||||
|
||||
eventBus.register(partyService.get());
|
||||
eventBus.register(overlayRenderer.get());
|
||||
eventBus.register(clanManager.get());
|
||||
eventBus.register(itemManager.get());
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
*/
|
||||
package net.runelite.client.plugins.chatfilter;
|
||||
|
||||
import com.google.common.base.CharMatcher;
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.inject.Provides;
|
||||
import java.util.ArrayList;
|
||||
@@ -62,7 +63,7 @@ public class ChatFilterPlugin extends Plugin
|
||||
|
||||
private static final String CENSOR_MESSAGE = "Hey, everyone, I just tried to say something very silly!";
|
||||
|
||||
private final JagexPrintableCharMatcher jagexPrintableCharMatcher = new JagexPrintableCharMatcher();
|
||||
private final CharMatcher jagexPrintableCharMatcher = Text.JAGEX_PRINTABLE_CHAR_MATCHER;
|
||||
private final List<Pattern> filteredPatterns = new ArrayList<>();
|
||||
|
||||
@Inject
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
* (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.chatfilter;
|
||||
package net.runelite.client.util;
|
||||
|
||||
import com.google.common.base.CharMatcher;
|
||||
|
||||
@@ -46,6 +46,8 @@ public class Text
|
||||
|
||||
private static final Joiner COMMA_JOINER = Joiner.on(",").skipNulls();
|
||||
|
||||
public static final CharMatcher JAGEX_PRINTABLE_CHAR_MATCHER = new JagexPrintableCharMatcher();
|
||||
|
||||
/**
|
||||
* Splits comma separated values to list of strings
|
||||
*
|
||||
|
||||
@@ -33,13 +33,18 @@ import javax.inject.Singleton;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.ChatMessageType;
|
||||
import net.runelite.client.account.AccountSession;
|
||||
import net.runelite.client.account.SessionManager;
|
||||
import net.runelite.client.chat.ChatMessageManager;
|
||||
import net.runelite.client.chat.QueuedMessage;
|
||||
import net.runelite.client.eventbus.EventBus;
|
||||
import net.runelite.client.eventbus.Subscribe;
|
||||
import net.runelite.client.events.PartyChanged;
|
||||
import static net.runelite.client.util.Text.JAGEX_PRINTABLE_CHAR_MATCHER;
|
||||
import net.runelite.http.api.ws.messages.party.Join;
|
||||
import net.runelite.http.api.ws.messages.party.Part;
|
||||
import net.runelite.http.api.ws.messages.party.PartyChatMessage;
|
||||
import net.runelite.http.api.ws.messages.party.UserJoin;
|
||||
import net.runelite.http.api.ws.messages.party.UserPart;
|
||||
import net.runelite.http.api.ws.messages.party.UserSync;
|
||||
@@ -49,10 +54,12 @@ import net.runelite.http.api.ws.messages.party.UserSync;
|
||||
public class PartyService
|
||||
{
|
||||
public static final int PARTY_MAX = 15;
|
||||
private static final int MAX_MESSAGE_LEN = 150;
|
||||
|
||||
private final WSClient wsClient;
|
||||
private final SessionManager sessionManager;
|
||||
private final EventBus eventBus;
|
||||
private final ChatMessageManager chat;
|
||||
private final List<PartyMember> members = new ArrayList<>();
|
||||
|
||||
@Getter
|
||||
@@ -65,11 +72,12 @@ public class PartyService
|
||||
private String username;
|
||||
|
||||
@Inject
|
||||
private PartyService(final WSClient wsClient, final SessionManager sessionManager, final EventBus eventBus)
|
||||
private PartyService(final WSClient wsClient, final SessionManager sessionManager, final EventBus eventBus, final ChatMessageManager chat)
|
||||
{
|
||||
this.wsClient = wsClient;
|
||||
this.sessionManager = sessionManager;
|
||||
this.eventBus = eventBus;
|
||||
this.chat = chat;
|
||||
}
|
||||
|
||||
public void changeParty(UUID newParty)
|
||||
@@ -141,6 +149,27 @@ public class PartyService
|
||||
members.removeIf(member -> member.getMemberId().equals(message.getMemberId()));
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onPartyChatMessage(final PartyChatMessage message)
|
||||
{
|
||||
// Remove non-printable characters, and <img> tags from message
|
||||
String sentMesage = JAGEX_PRINTABLE_CHAR_MATCHER.retainFrom(message.getValue())
|
||||
.replaceAll("<img=.+>", "");
|
||||
|
||||
// Cap the mesage length
|
||||
if (sentMesage.length() > MAX_MESSAGE_LEN)
|
||||
{
|
||||
sentMesage = sentMesage.substring(0, MAX_MESSAGE_LEN);
|
||||
}
|
||||
|
||||
chat.queue(QueuedMessage.builder()
|
||||
.type(ChatMessageType.FRIENDSCHAT)
|
||||
.sender("Party")
|
||||
.name(getMemberById(message.getMemberId()).getName())
|
||||
.runeLiteFormattedMessage(sentMesage)
|
||||
.build());
|
||||
}
|
||||
|
||||
public PartyMember getLocalMember()
|
||||
{
|
||||
return getMemberByName(username);
|
||||
|
||||
Reference in New Issue
Block a user