/*
 * Copyright (c) 2017, Adam <Adam@sigterm.info>
 * 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;

import net.runelite.http.api.ws.messages.LoginResponse;
import net.runelite.http.api.ws.messages.Handshake;
import net.runelite.http.api.ws.messages.Ping;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

public class WebsocketGsonFactory
{
	public static Gson build()
	{
		RuntimeTypeAdapterFactory<WebsocketMessage> typeAdapter = RuntimeTypeAdapterFactory.of(WebsocketMessage.class)
			.registerSubtype(Handshake.class)
			.registerSubtype(LoginResponse.class)
			.registerSubtype(Ping.class);

		return new GsonBuilder()
			.registerTypeAdapterFactory(typeAdapter)
			.create();
	}
}

@@ -1419,596 +1419,1737 @@
 ort 
-net.runelite.http.api.ws.messages.LoginResponse;%0Aimport net.runelite.http.api.ws.messages.Handshake;%0Aimport net.runelite.http.api.ws.messages.Ping;%0Aimport com.google.gson.Gson;%0Aimport com.google.gson.GsonBuilder;%0A%0Apublic class WebsocketGsonFactory%0A%7B%0A%09public static Gson build()%0A%09%7B%0A%09%09RuntimeTypeAdapterFactory%3CWebsocketMessage%3E typeAdapter = RuntimeTypeAdapterFactory.of(WebsocketMessage.class)%0A%09%09%09.registerSubtype(Handshake.class)%0A%09%09%09.registerSubtype(LoginResponse.class)%0A%09%09%09.registerSubtype(Ping.class);%0A%0A%09%09return new GsonBuilder()%0A%09%09%09.registerTypeAdapterFactory(typeAdapter)%0A%09%09%09.create(
+com.google.gson.Gson;%0Aimport com.google.gson.GsonBuilder;%0Aimport java.util.ArrayList;%0Aimport java.util.Collection;%0Aimport java.util.Collections;%0Aimport java.util.List;%0Aimport net.runelite.http.api.ws.messages.Handshake;%0Aimport net.runelite.http.api.ws.messages.LoginResponse;%0Aimport net.runelite.http.api.ws.messages.Ping;%0Aimport net.runelite.http.api.ws.messages.party.Join;%0Aimport net.runelite.http.api.ws.messages.party.Part;%0Aimport net.runelite.http.api.ws.messages.party.UserJoin;%0Aimport net.runelite.http.api.ws.messages.party.UserPart;%0A%0Apublic class WebsocketGsonFactory%0A%7B%0A%09private static final Collection%3CClass%3C? extends WebsocketMessage%3E%3E MESSAGES;%0A%0A%09static%0A%09%7B%0A%09%09final List%3CClass%3C? extends WebsocketMessage%3E%3E messages = new ArrayList%3C%3E();%0A%09%09messages.add(Handshake.class);%0A%09%09messages.add(LoginResponse.class);%0A%09%09messages.add(Ping.class);%0A%09%09messages.add(Join.class);%0A%09%09messages.add(Part.class);%0A%09%09messages.add(UserJoin.class);%0A%09%09messages.add(UserPart.class);%0A%09%09MESSAGES = messages;%0A%09%7D%0A%0A%09public static RuntimeTypeAdapterFactory%3CWebsocketMessage%3E factory(final Collection%3CClass%3C? extends WebsocketMessage%3E%3E messages)%0A%09%7B%0A%09%09final RuntimeTypeAdapterFactory%3CWebsocketMessage%3E factory = RuntimeTypeAdapterFactory.of(WebsocketMessage.class);%0A%0A%09%09for (Class%3C? extends WebsocketMessage%3E message : MESSAGES)%0A%09%09%7B%0A%09%09%09factory.registerSubtype(message);%0A%09%09%7D%0A%0A%09%09for (Class%3C? extends WebsocketMessage%3E message : messages)%0A%09%09%7B%0A%09%09%09factory.registerSubtype(message);%0A%09%09%7D%0A%0A%09%09return factory;%0A%09%7D%0A%0A%09public static Gson build(final RuntimeTypeAdapterFactory%3CWebsocketMessage%3E factory)%0A%09%7B%0A%09%09return new GsonBuilder()%0A%09%09%09.registerTypeAdapterFactory(factory)%0A%09%09%09.create();%0A%09%7D%0A%0A%09public static Gson build()%0A%09%7B%0A%09%09return build(factory(Collections.emptyList())
 );%0A%09

Make WebsocketGsonFactory more extensible