party: Revert botches and fix party support
This commit is contained in:
@@ -29,7 +29,6 @@ import net.runelite.api.events.Event;
|
|||||||
public class WebsocketMessage implements Event
|
public class WebsocketMessage implements Event
|
||||||
{
|
{
|
||||||
protected boolean _party;
|
protected boolean _party;
|
||||||
public String text;
|
|
||||||
|
|
||||||
public boolean isParty()
|
public boolean isParty()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -25,9 +25,10 @@
|
|||||||
package net.runelite.http.api.ws.messages;
|
package net.runelite.http.api.ws.messages;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import net.runelite.api.events.Event;
|
||||||
import net.runelite.http.api.ws.WebsocketMessage;
|
import net.runelite.http.api.ws.WebsocketMessage;
|
||||||
|
|
||||||
public class Handshake extends WebsocketMessage
|
public class Handshake extends WebsocketMessage implements Event
|
||||||
{
|
{
|
||||||
private UUID session;
|
private UUID session;
|
||||||
|
|
||||||
|
|||||||
@@ -59,21 +59,13 @@ import net.runelite.api.events.ScriptCallbackEvent;
|
|||||||
import net.runelite.client.account.SessionManager;
|
import net.runelite.client.account.SessionManager;
|
||||||
import net.runelite.client.callback.Hooks;
|
import net.runelite.client.callback.Hooks;
|
||||||
import net.runelite.client.chat.ChatMessageManager;
|
import net.runelite.client.chat.ChatMessageManager;
|
||||||
import net.runelite.client.chat.CommandManager;
|
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
import net.runelite.client.config.OpenOSRSConfig;
|
import net.runelite.client.config.OpenOSRSConfig;
|
||||||
import net.runelite.client.discord.DiscordService;
|
import net.runelite.client.discord.DiscordService;
|
||||||
import net.runelite.client.eventbus.EventBus;
|
import net.runelite.client.eventbus.EventBus;
|
||||||
import net.runelite.client.events.ExternalPluginsLoaded;
|
import net.runelite.client.events.ExternalPluginsLoaded;
|
||||||
import net.runelite.client.game.ClanManager;
|
|
||||||
import net.runelite.client.game.ItemManager;
|
|
||||||
import net.runelite.client.game.LootManager;
|
|
||||||
import net.runelite.client.game.PlayerManager;
|
|
||||||
import net.runelite.client.game.WorldService;
|
import net.runelite.client.game.WorldService;
|
||||||
import net.runelite.client.game.XpDropManager;
|
|
||||||
import net.runelite.client.game.chatbox.ChatboxPanelManager;
|
|
||||||
import net.runelite.client.graphics.ModelOutlineRenderer;
|
import net.runelite.client.graphics.ModelOutlineRenderer;
|
||||||
import net.runelite.client.menus.MenuManager;
|
|
||||||
import net.runelite.client.plugins.ExternalPluginManager;
|
import net.runelite.client.plugins.ExternalPluginManager;
|
||||||
import net.runelite.client.plugins.PluginManager;
|
import net.runelite.client.plugins.PluginManager;
|
||||||
import net.runelite.client.rs.ClientLoader;
|
import net.runelite.client.rs.ClientLoader;
|
||||||
@@ -82,7 +74,6 @@ import net.runelite.client.task.Scheduler;
|
|||||||
import net.runelite.client.ui.ClientUI;
|
import net.runelite.client.ui.ClientUI;
|
||||||
import net.runelite.client.ui.RuneLiteSplashScreen;
|
import net.runelite.client.ui.RuneLiteSplashScreen;
|
||||||
import net.runelite.client.ui.overlay.OverlayManager;
|
import net.runelite.client.ui.overlay.OverlayManager;
|
||||||
import net.runelite.client.ui.overlay.OverlayRenderer;
|
|
||||||
import net.runelite.client.ui.overlay.WidgetOverlay;
|
import net.runelite.client.ui.overlay.WidgetOverlay;
|
||||||
import net.runelite.client.ui.overlay.arrow.ArrowMinimapOverlay;
|
import net.runelite.client.ui.overlay.arrow.ArrowMinimapOverlay;
|
||||||
import net.runelite.client.ui.overlay.arrow.ArrowWorldOverlay;
|
import net.runelite.client.ui.overlay.arrow.ArrowWorldOverlay;
|
||||||
@@ -91,7 +82,6 @@ import net.runelite.client.ui.overlay.tooltip.TooltipOverlay;
|
|||||||
import net.runelite.client.ui.overlay.worldmap.WorldMapOverlay;
|
import net.runelite.client.ui.overlay.worldmap.WorldMapOverlay;
|
||||||
import net.runelite.client.util.Groups;
|
import net.runelite.client.util.Groups;
|
||||||
import net.runelite.client.util.WorldUtil;
|
import net.runelite.client.util.WorldUtil;
|
||||||
import net.runelite.client.ws.PartyService;
|
|
||||||
import net.runelite.http.api.worlds.World;
|
import net.runelite.http.api.worlds.World;
|
||||||
import net.runelite.http.api.worlds.WorldResult;
|
import net.runelite.http.api.worlds.WorldResult;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -145,24 +135,9 @@ public class RuneLite
|
|||||||
@Inject
|
@Inject
|
||||||
private OverlayManager overlayManager;
|
private OverlayManager overlayManager;
|
||||||
|
|
||||||
@Inject
|
|
||||||
private Provider<ItemManager> itemManager;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private Provider<OverlayRenderer> overlayRenderer;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private Provider<ClanManager> clanManager;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private Provider<ChatMessageManager> chatMessageManager;
|
private Provider<ChatMessageManager> chatMessageManager;
|
||||||
|
|
||||||
@Inject
|
|
||||||
private Provider<MenuManager> menuManager;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private Provider<CommandManager> commandManager;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private Provider<InfoBoxOverlay> infoBoxOverlay;
|
private Provider<InfoBoxOverlay> infoBoxOverlay;
|
||||||
|
|
||||||
@@ -178,21 +153,6 @@ public class RuneLite
|
|||||||
@Inject
|
@Inject
|
||||||
private Provider<ArrowMinimapOverlay> arrowMinimapOverlay;
|
private Provider<ArrowMinimapOverlay> arrowMinimapOverlay;
|
||||||
|
|
||||||
@Inject
|
|
||||||
private Provider<LootManager> lootManager;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private Provider<XpDropManager> xpDropManager;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private Provider<PlayerManager> playerManager;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private Provider<ChatboxPanelManager> chatboxPanelManager;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private Provider<PartyService> partyService;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private Groups groups;
|
private Groups groups;
|
||||||
|
|
||||||
@@ -426,18 +386,6 @@ public class RuneLite
|
|||||||
// Initialize chat colors
|
// Initialize chat colors
|
||||||
chatMessageManager.get().loadColors();
|
chatMessageManager.get().loadColors();
|
||||||
|
|
||||||
overlayRenderer.get();
|
|
||||||
clanManager.get();
|
|
||||||
itemManager.get();
|
|
||||||
menuManager.get();
|
|
||||||
chatMessageManager.get();
|
|
||||||
commandManager.get();
|
|
||||||
lootManager.get();
|
|
||||||
xpDropManager.get();
|
|
||||||
playerManager.get();
|
|
||||||
chatboxPanelManager.get();
|
|
||||||
partyService.get();
|
|
||||||
|
|
||||||
eventBus.subscribe(GameStateChanged.class, this, hooks::onGameStateChanged);
|
eventBus.subscribe(GameStateChanged.class, this, hooks::onGameStateChanged);
|
||||||
eventBus.subscribe(ScriptCallbackEvent.class, this, hooks::onScriptCallbackEvent);
|
eventBus.subscribe(ScriptCallbackEvent.class, this, hooks::onScriptCallbackEvent);
|
||||||
|
|
||||||
|
|||||||
@@ -76,6 +76,8 @@ public class EventBus implements EventBusInterface
|
|||||||
// Subscribe on lifecycle (for example from plugin startUp -> shutdown)
|
// Subscribe on lifecycle (for example from plugin startUp -> shutdown)
|
||||||
public <T extends Event> void subscribe(Class<T> eventClass, @NonNull Object lifecycle, @NonNull Consumer<T> action, int takeUntil, @Nullable EventScheduler subscribe, @Nullable EventScheduler observe)
|
public <T extends Event> void subscribe(Class<T> eventClass, @NonNull Object lifecycle, @NonNull Consumer<T> action, int takeUntil, @Nullable EventScheduler subscribe, @Nullable EventScheduler observe)
|
||||||
{
|
{
|
||||||
|
assert Event.class.isAssignableFrom(eventClass) : "Parameters of methods annotated with @Subscribe should implement net.runelite.api.events.Event";
|
||||||
|
|
||||||
if (subscriptionList.containsKey(lifecycle) && eventClass.equals(subscriptionList.get(lifecycle)))
|
if (subscriptionList.containsKey(lifecycle) && eventClass.equals(subscriptionList.get(lifecycle)))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -39,12 +39,11 @@ import net.runelite.http.api.RuneLiteAPI;
|
|||||||
import net.runelite.http.api.ws.WebsocketGsonFactory;
|
import net.runelite.http.api.ws.WebsocketGsonFactory;
|
||||||
import net.runelite.http.api.ws.WebsocketMessage;
|
import net.runelite.http.api.ws.WebsocketMessage;
|
||||||
import net.runelite.http.api.ws.messages.Handshake;
|
import net.runelite.http.api.ws.messages.Handshake;
|
||||||
import net.runelite.http.api.ws.messages.party.PartyMemberMessage;
|
import net.runelite.http.api.ws.messages.party.PartyMessage;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import okhttp3.WebSocket;
|
import okhttp3.WebSocket;
|
||||||
import okhttp3.WebSocketListener;
|
import okhttp3.WebSocketListener;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Singleton
|
@Singleton
|
||||||
@@ -148,21 +147,13 @@ public class WSClient extends WebSocketListener implements AutoCloseable
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClosed(@NotNull WebSocket webSocket, int code, @NotNull String reason)
|
public void onOpen(WebSocket webSocket, Response response)
|
||||||
{
|
{
|
||||||
log.info("Websocket {} closed: {}/{}", webSocket, code, reason);
|
log.info("Websocket {} opened", webSocket);
|
||||||
this.webSocket = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NotNull WebSocket webSocket, @NotNull Throwable t, Response response)
|
public void onMessage(WebSocket webSocket, String text)
|
||||||
{
|
|
||||||
log.warn("Error in websocket {}:{}", response, t);
|
|
||||||
this.webSocket = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onMessage(@NotNull WebSocket webSocket, @NotNull String text)
|
|
||||||
{
|
{
|
||||||
final WebsocketMessage message;
|
final WebsocketMessage message;
|
||||||
|
|
||||||
@@ -175,23 +166,29 @@ public class WSClient extends WebSocketListener implements AutoCloseable
|
|||||||
log.debug("Failed to deserialize message", e);
|
log.debug("Failed to deserialize message", e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
message.text = text;
|
|
||||||
|
|
||||||
for (Class<? extends WebsocketMessage> clazz : messages)
|
if (message.isParty() && !(message instanceof PartyMessage))
|
||||||
{
|
{
|
||||||
if (clazz.isInstance(message))
|
// spoofed message?
|
||||||
{
|
return;
|
||||||
eventBus.post(clazz, message);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
eventBus.post(message instanceof PartyMemberMessage ? PartyMemberMessage.class : WebsocketMessage.class, message);
|
log.debug("Got: {}", text);
|
||||||
|
|
||||||
|
eventBus.post(message.getClass(), message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onOpen(@NotNull WebSocket webSocket, @NotNull Response response)
|
public void onClosed(WebSocket webSocket, int code, String reason)
|
||||||
{
|
{
|
||||||
log.info("Websocket {} opened", webSocket);
|
log.info("Websocket {} closed: {}/{}", webSocket, code, reason);
|
||||||
|
this.webSocket = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(WebSocket webSocket, Throwable t, Response response)
|
||||||
|
{
|
||||||
|
log.warn("Error in websocket {}:{}", response, t);
|
||||||
|
this.webSocket = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user