Merge pull request #1 from runelite-extended/master

pr
This commit is contained in:
Ian William O'Neill
2019-07-18 19:34:01 +01:00
committed by GitHub
334 changed files with 70634 additions and 3492 deletions

View File

@@ -7,7 +7,7 @@
[![Build Status](https://travis-ci.org/runelite-extended/runelite.svg?branch=master)](https://travis-ci.org/runelite-extended/runelite) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) [![HitCount](http://hits.dwyl.io/runelite-extended/runelite.svg)](http://hits.dwyl.io/runelite-extended/runelite) [![saythanks](https://img.shields.io/badge/say-thanks-32cd32.svg)](https://www.patreon.com/RuneLitePlus) [![Build Status](https://travis-ci.org/runelite-extended/runelite.svg?branch=master)](https://travis-ci.org/runelite-extended/runelite) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) [![HitCount](http://hits.dwyl.io/runelite-extended/runelite.svg)](http://hits.dwyl.io/runelite-extended/runelite) [![saythanks](https://img.shields.io/badge/say-thanks-32cd32.svg)](https://www.patreon.com/RuneLitePlus)
[RuneLitePlus](https://runelitepl.us) is a extended version of [RuneLite](https://github.com/runelite/runelite) that provides more functionality and less restrictions while staying more open-source. [RuneLitePlus](https://runelitepl.us) is an extended version of [RuneLite](https://github.com/runelite/runelite) that provides more functionality and less restrictions while staying more open-source.

View File

@@ -27,6 +27,7 @@ package net.runelite.cache.io;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import java.io.IOException; import java.io.IOException;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.nio.Buffer;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
public final class OutputStream extends java.io.OutputStream public final class OutputStream extends java.io.OutputStream
@@ -56,7 +57,7 @@ public final class OutputStream extends java.io.OutputStream
int newCapacity = buffer.capacity() * 2; int newCapacity = buffer.capacity() * 2;
ByteBuffer old = buffer; ByteBuffer old = buffer;
old.flip(); ((Buffer) old).flip();
buffer = ByteBuffer.allocate(newCapacity); buffer = ByteBuffer.allocate(newCapacity);
@@ -196,7 +197,7 @@ public final class OutputStream extends java.io.OutputStream
public byte[] flip() public byte[] flip()
{ {
buffer.flip(); ((Buffer) buffer).flip();
byte[] b = new byte[buffer.limit()]; byte[] b = new byte[buffer.limit()];
buffer.get(b); buffer.get(b);
return b; return b;

View File

@@ -0,0 +1,99 @@
/*
* Copyright (c) 2018, Forsco <https://github.com/forsco>
* 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.discord;
import com.google.gson.Gson;
import java.io.IOException;
import lombok.extern.slf4j.Slf4j;
import net.runelite.http.api.RuneLiteAPI;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.HttpUrl;
import okhttp3.MediaType;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
@Slf4j
public class DiscordClient
{
public static final Gson gson = new Gson();
private static final MediaType JSON = MediaType.parse("application/json");
public void message(HttpUrl url, DiscordMessage discordMessage)
{
log.info("Message being sent");
message(url, discordMessage, 0, 5);
}
private void message(HttpUrl url, DiscordMessage discordMessage, int retryAttempt, int maxAttempts)
{
Request request = new Request.Builder()
.post(RequestBody.create(JSON, gson.toJson(discordMessage)))
.url(url)
.build();
log.info("Attempting to message with {}", discordMessage);
RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback()
{
@Override
public void onFailure(Call call, IOException e)
{
log.warn("Unable to submit discord post.", e);
if (retryAttempt < maxAttempts)
{
message(url, discordMessage, retryAttempt + 1, maxAttempts);
}
}
@Override
public void onResponse(Call call, Response response) throws IOException
{
try
{
if (response.body() == null)
{
log.error("API Call - Reponse was null.");
return;
}
if (response.body().string().contains("You are being rate limited") && retryAttempt < maxAttempts)
{
log.error("You are being rate limited, retrying...");
message(url, discordMessage, retryAttempt + 1, maxAttempts);
}
}
finally
{
response.close();
log.debug("Submitted discord log record");
}
}
});
}
}

View File

@@ -0,0 +1,108 @@
/*
* Copyright (c) 2018, Forsco <https://github.com/forsco>
* 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.discord;
import java.util.ArrayList;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import net.runelite.http.api.discord.embed.AuthorEmbed;
import net.runelite.http.api.discord.embed.FieldEmbed;
import net.runelite.http.api.discord.embed.FooterEmbed;
import net.runelite.http.api.discord.embed.ImageEmbed;
import net.runelite.http.api.discord.embed.ProviderEmbed;
import net.runelite.http.api.discord.embed.ThumbnailEmbed;
import net.runelite.http.api.discord.embed.VideoEmbed;
@Getter
@Setter
@Builder
@AllArgsConstructor
@ToString
public class DiscordEmbed
{
String title;
String type;
String description;
String url;
String timestamp;
String iconurl;
String color;
FooterEmbed footer;
ImageEmbed image;
ThumbnailEmbed thumbnail;
VideoEmbed video;
ProviderEmbed provider;
AuthorEmbed author;
List<FieldEmbed> fields = new ArrayList<>();
public DiscordEmbed()
{
}
public DiscordEmbed(String title, String description)
{
this(title, description, null);
}
public DiscordEmbed(String title, String description, String url)
{
setTitle(title);
setDescription(description);
setUrl(url);
}
public static DiscordMessage toDiscordMessage(DiscordEmbed embed, String username, String avatarURL)
{
return DiscordMessage.builder()
.username(username)
.avatarUrl(avatarURL)
.content("")
.embed(embed)
.build();
}
public DiscordMessage toDiscordMessage(String username, String avatarUrl)
{
return DiscordEmbed.toDiscordMessage(this, username, avatarUrl);
}
public static class DiscordEmbedBuilder
{
List<FieldEmbed> fields = new ArrayList<>();
public DiscordEmbedBuilder field(FieldEmbed field)
{
fields.add(field);
return this;
}
}
}

View File

@@ -0,0 +1,93 @@
/*
* Copyright (c) 2018, Forsco <https://github.com/forsco>
* 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.discord;
import com.google.gson.annotations.SerializedName;
import java.util.ArrayList;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@Getter
@Setter
@Builder
@AllArgsConstructor
@ToString
public class DiscordMessage
{
String username;
String content;
@SerializedName("avatar_url")
String avatarUrl;
@SerializedName("tts")
boolean textToSpeech;
List<DiscordEmbed> embeds = new ArrayList<>();
public DiscordMessage()
{
}
public DiscordMessage(String username, String content, String avatar_url)
{
this(username, content, avatar_url, false);
}
public DiscordMessage(String username, String content, String avatar_url, boolean tts)
{
setUsername(username);
setContent(content);
setAvatarUrl(avatar_url);
setTextToSpeech(tts);
}
public void setUsername(String username)
{
if (username != null)
{
this.username = username.substring(0, Math.min(31, username.length()));
}
else
{
this.username = null;
}
}
public static class DiscordMessageBuilder
{
List<DiscordEmbed> embeds = new ArrayList<>();
public DiscordMessageBuilder embed(DiscordEmbed embed)
{
embeds.add(embed);
return this;
}
}
}

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2018, https://runelitepl.us * Copyright (c) 2018, Forsco <https://github.com/forsco>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -7,6 +7,7 @@
* *
* 1. Redistributions of source code must retain the above copyright notice, this * 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer. * list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, * 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation * this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution. * and/or other materials provided with the distribution.
@@ -22,39 +23,26 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
package net.runelite.client.plugins.vorkath;
import java.awt.Color; package net.runelite.http.api.discord.embed;
import java.awt.Dimension;
import java.awt.Graphics2D;
import javax.inject.Inject;
import javax.inject.Singleton;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayLayer;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.OverlayUtil;
@Singleton import lombok.AllArgsConstructor;
public class ZombifiedSpawnOverlay extends Overlay import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class AuthorEmbed
{ {
private final VorkathPlugin plugin; String name;
String url;
@Inject String icon_url;
public ZombifiedSpawnOverlay(final VorkathPlugin plugin) String proxy_icon_url;
{
setPosition(OverlayPosition.DYNAMIC);
setLayer(OverlayLayer.ABOVE_SCENE);
this.plugin = plugin;
}
@Override
public Dimension render(Graphics2D graphics)
{
if (plugin.getZombifiedSpawn() != null)
{
OverlayUtil.renderActorOverlayImage(graphics, plugin.getZombifiedSpawn(), VorkathPlugin.SPAWN, Color.green, 10);
}
return null;
}
} }

View File

@@ -0,0 +1,50 @@
/*
* Copyright (c) 2018, Forsco <https://github.com/forsco>
* 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.discord.embed;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class FieldEmbed
{
@NonNull
String name;
@NonNull
String value;
boolean inline;
}

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2018, Abex * Copyright (c) 2018, Forsco <https://github.com/forsco>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -7,6 +7,7 @@
* *
* 1. Redistributions of source code must retain the above copyright notice, this * 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer. * list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, * 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation * this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution. * and/or other materials provided with the distribution.
@@ -22,20 +23,25 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
package net.runelite.client.eventbus;
import java.lang.annotation.Documented; package net.runelite.http.api.discord.embed;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/** import lombok.AllArgsConstructor;
* Marks a method as an event subscriber. import lombok.Builder;
*/ import lombok.Getter;
@Retention(RetentionPolicy.RUNTIME) import lombok.NoArgsConstructor;
@Target(ElementType.METHOD) import lombok.Setter;
@Documented import lombok.ToString;
public @interface Subscribe
@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class FooterEmbed
{ {
String text;
String icon_url;
String proxy_icon_url;
} }

View File

@@ -0,0 +1,48 @@
/*
* Copyright (c) 2018, Forsco <https://github.com/forsco>
* 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.discord.embed;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class ImageEmbed
{
String url;
String proxy_url;
int height;
int width;
}

View File

@@ -0,0 +1,46 @@
/*
* Copyright (c) 2018, Forsco <https://github.com/forsco>
* 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.discord.embed;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class ProviderEmbed
{
String name;
String url;
}

View File

@@ -0,0 +1,48 @@
/*
* Copyright (c) 2018, Forsco <https://github.com/forsco>
* 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.discord.embed;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class ThumbnailEmbed
{
String url;
String proxy_url;
int height;
int width;
}

View File

@@ -0,0 +1,47 @@
/*
* Copyright (c) 2018, Forsco <https://github.com/forsco>
* 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.discord.embed;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class VideoEmbed
{
String url;
int height;
int width;
}

View File

@@ -29,6 +29,7 @@ import lombok.Value;
@Value @Value
public class ItemStats public class ItemStats
{ {
private String name;
private boolean quest; private boolean quest;
private boolean equipable; private boolean equipable;
private double weight; private double weight;
@@ -76,7 +77,7 @@ public class ItemStats
newEquipment = equipment; newEquipment = equipment;
} }
return new ItemStats(quest, equipable, newWeight, newEquipment); return new ItemStats(name, quest, equipable, newWeight, newEquipment);
} }
} }

View File

@@ -62,18 +62,6 @@ public class XteaClient
.url(url) .url(url)
.build(); .build();
try
{
try (Response response = RuneLiteAPI.RLP_CLIENT.newCall(request).execute())
{
logger.debug("xtea response " + response.code());
}
}
catch (IOException e)
{
e.printStackTrace();
}
RuneLiteAPI.RLP_CLIENT.newCall(request).enqueue(new Callback() RuneLiteAPI.RLP_CLIENT.newCall(request).enqueue(new Callback()
{ {
@Override @Override
@@ -114,9 +102,7 @@ public class XteaClient
{ {
InputStream in = response.body().byteStream(); InputStream in = response.body().byteStream();
// CHECKSTYLE:OFF // CHECKSTYLE:OFF
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), new TypeToken<List<XteaKey>>() return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), new TypeToken<List<XteaKey>>() {}.getType());
{
}.getType());
// CHECKSTYLE:ON // CHECKSTYLE:ON
} }
catch (JsonParseException ex) catch (JsonParseException ex)

View File

@@ -363,6 +363,7 @@ public interface Client extends GameShell
* @param scale the scale of the sprite * @param scale the scale of the sprite
* @return the created sprite * @return the created sprite
*/ */
@Nullable
Sprite createItemSprite(int itemId, int quantity, int border, int shadowColor, int stackable, boolean noted, int scale); Sprite createItemSprite(int itemId, int quantity, int border, int shadowColor, int stackable, boolean noted, int scale);
/** /**
@@ -373,6 +374,7 @@ public interface Client extends GameShell
* @param fileId the sprites file ID * @param fileId the sprites file ID
* @return the sprite image of the file * @return the sprite image of the file
*/ */
@Nullable
Sprite[] getSprites(IndexDataBase source, int archiveId, int fileId); Sprite[] getSprites(IndexDataBase source, int archiveId, int fileId);
/** /**
@@ -1679,15 +1681,25 @@ public interface Client extends GameShell
boolean isSpellSelected(); boolean isSpellSelected();
/** /**
* Set whether or not player attack options will be hidden for clanmembers/friends * Set whether or not player attack options will be hidden for friends
*/ */
void setHideFriendAttackOptions(boolean yes); void setHideFriendAttackOptions(boolean yes);
/** /**
* Set whether or not player cast options will be hidden for clanmembers/friends * Set whether or not player cast options will be hidden for friends
*/ */
void setHideFriendCastOptions(boolean yes); void setHideFriendCastOptions(boolean yes);
/**
* Set whether or not player attack options will be hidden for clanmates
*/
void setHideClanmateAttackOptions(boolean yes);
/**
* Set whether or not player cast options will be hidden for clanmates
*/
void setHideClanmateCastOptions(boolean yes);
/** /**
* Set spells excluded from above hiding * Set spells excluded from above hiding
*/ */

View File

@@ -82,9 +82,9 @@ public class ProjectileID
public static final int CERB_FIRE = 1247; public static final int CERB_FIRE = 1247;
/** /**
* missing: marble gargoyle, superior dark beast * missing: superior dark beast
*/ */
public static final int MARBLE_GARGOYLE_AOE = 1453;
/** /**
* non AOE, regular projectiles * non AOE, regular projectiles
*/ */

View File

@@ -160,9 +160,11 @@ public final class ScriptID
/** /**
* Handles zoom input * Handles zoom input
*
* Updates the VarClientInts (73, 74) to this same value
* <ul> * <ul>
* <li> int zoom value </li> * <li> int Reset zoom position </li>
* <li> int zoom value </li> * <li> int Reset zoom position </li>
* </ul> * </ul>
*/ */
public static final int CAMERA_DO_ZOOM = 42; public static final int CAMERA_DO_ZOOM = 42;

View File

@@ -41,14 +41,14 @@ public interface Callbacks
* *
* @param event the event * @param event the event
*/ */
void post(Object event); <T> void post(Class<T> eventClass, Object event);
/** /**
* Post a deferred event, which gets delayed until the next cycle. * Post a deferred event, which gets delayed until the next cycle.
* *
* @param event the event * @param event the event
*/ */
void postDeferred(Object event); <T> void postDeferred(Class<T> eventClass, Object event);
/** /**
* Called each client cycle. * Called each client cycle.

View File

@@ -300,6 +300,16 @@
<artifactId>httpmime</artifactId> <artifactId>httpmime</artifactId>
<version>4.5.9</version> <version>4.5.9</version>
</dependency> </dependency>
<dependency>
<groupId>io.reactivex.rxjava2</groupId>
<artifactId>rxjava</artifactId>
<version>2.2.10</version>
</dependency>
<dependency>
<groupId>com.jakewharton.rxrelay2</groupId>
<artifactId>rxrelay</artifactId>
<version>2.1.0</version>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@@ -48,16 +48,9 @@ import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.client.account.SessionManager; import net.runelite.client.account.SessionManager;
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.discord.DiscordService; import net.runelite.client.discord.DiscordService;
import net.runelite.client.eventbus.EventBus;
import net.runelite.client.game.ClanManager;
import net.runelite.client.game.ItemManager;
import net.runelite.client.game.LootManager;
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.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginInstantiationException; import net.runelite.client.plugins.PluginInstantiationException;
import net.runelite.client.plugins.PluginManager; import net.runelite.client.plugins.PluginManager;
@@ -65,18 +58,14 @@ import net.runelite.client.rs.ClientLoader;
import net.runelite.client.rs.ClientUpdateCheckMode; import net.runelite.client.rs.ClientUpdateCheckMode;
import net.runelite.client.task.Scheduler; import net.runelite.client.task.Scheduler;
import net.runelite.client.ui.ClientUI; import net.runelite.client.ui.ClientUI;
import net.runelite.client.ui.DrawManager;
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;
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
import net.runelite.client.ui.overlay.infobox.InfoBoxOverlay; import net.runelite.client.ui.overlay.infobox.InfoBoxOverlay;
import net.runelite.client.ui.overlay.tooltip.TooltipOverlay; 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.ws.PartyService;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@Singleton @Singleton
@@ -97,15 +86,9 @@ public class RuneLite
@Inject @Inject
private PluginManager pluginManager; private PluginManager pluginManager;
@Inject
private EventBus eventBus;
@Inject @Inject
private ConfigManager configManager; private ConfigManager configManager;
@Inject
private DrawManager drawManager;
@Inject @Inject
private SessionManager sessionManager; private SessionManager sessionManager;
@@ -118,33 +101,12 @@ public class RuneLite
@Inject @Inject
private ClientUI clientUI; private ClientUI clientUI;
@Inject
private InfoBoxManager infoBoxManager;
@Inject @Inject
private OverlayManager overlayManager; private OverlayManager overlayManager;
@Inject
private PartyService partyService;
@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;
@@ -160,12 +122,6 @@ public class RuneLite
@Inject @Inject
private Provider<ArrowMinimapOverlay> arrowMinimapOverlay; private Provider<ArrowMinimapOverlay> arrowMinimapOverlay;
@Inject
private Provider<LootManager> lootManager;
@Inject
private Provider<ChatboxPanelManager> chatboxPanelManager;
@Inject @Inject
@Nullable @Nullable
private Client client; private Client client;
@@ -351,28 +307,11 @@ public class RuneLite
// Close the splash screen // Close the splash screen
splashScreen.close(); splashScreen.close();
// Register event listeners
eventBus.register(clientUI);
eventBus.register(pluginManager);
eventBus.register(overlayManager);
eventBus.register(drawManager);
eventBus.register(infoBoxManager);
eventBus.register(partyService);
if (!isOutdated) if (!isOutdated)
{ {
// Initialize chat colors // Initialize chat colors
chatMessageManager.get().loadColors(); chatMessageManager.get().loadColors();
eventBus.register(overlayRenderer.get());
eventBus.register(clanManager.get());
eventBus.register(itemManager.get());
eventBus.register(menuManager.get());
eventBus.register(chatMessageManager.get());
eventBus.register(commandManager.get());
eventBus.register(lootManager.get());
eventBus.register(chatboxPanelManager.get());
// Add core overlays // Add core overlays
WidgetOverlay.createOverlays(client).forEach(overlayManager::add); WidgetOverlay.createOverlays(client).forEach(overlayManager::add);
overlayManager.add(infoBoxOverlay.get()); overlayManager.add(infoBoxOverlay.get());

View File

@@ -32,7 +32,6 @@ import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import javax.inject.Singleton; import javax.inject.Singleton;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.hooks.Callbacks; import net.runelite.api.hooks.Callbacks;
import net.runelite.client.account.SessionManager; import net.runelite.client.account.SessionManager;
@@ -56,7 +55,6 @@ import okhttp3.OkHttpClient;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@Slf4j
public class RuneLiteModule extends AbstractModule public class RuneLiteModule extends AbstractModule
{ {
private final ClientUpdateCheckMode updateCheckMode; private final ClientUpdateCheckMode updateCheckMode;

View File

@@ -39,7 +39,6 @@ import lombok.extern.slf4j.Slf4j;
import net.runelite.client.RuneLite; import net.runelite.client.RuneLite;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.EventBus; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.events.SessionClose; import net.runelite.client.events.SessionClose;
import net.runelite.client.events.SessionOpen; import net.runelite.client.events.SessionOpen;
import net.runelite.client.util.LinkBrowser; import net.runelite.client.util.LinkBrowser;
@@ -67,7 +66,8 @@ public class SessionManager
this.configManager = configManager; this.configManager = configManager;
this.eventBus = eventBus; this.eventBus = eventBus;
this.wsClient = wsClient; this.wsClient = wsClient;
eventBus.register(this);
this.eventBus.subscribe(LoginResponse.class, this, this::onLoginResponse);
} }
public void loadSession() public void loadSession()
@@ -150,7 +150,7 @@ public class SessionManager
configManager.switchSession(); configManager.switchSession();
} }
eventBus.post(new SessionOpen()); eventBus.post(SessionOpen.class, new SessionOpen());
} }
private void closeSession() private void closeSession()
@@ -179,7 +179,7 @@ public class SessionManager
// Restore config // Restore config
configManager.switchSession(); configManager.switchSession();
eventBus.post(new SessionClose()); eventBus.post(SessionClose.class, new SessionClose());
} }
public void login() public void login()
@@ -207,8 +207,7 @@ public class SessionManager
LinkBrowser.browse(login.getOauthUrl()); LinkBrowser.browse(login.getOauthUrl());
} }
@Subscribe private void onLoginResponse(LoginResponse loginResponse)
public void onLoginResponse(LoginResponse loginResponse)
{ {
log.debug("Now logged in as {}", loginResponse.getUsername()); log.debug("Now logged in as {}", loginResponse.getUsername());

View File

@@ -58,7 +58,7 @@ public class ClientThread
{ {
if (client.isClientThread()) if (client.isClientThread())
{ {
if (r.getAsBoolean()) if (!r.getAsBoolean())
{ {
invokes.add(r); invokes.add(r);
} }

View File

@@ -128,15 +128,15 @@ public class Hooks implements Callbacks
private boolean shouldProcessGameTick; private boolean shouldProcessGameTick;
@Override @Override
public void post(Object event) public <T> void post(Class<T> eventClass, Object event)
{ {
eventBus.post(event); eventBus.post(eventClass, event);
} }
@Override @Override
public void postDeferred(Object event) public <T> void postDeferred(Class<T> eventClass, Object event)
{ {
deferredEventBus.post(event); deferredEventBus.post(eventClass, event);
} }
@Override @Override
@@ -148,13 +148,13 @@ public class Hooks implements Callbacks
deferredEventBus.replay(); deferredEventBus.replay();
eventBus.post(GameTick.INSTANCE); eventBus.post(GameTick.class, GameTick.INSTANCE);
int tick = client.getTickCount(); int tick = client.getTickCount();
client.setTickCount(tick + 1); client.setTickCount(tick + 1);
} }
eventBus.post(BeforeRender.INSTANCE); eventBus.post(BeforeRender.class, BeforeRender.INSTANCE);
clientThread.invoke(); clientThread.invoke();
@@ -509,7 +509,7 @@ public class Hooks implements Callbacks
public static boolean drawMenu() public static boolean drawMenu()
{ {
BeforeMenuRender event = new BeforeMenuRender(); BeforeMenuRender event = new BeforeMenuRender();
client.getCallbacks().post(event); client.getCallbacks().post(BeforeMenuRender.class, event);
return event.isConsumed(); return event.isConsumed();
} }
} }

View File

@@ -31,18 +31,15 @@ import java.util.function.BiConsumer;
import java.util.function.BiPredicate; import java.util.function.BiPredicate;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.GameState; import net.runelite.api.GameState;
import net.runelite.api.events.ChatMessage; import net.runelite.api.events.ChatMessage;
import net.runelite.client.eventbus.EventBus; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.events.ChatInput; import net.runelite.client.events.ChatInput;
import net.runelite.client.events.ChatboxInput; import net.runelite.client.events.ChatboxInput;
import net.runelite.client.events.PrivateMessageInput; import net.runelite.client.events.PrivateMessageInput;
@Singleton @Singleton
@Slf4j
public class ChatCommandManager implements ChatboxInputListener public class ChatCommandManager implements ChatboxInputListener
{ {
private final Map<String, ChatCommand> commands = new HashMap<>(); private final Map<String, ChatCommand> commands = new HashMap<>();
@@ -55,8 +52,10 @@ public class ChatCommandManager implements ChatboxInputListener
{ {
this.client = client; this.client = client;
this.scheduledExecutorService = scheduledExecutorService; this.scheduledExecutorService = scheduledExecutorService;
eventBus.register(this); // eventBus.register(this);
commandManager.register(this); commandManager.register(this);
eventBus.subscribe(ChatMessage.class, this, this::onChatMessage);
} }
public void registerCommand(String command, BiConsumer<ChatMessage, String> execute) public void registerCommand(String command, BiConsumer<ChatMessage, String> execute)
@@ -84,8 +83,7 @@ public class ChatCommandManager implements ChatboxInputListener
commands.remove(command.toLowerCase()); commands.remove(command.toLowerCase());
} }
@Subscribe private void onChatMessage(ChatMessage chatMessage)
public void onChatMessage(ChatMessage chatMessage)
{ {
if (client.getGameState() != GameState.LOGGED_IN) if (client.getGameState() != GameState.LOGGED_IN)
{ {

View File

@@ -52,7 +52,7 @@ import net.runelite.api.events.ScriptCallbackEvent;
import net.runelite.api.events.VarbitChanged; import net.runelite.api.events.VarbitChanged;
import net.runelite.client.callback.ClientThread; import net.runelite.client.callback.ClientThread;
import net.runelite.client.config.ChatColorConfig; import net.runelite.client.config.ChatColorConfig;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.ui.JagexColors; import net.runelite.client.ui.JagexColors;
import net.runelite.client.util.ColorUtil; import net.runelite.client.util.ColorUtil;
@@ -70,17 +70,23 @@ public class ChatMessageManager
@Inject @Inject
private ChatMessageManager( private ChatMessageManager(
Client client, final Client client,
ChatColorConfig chatColorConfig, final ChatColorConfig chatColorConfig,
ClientThread clientThread) final ClientThread clientThread,
final EventBus eventbus)
{ {
this.client = client; this.client = client;
this.chatColorConfig = chatColorConfig; this.chatColorConfig = chatColorConfig;
this.clientThread = clientThread; this.clientThread = clientThread;
eventbus.subscribe(VarbitChanged.class, this, this::onVarbitChanged);
eventbus.subscribe(ResizeableChanged.class, this, this::onResizeableChanged);
eventbus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
eventbus.subscribe(ChatMessage.class, this, this::onChatMessage);
eventbus.subscribe(ScriptCallbackEvent.class, this, this::onScriptCallbackEvent);
} }
@Subscribe private void onVarbitChanged(VarbitChanged event)
public void onVarbitChanged(VarbitChanged event)
{ {
int setting = client.getVar(Varbits.TRANSPARENT_CHATBOX); int setting = client.getVar(Varbits.TRANSPARENT_CHATBOX);
@@ -91,14 +97,12 @@ public class ChatMessageManager
} }
} }
@Subscribe private void onResizeableChanged(ResizeableChanged event)
public void onResizeableChanged(ResizeableChanged event)
{ {
refreshAll(); refreshAll();
} }
@Subscribe private void onConfigChanged(ConfigChanged event)
public void onConfigChanged(ConfigChanged event)
{ {
if (event.getGroup().equals("textrecolor")) if (event.getGroup().equals("textrecolor"))
{ {
@@ -107,8 +111,7 @@ public class ChatMessageManager
} }
} }
@Subscribe private void onChatMessage(ChatMessage chatMessage)
public void onChatMessage(ChatMessage chatMessage)
{ {
MessageNode messageNode = chatMessage.getMessageNode(); MessageNode messageNode = chatMessage.getMessageNode();
ChatMessageType chatMessageType = chatMessage.getType(); ChatMessageType chatMessageType = chatMessage.getType();
@@ -173,8 +176,7 @@ public class ChatMessageManager
} }
} }
@Subscribe private void onScriptCallbackEvent(ScriptCallbackEvent scriptCallbackEvent)
public void onScriptCallbackEvent(ScriptCallbackEvent scriptCallbackEvent)
{ {
final String eventName = scriptCallbackEvent.getEventName(); final String eventName = scriptCallbackEvent.getEventName();

View File

@@ -38,7 +38,6 @@ import net.runelite.api.events.CommandExecuted;
import net.runelite.api.events.ScriptCallbackEvent; import net.runelite.api.events.ScriptCallbackEvent;
import net.runelite.client.callback.ClientThread; import net.runelite.client.callback.ClientThread;
import net.runelite.client.eventbus.EventBus; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.events.ChatboxInput; import net.runelite.client.events.ChatboxInput;
import net.runelite.client.events.PrivateMessageInput; import net.runelite.client.events.PrivateMessageInput;
@@ -58,11 +57,17 @@ public class CommandManager
private final List<ChatboxInputListener> chatboxInputListenerList = new ArrayList<>(); private final List<ChatboxInputListener> chatboxInputListenerList = new ArrayList<>();
@Inject @Inject
private CommandManager(Client client, EventBus eventBus, ClientThread clientThread) private CommandManager(
final Client client,
final EventBus eventBus,
final ClientThread clientThread
)
{ {
this.client = client; this.client = client;
this.eventBus = eventBus; this.eventBus = eventBus;
this.clientThread = clientThread; this.clientThread = clientThread;
eventBus.subscribe(ScriptCallbackEvent.class, this, this::onScriptCallbackEvent);
} }
public void register(ChatboxInputListener chatboxInputListener) public void register(ChatboxInputListener chatboxInputListener)
@@ -75,7 +80,6 @@ public class CommandManager
chatboxInputListenerList.remove(chatboxInputListener); chatboxInputListenerList.remove(chatboxInputListener);
} }
@Subscribe
private void onScriptCallbackEvent(ScriptCallbackEvent event) private void onScriptCallbackEvent(ScriptCallbackEvent event)
{ {
if (sending) if (sending)
@@ -115,7 +119,7 @@ public class CommandManager
String[] args = Arrays.copyOfRange(split, 1, split.length); String[] args = Arrays.copyOfRange(split, 1, split.length);
CommandExecuted commandExecuted = new CommandExecuted(command, args); CommandExecuted commandExecuted = new CommandExecuted(command, args);
eventBus.post(commandExecuted); eventBus.post(CommandExecuted.class, commandExecuted);
} }
private void handleInput(ScriptCallbackEvent event) private void handleInput(ScriptCallbackEvent event)

View File

@@ -66,8 +66,8 @@ import net.runelite.api.events.ConfigChanged;
import net.runelite.client.RuneLite; import net.runelite.client.RuneLite;
import static net.runelite.client.RuneLite.PROFILES_DIR; import static net.runelite.client.RuneLite.PROFILES_DIR;
import net.runelite.client.eventbus.EventBus; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.util.ColorUtil;
import net.runelite.client.ui.FontManager; import net.runelite.client.ui.FontManager;
import net.runelite.client.util.ColorUtil;
@Singleton @Singleton
@Slf4j @Slf4j
@@ -89,7 +89,6 @@ public class ConfigManager
@Inject @Inject
public ConfigManager(ScheduledExecutorService scheduledExecutorService) public ConfigManager(ScheduledExecutorService scheduledExecutorService)
{ {
scheduledExecutorService.scheduleWithFixedDelay(this::sendConfig, 30, 30, TimeUnit.SECONDS); scheduledExecutorService.scheduleWithFixedDelay(this::sendConfig, 30, 30, TimeUnit.SECONDS);
} }
@@ -194,7 +193,7 @@ public class ConfigManager
configChanged.setKey(key); configChanged.setKey(key);
configChanged.setOldValue(null); configChanged.setOldValue(null);
configChanged.setNewValue(value); configChanged.setNewValue(value);
eventBus.post(configChanged); eventBus.post(ConfigChanged.class, configChanged);
}); });
} }
catch (Exception ex) catch (Exception ex)
@@ -233,7 +232,7 @@ public class ConfigManager
private void postConfigChanged(ConfigChanged configChanged) private void postConfigChanged(ConfigChanged configChanged)
{ {
configObjectCache.remove(configChanged.getGroup() + "." + configChanged.getKey()); configObjectCache.remove(configChanged.getGroup() + "." + configChanged.getKey());
eventBus.post(configChanged); eventBus.post(ConfigChanged.class, configChanged);
} }
public <T> T getConfig(Class<T> clazz) public <T> T getConfig(Class<T> clazz)
@@ -332,7 +331,7 @@ public class ConfigManager
configChanged.setKey(key); configChanged.setKey(key);
configChanged.setOldValue(oldValue); configChanged.setOldValue(oldValue);
eventBus.post(configChanged); eventBus.post(ConfigChanged.class, configChanged);
} }
public ConfigDescriptor getConfigDescriptor(Object configurationProxy) public ConfigDescriptor getConfigDescriptor(Object configurationProxy)

View File

@@ -28,6 +28,7 @@ import java.awt.Dimension;
import java.awt.Font; import java.awt.Font;
import net.runelite.api.Constants; import net.runelite.api.Constants;
import net.runelite.client.ui.FontManager; import net.runelite.client.ui.FontManager;
import net.runelite.client.ui.ContainableFrame;
@ConfigGroup("runelite") @ConfigGroup("runelite")
public interface RuneLiteConfig extends Config public interface RuneLiteConfig extends Config
@@ -66,14 +67,14 @@ public interface RuneLiteConfig extends Config
} }
@ConfigItem( @ConfigItem(
keyName = "containInScreen", keyName = "containInScreen2",
name = "Contain in screen", name = "Contain in screen",
description = "Makes the client stay contained in the screen when attempted to move out of it.<br>Note: Only works if custom chrome is enabled.", description = "Makes the client stay contained in the screen when attempted to move out of it.<br>Note: 'Always' only works if custom chrome is enabled.",
position = 13 position = 13
) )
default boolean containInScreen() default ContainableFrame.Mode containInScreen()
{ {
return false; return ContainableFrame.Mode.RESIZING;
} }
@ConfigItem( @ConfigItem(

View File

@@ -198,7 +198,7 @@ public class DiscordService implements AutoCloseable
{ {
log.info("Discord RPC service is ready with user {}.", user.username); log.info("Discord RPC service is ready with user {}.", user.username);
currentUser = user; currentUser = user;
eventBus.post(new DiscordReady( eventBus.post(DiscordReady.class, new DiscordReady(
user.userId, user.userId,
user.username, user.username,
user.discriminator, user.discriminator,
@@ -207,28 +207,28 @@ public class DiscordService implements AutoCloseable
private void disconnected(int errorCode, String message) private void disconnected(int errorCode, String message)
{ {
eventBus.post(new DiscordDisconnected(errorCode, message)); eventBus.post(DiscordDisconnected.class, new DiscordDisconnected(errorCode, message));
} }
private void errored(int errorCode, String message) private void errored(int errorCode, String message)
{ {
log.warn("Discord error: {} - {}", errorCode, message); log.warn("Discord error: {} - {}", errorCode, message);
eventBus.post(new DiscordErrored(errorCode, message)); eventBus.post(DiscordErrored.class, new DiscordErrored(errorCode, message));
} }
private void joinGame(String joinSecret) private void joinGame(String joinSecret)
{ {
eventBus.post(new DiscordJoinGame(joinSecret)); eventBus.post(DiscordJoinGame.class, new DiscordJoinGame(joinSecret));
} }
private void spectateGame(String spectateSecret) private void spectateGame(String spectateSecret)
{ {
eventBus.post(new DiscordSpectateGame(spectateSecret)); eventBus.post(DiscordSpectateGame.class, new DiscordSpectateGame(spectateSecret));
} }
private void joinRequest(DiscordUser user) private void joinRequest(DiscordUser user)
{ {
eventBus.post(new DiscordJoinRequest( eventBus.post(DiscordJoinRequest.class, new DiscordJoinRequest(
user.userId, user.userId,
user.username, user.username,
user.discriminator, user.discriminator,

View File

@@ -1,249 +1,72 @@
/*
* Copyright (c) 2018, Tomas Slusny <slusnucky@gmail.com>
* Copyright (c) 2018, Abex
* 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.eventbus; package net.runelite.client.eventbus;
import com.google.common.base.Preconditions; import com.jakewharton.rxrelay2.PublishRelay;
import com.google.common.collect.HashMultimap; import com.jakewharton.rxrelay2.Relay;
import com.google.common.collect.ImmutableMultimap; import io.reactivex.annotations.NonNull;
import com.google.common.collect.Multimap; import io.reactivex.disposables.CompositeDisposable;
import java.lang.invoke.CallSite; import io.reactivex.disposables.Disposable;
import java.lang.invoke.LambdaMetafactory; import io.reactivex.functions.Consumer;
import java.lang.invoke.MethodHandle; import java.util.HashMap;
import java.lang.invoke.MethodHandles; import java.util.Map;
import java.lang.invoke.MethodType; import java.util.Objects;
import java.lang.reflect.Field; import javax.inject.Singleton;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.function.Consumer;
import javax.annotation.Nonnull;
import javax.annotation.concurrent.ThreadSafe;
import lombok.EqualsAndHashCode;
import lombok.RequiredArgsConstructor;
import lombok.Value;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@Slf4j @Slf4j
@RequiredArgsConstructor @Singleton
@ThreadSafe public class EventBus implements EventBusInterface
public class EventBus
{ {
@FunctionalInterface private Map<Class<?>, Relay<Object>> subjectList = new HashMap<>();
public interface SubscriberMethod private Map<Object, CompositeDisposable> subscriptionsMap = new HashMap<>();
@NonNull
private <T> Relay<Object> getSubject(Class<T> eventClass)
{ {
void invoke(Object event); return subjectList.computeIfAbsent(eventClass, k -> PublishRelay.create().toSerialized());
} }
@Value @NonNull
private static class Subscriber private CompositeDisposable getCompositeDisposable(@NonNull Object object)
{ {
private final Object object; CompositeDisposable compositeDisposable = subscriptionsMap.get(object);
private final Method method; if (compositeDisposable == null)
@EqualsAndHashCode.Exclude
private final SubscriberMethod lamda;
void invoke(final Object arg) throws Exception
{ {
if (lamda != null) compositeDisposable = new CompositeDisposable();
subscriptionsMap.put(object, compositeDisposable);
}
return compositeDisposable;
}
@Override
// Subscribe on lifecycle (for example from plugin startUp -> shutdown)
public <T> void subscribe(Class<T> eventClass, @NonNull Object lifecycle, @NonNull Consumer<T> action)
{
Disposable disposable = getSubject(eventClass)
.filter(Objects::nonNull) // Filter out null objects, better safe than sorry
.cast(eventClass) // Cast it for easier usage
.subscribe(action, error ->
{ {
lamda.invoke(arg); log.error("Error in eventbus: {}", error.getMessage());
} });
else
{ getCompositeDisposable(lifecycle).add(disposable);
method.invoke(object, arg); }
}
@Override
public void unregister(@NonNull Object lifecycle)
{
//We have to remove the composition from the map, because once you dispose it can't be used anymore
CompositeDisposable compositeDisposable = subscriptionsMap.remove(lifecycle);
if (compositeDisposable != null)
{
compositeDisposable.dispose();
} }
} }
private final Consumer<Throwable> exceptionHandler; @Override
private ImmutableMultimap<Class, Subscriber> subscribers = ImmutableMultimap.of(); public <T> void post(Class<T> eventClass, @NonNull Object event)
/**
* Instantiates EventBus with default exception handler
*/
public EventBus()
{ {
this((e) -> log.warn("Uncaught exception in event subscriber", e)); getSubject(eventClass).accept(event);
}
/**
* Registers subscriber to EventBus. All methods in subscriber and it's parent classes are checked for
* {@link Subscribe} annotation and then added to map of subscriptions.
*
* @param object subscriber to register
* @throws IllegalArgumentException in case subscriber method name is wrong (correct format is 'on' + EventName
*/
public synchronized void register(@Nonnull final Object object)
{
final ImmutableMultimap.Builder<Class, Subscriber> builder = ImmutableMultimap.builder();
if (subscribers != null)
{
builder.putAll(subscribers);
}
for (Class<?> clazz = object.getClass(); clazz != null; clazz = clazz.getSuperclass())
{
for (final Method method : clazz.getDeclaredMethods())
{
final Subscribe sub = method.getAnnotation(Subscribe.class);
if (sub == null)
{
continue;
}
Preconditions.checkArgument(method.getReturnType() == Void.TYPE, "@Subscribed method \"" + method + "\" cannot return a value");
Preconditions.checkArgument(method.getParameterCount() == 1, "@Subscribed method \"" + method + "\" must take exactly 1 argument");
Preconditions.checkArgument(!Modifier.isStatic(method.getModifiers()), "@Subscribed method \"" + method + "\" cannot be static");
final Class<?> parameterClazz = method.getParameterTypes()[0];
Preconditions.checkArgument(!parameterClazz.isPrimitive(), "@Subscribed method \"" + method + "\" cannot subscribe to primitives");
Preconditions.checkArgument((parameterClazz.getModifiers() & (Modifier.ABSTRACT | Modifier.INTERFACE)) == 0, "@Subscribed method \"" + method + "\" cannot subscribe to polymorphic classes");
for (Class<?> psc = parameterClazz.getSuperclass(); psc != null; psc = psc.getSuperclass())
{
if (subscribers.containsKey(psc))
{
throw new IllegalArgumentException("@Subscribed method \"" + method + "\" cannot subscribe to class which inherits from subscribed class \"" + psc + "\"");
}
}
final String preferredName = "on" + parameterClazz.getSimpleName();
Preconditions.checkArgument(method.getName().equals(preferredName), "Subscribed method " + method + " should be named " + preferredName);
method.setAccessible(true);
SubscriberMethod lambda = null;
try
{
final MethodHandles.Lookup caller = privateLookupIn(clazz);
final MethodType subscription = MethodType.methodType(void.class, parameterClazz);
final MethodHandle target = caller.findVirtual(clazz, method.getName(), subscription);
final CallSite site = LambdaMetafactory.metafactory(
caller,
"invoke",
MethodType.methodType(SubscriberMethod.class, clazz),
subscription.changeParameterType(0, Object.class),
target,
subscription);
final MethodHandle factory = site.getTarget();
lambda = (SubscriberMethod) factory.bindTo(object).invokeExact();
}
catch (Throwable e)
{
log.warn("Unable to create lambda for method {}", method, e);
}
final Subscriber subscriber = new Subscriber(object, method, lambda);
builder.put(parameterClazz, subscriber);
log.debug("Registering {} - {}", parameterClazz, subscriber);
}
}
subscribers = builder.build();
}
/**
* Unregisters all subscribed methods from provided subscriber object.
*
* @param object object to unsubscribe from
*/
public synchronized void unregister(@Nonnull final Object object)
{
if (subscribers == null)
{
return;
}
final Multimap<Class, Subscriber> map = HashMultimap.create();
map.putAll(subscribers);
for (Class<?> clazz = object.getClass(); clazz != null; clazz = clazz.getSuperclass())
{
for (final Method method : clazz.getDeclaredMethods())
{
final Subscribe sub = method.getAnnotation(Subscribe.class);
if (sub == null)
{
continue;
}
final Class<?> parameterClazz = method.getParameterTypes()[0];
map.remove(parameterClazz, new Subscriber(object, method, null));
}
}
subscribers = ImmutableMultimap.copyOf(map);
}
/**
* Posts provided event to all registered subscribers. Subscriber calls are invoked immediately and in order
* in which subscribers were registered.
*
* @param event event to post
*/
public void post(@Nonnull final Object event)
{
for (final Subscriber subscriber : subscribers.get(event.getClass()))
{
try
{
subscriber.invoke(event);
}
catch (Exception e)
{
exceptionHandler.accept(e);
}
}
}
private static MethodHandles.Lookup privateLookupIn(Class clazz) throws IllegalAccessException, NoSuchFieldException, InvocationTargetException
{
try
{
// Java 9+ has privateLookupIn method on MethodHandles, but since we are shipping and using Java 8
// we need to access it via reflection. This is preferred way because it's Java 9+ public api and is
// likely to not change
final Method privateLookupIn = MethodHandles.class.getMethod("privateLookupIn", Class.class, MethodHandles.Lookup.class);
return (MethodHandles.Lookup) privateLookupIn.invoke(null, clazz, MethodHandles.lookup());
}
catch (NoSuchMethodException e)
{
// In Java 8 we first do standard lookupIn class
final MethodHandles.Lookup lookupIn = MethodHandles.lookup().in(clazz);
// and then we mark it as trusted for private lookup via reflection on private field
final Field modes = MethodHandles.Lookup.class.getDeclaredField("allowedModes");
modes.setAccessible(true);
modes.setInt(lookupIn, -1); // -1 == TRUSTED
return lookupIn;
}
} }
} }

View File

@@ -0,0 +1,13 @@
package net.runelite.client.eventbus;
import io.reactivex.annotations.NonNull;
import io.reactivex.functions.Consumer;
public interface EventBusInterface
{
<T> void subscribe(Class<T> eventClass, @NonNull Object lifecycle, @NonNull Consumer<T> action);
void unregister(@NonNull Object lifecycle);
<T> void post(Class<T> eventClass, @NonNull Object event);
}

View File

@@ -44,7 +44,7 @@ import net.runelite.api.IndexedSprite;
import net.runelite.api.SpriteID; import net.runelite.api.SpriteID;
import net.runelite.api.events.ClanChanged; import net.runelite.api.events.ClanChanged;
import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.GameStateChanged;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.util.ImageUtil; import net.runelite.client.util.ImageUtil;
import net.runelite.client.util.Text; import net.runelite.client.util.Text;
@@ -97,10 +97,17 @@ public class ClanManager
private int modIconsLength; private int modIconsLength;
@Inject @Inject
private ClanManager(Client client, SpriteManager spriteManager) private ClanManager(
final Client client,
final SpriteManager spriteManager,
final EventBus eventbus
)
{ {
this.client = client; this.client = client;
this.spriteManager = spriteManager; this.spriteManager = spriteManager;
eventbus.subscribe(GameStateChanged.class, this, this::onGameStateChanged);
eventbus.subscribe(ClanChanged.class, this, this::onClanChanged);
} }
public ClanMemberRank getRank(String playerName) public ClanMemberRank getRank(String playerName)
@@ -123,8 +130,7 @@ public class ClanManager
return modIconsLength - CLANCHAT_IMAGES.length + clanMemberRank.ordinal() - 1; return modIconsLength - CLANCHAT_IMAGES.length + clanMemberRank.ordinal() - 1;
} }
@Subscribe private void onGameStateChanged(GameStateChanged gameStateChanged)
public void onGameStateChanged(GameStateChanged gameStateChanged)
{ {
if (gameStateChanged.getGameState() == GameState.LOGGED_IN if (gameStateChanged.getGameState() == GameState.LOGGED_IN
&& modIconsLength == 0) && modIconsLength == 0)
@@ -133,8 +139,7 @@ public class ClanManager
} }
} }
@Subscribe private void onClanChanged(ClanChanged clanChanged)
public void onClanChanged(ClanChanged clanChanged)
{ {
clanRanksCache.invalidateAll(); clanRanksCache.invalidateAll();
} }

View File

@@ -28,9 +28,14 @@ import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader; import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache; import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import java.awt.Color; import java.awt.Color;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@@ -50,121 +55,12 @@ import static net.runelite.api.Constants.HIGH_ALCHEMY_MULTIPLIER;
import net.runelite.api.GameState; import net.runelite.api.GameState;
import net.runelite.api.ItemDefinition; import net.runelite.api.ItemDefinition;
import net.runelite.api.ItemID; import net.runelite.api.ItemID;
import static net.runelite.api.ItemID.AGILITY_CAPE; import static net.runelite.api.ItemID.*;
import static net.runelite.api.ItemID.AGILITY_CAPET;
import static net.runelite.api.ItemID.AGILITY_CAPET_13341;
import static net.runelite.api.ItemID.AGILITY_CAPE_13340;
import static net.runelite.api.ItemID.BOOTS_OF_LIGHTNESS;
import static net.runelite.api.ItemID.BOOTS_OF_LIGHTNESS_89;
import static net.runelite.api.ItemID.GRACEFUL_BOOTS;
import static net.runelite.api.ItemID.GRACEFUL_BOOTS_11861;
import static net.runelite.api.ItemID.GRACEFUL_BOOTS_13589;
import static net.runelite.api.ItemID.GRACEFUL_BOOTS_13590;
import static net.runelite.api.ItemID.GRACEFUL_BOOTS_13601;
import static net.runelite.api.ItemID.GRACEFUL_BOOTS_13602;
import static net.runelite.api.ItemID.GRACEFUL_BOOTS_13613;
import static net.runelite.api.ItemID.GRACEFUL_BOOTS_13614;
import static net.runelite.api.ItemID.GRACEFUL_BOOTS_13625;
import static net.runelite.api.ItemID.GRACEFUL_BOOTS_13626;
import static net.runelite.api.ItemID.GRACEFUL_BOOTS_13637;
import static net.runelite.api.ItemID.GRACEFUL_BOOTS_13638;
import static net.runelite.api.ItemID.GRACEFUL_BOOTS_13677;
import static net.runelite.api.ItemID.GRACEFUL_BOOTS_13678;
import static net.runelite.api.ItemID.GRACEFUL_BOOTS_21076;
import static net.runelite.api.ItemID.GRACEFUL_BOOTS_21078;
import static net.runelite.api.ItemID.GRACEFUL_CAPE;
import static net.runelite.api.ItemID.GRACEFUL_CAPE_11853;
import static net.runelite.api.ItemID.GRACEFUL_CAPE_13581;
import static net.runelite.api.ItemID.GRACEFUL_CAPE_13582;
import static net.runelite.api.ItemID.GRACEFUL_CAPE_13593;
import static net.runelite.api.ItemID.GRACEFUL_CAPE_13594;
import static net.runelite.api.ItemID.GRACEFUL_CAPE_13605;
import static net.runelite.api.ItemID.GRACEFUL_CAPE_13606;
import static net.runelite.api.ItemID.GRACEFUL_CAPE_13617;
import static net.runelite.api.ItemID.GRACEFUL_CAPE_13618;
import static net.runelite.api.ItemID.GRACEFUL_CAPE_13629;
import static net.runelite.api.ItemID.GRACEFUL_CAPE_13630;
import static net.runelite.api.ItemID.GRACEFUL_CAPE_13669;
import static net.runelite.api.ItemID.GRACEFUL_CAPE_13670;
import static net.runelite.api.ItemID.GRACEFUL_CAPE_21064;
import static net.runelite.api.ItemID.GRACEFUL_CAPE_21066;
import static net.runelite.api.ItemID.GRACEFUL_GLOVES;
import static net.runelite.api.ItemID.GRACEFUL_GLOVES_11859;
import static net.runelite.api.ItemID.GRACEFUL_GLOVES_13587;
import static net.runelite.api.ItemID.GRACEFUL_GLOVES_13588;
import static net.runelite.api.ItemID.GRACEFUL_GLOVES_13599;
import static net.runelite.api.ItemID.GRACEFUL_GLOVES_13600;
import static net.runelite.api.ItemID.GRACEFUL_GLOVES_13611;
import static net.runelite.api.ItemID.GRACEFUL_GLOVES_13612;
import static net.runelite.api.ItemID.GRACEFUL_GLOVES_13623;
import static net.runelite.api.ItemID.GRACEFUL_GLOVES_13624;
import static net.runelite.api.ItemID.GRACEFUL_GLOVES_13635;
import static net.runelite.api.ItemID.GRACEFUL_GLOVES_13636;
import static net.runelite.api.ItemID.GRACEFUL_GLOVES_13675;
import static net.runelite.api.ItemID.GRACEFUL_GLOVES_13676;
import static net.runelite.api.ItemID.GRACEFUL_GLOVES_21073;
import static net.runelite.api.ItemID.GRACEFUL_GLOVES_21075;
import static net.runelite.api.ItemID.GRACEFUL_HOOD;
import static net.runelite.api.ItemID.GRACEFUL_HOOD_11851;
import static net.runelite.api.ItemID.GRACEFUL_HOOD_13579;
import static net.runelite.api.ItemID.GRACEFUL_HOOD_13580;
import static net.runelite.api.ItemID.GRACEFUL_HOOD_13591;
import static net.runelite.api.ItemID.GRACEFUL_HOOD_13592;
import static net.runelite.api.ItemID.GRACEFUL_HOOD_13603;
import static net.runelite.api.ItemID.GRACEFUL_HOOD_13604;
import static net.runelite.api.ItemID.GRACEFUL_HOOD_13615;
import static net.runelite.api.ItemID.GRACEFUL_HOOD_13616;
import static net.runelite.api.ItemID.GRACEFUL_HOOD_13627;
import static net.runelite.api.ItemID.GRACEFUL_HOOD_13628;
import static net.runelite.api.ItemID.GRACEFUL_HOOD_13667;
import static net.runelite.api.ItemID.GRACEFUL_HOOD_13668;
import static net.runelite.api.ItemID.GRACEFUL_HOOD_21061;
import static net.runelite.api.ItemID.GRACEFUL_HOOD_21063;
import static net.runelite.api.ItemID.GRACEFUL_LEGS;
import static net.runelite.api.ItemID.GRACEFUL_LEGS_11857;
import static net.runelite.api.ItemID.GRACEFUL_LEGS_13585;
import static net.runelite.api.ItemID.GRACEFUL_LEGS_13586;
import static net.runelite.api.ItemID.GRACEFUL_LEGS_13597;
import static net.runelite.api.ItemID.GRACEFUL_LEGS_13598;
import static net.runelite.api.ItemID.GRACEFUL_LEGS_13609;
import static net.runelite.api.ItemID.GRACEFUL_LEGS_13610;
import static net.runelite.api.ItemID.GRACEFUL_LEGS_13621;
import static net.runelite.api.ItemID.GRACEFUL_LEGS_13622;
import static net.runelite.api.ItemID.GRACEFUL_LEGS_13633;
import static net.runelite.api.ItemID.GRACEFUL_LEGS_13634;
import static net.runelite.api.ItemID.GRACEFUL_LEGS_13673;
import static net.runelite.api.ItemID.GRACEFUL_LEGS_13674;
import static net.runelite.api.ItemID.GRACEFUL_LEGS_21070;
import static net.runelite.api.ItemID.GRACEFUL_LEGS_21072;
import static net.runelite.api.ItemID.GRACEFUL_TOP;
import static net.runelite.api.ItemID.GRACEFUL_TOP_11855;
import static net.runelite.api.ItemID.GRACEFUL_TOP_13583;
import static net.runelite.api.ItemID.GRACEFUL_TOP_13584;
import static net.runelite.api.ItemID.GRACEFUL_TOP_13595;
import static net.runelite.api.ItemID.GRACEFUL_TOP_13596;
import static net.runelite.api.ItemID.GRACEFUL_TOP_13607;
import static net.runelite.api.ItemID.GRACEFUL_TOP_13608;
import static net.runelite.api.ItemID.GRACEFUL_TOP_13619;
import static net.runelite.api.ItemID.GRACEFUL_TOP_13620;
import static net.runelite.api.ItemID.GRACEFUL_TOP_13631;
import static net.runelite.api.ItemID.GRACEFUL_TOP_13632;
import static net.runelite.api.ItemID.GRACEFUL_TOP_13671;
import static net.runelite.api.ItemID.GRACEFUL_TOP_13672;
import static net.runelite.api.ItemID.GRACEFUL_TOP_21067;
import static net.runelite.api.ItemID.GRACEFUL_TOP_21069;
import static net.runelite.api.ItemID.MAX_CAPE;
import static net.runelite.api.ItemID.MAX_CAPE_13342;
import static net.runelite.api.ItemID.PENANCE_GLOVES;
import static net.runelite.api.ItemID.PENANCE_GLOVES_10554;
import static net.runelite.api.ItemID.SPOTTED_CAPE;
import static net.runelite.api.ItemID.SPOTTED_CAPE_10073;
import static net.runelite.api.ItemID.SPOTTIER_CAPE;
import static net.runelite.api.ItemID.SPOTTIER_CAPE_10074;
import net.runelite.api.Sprite; import net.runelite.api.Sprite;
import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.GameStateChanged;
import net.runelite.api.events.PostItemDefinition; import net.runelite.api.events.PostItemDefinition;
import net.runelite.client.callback.ClientThread; import net.runelite.client.callback.ClientThread;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.EventBus;
import net.runelite.http.api.item.ItemClient; import net.runelite.http.api.item.ItemClient;
import net.runelite.http.api.item.ItemPrice; import net.runelite.http.api.item.ItemPrice;
import net.runelite.http.api.item.ItemStats; import net.runelite.http.api.item.ItemStats;
@@ -174,33 +70,6 @@ import org.jetbrains.annotations.NotNull;
@Slf4j @Slf4j
public class ItemManager public class ItemManager
{ {
@Value
private static class ImageKey
{
private final int itemId;
private final int itemQuantity;
private final boolean stackable;
}
@Value
private static class OutlineKey
{
private final int itemId;
private final int itemQuantity;
private final Color outlineColor;
}
private final Client client;
private final ScheduledExecutorService scheduledExecutorService;
private final ClientThread clientThread;
private final ItemClient itemClient = new ItemClient();
private Map<Integer, ItemPrice> itemPrices = Collections.emptyMap();
private Map<Integer, ItemStats> itemStats = Collections.emptyMap();
private final LoadingCache<ImageKey, AsyncBufferedImage> itemImages;
private final LoadingCache<Integer, ItemDefinition> itemDefinitions;
private final LoadingCache<OutlineKey, BufferedImage> itemOutlines;
// Worn items with weight reducing property have a different worn and inventory ItemID // Worn items with weight reducing property have a different worn and inventory ItemID
private static final ImmutableMap<Integer, Integer> WORN_ITEMS = ImmutableMap.<Integer, Integer>builder(). private static final ImmutableMap<Integer, Integer> WORN_ITEMS = ImmutableMap.<Integer, Integer>builder().
put(BOOTS_OF_LIGHTNESS_89, BOOTS_OF_LIGHTNESS). put(BOOTS_OF_LIGHTNESS_89, BOOTS_OF_LIGHTNESS).
@@ -263,9 +132,23 @@ public class ItemManager
put(AGILITY_CAPET_13341, AGILITY_CAPET). put(AGILITY_CAPET_13341, AGILITY_CAPET).
put(AGILITY_CAPE_13340, AGILITY_CAPE). put(AGILITY_CAPE_13340, AGILITY_CAPE).
build(); build();
private final Client client;
private final ScheduledExecutorService scheduledExecutorService;
private final ClientThread clientThread;
private final ItemClient itemClient = new ItemClient();
private final ImmutableMap<Integer, ItemStats> itemStatMap;
private final LoadingCache<ImageKey, AsyncBufferedImage> itemImages;
private final LoadingCache<Integer, ItemDefinition> itemDefinitions;
private final LoadingCache<OutlineKey, BufferedImage> itemOutlines;
private Map<Integer, ItemPrice> itemPrices = Collections.emptyMap();
private Map<Integer, ItemStats> itemStats = Collections.emptyMap();
@Inject @Inject
public ItemManager(Client client, ScheduledExecutorService executor, ClientThread clientThread) public ItemManager(
Client client,
ScheduledExecutorService executor,
ClientThread clientThread,
EventBus eventbus
)
{ {
this.client = client; this.client = client;
this.scheduledExecutorService = executor; this.scheduledExecutorService = executor;
@@ -309,6 +192,19 @@ public class ItemManager
return loadItemOutline(key.itemId, key.itemQuantity, key.outlineColor); return loadItemOutline(key.itemId, key.itemQuantity, key.outlineColor);
} }
}); });
final Gson gson = new Gson();
final Type typeToken = new TypeToken<Map<Integer, ItemStats>>()
{
}.getType();
final InputStream statsFile = getClass().getResourceAsStream("/item_stats.json");
final Map<Integer, ItemStats> stats = gson.fromJson(new InputStreamReader(statsFile), typeToken);
itemStatMap = ImmutableMap.copyOf(stats);
eventbus.subscribe(GameStateChanged.class, this, this::onGameStateChanged);
eventbus.subscribe(PostItemDefinition.class, this, this::onPostItemDefinition);
} }
private void loadPrices() private void loadPrices()
@@ -352,9 +248,7 @@ public class ItemManager
} }
} }
private void onGameStateChanged(final GameStateChanged event)
@Subscribe
public void onGameStateChanged(final GameStateChanged event)
{ {
if (event.getGameState() == GameState.HOPPING || event.getGameState() == GameState.LOGIN_SCREEN) if (event.getGameState() == GameState.HOPPING || event.getGameState() == GameState.LOGIN_SCREEN)
{ {
@@ -362,8 +256,7 @@ public class ItemManager
} }
} }
@Subscribe private void onPostItemDefinition(PostItemDefinition event)
public void onPostItemDefinition(PostItemDefinition event)
{ {
itemDefinitions.put(event.getItemDefinition().getId(), event.getItemDefinition()); itemDefinitions.put(event.getItemDefinition().getId(), event.getItemDefinition());
} }
@@ -392,7 +285,7 @@ public class ItemManager
/** /**
* Look up an item's price * Look up an item's price
* *
* @param itemID item id * @param itemID item id
* @param ignoreUntradeableMap should the price returned ignore the {@link UntradeableItemMapping} * @param ignoreUntradeableMap should the price returned ignore the {@link UntradeableItemMapping}
* @return item price * @return item price
*/ */
@@ -473,7 +366,7 @@ public class ItemManager
return null; return null;
} }
return itemStats.get(canonicalize(itemId)); return itemStatMap.get(canonicalize(itemId));
} }
/** /**
@@ -629,4 +522,20 @@ public class ItemManager
return null; return null;
} }
} }
@Value
private static class ImageKey
{
private final int itemId;
private final int itemQuantity;
private final boolean stackable;
}
@Value
private static class OutlineKey
{
private final int itemId;
private final int itemQuantity;
private final Color outlineColor;
}
} }

View File

@@ -0,0 +1,27 @@
package net.runelite.client.game;
import lombok.Value;
@Value
public class ItemStat
{
private int slot;
private int astab;
private int aslash;
private int acrush;
private int amagic;
private int arange;
private int dstab;
private int dslash;
private int dcrush;
private int dmagic;
private int drange;
private int str;
private int rstr;
private int mdmg;
private int prayer;
private int aspeed;
}

View File

@@ -54,7 +54,6 @@ import net.runelite.api.events.ItemSpawned;
import net.runelite.api.events.NpcDespawned; import net.runelite.api.events.NpcDespawned;
import net.runelite.api.events.PlayerDespawned; import net.runelite.api.events.PlayerDespawned;
import net.runelite.client.eventbus.EventBus; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.events.NpcLootReceived; import net.runelite.client.events.NpcLootReceived;
import net.runelite.client.events.PlayerLootReceived; import net.runelite.client.events.PlayerLootReceived;
@@ -74,14 +73,24 @@ public class LootManager
private WorldPoint krakenPlayerLocation; private WorldPoint krakenPlayerLocation;
@Inject @Inject
private LootManager(EventBus eventBus, Client client) private LootManager(
final EventBus eventBus,
final Client client
)
{ {
this.eventBus = eventBus; this.eventBus = eventBus;
this.client = client; this.client = client;
eventBus.subscribe(GameTick.class, this, this::onGameTick);
eventBus.subscribe(NpcDespawned.class, this, this::onNpcDespawned);
eventBus.subscribe(PlayerDespawned.class, this, this::onPlayerDespawned);
eventBus.subscribe(ItemSpawned.class, this, this::onItemSpawned);
eventBus.subscribe(ItemDespawned.class, this, this::onItemDespawned);
eventBus.subscribe(ItemQuantityChanged.class, this, this::onItemQuantityChanged);
eventBus.subscribe(AnimationChanged.class, this, this::onAnimationChanged);
} }
@Subscribe private void onNpcDespawned(NpcDespawned npcDespawned)
public void onNpcDespawned(NpcDespawned npcDespawned)
{ {
final NPC npc = npcDespawned.getNpc(); final NPC npc = npcDespawned.getNpc();
if (!npc.isDead()) if (!npc.isDead())
@@ -123,8 +132,7 @@ public class LootManager
processNpcLoot(npc); processNpcLoot(npc);
} }
@Subscribe private void onPlayerDespawned(PlayerDespawned playerDespawned)
public void onPlayerDespawned(PlayerDespawned playerDespawned)
{ {
final Player player = playerDespawned.getPlayer(); final Player player = playerDespawned.getPlayer();
// Only care about dead Players // Only care about dead Players
@@ -150,11 +158,10 @@ public class LootManager
} }
killPoints.add(location); killPoints.add(location);
eventBus.post(new PlayerLootReceived(player, items)); eventBus.post(PlayerLootReceived.class, new PlayerLootReceived(player, items));
} }
@Subscribe private void onItemSpawned(ItemSpawned itemSpawned)
public void onItemSpawned(ItemSpawned itemSpawned)
{ {
final Item item = itemSpawned.getItem(); final Item item = itemSpawned.getItem();
final Tile tile = itemSpawned.getTile(); final Tile tile = itemSpawned.getTile();
@@ -164,16 +171,14 @@ public class LootManager
log.debug("Item spawn {} ({}) location {},{}", item.getId(), item.getQuantity(), location); log.debug("Item spawn {} ({}) location {},{}", item.getId(), item.getQuantity(), location);
} }
@Subscribe private void onItemDespawned(ItemDespawned itemDespawned)
public void onItemDespawned(ItemDespawned itemDespawned)
{ {
final Item item = itemDespawned.getItem(); final Item item = itemDespawned.getItem();
final LocalPoint location = itemDespawned.getTile().getLocalLocation(); final LocalPoint location = itemDespawned.getTile().getLocalLocation();
log.debug("Item despawn {} ({}) location {},{}", item.getId(), item.getQuantity(), location); log.debug("Item despawn {} ({}) location {},{}", item.getId(), item.getQuantity(), location);
} }
@Subscribe private void onItemQuantityChanged(ItemQuantityChanged itemQuantityChanged)
public void onItemQuantityChanged(ItemQuantityChanged itemQuantityChanged)
{ {
final Item item = itemQuantityChanged.getItem(); final Item item = itemQuantityChanged.getItem();
final Tile tile = itemQuantityChanged.getTile(); final Tile tile = itemQuantityChanged.getTile();
@@ -189,8 +194,7 @@ public class LootManager
itemSpawns.put(packed, new ItemStack(item.getId(), diff, location)); itemSpawns.put(packed, new ItemStack(item.getId(), diff, location));
} }
@Subscribe private void onAnimationChanged(AnimationChanged e)
public void onAnimationChanged(AnimationChanged e)
{ {
if (!(e.getActor() instanceof NPC)) if (!(e.getActor() instanceof NPC))
{ {
@@ -219,8 +223,7 @@ public class LootManager
} }
} }
@Subscribe private void onGameTick(GameTick gameTick)
public void onGameTick(GameTick gameTick)
{ {
playerLocationLastTick = client.getLocalPlayer().getWorldLocation(); playerLocationLastTick = client.getLocalPlayer().getWorldLocation();
itemSpawns.clear(); itemSpawns.clear();
@@ -257,7 +260,7 @@ public class LootManager
} }
killPoints.add(location); killPoints.add(location);
eventBus.post(new NpcLootReceived(npc, allItems)); eventBus.post(NpcLootReceived.class, new NpcLootReceived(npc, allItems));
} }
private WorldPoint getDropLocation(NPC npc, WorldPoint worldLocation) private WorldPoint getDropLocation(NPC npc, WorldPoint worldLocation)

View File

@@ -37,14 +37,14 @@ import javax.swing.ImageIcon;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.GameState; import net.runelite.api.GameState;
import net.runelite.api.Sprite; import net.runelite.api.Sprite;
import net.runelite.client.callback.ClientThread; import net.runelite.client.callback.ClientThread;
import net.runelite.client.ui.overlay.infobox.InfoBox;
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
import net.runelite.client.util.ImageUtil; import net.runelite.client.util.ImageUtil;
@Slf4j
@Singleton @Singleton
public class SpriteManager public class SpriteManager
{ {
@@ -54,7 +54,10 @@ public class SpriteManager
@Inject @Inject
private ClientThread clientThread; private ClientThread clientThread;
private final Cache<Long, BufferedImage> cache = CacheBuilder.newBuilder() @Inject
private InfoBoxManager infoBoxManager;
public Cache<Long, BufferedImage> cache = CacheBuilder.newBuilder()
.maximumSize(128L) .maximumSize(128L)
.expireAfterAccess(1, TimeUnit.HOURS) .expireAfterAccess(1, TimeUnit.HOURS)
.build(); .build();
@@ -76,6 +79,11 @@ public class SpriteManager
} }
Sprite[] sp = client.getSprites(client.getIndexSprites(), archive, 0); Sprite[] sp = client.getSprites(client.getIndexSprites(), archive, 0);
if (sp == null)
{
return null;
}
BufferedImage img = sp[file].toBufferedImage(); BufferedImage img = sp[file].toBufferedImage();
cache.put(key, img); cache.put(key, img);
@@ -104,6 +112,15 @@ public class SpriteManager
}); });
} }
public void getSpriteAsync(int archive, int file, InfoBox infoBox)
{
getSpriteAsync(archive, file, img ->
{
infoBox.setImage(img);
infoBoxManager.updateInfoBoxImage(infoBox);
});
}
/** /**
* Calls setIcon on c, ensuring it is repainted when this changes * Calls setIcon on c, ensuring it is repainted when this changes
*/ */

View File

@@ -41,7 +41,6 @@ import net.runelite.api.widgets.Widget;
import net.runelite.api.widgets.WidgetInfo; import net.runelite.api.widgets.WidgetInfo;
import net.runelite.client.callback.ClientThread; import net.runelite.client.callback.ClientThread;
import net.runelite.client.eventbus.EventBus; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.input.KeyListener; import net.runelite.client.input.KeyListener;
import net.runelite.client.input.KeyManager; import net.runelite.client.input.KeyManager;
import net.runelite.client.input.MouseListener; import net.runelite.client.input.MouseListener;
@@ -79,6 +78,10 @@ public class ChatboxPanelManager
this.chatboxTextMenuInputProvider = chatboxTextMenuInputProvider; this.chatboxTextMenuInputProvider = chatboxTextMenuInputProvider;
this.chatboxTextInputProvider = chatboxTextInputProvider; this.chatboxTextInputProvider = chatboxTextInputProvider;
eventBus.subscribe(ScriptCallbackEvent.class, this, this::onScriptCallbackEvent);
eventBus.subscribe(GameStateChanged.class, this, this::onGameStateChanged);
} }
public void close() public void close()
@@ -103,7 +106,7 @@ public class ChatboxPanelManager
{ {
client.runScript(ScriptID.CLEAR_CHATBOX_PANEL); client.runScript(ScriptID.CLEAR_CHATBOX_PANEL);
eventBus.register(input); // eventBus.register(input);
if (input instanceof KeyListener) if (input instanceof KeyListener)
{ {
keyManager.registerKeyListener((KeyListener) input); keyManager.registerKeyListener((KeyListener) input);
@@ -150,8 +153,7 @@ public class ChatboxPanelManager
.prompt(prompt); .prompt(prompt);
} }
@Subscribe private void onScriptCallbackEvent(ScriptCallbackEvent ev)
public void onScriptCallbackEvent(ScriptCallbackEvent ev)
{ {
if (currentInput != null && "resetChatboxInput".equals(ev.getEventName())) if (currentInput != null && "resetChatboxInput".equals(ev.getEventName()))
{ {
@@ -159,7 +161,6 @@ public class ChatboxPanelManager
} }
} }
@Subscribe
private void onGameStateChanged(GameStateChanged ev) private void onGameStateChanged(GameStateChanged ev)
{ {
if (currentInput != null && ev.getGameState() == GameState.LOGIN_SCREEN) if (currentInput != null && ev.getGameState() == GameState.LOGIN_SCREEN)

View File

@@ -31,7 +31,6 @@ import java.util.List;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.Getter; import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.FontID; import net.runelite.api.FontID;
import net.runelite.api.widgets.JavaScriptCallback; import net.runelite.api.widgets.JavaScriptCallback;
import net.runelite.api.widgets.Widget; import net.runelite.api.widgets.Widget;
@@ -41,7 +40,6 @@ import net.runelite.api.widgets.WidgetTextAlignment;
import net.runelite.api.widgets.WidgetType; import net.runelite.api.widgets.WidgetType;
import net.runelite.client.input.KeyListener; import net.runelite.client.input.KeyListener;
@Slf4j
public class ChatboxTextMenuInput extends ChatboxInput implements KeyListener public class ChatboxTextMenuInput extends ChatboxInput implements KeyListener
{ {
@Data @Data

View File

@@ -66,7 +66,6 @@ import net.runelite.api.events.WidgetMenuOptionClicked;
import net.runelite.api.events.WidgetPressed; import net.runelite.api.events.WidgetPressed;
import net.runelite.api.widgets.WidgetInfo; import net.runelite.api.widgets.WidgetInfo;
import net.runelite.client.eventbus.EventBus; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.util.Text; import net.runelite.client.util.Text;
@Singleton @Singleton
@@ -106,6 +105,15 @@ public class MenuManager
{ {
this.client = client; this.client = client;
this.eventBus = eventBus; this.eventBus = eventBus;
eventBus.subscribe(MenuOpened.class, this, this::onMenuOpened);
eventBus.subscribe(MenuEntryAdded.class, this, this::onMenuEntryAdded);
eventBus.subscribe(BeforeRender.class, this, this::onBeforeRender);
eventBus.subscribe(PlayerMenuOptionsChanged.class, this, this::onPlayerMenuOptionsChanged);
eventBus.subscribe(NpcActionChanged.class, this, this::onNpcActionChanged);
eventBus.subscribe(WidgetPressed.class, this, this::onWidgetPressed);
eventBus.subscribe(MenuOptionClicked.class, this, this::onMenuOptionClicked);
} }
/** /**
@@ -145,8 +153,7 @@ public class MenuManager
return false; return false;
} }
@Subscribe private void onMenuOpened(MenuOpened event)
public void onMenuOpened(MenuOpened event)
{ {
currentPriorityEntries.clear(); currentPriorityEntries.clear();
@@ -256,8 +263,7 @@ public class MenuManager
client.setMenuEntries(arrayEntries); client.setMenuEntries(arrayEntries);
} }
@Subscribe private void onMenuEntryAdded(MenuEntryAdded event)
public void onMenuEntryAdded(MenuEntryAdded event)
{ {
int widgetId = event.getActionParam1(); int widgetId = event.getActionParam1();
Collection<WidgetMenuOption> options = managedMenuOptions.get(widgetId); Collection<WidgetMenuOption> options = managedMenuOptions.get(widgetId);
@@ -280,8 +286,7 @@ public class MenuManager
} }
} }
@Subscribe private void onBeforeRender(BeforeRender event)
public void onBeforeRender(BeforeRender event)
{ {
rebuildLeftClickMenu(); rebuildLeftClickMenu();
} }
@@ -364,8 +369,7 @@ public class MenuManager
} }
} }
@Subscribe private void onPlayerMenuOptionsChanged(PlayerMenuOptionsChanged event)
public void onPlayerMenuOptionsChanged(PlayerMenuOptionsChanged event)
{ {
int idx = event.getIndex(); int idx = event.getIndex();
@@ -389,8 +393,7 @@ public class MenuManager
addPlayerMenuItem(newIdx, menuText); addPlayerMenuItem(newIdx, menuText);
} }
@Subscribe private void onNpcActionChanged(NpcActionChanged event)
public void onNpcActionChanged(NpcActionChanged event)
{ {
NPCDefinition composition = event.getNpcDefinition(); NPCDefinition composition = event.getNpcDefinition();
for (String npcOption : npcMenuOptions) for (String npcOption : npcMenuOptions)
@@ -439,14 +442,12 @@ public class MenuManager
} }
} }
@Subscribe private void onWidgetPressed(WidgetPressed event)
public void onWidgetPressed(WidgetPressed event)
{ {
leftClickEntry = rebuildLeftClickMenu(); leftClickEntry = rebuildLeftClickMenu();
} }
@Subscribe private void onMenuOptionClicked(MenuOptionClicked event)
public void onMenuOptionClicked(MenuOptionClicked event)
{ {
if (!client.isMenuOpen() && event.isAuthentic()) if (!client.isMenuOpen() && event.isAuthentic())
{ {
@@ -481,7 +482,7 @@ public class MenuManager
customMenu.setMenuOption(event.getOption()); customMenu.setMenuOption(event.getOption());
customMenu.setMenuTarget(event.getTarget()); customMenu.setMenuTarget(event.getTarget());
customMenu.setWidget(curMenuOption.getWidget()); customMenu.setWidget(curMenuOption.getWidget());
eventBus.post(customMenu); eventBus.post(WidgetMenuOptionClicked.class, customMenu);
return; // don't continue because it's not a player option return; // don't continue because it's not a player option
} }
} }
@@ -496,7 +497,7 @@ public class MenuManager
playerMenuOptionClicked.setMenuOption(event.getOption()); playerMenuOptionClicked.setMenuOption(event.getOption());
playerMenuOptionClicked.setMenuTarget(username); playerMenuOptionClicked.setMenuTarget(username);
eventBus.post(playerMenuOptionClicked); eventBus.post(PlayerMenuOptionClicked.class, playerMenuOptionClicked);
} }
private void addPlayerMenuItem(int playerOptionIndex, String menuText) private void addPlayerMenuItem(int playerOptionIndex, String menuText)

View File

@@ -68,7 +68,6 @@ import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.config.RuneLiteConfig; import net.runelite.client.config.RuneLiteConfig;
import net.runelite.client.eventbus.EventBus; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.events.PluginChanged; import net.runelite.client.events.PluginChanged;
import net.runelite.client.events.SessionClose; import net.runelite.client.events.SessionClose;
import net.runelite.client.events.SessionOpen; import net.runelite.client.events.SessionOpen;
@@ -126,14 +125,12 @@ public class PluginManager
pluginWatcher.start(); pluginWatcher.start();
} }
@Subscribe private void onSessionOpen(SessionOpen event)
public void onSessionOpen(SessionOpen event)
{ {
refreshPlugins(); refreshPlugins();
} }
@Subscribe private void onSessionClose(SessionClose event)
public void onSessionClose(SessionClose event)
{ {
refreshPlugins(); refreshPlugins();
} }
@@ -368,9 +365,9 @@ public class PluginManager
} }
} }
eventBus.register(plugin); // eventBus.register(plugin);
schedule(plugin); schedule(plugin);
eventBus.post(new PluginChanged(plugin, true)); eventBus.post(PluginChanged.class, new PluginChanged(plugin, true));
} }
catch (InterruptedException | InvocationTargetException | IllegalArgumentException ex) catch (InterruptedException | InvocationTargetException | IllegalArgumentException ex)
{ {
@@ -392,7 +389,6 @@ public class PluginManager
try try
{ {
unschedule(plugin); unschedule(plugin);
eventBus.unregister(plugin);
// plugins always stop in the event thread // plugins always stop in the event thread
SwingUtilities.invokeAndWait(() -> SwingUtilities.invokeAndWait(() ->
@@ -408,7 +404,7 @@ public class PluginManager
}); });
log.debug("Plugin {} is now stopped", plugin.getClass().getSimpleName()); log.debug("Plugin {} is now stopped", plugin.getClass().getSimpleName());
eventBus.post(new PluginChanged(plugin, false)); eventBus.post(PluginChanged.class, new PluginChanged(plugin, false));
} }
catch (InterruptedException | InvocationTargetException ex) catch (InterruptedException | InvocationTargetException ex)

View File

@@ -32,7 +32,7 @@ import javax.swing.JOptionPane;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.runelite.client.account.AccountSession; import net.runelite.client.account.AccountSession;
import net.runelite.client.account.SessionManager; import net.runelite.client.account.SessionManager;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.events.SessionClose; import net.runelite.client.events.SessionClose;
import net.runelite.client.events.SessionOpen; import net.runelite.client.events.SessionOpen;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
@@ -60,6 +60,9 @@ public class AccountPlugin extends Plugin
@Inject @Inject
private ScheduledExecutorService executor; private ScheduledExecutorService executor;
@Inject
private EventBus eventBus;
private NavigationButton loginButton; private NavigationButton loginButton;
private NavigationButton logoutButton; private NavigationButton logoutButton;
@@ -74,6 +77,8 @@ public class AccountPlugin extends Plugin
@Override @Override
protected void startUp() throws Exception protected void startUp() throws Exception
{ {
addSubscriptions();
loginButton = NavigationButton.builder() loginButton = NavigationButton.builder()
.tab(false) .tab(false)
.icon(LOGIN_IMAGE) .icon(LOGIN_IMAGE)
@@ -103,10 +108,18 @@ public class AccountPlugin extends Plugin
@Override @Override
protected void shutDown() throws Exception protected void shutDown() throws Exception
{ {
eventBus.unregister(this);
clientToolbar.removeNavigation(loginButton); clientToolbar.removeNavigation(loginButton);
clientToolbar.removeNavigation(logoutButton); clientToolbar.removeNavigation(logoutButton);
} }
private void addSubscriptions()
{
eventBus.subscribe(SessionClose.class, this, this::onSessionClose);
eventBus.subscribe(SessionOpen.class, this, this::onSessionOpen);
}
private void loginClick() private void loginClick()
{ {
executor.execute(sessionManager::login); executor.execute(sessionManager::login);
@@ -122,14 +135,12 @@ public class AccountPlugin extends Plugin
} }
} }
@Subscribe private void onSessionClose(SessionClose e)
public void onSessionClose(SessionClose e)
{ {
addAndRemoveButtons(); addAndRemoveButtons();
} }
@Subscribe private void onSessionOpen(SessionOpen sessionOpen)
public void onSessionOpen(SessionOpen sessionOpen)
{ {
AccountSession session = sessionManager.getAccountSession(); AccountSession session = sessionManager.getAccountSession();

View File

@@ -44,7 +44,7 @@ import net.runelite.api.widgets.Widget;
import net.runelite.api.widgets.WidgetID; import net.runelite.api.widgets.WidgetID;
import net.runelite.api.widgets.WidgetInfo; import net.runelite.api.widgets.WidgetInfo;
import net.runelite.client.callback.ClientThread; import net.runelite.client.callback.ClientThread;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.plugins.achievementdiary.diaries.ArdougneDiaryRequirement; import net.runelite.client.plugins.achievementdiary.diaries.ArdougneDiaryRequirement;
@@ -79,8 +79,22 @@ public class DiaryRequirementsPlugin extends Plugin
@Inject @Inject
private ClientThread clientThread; private ClientThread clientThread;
@Subscribe @Inject
public void onWidgetLoaded(final WidgetLoaded event) private EventBus eventBus;
@Override
protected void startUp() throws Exception
{
eventBus.subscribe(WidgetLoaded.class, this, this::onWidgetLoaded);
}
@Override
protected void shutDown() throws Exception
{
eventBus.unregister(this);
}
private void onWidgetLoaded(final WidgetLoaded event)
{ {
if (event.getGroupId() == WidgetID.DIARY_QUEST_GROUP_ID) if (event.getGroupId() == WidgetID.DIARY_QUEST_GROUP_ID)
{ {

View File

@@ -70,7 +70,7 @@ import net.runelite.api.events.WallObjectDespawned;
import net.runelite.api.events.WallObjectSpawned; import net.runelite.api.events.WallObjectSpawned;
import net.runelite.client.Notifier; import net.runelite.client.Notifier;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.game.AgilityShortcut; import net.runelite.client.game.AgilityShortcut;
import net.runelite.client.game.ItemManager; import net.runelite.client.game.ItemManager;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
@@ -120,6 +120,9 @@ public class AgilityPlugin extends Plugin
@Inject @Inject
private ItemManager itemManager; private ItemManager itemManager;
@Inject
private EventBus eventBus;
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
private AgilitySession session; private AgilitySession session;
@@ -166,6 +169,7 @@ public class AgilityPlugin extends Plugin
protected void startUp() throws Exception protected void startUp() throws Exception
{ {
updateConfig(); updateConfig();
addSubscriptions();
overlayManager.add(agilityOverlay); overlayManager.add(agilityOverlay);
overlayManager.add(lapCounterOverlay); overlayManager.add(lapCounterOverlay);
@@ -175,6 +179,8 @@ public class AgilityPlugin extends Plugin
@Override @Override
protected void shutDown() throws Exception protected void shutDown() throws Exception
{ {
eventBus.unregister(this);
overlayManager.remove(agilityOverlay); overlayManager.remove(agilityOverlay);
overlayManager.remove(lapCounterOverlay); overlayManager.remove(lapCounterOverlay);
marksOfGrace.clear(); marksOfGrace.clear();
@@ -183,8 +189,31 @@ public class AgilityPlugin extends Plugin
agilityLevel = 0; agilityLevel = 0;
} }
@Subscribe private void addSubscriptions()
public void onGameStateChanged(GameStateChanged event) {
eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
eventBus.subscribe(GameStateChanged.class, this, this::onGameStateChanged);
eventBus.subscribe(ExperienceChanged.class, this, this::onExperienceChanged);
eventBus.subscribe(BoostedLevelChanged.class, this, this::onBoostedLevelChanged);
eventBus.subscribe(ItemSpawned.class, this, this::onItemSpawned);
eventBus.subscribe(ItemDespawned.class, this, this::onItemDespawned);
eventBus.subscribe(GameTick.class, this, this::onGameTick);
eventBus.subscribe(GameObjectSpawned.class, this, this::onGameObjectSpawned);
eventBus.subscribe(GameObjectChanged.class, this, this::onGameObjectChanged);
eventBus.subscribe(GameObjectDespawned.class, this, this::onGameObjectDespawned);
eventBus.subscribe(GroundObjectSpawned.class, this, this::onGroundObjectSpawned);
eventBus.subscribe(GroundObjectChanged.class, this, this::onGroundObjectChanged);
eventBus.subscribe(GroundObjectDespawned.class, this, this::onGroundObjectDespawned);
eventBus.subscribe(WallObjectSpawned.class, this, this::onWallObjectSpawned);
eventBus.subscribe(WallObjectChanged.class, this, this::onWallObjectChanged);
eventBus.subscribe(WallObjectDespawned.class, this, this::onWallObjectDespawned);
eventBus.subscribe(DecorativeObjectSpawned.class, this, this::onDecorativeObjectSpawned);
eventBus.subscribe(DecorativeObjectChanged.class, this, this::onDecorativeObjectChanged);
eventBus.subscribe(DecorativeObjectDespawned.class, this, this::onDecorativeObjectDespawned);
eventBus.subscribe(MenuEntryAdded.class, this, this::onMenuEntryAdded);
}
private void onGameStateChanged(GameStateChanged event)
{ {
switch (event.getGameState()) switch (event.getGameState())
{ {
@@ -208,8 +237,7 @@ public class AgilityPlugin extends Plugin
} }
} }
@Subscribe private void onConfigChanged(ConfigChanged event)
public void onConfigChanged(ConfigChanged event)
{ {
if (!event.getGroup().equals("agility")) if (!event.getGroup().equals("agility"))
{ {
@@ -242,8 +270,7 @@ public class AgilityPlugin extends Plugin
this.showShortcutLevel = config.showShortcutLevel(); this.showShortcutLevel = config.showShortcutLevel();
} }
@Subscribe private void onExperienceChanged(ExperienceChanged event)
public void onExperienceChanged(ExperienceChanged event)
{ {
if (event.getSkill() != AGILITY || !this.showLapCount) if (event.getSkill() != AGILITY || !this.showLapCount)
{ {
@@ -278,9 +305,7 @@ public class AgilityPlugin extends Plugin
} }
} }
private void onBoostedLevelChanged(BoostedLevelChanged boostedLevelChanged)
@Subscribe
public void onBoostedLevelChanged(BoostedLevelChanged boostedLevelChanged)
{ {
Skill skill = boostedLevelChanged.getSkill(); Skill skill = boostedLevelChanged.getSkill();
if (skill == AGILITY) if (skill == AGILITY)
@@ -289,8 +314,7 @@ public class AgilityPlugin extends Plugin
} }
} }
@Subscribe private void onItemSpawned(ItemSpawned itemSpawned)
public void onItemSpawned(ItemSpawned itemSpawned)
{ {
if (obstacles.isEmpty()) if (obstacles.isEmpty())
{ {
@@ -306,15 +330,13 @@ public class AgilityPlugin extends Plugin
} }
} }
@Subscribe private void onItemDespawned(ItemDespawned itemDespawned)
public void onItemDespawned(ItemDespawned itemDespawned)
{ {
final Tile tile = itemDespawned.getTile(); final Tile tile = itemDespawned.getTile();
marksOfGrace.remove(tile); marksOfGrace.remove(tile);
} }
@Subscribe private void onGameTick(GameTick tick)
public void onGameTick(GameTick tick)
{ {
if (isInAgilityArena()) if (isInAgilityArena())
{ {
@@ -365,74 +387,62 @@ public class AgilityPlugin extends Plugin
infoBoxManager.addInfoBox(new AgilityArenaTimer(this, itemManager.getImage(AGILITY_ARENA_TICKET))); infoBoxManager.addInfoBox(new AgilityArenaTimer(this, itemManager.getImage(AGILITY_ARENA_TICKET)));
} }
@Subscribe private void onGameObjectSpawned(GameObjectSpawned event)
public void onGameObjectSpawned(GameObjectSpawned event)
{ {
onTileObject(event.getTile(), null, event.getGameObject()); onTileObject(event.getTile(), null, event.getGameObject());
} }
@Subscribe private void onGameObjectChanged(GameObjectChanged event)
public void onGameObjectChanged(GameObjectChanged event)
{ {
onTileObject(event.getTile(), event.getPrevious(), event.getGameObject()); onTileObject(event.getTile(), event.getPrevious(), event.getGameObject());
} }
@Subscribe private void onGameObjectDespawned(GameObjectDespawned event)
public void onGameObjectDespawned(GameObjectDespawned event)
{ {
onTileObject(event.getTile(), event.getGameObject(), null); onTileObject(event.getTile(), event.getGameObject(), null);
} }
@Subscribe private void onGroundObjectSpawned(GroundObjectSpawned event)
public void onGroundObjectSpawned(GroundObjectSpawned event)
{ {
onTileObject(event.getTile(), null, event.getGroundObject()); onTileObject(event.getTile(), null, event.getGroundObject());
} }
@Subscribe private void onGroundObjectChanged(GroundObjectChanged event)
public void onGroundObjectChanged(GroundObjectChanged event)
{ {
onTileObject(event.getTile(), event.getPrevious(), event.getGroundObject()); onTileObject(event.getTile(), event.getPrevious(), event.getGroundObject());
} }
@Subscribe private void onGroundObjectDespawned(GroundObjectDespawned event)
public void onGroundObjectDespawned(GroundObjectDespawned event)
{ {
onTileObject(event.getTile(), event.getGroundObject(), null); onTileObject(event.getTile(), event.getGroundObject(), null);
} }
@Subscribe private void onWallObjectSpawned(WallObjectSpawned event)
public void onWallObjectSpawned(WallObjectSpawned event)
{ {
onTileObject(event.getTile(), null, event.getWallObject()); onTileObject(event.getTile(), null, event.getWallObject());
} }
@Subscribe private void onWallObjectChanged(WallObjectChanged event)
public void onWallObjectChanged(WallObjectChanged event)
{ {
onTileObject(event.getTile(), event.getPrevious(), event.getWallObject()); onTileObject(event.getTile(), event.getPrevious(), event.getWallObject());
} }
@Subscribe private void onWallObjectDespawned(WallObjectDespawned event)
public void onWallObjectDespawned(WallObjectDespawned event)
{ {
onTileObject(event.getTile(), event.getWallObject(), null); onTileObject(event.getTile(), event.getWallObject(), null);
} }
@Subscribe private void onDecorativeObjectSpawned(DecorativeObjectSpawned event)
public void onDecorativeObjectSpawned(DecorativeObjectSpawned event)
{ {
onTileObject(event.getTile(), null, event.getDecorativeObject()); onTileObject(event.getTile(), null, event.getDecorativeObject());
} }
@Subscribe private void onDecorativeObjectChanged(DecorativeObjectChanged event)
public void onDecorativeObjectChanged(DecorativeObjectChanged event)
{ {
onTileObject(event.getTile(), event.getPrevious(), event.getDecorativeObject()); onTileObject(event.getTile(), event.getPrevious(), event.getDecorativeObject());
} }
@Subscribe private void onDecorativeObjectDespawned(DecorativeObjectDespawned event)
public void onDecorativeObjectDespawned(DecorativeObjectDespawned event)
{ {
onTileObject(event.getTile(), event.getDecorativeObject(), null); onTileObject(event.getTile(), event.getDecorativeObject(), null);
} }
@@ -484,8 +494,7 @@ public class AgilityPlugin extends Plugin
} }
} }
@Subscribe private void onMenuEntryAdded(MenuEntryAdded event)
public void onMenuEntryAdded(MenuEntryAdded event)
{ {
if (!this.showShortcutLevel) if (!this.showShortcutLevel)
{ {

View File

@@ -46,7 +46,7 @@ import net.runelite.api.events.ChatMessage;
import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.GameStateChanged;
import net.runelite.api.events.NpcSpawned; import net.runelite.api.events.NpcSpawned;
import net.runelite.api.events.ProjectileMoved; import net.runelite.api.events.ProjectileMoved;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.plugins.PluginType; import net.runelite.client.plugins.PluginType;
@@ -89,9 +89,14 @@ public class HydraPlugin extends Plugin
@Inject @Inject
private HydraSceneOverlay poisonOverlay; private HydraSceneOverlay poisonOverlay;
@Inject
private EventBus eventBus;
@Override @Override
protected void startUp() protected void startUp()
{ {
addSubscriptions();
inHydraInstance = checkArea(); inHydraInstance = checkArea();
lastAttackTick = -1; lastAttackTick = -1;
poisonProjectiles.clear(); poisonProjectiles.clear();
@@ -100,6 +105,8 @@ public class HydraPlugin extends Plugin
@Override @Override
protected void shutDown() protected void shutDown()
{ {
eventBus.unregister(this);
inHydraInstance = false; inHydraInstance = false;
hydra = null; hydra = null;
poisonProjectiles.clear(); poisonProjectiles.clear();
@@ -107,7 +114,15 @@ public class HydraPlugin extends Plugin
lastAttackTick = -1; lastAttackTick = -1;
} }
@Subscribe private void addSubscriptions()
{
eventBus.subscribe(GameStateChanged.class, this, this::onGameStateChanged);
eventBus.subscribe(NpcSpawned.class, this, this::onNpcSpawned);
eventBus.subscribe(AnimationChanged.class, this, this::onAnimationChanged);
eventBus.subscribe(ProjectileMoved.class, this, this::onProjectileMoved);
eventBus.subscribe(ChatMessage.class, this, this::onChatMessage);
}
private void onGameStateChanged(GameStateChanged state) private void onGameStateChanged(GameStateChanged state)
{ {
if (state.getGameState() != GameState.LOGGED_IN) if (state.getGameState() != GameState.LOGGED_IN)
@@ -140,7 +155,6 @@ public class HydraPlugin extends Plugin
addOverlays(); addOverlays();
} }
@Subscribe
private void onNpcSpawned(NpcSpawned event) private void onNpcSpawned(NpcSpawned event)
{ {
if (!inHydraInstance || event.getNpc().getId() != NpcID.ALCHEMICAL_HYDRA) if (!inHydraInstance || event.getNpc().getId() != NpcID.ALCHEMICAL_HYDRA)
@@ -152,8 +166,7 @@ public class HydraPlugin extends Plugin
addOverlays(); addOverlays();
} }
@Subscribe private void onAnimationChanged(AnimationChanged animationChanged)
public void onAnimationChanged(AnimationChanged animationChanged)
{ {
Actor actor = animationChanged.getActor(); Actor actor = animationChanged.getActor();
@@ -215,8 +228,7 @@ public class HydraPlugin extends Plugin
} }
} }
@Subscribe private void onProjectileMoved(ProjectileMoved event)
public void onProjectileMoved(ProjectileMoved event)
{ {
if (!inHydraInstance || hydra == null if (!inHydraInstance || hydra == null
|| client.getGameCycle() >= event.getProjectile().getStartMovementCycle()) || client.getGameCycle() >= event.getProjectile().getStartMovementCycle())
@@ -245,8 +257,7 @@ public class HydraPlugin extends Plugin
} }
} }
@Subscribe private void onChatMessage(ChatMessage event)
public void onChatMessage(ChatMessage event)
{ {
if (!event.getMessage().equals("The chemicals neutralise the Alchemical Hydra's defences!")) if (!event.getMessage().equals("The chemicals neutralise the Alchemical Hydra's defences!"))
{ {

View File

@@ -35,7 +35,7 @@ import net.runelite.api.ItemDefinition;
import net.runelite.api.ItemContainer; import net.runelite.api.ItemContainer;
import net.runelite.api.events.ItemContainerChanged; import net.runelite.api.events.ItemContainerChanged;
import net.runelite.client.callback.ClientThread; import net.runelite.client.callback.ClientThread;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.game.ItemManager; import net.runelite.client.game.ItemManager;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
@@ -61,11 +61,16 @@ public class AmmoPlugin extends Plugin
@Inject @Inject
private ItemManager itemManager; private ItemManager itemManager;
@Inject
private EventBus eventBus;
private AmmoCounter counterBox; private AmmoCounter counterBox;
@Override @Override
protected void startUp() throws Exception protected void startUp() throws Exception
{ {
eventBus.subscribe(ItemContainerChanged.class, this, this::onItemContainerChanged);
clientThread.invokeLater(() -> clientThread.invokeLater(() ->
{ {
final ItemContainer container = client.getItemContainer(InventoryID.EQUIPMENT); final ItemContainer container = client.getItemContainer(InventoryID.EQUIPMENT);
@@ -80,12 +85,13 @@ public class AmmoPlugin extends Plugin
@Override @Override
protected void shutDown() throws Exception protected void shutDown() throws Exception
{ {
eventBus.unregister(this);
infoBoxManager.removeInfoBox(counterBox); infoBoxManager.removeInfoBox(counterBox);
counterBox = null; counterBox = null;
} }
@Subscribe private void onItemContainerChanged(ItemContainerChanged event)
public void onItemContainerChanged(ItemContainerChanged event)
{ {
if (event.getItemContainer() != client.getItemContainer(InventoryID.EQUIPMENT)) if (event.getItemContainer() != client.getItemContainer(InventoryID.EQUIPMENT))
{ {

View File

@@ -30,7 +30,7 @@ import javax.inject.Singleton;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.ConfigChanged;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
@@ -51,6 +51,9 @@ public class AnimationSmoothingPlugin extends Plugin
@Inject @Inject
private AnimationSmoothingConfig config; private AnimationSmoothingConfig config;
@Inject
private EventBus eventBus;
@Provides @Provides
AnimationSmoothingConfig getConfig(ConfigManager configManager) AnimationSmoothingConfig getConfig(ConfigManager configManager)
{ {
@@ -60,20 +63,23 @@ public class AnimationSmoothingPlugin extends Plugin
@Override @Override
protected void startUp() throws Exception protected void startUp() throws Exception
{ {
eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
update(); update();
} }
@Override @Override
protected void shutDown() throws Exception protected void shutDown() throws Exception
{ {
eventBus.unregister(this);
client.setInterpolatePlayerAnimations(false); client.setInterpolatePlayerAnimations(false);
client.setInterpolateNpcAnimations(false); client.setInterpolateNpcAnimations(false);
client.setInterpolateObjectAnimations(false); client.setInterpolateObjectAnimations(false);
client.setInterpolateWidgetAnimations(false); client.setInterpolateWidgetAnimations(false);
} }
@Subscribe private void onConfigChanged(ConfigChanged event)
public void onConfigChanged(ConfigChanged event)
{ {
if (event.getGroup().equals(CONFIG_GROUP)) if (event.getGroup().equals(CONFIG_GROUP))
{ {

View File

@@ -80,9 +80,7 @@ public interface AntiDragConfig extends Config
keyName = "dragDelay", keyName = "dragDelay",
name = "Drag Delay", name = "Drag Delay",
description = "Configures the inventory drag delay in client ticks (20ms)", description = "Configures the inventory drag delay in client ticks (20ms)",
position = 3, position = 3
hidden = true,
unhide = "keybind"
) )
default int dragDelay() default int dragDelay()
{ {

View File

@@ -36,7 +36,7 @@ import net.runelite.api.events.ConfigChanged;
import net.runelite.api.events.FocusChanged; import net.runelite.api.events.FocusChanged;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.config.Keybind; import net.runelite.client.config.Keybind;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.input.KeyManager; import net.runelite.client.input.KeyManager;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
@@ -81,6 +81,9 @@ public class AntiDragPlugin extends Plugin
@Inject @Inject
private KeyManager keyManager; private KeyManager keyManager;
@Inject
private EventBus eventBus;
@Provides @Provides
AntiDragConfig getConfig(ConfigManager configManager) AntiDragConfig getConfig(ConfigManager configManager)
{ {
@@ -102,7 +105,9 @@ public class AntiDragPlugin extends Plugin
@Override @Override
protected void startUp() throws Exception protected void startUp() throws Exception
{ {
addSubscriptions();
updateConfig(); updateConfig();
if (this.keybind) if (this.keybind)
{ {
keyManager.registerKeyListener(hotkeyListener); keyManager.registerKeyListener(hotkeyListener);
@@ -113,14 +118,21 @@ public class AntiDragPlugin extends Plugin
@Override @Override
protected void shutDown() throws Exception protected void shutDown() throws Exception
{ {
eventBus.unregister(this);
client.setInventoryDragDelay(DEFAULT_DELAY); client.setInventoryDragDelay(DEFAULT_DELAY);
keyManager.unregisterKeyListener(hotkeyListener); keyManager.unregisterKeyListener(hotkeyListener);
toggleDrag = false; toggleDrag = false;
overlayManager.remove(overlay); overlayManager.remove(overlay);
} }
@Subscribe private void addSubscriptions()
public void onConfigChanged(ConfigChanged event) {
eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
eventBus.subscribe(FocusChanged.class, this, this::onFocusChanged);
}
private void onConfigChanged(ConfigChanged event)
{ {
if (event.getGroup().equals("antiDrag")) if (event.getGroup().equals("antiDrag"))
{ {
@@ -141,6 +153,10 @@ public class AntiDragPlugin extends Plugin
{ {
client.setInventoryDragDelay(this.alwaysOn ? this.dragDelay : DEFAULT_DELAY); client.setInventoryDragDelay(this.alwaysOn ? this.dragDelay : DEFAULT_DELAY);
} }
if (event.getKey().equals("dragDelay") && this.alwaysOn)
{
client.setInventoryDragDelay(this.dragDelay);
}
} }
} }
@@ -157,8 +173,7 @@ public class AntiDragPlugin extends Plugin
this.selectedCursor = config.selectedCursor(); this.selectedCursor = config.selectedCursor();
} }
@Subscribe private void onFocusChanged(FocusChanged focusChanged)
public void onFocusChanged(FocusChanged focusChanged)
{ {
if (!this.alwaysOn && !focusChanged.isFocused() && this.reqfocus) if (!this.alwaysOn && !focusChanged.isFocused() && this.reqfocus)
{ {

View File

@@ -123,7 +123,12 @@ public enum AoeProjectileInfo
/** /**
* Demonic gorilla * Demonic gorilla
*/ */
DEMONIC_GORILLA_BOULDER(ProjectileID.DEMONIC_GORILLA_BOULDER, 1); DEMONIC_GORILLA_BOULDER(ProjectileID.DEMONIC_GORILLA_BOULDER, 1),
/**
* Marble gargoyle (Superior Gargoyle)
*/
MARBLE_GARGOYLE_AOE(ProjectileID.MARBLE_GARGOYLE_AOE, 1);
private static final Map<Integer, AoeProjectileInfo> map = new HashMap<>(); private static final Map<Integer, AoeProjectileInfo> map = new HashMap<>();

View File

@@ -59,7 +59,7 @@ import net.runelite.api.events.GameTick;
import net.runelite.api.events.ProjectileMoved; import net.runelite.api.events.ProjectileMoved;
import net.runelite.client.Notifier; import net.runelite.client.Notifier;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.plugins.PluginType; import net.runelite.client.plugins.PluginType;
@@ -92,6 +92,8 @@ public class AoeWarningPlugin extends Plugin
private BombOverlay bombOverlay; private BombOverlay bombOverlay;
@Inject @Inject
private Client client; private Client client;
@Inject
private EventBus eventbus;
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
private List<WorldPoint> LightningTrail = new ArrayList<>(); private List<WorldPoint> LightningTrail = new ArrayList<>();
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
@@ -170,6 +172,7 @@ public class AoeWarningPlugin extends Plugin
protected void startUp() throws Exception protected void startUp() throws Exception
{ {
updateConfig(); updateConfig();
addSubscriptions();
overlayManager.add(coreOverlay); overlayManager.add(coreOverlay);
overlayManager.add(bombOverlay); overlayManager.add(bombOverlay);
@@ -179,13 +182,24 @@ public class AoeWarningPlugin extends Plugin
@Override @Override
protected void shutDown() throws Exception protected void shutDown() throws Exception
{ {
eventbus.unregister(this);
overlayManager.remove(coreOverlay); overlayManager.remove(coreOverlay);
overlayManager.remove(bombOverlay); overlayManager.remove(bombOverlay);
reset(); reset();
} }
@Subscribe private void addSubscriptions()
public void onConfigChanged(ConfigChanged event) {
eventbus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
eventbus.subscribe(ProjectileMoved.class, this, this::onProjectileMoved);
eventbus.subscribe(GameObjectSpawned.class, this, this::onGameObjectSpawned);
eventbus.subscribe(GameObjectDespawned.class, this, this::onGameObjectDespawned);
eventbus.subscribe(GameStateChanged.class, this, this::onGameStateChanged);
eventbus.subscribe(GameTick.class, this, this::onGameTick);
}
private void onConfigChanged(ConfigChanged event)
{ {
if (!event.getGroup().equals("aoe")) if (!event.getGroup().equals("aoe"))
{ {
@@ -195,8 +209,7 @@ public class AoeWarningPlugin extends Plugin
updateConfig(); updateConfig();
} }
@Subscribe private void onProjectileMoved(ProjectileMoved event)
public void onProjectileMoved(ProjectileMoved event)
{ {
Projectile projectile = event.getProjectile(); Projectile projectile = event.getProjectile();
@@ -223,8 +236,7 @@ public class AoeWarningPlugin extends Plugin
} }
} }
@Subscribe private void onGameObjectSpawned(GameObjectSpawned event)
public void onGameObjectSpawned(GameObjectSpawned event)
{ {
final GameObject gameObject = event.getGameObject(); final GameObject gameObject = event.getGameObject();
final WorldPoint wp = gameObject.getWorldLocation(); final WorldPoint wp = gameObject.getWorldLocation();
@@ -260,8 +272,7 @@ public class AoeWarningPlugin extends Plugin
} }
} }
@Subscribe private void onGameObjectDespawned(GameObjectDespawned event)
public void onGameObjectDespawned(GameObjectDespawned event)
{ {
GameObject gameObject = event.getGameObject(); GameObject gameObject = event.getGameObject();
WorldPoint wp = gameObject.getWorldLocation(); WorldPoint wp = gameObject.getWorldLocation();
@@ -286,8 +297,7 @@ public class AoeWarningPlugin extends Plugin
} }
} }
@Subscribe private void onGameStateChanged(GameStateChanged delta)
public void onGameStateChanged(GameStateChanged delta)
{ {
if (client.getGameState() == GameState.LOGGED_IN) if (client.getGameState() == GameState.LOGGED_IN)
{ {
@@ -295,8 +305,7 @@ public class AoeWarningPlugin extends Plugin
} }
} }
@Subscribe private void onGameTick(GameTick event)
public void onGameTick(GameTick event)
{ {
if (this.configLightningTrail) if (this.configLightningTrail)
{ {

View File

@@ -50,7 +50,7 @@ import net.runelite.api.widgets.WidgetInfo;
import static net.runelite.api.widgets.WidgetInfo.TO_GROUP; import static net.runelite.api.widgets.WidgetInfo.TO_GROUP;
import net.runelite.client.callback.ClientThread; import net.runelite.client.callback.ClientThread;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
import static net.runelite.client.plugins.attackstyles.AttackStyle.CASTING; import static net.runelite.client.plugins.attackstyles.AttackStyle.CASTING;
@@ -89,6 +89,9 @@ public class AttackStylesPlugin extends Plugin
@Inject @Inject
private AttackStylesOverlay overlay; private AttackStylesOverlay overlay;
@Inject
private EventBus eventBus;
@Provides @Provides
AttackStylesConfig provideConfig(ConfigManager configManager) AttackStylesConfig provideConfig(ConfigManager configManager)
{ {
@@ -110,6 +113,7 @@ public class AttackStylesPlugin extends Plugin
protected void startUp() throws Exception protected void startUp() throws Exception
{ {
updateConfig(); updateConfig();
addSubscriptions();
overlayManager.add(overlay); overlayManager.add(overlay);
@@ -140,12 +144,23 @@ public class AttackStylesPlugin extends Plugin
@Override @Override
protected void shutDown() protected void shutDown()
{ {
eventBus.unregister(this);
overlayManager.remove(overlay); overlayManager.remove(overlay);
hideWarnedStyles(false); hideWarnedStyles(false);
processWidgets(); processWidgets();
hideWidget(client.getWidget(WidgetInfo.COMBAT_AUTO_RETALIATE), false); hideWidget(client.getWidget(WidgetInfo.COMBAT_AUTO_RETALIATE), false);
} }
private void addSubscriptions()
{
eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
eventBus.subscribe(WidgetHiddenChanged.class, this, this::onWidgetHiddenChanged);
eventBus.subscribe(WidgetLoaded.class, this, this::onWidgetLoaded);
eventBus.subscribe(GameStateChanged.class, this, this::onGameStateChanged);
eventBus.subscribe(VarbitChanged.class, this, this::onVarbitChanged);
}
public AttackStyle getAttackStyle() public AttackStyle getAttackStyle()
{ {
return attackStyle; return attackStyle;
@@ -156,8 +171,7 @@ public class AttackStylesPlugin extends Plugin
return warnedSkillSelected; return warnedSkillSelected;
} }
@Subscribe private void onWidgetHiddenChanged(WidgetHiddenChanged event)
public void onWidgetHiddenChanged(WidgetHiddenChanged event)
{ {
if (event.getWidget().isSelfHidden() || TO_GROUP(event.getWidget().getId()) != COMBAT_GROUP_ID) if (event.getWidget().isSelfHidden() || TO_GROUP(event.getWidget().getId()) != COMBAT_GROUP_ID)
{ {
@@ -167,8 +181,7 @@ public class AttackStylesPlugin extends Plugin
processWidgets(); processWidgets();
} }
@Subscribe private void onWidgetLoaded(WidgetLoaded event)
public void onWidgetLoaded(WidgetLoaded event)
{ {
if (event.getGroupId() != COMBAT_GROUP_ID) if (event.getGroupId() != COMBAT_GROUP_ID)
{ {
@@ -195,8 +208,7 @@ public class AttackStylesPlugin extends Plugin
hideWidget(client.getWidget(WidgetInfo.COMBAT_AUTO_RETALIATE), this.hideAutoRetaliate); hideWidget(client.getWidget(WidgetInfo.COMBAT_AUTO_RETALIATE), this.hideAutoRetaliate);
} }
@Subscribe private void onGameStateChanged(GameStateChanged event)
public void onGameStateChanged(GameStateChanged event)
{ {
if (event.getGameState() == GameState.LOGGED_IN) if (event.getGameState() == GameState.LOGGED_IN)
{ {
@@ -208,8 +220,7 @@ public class AttackStylesPlugin extends Plugin
} }
} }
@Subscribe void onVarbitChanged(VarbitChanged event)
public void onVarbitChanged(VarbitChanged event)
{ {
if (attackStyleVarbit == -1 || attackStyleVarbit != client.getVar(VarPlayer.ATTACK_STYLE)) if (attackStyleVarbit == -1 || attackStyleVarbit != client.getVar(VarPlayer.ATTACK_STYLE))
{ {
@@ -236,8 +247,7 @@ public class AttackStylesPlugin extends Plugin
} }
} }
@Subscribe void onConfigChanged(ConfigChanged event)
public void onConfigChanged(ConfigChanged event)
{ {
if (event.getGroup().equals("attackIndicator")) if (event.getGroup().equals("attackIndicator"))
{ {

View File

@@ -39,7 +39,7 @@ import net.runelite.api.events.MenuShouldLeftClick;
import net.runelite.api.events.ScriptCallbackEvent; import net.runelite.api.events.ScriptCallbackEvent;
import net.runelite.client.callback.ClientThread; import net.runelite.client.callback.ClientThread;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.plugins.banktags.tabs.BankSearch; import net.runelite.client.plugins.banktags.tabs.BankSearch;
@@ -72,6 +72,9 @@ public class BankPlugin extends Plugin
@Inject @Inject
private BankSearch bankSearch; private BankSearch bankSearch;
@Inject
private EventBus eventBus;
private boolean forceRightClickFlag; private boolean forceRightClickFlag;
@Provides @Provides
@@ -93,17 +96,26 @@ public class BankPlugin extends Plugin
protected void startUp() throws Exception protected void startUp() throws Exception
{ {
updateConfig(); updateConfig();
addSubscriptions();
} }
@Override @Override
protected void shutDown() protected void shutDown()
{ {
eventBus.unregister(this);
clientThread.invokeLater(() -> bankSearch.reset(false)); clientThread.invokeLater(() -> bankSearch.reset(false));
forceRightClickFlag = false; forceRightClickFlag = false;
} }
@Subscribe private void addSubscriptions()
public void onMenuShouldLeftClick(MenuShouldLeftClick event) {
eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
eventBus.subscribe(MenuShouldLeftClick.class, this, this::onMenuShouldLeftClick);
eventBus.subscribe(MenuEntryAdded.class, this, this::onMenuEntryAdded);
eventBus.subscribe(ScriptCallbackEvent.class, this, this::onScriptCallbackEvent);
}
private void onMenuShouldLeftClick(MenuShouldLeftClick event)
{ {
if (!forceRightClickFlag) if (!forceRightClickFlag)
{ {
@@ -124,8 +136,7 @@ public class BankPlugin extends Plugin
} }
} }
@Subscribe private void onMenuEntryAdded(MenuEntryAdded event)
public void onMenuEntryAdded(MenuEntryAdded event)
{ {
if ((event.getOption().equals(DEPOSIT_WORN) && this.rightClickBankEquip) if ((event.getOption().equals(DEPOSIT_WORN) && this.rightClickBankEquip)
|| (event.getOption().equals(DEPOSIT_INVENTORY) && this.rightClickBankInventory) || (event.getOption().equals(DEPOSIT_INVENTORY) && this.rightClickBankInventory)
@@ -135,8 +146,7 @@ public class BankPlugin extends Plugin
} }
} }
@Subscribe private void onScriptCallbackEvent(ScriptCallbackEvent event)
public void onScriptCallbackEvent(ScriptCallbackEvent event)
{ {
if (!event.getEventName().equals("setBankTitle")) if (!event.getEventName().equals("setBankTitle"))
{ {
@@ -192,8 +202,7 @@ public class BankPlugin extends Plugin
stringStack[stringStackSize - 1] += strCurrentTab; stringStack[stringStackSize - 1] += strCurrentTab;
} }
@Subscribe private void onConfigChanged(ConfigChanged event)
public void onConfigChanged(ConfigChanged event)
{ {
if (!event.getGroup().equals("bank")) if (!event.getGroup().equals("bank"))
{ {

View File

@@ -60,7 +60,7 @@ import net.runelite.api.widgets.WidgetID;
import net.runelite.api.widgets.WidgetInfo; import net.runelite.api.widgets.WidgetInfo;
import net.runelite.client.callback.ClientThread; import net.runelite.client.callback.ClientThread;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.game.ItemManager; import net.runelite.client.game.ItemManager;
import net.runelite.client.game.SpriteManager; import net.runelite.client.game.SpriteManager;
import net.runelite.client.game.chatbox.ChatboxPanelManager; import net.runelite.client.game.chatbox.ChatboxPanelManager;
@@ -132,6 +132,9 @@ public class BankTagsPlugin extends Plugin implements MouseWheelListener, KeyLis
@Inject @Inject
private SpriteManager spriteManager; private SpriteManager spriteManager;
@Inject
private EventBus eventBus;
private boolean shiftPressed = false; private boolean shiftPressed = false;
private int nextRowIndex = 0; private int nextRowIndex = 0;
@@ -144,6 +147,8 @@ public class BankTagsPlugin extends Plugin implements MouseWheelListener, KeyLis
@Override @Override
public void startUp() public void startUp()
{ {
addSubscriptions();
keyManager.registerKeyListener(this); keyManager.registerKeyListener(this);
mouseManager.registerMouseWheelListener(this); mouseManager.registerMouseWheelListener(this);
clientThread.invokeLater(tabInterface::init); clientThread.invokeLater(tabInterface::init);
@@ -153,6 +158,8 @@ public class BankTagsPlugin extends Plugin implements MouseWheelListener, KeyLis
@Override @Override
public void shutDown() public void shutDown()
{ {
eventBus.unregister(this);
keyManager.unregisterKeyListener(this); keyManager.unregisterKeyListener(this);
mouseManager.unregisterMouseWheelListener(this); mouseManager.unregisterMouseWheelListener(this);
clientThread.invokeLater(tabInterface::destroy); clientThread.invokeLater(tabInterface::destroy);
@@ -161,6 +168,18 @@ public class BankTagsPlugin extends Plugin implements MouseWheelListener, KeyLis
shiftPressed = false; shiftPressed = false;
} }
private void addSubscriptions()
{
eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
eventBus.subscribe(ScriptCallbackEvent.class, this, this::onScriptCallbackEvent);
eventBus.subscribe(MenuEntryAdded.class, this, this::onMenuEntryAdded);
eventBus.subscribe(MenuOptionClicked.class, this, this::onMenuOptionClicked);
eventBus.subscribe(GameTick.class, this, this::onGameTick);
eventBus.subscribe(DraggingWidgetChanged.class, this, this::onDraggingWidgetChanged);
eventBus.subscribe(WidgetLoaded.class, this, this::onWidgetLoaded);
eventBus.subscribe(FocusChanged.class, this, this::onFocusChanged);
}
private boolean isSearching() private boolean isSearching()
{ {
return client.getVar(VarClientInt.INPUT_TYPE) == InputType.SEARCH.getType() return client.getVar(VarClientInt.INPUT_TYPE) == InputType.SEARCH.getType()
@@ -168,8 +187,7 @@ public class BankTagsPlugin extends Plugin implements MouseWheelListener, KeyLis
&& client.getVar(VarClientStr.INPUT_TEXT) != null && client.getVar(VarClientStr.INPUT_TEXT).length() > 0); && client.getVar(VarClientStr.INPUT_TEXT) != null && client.getVar(VarClientStr.INPUT_TEXT).length() > 0);
} }
@Subscribe private void onScriptCallbackEvent(ScriptCallbackEvent event)
public void onScriptCallbackEvent(ScriptCallbackEvent event)
{ {
String eventName = event.getEventName(); String eventName = event.getEventName();
@@ -284,8 +302,7 @@ public class BankTagsPlugin extends Plugin implements MouseWheelListener, KeyLis
} }
} }
@Subscribe private void onMenuEntryAdded(MenuEntryAdded event)
public void onMenuEntryAdded(MenuEntryAdded event)
{ {
MenuEntry[] entries = client.getMenuEntries(); MenuEntry[] entries = client.getMenuEntries();
@@ -318,8 +335,7 @@ public class BankTagsPlugin extends Plugin implements MouseWheelListener, KeyLis
tabInterface.handleAdd(event); tabInterface.handleAdd(event);
} }
@Subscribe private void onMenuOptionClicked(MenuOptionClicked event)
public void onMenuOptionClicked(MenuOptionClicked event)
{ {
if (event.getActionParam1() == WidgetInfo.BANK_ITEM_CONTAINER.getId() if (event.getActionParam1() == WidgetInfo.BANK_ITEM_CONTAINER.getId()
&& event.getMenuAction() == MenuAction.RUNELITE && event.getMenuAction() == MenuAction.RUNELITE
@@ -393,8 +409,7 @@ public class BankTagsPlugin extends Plugin implements MouseWheelListener, KeyLis
} }
} }
@Subscribe private void onConfigChanged(ConfigChanged configChanged)
public void onConfigChanged(ConfigChanged configChanged)
{ {
if (configChanged.getGroup().equals("banktags") && configChanged.getKey().equals("useTabs")) if (configChanged.getGroup().equals("banktags") && configChanged.getKey().equals("useTabs"))
{ {
@@ -409,20 +424,17 @@ public class BankTagsPlugin extends Plugin implements MouseWheelListener, KeyLis
} }
} }
@Subscribe private void onGameTick(GameTick event)
public void onGameTick(GameTick event)
{ {
tabInterface.update(); tabInterface.update();
} }
@Subscribe private void onDraggingWidgetChanged(DraggingWidgetChanged event)
public void onDraggingWidgetChanged(DraggingWidgetChanged event)
{ {
tabInterface.handleDrag(event.isDraggingWidget(), shiftPressed); tabInterface.handleDrag(event.isDraggingWidget(), shiftPressed);
} }
@Subscribe private void onWidgetLoaded(WidgetLoaded event)
public void onWidgetLoaded(WidgetLoaded event)
{ {
if (event.getGroupId() == WidgetID.BANK_GROUP_ID) if (event.getGroupId() == WidgetID.BANK_GROUP_ID)
{ {
@@ -430,8 +442,7 @@ public class BankTagsPlugin extends Plugin implements MouseWheelListener, KeyLis
} }
} }
@Subscribe private void onFocusChanged(FocusChanged event)
public void onFocusChanged(FocusChanged event)
{ {
if (!event.isFocused()) if (!event.isFocused())
{ {

View File

@@ -565,7 +565,15 @@ public class TabInterface
return; return;
} }
if (event.getActionParam1() == WidgetInfo.BANK_ITEM_CONTAINER.getId() if (chatboxPanelManager.getCurrentInput() != null
&& event.getMenuAction() != MenuAction.CANCEL
&& !event.getMenuEntry().equals(SCROLL_UP)
&& !event.getMenuEntry().equals(SCROLL_DOWN))
{
chatboxPanelManager.close();
}
if (event.getIdentifier() == WidgetInfo.BANK_ITEM_CONTAINER.getId()
&& event.getMenuAction() == MenuAction.EXAMINE_ITEM_BANK_EQ && event.getMenuAction() == MenuAction.EXAMINE_ITEM_BANK_EQ
&& event.getOption().equalsIgnoreCase("withdraw-x")) && event.getOption().equalsIgnoreCase("withdraw-x"))
{ {

View File

@@ -56,7 +56,7 @@ import net.runelite.client.chat.ChatMessageBuilder;
import net.runelite.client.chat.ChatMessageManager; import net.runelite.client.chat.ChatMessageManager;
import net.runelite.client.chat.QueuedMessage; import net.runelite.client.chat.QueuedMessage;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.plugins.PluginType; import net.runelite.client.plugins.PluginType;
@@ -91,6 +91,8 @@ public class BanListPlugin extends Plugin
private BanListConfig config; private BanListConfig config;
@Inject @Inject
private ChatMessageManager chatMessageManager; private ChatMessageManager chatMessageManager;
@Inject
private EventBus eventBus;
private String tobNames = ""; private String tobNames = "";
private boolean enableWDRScam; private boolean enableWDRScam;
private boolean enableWDRToxic; private boolean enableWDRToxic;
@@ -108,6 +110,7 @@ public class BanListPlugin extends Plugin
protected void startUp() throws Exception protected void startUp() throws Exception
{ {
updateConfig(); updateConfig();
addSubscriptions();
List<String> bannedPlayers = Splitter List<String> bannedPlayers = Splitter
.on(",") .on(",")
.trimResults() .trimResults()
@@ -120,14 +123,24 @@ public class BanListPlugin extends Plugin
@Override @Override
protected void shutDown() throws Exception protected void shutDown() throws Exception
{ {
eventBus.unregister(this);
wdrScamSet.clear(); wdrScamSet.clear();
wdrToxicSet.clear(); wdrToxicSet.clear();
runeWatchSet.clear(); runeWatchSet.clear();
manualBans.clear(); manualBans.clear();
} }
@Subscribe private void addSubscriptions()
public void onConfigChanged(ConfigChanged event) {
eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
eventBus.subscribe(WidgetHiddenChanged.class, this, this::onWidgetHiddenChanged);
eventBus.subscribe(ClanMemberJoined.class, this, this::onClanMemberJoined);
eventBus.subscribe(WidgetLoaded.class, this, this::onWidgetLoaded);
eventBus.subscribe(GameTick.class, this, this::onGameTick);
}
private void onConfigChanged(ConfigChanged event)
{ {
if (event.getGroup().equals("banlist") && event.getKey().equals("bannedPlayers")) if (event.getGroup().equals("banlist") && event.getKey().equals("bannedPlayers"))
{ {
@@ -159,8 +172,7 @@ public class BanListPlugin extends Plugin
/** /**
* Event to keep making sure player names are highlighted red in clan chat, since the red name goes away frequently * Event to keep making sure player names are highlighted red in clan chat, since the red name goes away frequently
*/ */
@Subscribe private void onWidgetHiddenChanged(WidgetHiddenChanged widgetHiddenChanged)
public void onWidgetHiddenChanged(WidgetHiddenChanged widgetHiddenChanged)
{ {
if (client.getGameState() != GameState.LOGGED_IN if (client.getGameState() != GameState.LOGGED_IN
|| client.getWidget(WidgetInfo.LOGIN_CLICK_TO_PLAY_SCREEN) != null || client.getWidget(WidgetInfo.LOGIN_CLICK_TO_PLAY_SCREEN) != null
@@ -180,9 +192,7 @@ public class BanListPlugin extends Plugin
}); });
} }
private void onClanMemberJoined(ClanMemberJoined event)
@Subscribe
public void onClanMemberJoined(ClanMemberJoined event)
{ {
ClanMember member = event.getMember(); ClanMember member = event.getMember();
String memberUsername = Text.standardize(member.getUsername().toLowerCase()); String memberUsername = Text.standardize(member.getUsername().toLowerCase());
@@ -212,8 +222,7 @@ public class BanListPlugin extends Plugin
/** /**
* If a trade window is opened and the person trading us is on the list, modify "trading with" * If a trade window is opened and the person trading us is on the list, modify "trading with"
*/ */
@Subscribe private void onWidgetLoaded(WidgetLoaded widgetLoaded)
public void onWidgetLoaded(WidgetLoaded widgetLoaded)
{ {
if (this.highlightInTrade && widgetLoaded.getGroupId() == TRADING_SCREEN) if (this.highlightInTrade && widgetLoaded.getGroupId() == TRADING_SCREEN)
{ //if trading window was loaded { //if trading window was loaded
@@ -233,9 +242,7 @@ public class BanListPlugin extends Plugin
} }
} }
private void onGameTick(GameTick event)
@Subscribe
public void onGameTick(GameTick event)
{ {
if (client.getWidget(WidgetInfo.THEATRE_OF_BLOOD_RAIDING_PARTY) == null) if (client.getWidget(WidgetInfo.THEATRE_OF_BLOOD_RAIDING_PARTY) == null)

View File

@@ -82,7 +82,7 @@ import net.runelite.client.chat.ChatMessageBuilder;
import net.runelite.client.chat.ChatMessageManager; import net.runelite.client.chat.ChatMessageManager;
import net.runelite.client.chat.QueuedMessage; import net.runelite.client.chat.QueuedMessage;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.game.ItemManager; import net.runelite.client.game.ItemManager;
import net.runelite.client.input.KeyListener; import net.runelite.client.input.KeyListener;
import net.runelite.client.input.KeyManager; import net.runelite.client.input.KeyManager;
@@ -155,6 +155,9 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
@Inject @Inject
private KeyManager keyManager; private KeyManager keyManager;
@Inject
private EventBus eventBus;
@Getter @Getter
private boolean inGame = false; private boolean inGame = false;
@@ -306,6 +309,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
protected void startUp() throws Exception protected void startUp() throws Exception
{ {
updateConfig(); updateConfig();
addSubscriptions();
font = FontManager.getRunescapeFont().deriveFont(Font.BOLD, 24); font = FontManager.getRunescapeFont().deriveFont(Font.BOLD, 24);
torsoImage = itemManager.getImage(ItemID.FIGHTER_TORSO); torsoImage = itemManager.getImage(ItemID.FIGHTER_TORSO);
@@ -323,6 +327,8 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
@Override @Override
protected void shutDown() throws Exception protected void shutDown() throws Exception
{ {
eventBus.unregister(this);
overlayManager.remove(widgetsOverlay); overlayManager.remove(widgetsOverlay);
overlayManager.remove(sceneOverlay); overlayManager.remove(sceneOverlay);
keyManager.unregisterKeyListener(this); keyManager.unregisterKeyListener(this);
@@ -343,6 +349,24 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
menu.clearHiddenMenus(); menu.clearHiddenMenus();
} }
private void addSubscriptions()
{
eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
eventBus.subscribe(WidgetLoaded.class, this, this::onWidgetLoaded);
eventBus.subscribe(ChatMessage.class, this, this::onChatMessage);
eventBus.subscribe(ItemSpawned.class, this, this::onItemSpawned);
eventBus.subscribe(ItemDespawned.class, this, this::onItemDespawned);
eventBus.subscribe(GameTick.class, this, this::onGameTick);
eventBus.subscribe(NpcSpawned.class, this, this::onNpcSpawned);
eventBus.subscribe(NpcDespawned.class, this, this::onNpcDespawned);
eventBus.subscribe(BeforeRender.class, this, this::onBeforeRender);
eventBus.subscribe(MenuEntryAdded.class, this, this::onMenuEntryAdded);
eventBus.subscribe(MenuOptionClicked.class, this, this::onMenuOptionClicked);
eventBus.subscribe(InteractingChanged.class, this, this::onInteractingChanged);
eventBus.subscribe(ProjectileSpawned.class, this, this::onProjectileSpawned);
eventBus.subscribe(VarbitChanged.class, this, this::onVarbitChanged);
}
@Override @Override
public void keyTyped(KeyEvent e) public void keyTyped(KeyEvent e)
{ {
@@ -376,8 +400,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
} }
} }
@Subscribe private void onConfigChanged(ConfigChanged configChanged)
public void onConfigChanged(ConfigChanged configChanged)
{ {
//not client thread be careful //not client thread be careful
if (!configChanged.getGroup().equals("barbarianAssault")) if (!configChanged.getGroup().equals("barbarianAssault"))
@@ -487,8 +510,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
this.showEggCountOverlay = config.showEggCountOverlay(); this.showEggCountOverlay = config.showEggCountOverlay();
} }
@Subscribe private void onWidgetLoaded(WidgetLoaded event)
public void onWidgetLoaded(WidgetLoaded event)
{ {
switch (event.getGroupId()) switch (event.getGroupId())
{ {
@@ -558,8 +580,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
} }
} }
@Subscribe private void onChatMessage(ChatMessage chatMessage)
public void onChatMessage(ChatMessage chatMessage)
{ {
if (!chatMessage.getType().equals(ChatMessageType.GAMEMESSAGE)) if (!chatMessage.getType().equals(ChatMessageType.GAMEMESSAGE))
{ {
@@ -578,6 +599,11 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
} }
else if (isInGame()) else if (isInGame())
{ {
if (scorecard != null)
{
scorecard.onChatMessage(chatMessage);
}
if (message.contains("exploded") && wave != null) if (message.contains("exploded") && wave != null)
{ {
wave.setWrongEggs(wave.getWrongEggs() + 1); wave.setWrongEggs(wave.getWrongEggs() + 1);
@@ -637,8 +663,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
} }
} }
@Subscribe private void onItemSpawned(ItemSpawned itemSpawned)
public void onItemSpawned(ItemSpawned itemSpawned)
{ {
if (!isInGame()) if (!isInGame())
{ {
@@ -657,8 +682,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
} }
} }
@Subscribe private void onItemDespawned(ItemDespawned itemDespawned)
public void onItemDespawned(ItemDespawned itemDespawned)
{ {
if (!isInGame()) if (!isInGame())
{ {
@@ -708,8 +732,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
} }
} }
@Subscribe private void onGameTick(GameTick event)
public void onGameTick(GameTick event)
{ {
// Keep in mind isInGame is delayed by a tick when a wave ends // Keep in mind isInGame is delayed by a tick when a wave ends
if (!isInGame() || getRole() == null) if (!isInGame() || getRole() == null)
@@ -740,8 +763,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
} }
} }
@Subscribe private void onNpcSpawned(NpcSpawned event)
public void onNpcSpawned(NpcSpawned event)
{ {
if (!isInGame()) if (!isInGame())
{ {
@@ -763,8 +785,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
} }
} }
@Subscribe private void onNpcDespawned(NpcDespawned event)
public void onNpcDespawned(NpcDespawned event)
{ {
if (!isInGame()) if (!isInGame())
{ {
@@ -779,8 +800,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
// This was almost certainly a waste of time to get working, because almost nobody // This was almost certainly a waste of time to get working, because almost nobody
// actually uses the horn of glory. At least now there shouldn't be anyone complaining // actually uses the horn of glory. At least now there shouldn't be anyone complaining
// about the horn of glory breaking anything and everything that should never break. // about the horn of glory breaking anything and everything that should never break.
@Subscribe private void onBeforeRender(BeforeRender event)
public void onBeforeRender(BeforeRender event)
{ {
if (!isInGame()) if (!isInGame())
{ {
@@ -953,8 +973,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
// onMenuEntryAdded is being used for conditional entry changes that are not // onMenuEntryAdded is being used for conditional entry changes that are not
// easily achievable using MenuManager, all other changes use MenuManager in // easily achievable using MenuManager, all other changes use MenuManager in
// the BarbarianAssaultMenu/Menus classes // the BarbarianAssaultMenu/Menus classes
@Subscribe private void onMenuEntryAdded(MenuEntryAdded event)
public void onMenuEntryAdded(MenuEntryAdded event)
{ {
if (!isInGame()) if (!isInGame())
{ {
@@ -1144,8 +1163,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
client.setMenuEntries(menu.toArray(new MenuEntry[0])); client.setMenuEntries(menu.toArray(new MenuEntry[0]));
} }
@Subscribe private void onMenuOptionClicked(MenuOptionClicked event)
public void onMenuOptionClicked(MenuOptionClicked event)
{ {
if (!isInGame() && getRole() != null) if (!isInGame() && getRole() != null)
{ {
@@ -1177,8 +1195,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
} }
// Interacting changed has a slight delay until after the hitsplat is applied // Interacting changed has a slight delay until after the hitsplat is applied
@Subscribe private void onInteractingChanged(InteractingChanged event)
public void onInteractingChanged(InteractingChanged event)
{ {
if (!isInGame() || getRole() != Role.HEALER) if (!isInGame() || getRole() != Role.HEALER)
{ {
@@ -1213,8 +1230,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
} }
@Subscribe private void onProjectileSpawned(ProjectileSpawned event)
public void onProjectileSpawned(ProjectileSpawned event)
{ {
if (!isInGame()) if (!isInGame())
{ {
@@ -1234,8 +1250,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener
} }
} }
@Subscribe private void onVarbitChanged(VarbitChanged event)
public void onVarbitChanged(VarbitChanged event)
{ {
int newInGameBit = client.getVar(Varbits.IN_GAME_BA); int newInGameBit = client.getVar(Varbits.IN_GAME_BA);

View File

@@ -33,7 +33,6 @@ import lombok.AccessLevel;
import lombok.Getter; import lombok.Getter;
import net.runelite.api.events.ChatMessage; import net.runelite.api.events.ChatMessage;
import net.runelite.client.chat.ChatMessageBuilder; import net.runelite.client.chat.ChatMessageBuilder;
import net.runelite.client.eventbus.Subscribe;
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
@@ -65,7 +64,6 @@ public class Scorecard
this.game = game; this.game = game;
} }
@Subscribe
public void onChatMessage(ChatMessage chatMessage) public void onChatMessage(ChatMessage chatMessage)
{ {
if (chatMessage.getMessage().startsWith("---- Points:") && game.getStage() == 1) if (chatMessage.getMessage().startsWith("---- Points:") && game.getStage() == 1)

View File

@@ -63,7 +63,7 @@ import net.runelite.client.chat.ChatMessageBuilder;
import net.runelite.client.chat.ChatMessageManager; import net.runelite.client.chat.ChatMessageManager;
import net.runelite.client.chat.QueuedMessage; import net.runelite.client.chat.QueuedMessage;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.game.ItemManager; import net.runelite.client.game.ItemManager;
import net.runelite.client.game.SpriteManager; import net.runelite.client.game.SpriteManager;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
@@ -141,6 +141,9 @@ public class BarrowsPlugin extends Plugin
@Inject @Inject
private BarrowsConfig config; private BarrowsConfig config;
@Inject
private EventBus eventBus;
@Provides @Provides
BarrowsConfig provideConfig(ConfigManager configManager) BarrowsConfig provideConfig(ConfigManager configManager)
{ {
@@ -164,6 +167,8 @@ public class BarrowsPlugin extends Plugin
protected void startUp() throws Exception protected void startUp() throws Exception
{ {
updateConfig(); updateConfig();
addSubscriptions();
overlayManager.add(barrowsOverlay); overlayManager.add(barrowsOverlay);
overlayManager.add(brotherOverlay); overlayManager.add(brotherOverlay);
} }
@@ -171,6 +176,8 @@ public class BarrowsPlugin extends Plugin
@Override @Override
protected void shutDown() protected void shutDown()
{ {
eventBus.unregister(this);
overlayManager.remove(barrowsOverlay); overlayManager.remove(barrowsOverlay);
overlayManager.remove(brotherOverlay); overlayManager.remove(brotherOverlay);
walls.clear(); walls.clear();
@@ -193,8 +200,20 @@ public class BarrowsPlugin extends Plugin
} }
} }
@Subscribe private void addSubscriptions()
public void onConfigChanged(ConfigChanged event) {
eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
eventBus.subscribe(WallObjectSpawned.class, this, this::onWallObjectSpawned);
eventBus.subscribe(WallObjectChanged.class, this, this::onWallObjectChanged);
eventBus.subscribe(WallObjectDespawned.class, this, this::onWallObjectDespawned);
eventBus.subscribe(GameObjectSpawned.class, this, this::onGameObjectSpawned);
eventBus.subscribe(GameObjectChanged.class, this, this::onGameObjectChanged);
eventBus.subscribe(GameObjectDespawned.class, this, this::onGameObjectDespawned);
eventBus.subscribe(GameStateChanged.class, this, this::onGameStateChanged);
eventBus.subscribe(WidgetLoaded.class, this, this::onWidgetLoaded);
}
private void onConfigChanged(ConfigChanged event)
{ {
if (event.getGroup().equals("barrows")) if (event.getGroup().equals("barrows"))
{ {
@@ -218,8 +237,7 @@ public class BarrowsPlugin extends Plugin
this.showPrayerDrainTimer = config.showPrayerDrainTimer(); this.showPrayerDrainTimer = config.showPrayerDrainTimer();
} }
@Subscribe private void onWallObjectSpawned(WallObjectSpawned event)
public void onWallObjectSpawned(WallObjectSpawned event)
{ {
WallObject wallObject = event.getWallObject(); WallObject wallObject = event.getWallObject();
if (BARROWS_WALLS.contains(wallObject.getId())) if (BARROWS_WALLS.contains(wallObject.getId()))
@@ -228,8 +246,7 @@ public class BarrowsPlugin extends Plugin
} }
} }
@Subscribe private void onWallObjectChanged(WallObjectChanged event)
public void onWallObjectChanged(WallObjectChanged event)
{ {
WallObject previous = event.getPrevious(); WallObject previous = event.getPrevious();
WallObject wallObject = event.getWallObject(); WallObject wallObject = event.getWallObject();
@@ -241,15 +258,13 @@ public class BarrowsPlugin extends Plugin
} }
} }
@Subscribe private void onWallObjectDespawned(WallObjectDespawned event)
public void onWallObjectDespawned(WallObjectDespawned event)
{ {
WallObject wallObject = event.getWallObject(); WallObject wallObject = event.getWallObject();
walls.remove(wallObject); walls.remove(wallObject);
} }
@Subscribe private void onGameObjectSpawned(GameObjectSpawned event)
public void onGameObjectSpawned(GameObjectSpawned event)
{ {
GameObject gameObject = event.getGameObject(); GameObject gameObject = event.getGameObject();
if (BARROWS_LADDERS.contains(gameObject.getId())) if (BARROWS_LADDERS.contains(gameObject.getId()))
@@ -258,8 +273,7 @@ public class BarrowsPlugin extends Plugin
} }
} }
@Subscribe private void onGameObjectChanged(GameObjectChanged event)
public void onGameObjectChanged(GameObjectChanged event)
{ {
GameObject previous = event.getPrevious(); GameObject previous = event.getPrevious();
GameObject gameObject = event.getGameObject(); GameObject gameObject = event.getGameObject();
@@ -271,15 +285,13 @@ public class BarrowsPlugin extends Plugin
} }
} }
@Subscribe private void onGameObjectDespawned(GameObjectDespawned event)
public void onGameObjectDespawned(GameObjectDespawned event)
{ {
GameObject gameObject = event.getGameObject(); GameObject gameObject = event.getGameObject();
ladders.remove(gameObject); ladders.remove(gameObject);
} }
@Subscribe private void onGameStateChanged(GameStateChanged event)
public void onGameStateChanged(GameStateChanged event)
{ {
if (event.getGameState() == GameState.LOADING) if (event.getGameState() == GameState.LOADING)
{ {
@@ -303,8 +315,7 @@ public class BarrowsPlugin extends Plugin
} }
} }
@Subscribe private void onWidgetLoaded(WidgetLoaded event)
public void onWidgetLoaded(WidgetLoaded event)
{ {
if (event.getGroupId() == WidgetID.BARROWS_REWARD_GROUP_ID && this.showChestValue) if (event.getGroupId() == WidgetID.BARROWS_REWARD_GROUP_ID && this.showChestValue)
{ {
@@ -359,10 +370,12 @@ public class BarrowsPlugin extends Plugin
final LoopTimer loopTimer = new LoopTimer( final LoopTimer loopTimer = new LoopTimer(
PRAYER_DRAIN_INTERVAL_MS, PRAYER_DRAIN_INTERVAL_MS,
ChronoUnit.MILLIS, ChronoUnit.MILLIS,
spriteManager.getSprite(SpriteID.TAB_PRAYER, 0), null,
this, this,
true); true);
spriteManager.getSpriteAsync(SpriteID.TAB_PRAYER, 0, loopTimer);
loopTimer.setPriority(InfoBoxPriority.MED); loopTimer.setPriority(InfoBoxPriority.MED);
loopTimer.setTooltip("Prayer Drain"); loopTimer.setTooltip("Prayer Drain");

View File

@@ -38,7 +38,7 @@ import net.runelite.api.events.ChatMessage;
import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.ConfigChanged;
import net.runelite.api.events.MenuEntryAdded; import net.runelite.api.events.MenuEntryAdded;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.plugins.PluginType; import net.runelite.client.plugins.PluginType;
@@ -68,6 +68,8 @@ public class BlackjackPlugin extends Plugin
private Client client; private Client client;
@Inject @Inject
private BlackjackConfig config; private BlackjackConfig config;
@Inject
private EventBus eventBus;
private boolean pickpocketOnAggro; private boolean pickpocketOnAggro;
@@ -80,11 +82,25 @@ public class BlackjackPlugin extends Plugin
@Override @Override
protected void startUp() throws Exception protected void startUp() throws Exception
{ {
addSubscriptions();
this.pickpocketOnAggro = config.pickpocketOnAggro(); this.pickpocketOnAggro = config.pickpocketOnAggro();
} }
@Subscribe @Override
public void onConfigChanged(ConfigChanged event) protected void shutDown() throws Exception
{
eventBus.unregister(this);
}
private void addSubscriptions()
{
eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
eventBus.subscribe(MenuEntryAdded.class, this, this::onMenuEntryAdded);
eventBus.subscribe(ChatMessage.class, this, this::onChatMessage);
}
private void onConfigChanged(ConfigChanged event)
{ {
if (event.getGroup().equals("blackjack")) if (event.getGroup().equals("blackjack"))
{ {
@@ -92,8 +108,7 @@ public class BlackjackPlugin extends Plugin
} }
} }
@Subscribe private void onMenuEntryAdded(MenuEntryAdded event)
public void onMenuEntryAdded(MenuEntryAdded event)
{ {
if (client.getGameState() != GameState.LOGGED_IN || if (client.getGameState() != GameState.LOGGED_IN ||
client.getVar(Varbits.QUEST_THE_FEUD) < 13 || client.getVar(Varbits.QUEST_THE_FEUD) < 13 ||
@@ -114,8 +129,7 @@ public class BlackjackPlugin extends Plugin
} }
} }
@Subscribe private void onChatMessage(ChatMessage event)
public void onChatMessage(ChatMessage event)
{ {
if (event.getType() == ChatMessageType.SPAM && event.getMessage().equals(SUCCESS_BLACKJACK) ^ (event.getMessage().equals(FAILED_BLACKJACK) && this.pickpocketOnAggro)) if (event.getType() == ChatMessageType.SPAM && event.getMessage().equals(SUCCESS_BLACKJACK) ^ (event.getMessage().equals(FAILED_BLACKJACK) && this.pickpocketOnAggro))
{ {

View File

@@ -46,7 +46,7 @@ import net.runelite.api.events.GameTick;
import net.runelite.api.widgets.Widget; import net.runelite.api.widgets.Widget;
import net.runelite.api.widgets.WidgetInfo; import net.runelite.api.widgets.WidgetInfo;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.game.ItemManager; import net.runelite.client.game.ItemManager;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
@@ -97,6 +97,9 @@ public class BlastFurnacePlugin extends Plugin
@Inject @Inject
private BlastFurnaceConfig config; private BlastFurnaceConfig config;
@Inject
private EventBus eventBus;
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
private boolean showConveyorBelt; private boolean showConveyorBelt;
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
@@ -106,6 +109,7 @@ public class BlastFurnacePlugin extends Plugin
protected void startUp() throws Exception protected void startUp() throws Exception
{ {
updateConfig(); updateConfig();
addSubscriptions();
overlayManager.add(overlay); overlayManager.add(overlay);
overlayManager.add(cofferOverlay); overlayManager.add(cofferOverlay);
@@ -115,6 +119,8 @@ public class BlastFurnacePlugin extends Plugin
@Override @Override
protected void shutDown() protected void shutDown()
{ {
eventBus.unregister(this);
infoBoxManager.removeIf(ForemanTimer.class::isInstance); infoBoxManager.removeIf(ForemanTimer.class::isInstance);
overlayManager.remove(overlay); overlayManager.remove(overlay);
overlayManager.remove(cofferOverlay); overlayManager.remove(cofferOverlay);
@@ -124,14 +130,22 @@ public class BlastFurnacePlugin extends Plugin
foremanTimer = null; foremanTimer = null;
} }
private void addSubscriptions()
{
eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
eventBus.subscribe(GameObjectSpawned.class, this, this::onGameObjectSpawned);
eventBus.subscribe(GameObjectDespawned.class, this, this::onGameObjectDespawned);
eventBus.subscribe(GameStateChanged.class, this, this::onGameStateChanged);
eventBus.subscribe(GameTick.class, this, this::onGameTick);
}
@Provides @Provides
BlastFurnaceConfig provideConfig(ConfigManager configManager) BlastFurnaceConfig provideConfig(ConfigManager configManager)
{ {
return configManager.getConfig(BlastFurnaceConfig.class); return configManager.getConfig(BlastFurnaceConfig.class);
} }
@Subscribe private void onConfigChanged(ConfigChanged event)
public void onConfigChanged(ConfigChanged event)
{ {
if (event.getGroup().equals("blastfurnace")) if (event.getGroup().equals("blastfurnace"))
{ {
@@ -139,8 +153,7 @@ public class BlastFurnacePlugin extends Plugin
} }
} }
@Subscribe private void onGameObjectSpawned(GameObjectSpawned event)
public void onGameObjectSpawned(GameObjectSpawned event)
{ {
GameObject gameObject = event.getGameObject(); GameObject gameObject = event.getGameObject();
@@ -156,8 +169,7 @@ public class BlastFurnacePlugin extends Plugin
} }
} }
@Subscribe private void onGameObjectDespawned(GameObjectDespawned event)
public void onGameObjectDespawned(GameObjectDespawned event)
{ {
GameObject gameObject = event.getGameObject(); GameObject gameObject = event.getGameObject();
@@ -173,8 +185,7 @@ public class BlastFurnacePlugin extends Plugin
} }
} }
@Subscribe private void onGameStateChanged(GameStateChanged event)
public void onGameStateChanged(GameStateChanged event)
{ {
if (event.getGameState() == GameState.LOADING) if (event.getGameState() == GameState.LOADING)
{ {
@@ -183,8 +194,7 @@ public class BlastFurnacePlugin extends Plugin
} }
} }
@Subscribe private void onGameTick(GameTick event)
public void onGameTick(GameTick event)
{ {
Widget npcDialog = client.getWidget(WidgetInfo.DIALOG_NPC_TEXT); Widget npcDialog = client.getWidget(WidgetInfo.DIALOG_NPC_TEXT);
if (npcDialog == null) if (npcDialog == null)

View File

@@ -42,7 +42,7 @@ import net.runelite.api.events.GameTick;
import net.runelite.api.widgets.Widget; import net.runelite.api.widgets.Widget;
import net.runelite.api.widgets.WidgetInfo; import net.runelite.api.widgets.WidgetInfo;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.ui.overlay.OverlayManager;
@@ -73,6 +73,9 @@ public class BlastMinePlugin extends Plugin
@Inject @Inject
private BlastMinePluginConfig config; private BlastMinePluginConfig config;
@Inject
private EventBus eventBus;
@Provides @Provides
BlastMinePluginConfig getConfig(ConfigManager configManager) BlastMinePluginConfig getConfig(ConfigManager configManager)
{ {
@@ -96,6 +99,7 @@ public class BlastMinePlugin extends Plugin
protected void startUp() throws Exception protected void startUp() throws Exception
{ {
updateConfig(); updateConfig();
addSubscriptions();
overlayManager.add(blastMineRockOverlay); overlayManager.add(blastMineRockOverlay);
overlayManager.add(blastMineOreCountOverlay); overlayManager.add(blastMineOreCountOverlay);
@@ -104,6 +108,8 @@ public class BlastMinePlugin extends Plugin
@Override @Override
protected void shutDown() throws Exception protected void shutDown() throws Exception
{ {
eventBus.unregister(this);
overlayManager.remove(blastMineRockOverlay); overlayManager.remove(blastMineRockOverlay);
overlayManager.remove(blastMineOreCountOverlay); overlayManager.remove(blastMineOreCountOverlay);
final Widget blastMineWidget = client.getWidget(WidgetInfo.BLAST_MINE); final Widget blastMineWidget = client.getWidget(WidgetInfo.BLAST_MINE);
@@ -114,8 +120,14 @@ public class BlastMinePlugin extends Plugin
} }
} }
@Subscribe private void addSubscriptions()
public void onGameObjectSpawned(GameObjectSpawned event) {
eventBus.subscribe(GameObjectSpawned.class, this, this::onGameObjectSpawned);
eventBus.subscribe(GameStateChanged.class, this, this::onGameStateChanged);
eventBus.subscribe(GameTick.class, this, this::onGameTick);
}
private void onGameObjectSpawned(GameObjectSpawned event)
{ {
final GameObject gameObject = event.getGameObject(); final GameObject gameObject = event.getGameObject();
BlastMineRockType blastMineRockType = BlastMineRockType.getRockType(gameObject.getId()); BlastMineRockType blastMineRockType = BlastMineRockType.getRockType(gameObject.getId());
@@ -133,8 +145,7 @@ public class BlastMinePlugin extends Plugin
} }
} }
@Subscribe private void onGameStateChanged(GameStateChanged event)
public void onGameStateChanged(GameStateChanged event)
{ {
if (event.getGameState() == GameState.LOADING) if (event.getGameState() == GameState.LOADING)
{ {
@@ -142,8 +153,7 @@ public class BlastMinePlugin extends Plugin
} }
} }
@Subscribe private void onGameTick(GameTick gameTick)
public void onGameTick(GameTick gameTick)
{ {
if (rocks.isEmpty()) if (rocks.isEmpty())
{ {

View File

@@ -45,7 +45,7 @@ import net.runelite.api.events.GameStateChanged;
import net.runelite.api.events.GameTick; import net.runelite.api.events.GameTick;
import net.runelite.client.Notifier; import net.runelite.client.Notifier;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.game.SkillIconManager; import net.runelite.client.game.SkillIconManager;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
@@ -98,6 +98,8 @@ public class BoostsPlugin extends Plugin
private SkillIconManager skillIconManager; private SkillIconManager skillIconManager;
@Inject @Inject
private CombatIconsOverlay combatIconsOverlay; private CombatIconsOverlay combatIconsOverlay;
@Inject
private EventBus eventBus;
private boolean isChangedDown = false; private boolean isChangedDown = false;
private boolean isChangedUp = false; private boolean isChangedUp = false;
@@ -133,6 +135,7 @@ public class BoostsPlugin extends Plugin
protected void startUp() throws Exception protected void startUp() throws Exception
{ {
updateConfig(); updateConfig();
addSubscriptions();
overlayManager.add(boostsOverlay); overlayManager.add(boostsOverlay);
overlayManager.add(combatIconsOverlay); overlayManager.add(combatIconsOverlay);
@@ -156,6 +159,7 @@ public class BoostsPlugin extends Plugin
@Override @Override
protected void shutDown() throws Exception protected void shutDown() throws Exception
{ {
eventBus.unregister(this);
overlayManager.remove(boostsOverlay); overlayManager.remove(boostsOverlay);
overlayManager.remove(combatIconsOverlay); overlayManager.remove(combatIconsOverlay);
infoBoxManager.removeIf(t -> t instanceof BoostIndicator || t instanceof StatChangeIndicator); infoBoxManager.removeIf(t -> t instanceof BoostIndicator || t instanceof StatChangeIndicator);
@@ -166,8 +170,15 @@ public class BoostsPlugin extends Plugin
isChangedDown = false; isChangedDown = false;
} }
@Subscribe private void addSubscriptions()
public void onGameStateChanged(GameStateChanged event) {
eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
eventBus.subscribe(GameStateChanged.class, this, this::onGameStateChanged);
eventBus.subscribe(BoostedLevelChanged.class, this, this::onBoostedLevelChanged);
eventBus.subscribe(GameTick.class, this, this::onGameTick);
}
private void onGameStateChanged(GameStateChanged event)
{ {
switch (event.getGameState()) switch (event.getGameState())
{ {
@@ -179,8 +190,7 @@ public class BoostsPlugin extends Plugin
} }
} }
@Subscribe private void onConfigChanged(ConfigChanged event)
public void onConfigChanged(ConfigChanged event)
{ {
if (!event.getGroup().equals("boosts")) if (!event.getGroup().equals("boosts"))
{ {
@@ -201,8 +211,7 @@ public class BoostsPlugin extends Plugin
} }
} }
@Subscribe private void onBoostedLevelChanged(BoostedLevelChanged boostedLevelChanged)
public void onBoostedLevelChanged(BoostedLevelChanged boostedLevelChanged)
{ {
Skill skill = boostedLevelChanged.getSkill(); Skill skill = boostedLevelChanged.getSkill();
@@ -251,8 +260,7 @@ public class BoostsPlugin extends Plugin
} }
} }
@Subscribe private void onGameTick(GameTick event)
public void onGameTick(GameTick event)
{ {
lastTickMillis = System.currentTimeMillis(); lastTickMillis = System.currentTimeMillis();

View File

@@ -30,7 +30,7 @@ import javax.inject.Singleton;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.runelite.api.NPC; import net.runelite.api.NPC;
import net.runelite.api.events.NpcDespawned; import net.runelite.api.events.NpcDespawned;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.game.ItemManager; import net.runelite.client.game.ItemManager;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
@@ -51,14 +51,23 @@ public class BossTimersPlugin extends Plugin
@Inject @Inject
private ItemManager itemManager; private ItemManager itemManager;
@Inject
private EventBus eventBus;
@Override
protected void startUp() throws Exception
{
eventBus.subscribe(NpcDespawned.class, this, this::onNpcDespawned);
}
@Override @Override
protected void shutDown() throws Exception protected void shutDown() throws Exception
{ {
eventBus.unregister(this);
infoBoxManager.removeIf(t -> t instanceof RespawnTimer); infoBoxManager.removeIf(t -> t instanceof RespawnTimer);
} }
@Subscribe private void onNpcDespawned(NpcDespawned npcDespawned)
public void onNpcDespawned(NpcDespawned npcDespawned)
{ {
NPC npc = npcDespawned.getNpc(); NPC npc = npcDespawned.getNpc();

View File

@@ -56,7 +56,7 @@ import net.runelite.api.events.ProjectileMoved;
import net.runelite.client.Notifier; import net.runelite.client.Notifier;
import net.runelite.client.callback.ClientThread; import net.runelite.client.callback.ClientThread;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.game.ItemManager; import net.runelite.client.game.ItemManager;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
@@ -123,6 +123,9 @@ public class CannonPlugin extends Plugin
@Inject @Inject
private ClientThread clientThread; private ClientThread clientThread;
@Inject
private EventBus eventbus;
private boolean lock; private boolean lock;
private boolean showEmptyCannonNotification; private boolean showEmptyCannonNotification;
@@ -146,6 +149,7 @@ public class CannonPlugin extends Plugin
protected void startUp() throws Exception protected void startUp() throws Exception
{ {
updateConfig(); updateConfig();
addSubscriptions();
overlayManager.add(cannonOverlay); overlayManager.add(cannonOverlay);
overlayManager.add(cannonSpotOverlay); overlayManager.add(cannonSpotOverlay);
@@ -155,6 +159,8 @@ public class CannonPlugin extends Plugin
@Override @Override
protected void shutDown() throws Exception protected void shutDown() throws Exception
{ {
eventbus.unregister(this);
cannonSpotOverlay.setHidden(true); cannonSpotOverlay.setHidden(true);
overlayManager.remove(cannonOverlay); overlayManager.remove(cannonOverlay);
overlayManager.remove(cannonSpotOverlay); overlayManager.remove(cannonSpotOverlay);
@@ -167,8 +173,17 @@ public class CannonPlugin extends Plugin
spotPoints.clear(); spotPoints.clear();
} }
@Subscribe private void addSubscriptions()
public void onItemContainerChanged(ItemContainerChanged event) {
eventbus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
eventbus.subscribe(ItemContainerChanged.class, this, this::onItemContainerChanged);
eventbus.subscribe(GameObjectSpawned.class, this, this::onGameObjectSpawned);
eventbus.subscribe(ProjectileMoved.class, this, this::onProjectileMoved);
eventbus.subscribe(ChatMessage.class, this, this::onChatMessage);
eventbus.subscribe(GameTick.class, this, this::onGameTick);
}
private void onItemContainerChanged(ItemContainerChanged event)
{ {
if (event.getItemContainer() != client.getItemContainer(InventoryID.INVENTORY)) if (event.getItemContainer() != client.getItemContainer(InventoryID.INVENTORY))
{ {
@@ -178,8 +193,7 @@ public class CannonPlugin extends Plugin
cannonSpotOverlay.setHidden(!ItemUtil.containsAllItemIds(event.getItemContainer().getItems(), CANNON_PARTS)); cannonSpotOverlay.setHidden(!ItemUtil.containsAllItemIds(event.getItemContainer().getItems(), CANNON_PARTS));
} }
@Subscribe private void onConfigChanged(ConfigChanged event)
public void onConfigChanged(ConfigChanged event)
{ {
if (event.getGroup().equals("cannon")) if (event.getGroup().equals("cannon"))
{ {
@@ -223,8 +237,7 @@ public class CannonPlugin extends Plugin
} }
} }
@Subscribe private void onGameObjectSpawned(GameObjectSpawned event)
public void onGameObjectSpawned(GameObjectSpawned event)
{ {
GameObject gameObject = event.getGameObject(); GameObject gameObject = event.getGameObject();
@@ -238,8 +251,7 @@ public class CannonPlugin extends Plugin
} }
} }
@Subscribe private void onProjectileMoved(ProjectileMoved event)
public void onProjectileMoved(ProjectileMoved event)
{ {
Projectile projectile = event.getProjectile(); Projectile projectile = event.getProjectile();
@@ -261,8 +273,7 @@ public class CannonPlugin extends Plugin
} }
} }
@Subscribe private void onChatMessage(ChatMessage event)
public void onChatMessage(ChatMessage event)
{ {
if (event.getType() != ChatMessageType.SPAM && event.getType() != ChatMessageType.GAMEMESSAGE) if (event.getType() != ChatMessageType.SPAM && event.getType() != ChatMessageType.GAMEMESSAGE)
{ {
@@ -345,8 +356,7 @@ public class CannonPlugin extends Plugin
} }
} }
@Subscribe private void onGameTick(GameTick event)
public void onGameTick(GameTick event)
{ {
skipProjectileCheckThisTick = false; skipProjectileCheckThisTick = false;
} }

View File

@@ -37,7 +37,7 @@ import net.runelite.api.events.GameStateChanged;
import net.runelite.api.events.GameTick; import net.runelite.api.events.GameTick;
import net.runelite.api.events.NpcDespawned; import net.runelite.api.events.NpcDespawned;
import net.runelite.api.events.NpcSpawned; import net.runelite.api.events.NpcSpawned;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.ui.overlay.OverlayManager;
@@ -59,21 +59,34 @@ public class CerberusPlugin extends Plugin
@Inject @Inject
private CerberusOverlay overlay; private CerberusOverlay overlay;
@Inject
private EventBus eventBus;
@Override @Override
protected void startUp() throws Exception protected void startUp() throws Exception
{ {
overlayManager.add(overlay); overlayManager.add(overlay);
addSubscriptions();
} }
@Override @Override
protected void shutDown() throws Exception protected void shutDown() throws Exception
{ {
eventBus.unregister(this);
overlayManager.remove(overlay); overlayManager.remove(overlay);
ghosts.clear(); ghosts.clear();
} }
@Subscribe private void addSubscriptions()
public void onGameStateChanged(GameStateChanged event) {
eventBus.subscribe(GameStateChanged.class, this, this::onGameStateChanged);
eventBus.subscribe(NpcSpawned.class, this, this::onNpcSpawned);
eventBus.subscribe(NpcDespawned.class, this, this::onNpcDespawned);
eventBus.subscribe(GameTick.class, this, this::onGameTick);
}
private void onGameStateChanged(GameStateChanged event)
{ {
GameState gameState = event.getGameState(); GameState gameState = event.getGameState();
if (gameState == GameState.LOGIN_SCREEN || gameState == GameState.HOPPING || gameState == GameState.CONNECTION_LOST) if (gameState == GameState.LOGIN_SCREEN || gameState == GameState.HOPPING || gameState == GameState.CONNECTION_LOST)
@@ -82,21 +95,18 @@ public class CerberusPlugin extends Plugin
} }
} }
@Subscribe private void onNpcSpawned(final NpcSpawned event)
public void onNpcSpawned(final NpcSpawned event)
{ {
final NPC npc = event.getNpc(); final NPC npc = event.getNpc();
CerberusGhost.fromNPC(npc).ifPresent(ghost -> ghosts.add(npc)); CerberusGhost.fromNPC(npc).ifPresent(ghost -> ghosts.add(npc));
} }
@Subscribe private void onNpcDespawned(final NpcDespawned event)
public void onNpcDespawned(final NpcDespawned event)
{ {
ghosts.remove(event.getNpc()); ghosts.remove(event.getNpc());
} }
@Subscribe void onGameTick(GameTick gameTick)
public void onGameTick(GameTick gameTick)
{ {
if (ghosts.isEmpty()) if (ghosts.isEmpty())
{ {

View File

@@ -33,7 +33,7 @@ import net.runelite.api.widgets.WidgetInfo;
import net.runelite.api.widgets.WidgetPositionMode; import net.runelite.api.widgets.WidgetPositionMode;
import net.runelite.api.widgets.WidgetSizeMode; import net.runelite.api.widgets.WidgetSizeMode;
import net.runelite.api.widgets.WidgetType; import net.runelite.api.widgets.WidgetType;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
@@ -47,8 +47,22 @@ public class ChatboxPerformancePlugin extends Plugin
@Inject @Inject
private Client client; private Client client;
@Subscribe @Inject
public void onWidgetPositioned(WidgetPositioned event) private EventBus eventBus;
@Override
protected void startUp() throws Exception
{
eventBus.subscribe(WidgetPositioned.class, this, this::onWidgetPositioned);
}
@Override
protected void shutDown() throws Exception
{
eventBus.unregister(this);
}
private void onWidgetPositioned(WidgetPositioned event)
{ {
if (!areWidgetsFixed()) if (!areWidgetsFixed())
{ {

View File

@@ -56,7 +56,7 @@ import net.runelite.client.chat.ChatCommandManager;
import net.runelite.client.chat.ChatMessageBuilder; import net.runelite.client.chat.ChatMessageBuilder;
import net.runelite.client.chat.ChatMessageManager; import net.runelite.client.chat.ChatMessageManager;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.events.ChatInput; import net.runelite.client.events.ChatInput;
import net.runelite.client.game.ItemManager; import net.runelite.client.game.ItemManager;
import net.runelite.client.input.KeyManager; import net.runelite.client.input.KeyManager;
@@ -140,9 +140,14 @@ public class ChatCommandsPlugin extends Plugin
@Inject @Inject
private ChatKeyboardListener chatKeyboardListener; private ChatKeyboardListener chatKeyboardListener;
@Inject
private EventBus eventBus;
@Override @Override
public void startUp() public void startUp()
{ {
addSubscriptions();
keyManager.registerKeyListener(chatKeyboardListener); keyManager.registerKeyListener(chatKeyboardListener);
chatCommandManager.registerCommandAsync(TOTAL_LEVEL_COMMAND_STRING, this::playerSkillLookup); chatCommandManager.registerCommandAsync(TOTAL_LEVEL_COMMAND_STRING, this::playerSkillLookup);
@@ -160,6 +165,8 @@ public class ChatCommandsPlugin extends Plugin
@Override @Override
public void shutDown() public void shutDown()
{ {
eventBus.unregister(this);
lastBossKill = null; lastBossKill = null;
keyManager.unregisterKeyListener(chatKeyboardListener); keyManager.unregisterKeyListener(chatKeyboardListener);
@@ -176,6 +183,14 @@ public class ChatCommandsPlugin extends Plugin
chatCommandManager.unregisterCommand(DUEL_ARENA_COMMAND); chatCommandManager.unregisterCommand(DUEL_ARENA_COMMAND);
} }
private void addSubscriptions()
{
eventBus.subscribe(ChatMessage.class, this, this::onChatMessage);
eventBus.subscribe(GameTick.class, this, this::onGameTick);
eventBus.subscribe(WidgetLoaded.class, this, this::onWidgetLoaded);
eventBus.subscribe(VarbitChanged.class, this, this::onVarbitChanged);
}
@Provides @Provides
ChatCommandsConfig provideConfig(ConfigManager configManager) ChatCommandsConfig provideConfig(ConfigManager configManager)
{ {
@@ -208,8 +223,7 @@ public class ChatCommandsPlugin extends Plugin
return personalBest == null ? 0 : personalBest; return personalBest == null ? 0 : personalBest;
} }
@Subscribe void onChatMessage(ChatMessage chatMessage)
public void onChatMessage(ChatMessage chatMessage)
{ {
if (chatMessage.getType() != ChatMessageType.TRADE if (chatMessage.getType() != ChatMessageType.TRADE
&& chatMessage.getType() != ChatMessageType.GAMEMESSAGE && chatMessage.getType() != ChatMessageType.GAMEMESSAGE
@@ -324,8 +338,7 @@ public class ChatCommandsPlugin extends Plugin
} }
} }
@Subscribe private void onGameTick(GameTick event)
public void onGameTick(GameTick event)
{ {
if (!logKills) if (!logKills)
{ {
@@ -361,8 +374,7 @@ public class ChatCommandsPlugin extends Plugin
} }
} }
@Subscribe private void onWidgetLoaded(WidgetLoaded widget)
public void onWidgetLoaded(WidgetLoaded widget)
{ {
// don't load kc if in an instance, if the player is in another players poh // don't load kc if in an instance, if the player is in another players poh
// and reading their boss log // and reading their boss log
@@ -374,8 +386,7 @@ public class ChatCommandsPlugin extends Plugin
logKills = true; logKills = true;
} }
@Subscribe private void onVarbitChanged(VarbitChanged varbitChanged)
public void onVarbitChanged(VarbitChanged varbitChanged)
{ {
hiscoreEndpoint = getLocalHiscoreEndpointType(); hiscoreEndpoint = getLocalHiscoreEndpointType();
} }

View File

@@ -45,7 +45,7 @@ import net.runelite.api.events.ConfigChanged;
import net.runelite.api.events.OverheadTextChanged; import net.runelite.api.events.OverheadTextChanged;
import net.runelite.api.events.ScriptCallbackEvent; import net.runelite.api.events.ScriptCallbackEvent;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.util.Text; import net.runelite.client.util.Text;
@@ -75,6 +75,9 @@ public class ChatFilterPlugin extends Plugin
@Inject @Inject
private ChatFilterConfig config; private ChatFilterConfig config;
@Inject
private EventBus eventBus;
@Setter(AccessLevel.PACKAGE) @Setter(AccessLevel.PACKAGE)
private ChatFilterType filterType; private ChatFilterType filterType;
@Setter(AccessLevel.PACKAGE) @Setter(AccessLevel.PACKAGE)
@@ -96,6 +99,8 @@ public class ChatFilterPlugin extends Plugin
protected void startUp() throws Exception protected void startUp() throws Exception
{ {
updateConfig(); updateConfig();
addSubscriptions();
updateFilteredPatterns(); updateFilteredPatterns();
client.refreshChat(); client.refreshChat();
} }
@@ -103,12 +108,20 @@ public class ChatFilterPlugin extends Plugin
@Override @Override
protected void shutDown() throws Exception protected void shutDown() throws Exception
{ {
eventBus.unregister(this);
filteredPatterns.clear(); filteredPatterns.clear();
client.refreshChat(); client.refreshChat();
} }
@Subscribe private void addSubscriptions()
public void onScriptCallbackEvent(ScriptCallbackEvent event) {
eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
eventBus.subscribe(ScriptCallbackEvent.class, this, this::onScriptCallbackEvent);
eventBus.subscribe(OverheadTextChanged.class, this, this::onOverheadTextChanged);
}
private void onScriptCallbackEvent(ScriptCallbackEvent event)
{ {
if (!"chatFilterCheck".equals(event.getEventName())) if (!"chatFilterCheck".equals(event.getEventName()))
{ {
@@ -171,10 +184,9 @@ public class ChatFilterPlugin extends Plugin
} }
} }
@Subscribe private void onOverheadTextChanged(OverheadTextChanged event)
public void onOverheadTextChanged(OverheadTextChanged event)
{ {
if (!(event.getActor() instanceof Player) || !shouldFilterPlayerMessage(event.getActor().getName())) if (!(event.getActor() instanceof Player) || event.getActor().getName() == null || !shouldFilterPlayerMessage(event.getActor().getName()))
{ {
return; return;
} }
@@ -254,8 +266,7 @@ public class ChatFilterPlugin extends Plugin
.forEach(filteredPatterns::add); .forEach(filteredPatterns::add);
} }
@Subscribe private void onConfigChanged(ConfigChanged event)
public void onConfigChanged(ConfigChanged event)
{ {
if (!"chatfilter".equals(event.getGroup())) if (!"chatfilter".equals(event.getGroup()))
{ {

View File

@@ -46,7 +46,7 @@ import net.runelite.client.callback.ClientThread;
import net.runelite.client.chat.ChatMessageManager; import net.runelite.client.chat.ChatMessageManager;
import net.runelite.client.chat.QueuedMessage; import net.runelite.client.chat.QueuedMessage;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.input.KeyListener; import net.runelite.client.input.KeyListener;
import net.runelite.client.input.KeyManager; import net.runelite.client.input.KeyManager;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
@@ -85,6 +85,9 @@ public class ChatHistoryPlugin extends Plugin implements KeyListener
@Inject @Inject
private ChatMessageManager chatMessageManager; private ChatMessageManager chatMessageManager;
@Inject
private EventBus eventBus;
private boolean retainChatHistory; private boolean retainChatHistory;
private boolean pmTargetCycling; private boolean pmTargetCycling;
@@ -98,6 +101,7 @@ public class ChatHistoryPlugin extends Plugin implements KeyListener
protected void startUp() protected void startUp()
{ {
updateConfig(); updateConfig();
addSubscriptions();
messageQueue = EvictingQueue.create(100); messageQueue = EvictingQueue.create(100);
friends = new ArrayDeque<>(FRIENDS_MAX_SIZE + 1); friends = new ArrayDeque<>(FRIENDS_MAX_SIZE + 1);
@@ -107,6 +111,8 @@ public class ChatHistoryPlugin extends Plugin implements KeyListener
@Override @Override
protected void shutDown() protected void shutDown()
{ {
eventBus.unregister(this);
messageQueue.clear(); messageQueue.clear();
messageQueue = null; messageQueue = null;
friends.clear(); friends.clear();
@@ -114,8 +120,14 @@ public class ChatHistoryPlugin extends Plugin implements KeyListener
keyManager.unregisterKeyListener(this); keyManager.unregisterKeyListener(this);
} }
@Subscribe private void addSubscriptions()
public void onChatMessage(ChatMessage chatMessage) {
eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
eventBus.subscribe(ChatMessage.class, this, this::onChatMessage);
eventBus.subscribe(MenuOptionClicked.class, this, this::onMenuOptionClicked);
}
private void onChatMessage(ChatMessage chatMessage)
{ {
// Start sending old messages right after the welcome message, as that is most reliable source // Start sending old messages right after the welcome message, as that is most reliable source
// of information that chat history was reset // of information that chat history was reset
@@ -159,8 +171,8 @@ public class ChatHistoryPlugin extends Plugin implements KeyListener
.type(chatMessage.getType()) .type(chatMessage.getType())
.name(chatMessage.getName()) .name(chatMessage.getName())
.sender(chatMessage.getSender()) .sender(chatMessage.getSender())
.value(nbsp(chatMessage.getMessage())) .value(tweakSpaces(chatMessage.getMessage()))
.runeLiteFormattedMessage(nbsp(chatMessage.getMessageNode().getRuneLiteFormatMessage())) .runeLiteFormattedMessage(tweakSpaces(chatMessage.getMessageNode().getRuneLiteFormatMessage()))
.timestamp(chatMessage.getTimestamp()) .timestamp(chatMessage.getTimestamp())
.build(); .build();
@@ -171,8 +183,7 @@ public class ChatHistoryPlugin extends Plugin implements KeyListener
} }
} }
@Subscribe private void onMenuOptionClicked(MenuOptionClicked event)
public void onMenuOptionClicked(MenuOptionClicked event)
{ {
String menuOption = event.getOption(); String menuOption = event.getOption();
@@ -192,16 +203,18 @@ public class ChatHistoryPlugin extends Plugin implements KeyListener
} }
/** /**
* Small hack to prevent plugins checking for specific messages to match * Small hack to prevent plugins checking for specific messages to match. This works because the "—" character
* cannot be seen in-game. This replacement preserves wrapping on chat history messages.
* *
* @param message message * @param message message
* @return message with nbsp * @return message with invisible character before every space
*/ */
private static String nbsp(final String message) private static String tweakSpaces(final String message)
{ {
if (message != null) if (message != null)
{ {
return message.replace(' ', '\u00A0'); // First replacement cleans up prior applications of this so as not to keep extending the message
return message.replace("", " ").replace(" ", "");
} }
return null; return null;
@@ -267,8 +280,7 @@ public class ChatHistoryPlugin extends Plugin implements KeyListener
return friends.getLast(); return friends.getLast();
} }
@Subscribe private void onConfigChanged(ConfigChanged event)
public void onConfigChanged(ConfigChanged event)
{ {
if (!"chathistory".equals(event.getGroup())) if (!"chathistory".equals(event.getGroup()))
{ {

View File

@@ -47,7 +47,7 @@ import net.runelite.client.RuneLiteProperties;
import net.runelite.client.chat.ChatColorType; import net.runelite.client.chat.ChatColorType;
import net.runelite.client.chat.ChatMessageManager; import net.runelite.client.chat.ChatMessageManager;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.util.Text; import net.runelite.client.util.Text;
@@ -76,6 +76,9 @@ public class ChatNotificationsPlugin extends Plugin
@Inject @Inject
private RuneLiteProperties runeLiteProperties; private RuneLiteProperties runeLiteProperties;
@Inject
private EventBus eventBus;
//Custom Highlights //Custom Highlights
private Pattern usernameMatcher = null; private Pattern usernameMatcher = null;
private String usernameReplacer = ""; private String usernameReplacer = "";
@@ -102,17 +105,27 @@ public class ChatNotificationsPlugin extends Plugin
public void startUp() public void startUp()
{ {
updateConfig(); updateConfig();
addSubscriptions();
updateHighlights(); updateHighlights();
} }
@Override @Override
public void shutDown() public void shutDown()
{ {
eventBus.unregister(this);
this.privateMessageHashes.clear(); this.privateMessageHashes.clear();
} }
@Subscribe private void addSubscriptions()
public void onGameStateChanged(GameStateChanged event) {
eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
eventBus.subscribe(GameStateChanged.class, this, this::onGameStateChanged);
eventBus.subscribe(ChatMessage.class, this, this::onChatMessage);
}
private void onGameStateChanged(GameStateChanged event)
{ {
switch (event.getGameState()) switch (event.getGameState())
{ {
@@ -123,8 +136,7 @@ public class ChatNotificationsPlugin extends Plugin
} }
} }
@Subscribe private void onConfigChanged(ConfigChanged event)
public void onConfigChanged(ConfigChanged event)
{ {
if (event.getGroup().equals("chatnotification")) if (event.getGroup().equals("chatnotification"))
{ {
@@ -150,8 +162,7 @@ public class ChatNotificationsPlugin extends Plugin
} }
} }
@Subscribe void onChatMessage(ChatMessage chatMessage)
public void onChatMessage(ChatMessage chatMessage)
{ {
MessageNode messageNode = chatMessage.getMessageNode(); MessageNode messageNode = chatMessage.getMessageNode();
boolean update = false; boolean update = false;

View File

@@ -26,7 +26,7 @@ import net.runelite.api.widgets.WidgetInfo;
import net.runelite.client.callback.ClientThread; import net.runelite.client.callback.ClientThread;
import net.runelite.client.chat.ChatMessageManager; import net.runelite.client.chat.ChatMessageManager;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.input.KeyListener; import net.runelite.client.input.KeyListener;
import net.runelite.client.input.KeyManager; import net.runelite.client.input.KeyManager;
import net.runelite.client.menus.MenuManager; import net.runelite.client.menus.MenuManager;
@@ -74,6 +74,9 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener
@Inject @Inject
private ChatTranslationConfig config; private ChatTranslationConfig config;
@Inject
private EventBus eventBus;
private boolean translateOptionVisable; private boolean translateOptionVisable;
private boolean publicChat; private boolean publicChat;
private String getPlayerNames; private String getPlayerNames;
@@ -91,6 +94,7 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener
protected void startUp() throws Exception protected void startUp() throws Exception
{ {
updateConfig(); updateConfig();
addSubscriptions();
if (client != null && this.translateOptionVisable) if (client != null && this.translateOptionVisable)
{ {
@@ -104,6 +108,7 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener
@Override @Override
protected void shutDown() throws Exception protected void shutDown() throws Exception
{ {
eventBus.unregister(this);
if (client != null && this.translateOptionVisable) if (client != null && this.translateOptionVisable)
{ {
menuManager.get().removePlayerMenuItem(TRANSLATE); menuManager.get().removePlayerMenuItem(TRANSLATE);
@@ -113,8 +118,15 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener
playerNames.clear(); playerNames.clear();
} }
@Subscribe private void addSubscriptions()
public void onConfigChanged(ConfigChanged event) {
eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
eventBus.subscribe(MenuEntryAdded.class, this, this::onMenuEntryAdded);
eventBus.subscribe(PlayerMenuOptionClicked.class, this, this::onPlayerMenuOptionClicked);
eventBus.subscribe(ChatMessage.class, this, this::onChatMessage);
}
private void onConfigChanged(ConfigChanged event)
{ {
if (event.getGroup().equals("chattranslation")) if (event.getGroup().equals("chattranslation"))
{ {
@@ -132,8 +144,7 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener
} }
} }
@Subscribe private void onMenuEntryAdded(MenuEntryAdded event)
public void onMenuEntryAdded(MenuEntryAdded event)
{ {
if (!this.translateOptionVisable) if (!this.translateOptionVisable)
{ {
@@ -165,8 +176,7 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener
} }
} }
@Subscribe private void onPlayerMenuOptionClicked(PlayerMenuOptionClicked event)
public void onPlayerMenuOptionClicked(PlayerMenuOptionClicked event)
{ {
if (event.getMenuOption().equals(TRANSLATE)) if (event.getMenuOption().equals(TRANSLATE))
{ {
@@ -181,8 +191,7 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener
} }
} }
@Subscribe private void onChatMessage(ChatMessage chatMessage)
public void onChatMessage(ChatMessage chatMessage)
{ {
if (client.getGameState() != GameState.LOADING && client.getGameState() != GameState.LOGGED_IN) if (client.getGameState() != GameState.LOADING && client.getGameState() != GameState.LOGGED_IN)
{ {

View File

@@ -70,7 +70,7 @@ import net.runelite.api.widgets.WidgetType;
import net.runelite.client.callback.ClientThread; import net.runelite.client.callback.ClientThread;
import net.runelite.client.chat.ChatMessageBuilder; import net.runelite.client.chat.ChatMessageBuilder;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.game.ClanManager; import net.runelite.client.game.ClanManager;
import net.runelite.client.game.SpriteManager; import net.runelite.client.game.SpriteManager;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
@@ -114,6 +114,9 @@ public class ClanChatPlugin extends Plugin
@Inject @Inject
private ClientThread clientThread; private ClientThread clientThread;
@Inject
private EventBus eventBus;
private List<String> chats = new ArrayList<>(); private List<String> chats = new ArrayList<>();
public static CopyOnWriteArrayList<Player> getClanMembers() public static CopyOnWriteArrayList<Player> getClanMembers()
@@ -151,19 +154,37 @@ public class ClanChatPlugin extends Plugin
public void startUp() public void startUp()
{ {
updateConfig(); updateConfig();
addSubscriptions();
chats = new ArrayList<>(Text.fromCSV(this.chatsData)); chats = new ArrayList<>(Text.fromCSV(this.chatsData));
} }
@Override @Override
public void shutDown() public void shutDown()
{ {
eventBus.unregister(this);
clanMembers.clear(); clanMembers.clear();
removeClanCounter(); removeClanCounter();
resetClanChats(); resetClanChats();
} }
@Subscribe private void addSubscriptions()
public void onConfigChanged(ConfigChanged configChanged) {
eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
eventBus.subscribe(ClanMemberJoined.class, this, this::onClanMemberJoined);
eventBus.subscribe(ClanMemberLeft.class, this, this::onClanMemberLeft);
eventBus.subscribe(GameTick.class, this, this::onGameTick);
eventBus.subscribe(VarClientStrChanged.class, this, this::onVarClientStrChanged);
eventBus.subscribe(ChatMessage.class, this, this::onChatMessage);
eventBus.subscribe(GameStateChanged.class, this, this::onGameStateChanged);
eventBus.subscribe(PlayerSpawned.class, this, this::onPlayerSpawned);
eventBus.subscribe(PlayerDespawned.class, this, this::onPlayerDespawned);
eventBus.subscribe(ClanChanged.class, this, this::onClanChanged);
eventBus.subscribe(ScriptCallbackEvent.class, this, this::onScriptCallbackEvent);
}
private void onConfigChanged(ConfigChanged configChanged)
{ {
if (configChanged.getGroup().equals("clanchat")) if (configChanged.getGroup().equals("clanchat"))
{ {
@@ -185,8 +206,7 @@ public class ClanChatPlugin extends Plugin
} }
} }
@Subscribe private void onClanMemberJoined(ClanMemberJoined event)
public void onClanMemberJoined(ClanMemberJoined event)
{ {
final ClanMember member = event.getMember(); final ClanMember member = event.getMember();
@@ -231,8 +251,7 @@ public class ClanChatPlugin extends Plugin
} }
} }
@Subscribe private void onClanMemberLeft(ClanMemberLeft event)
public void onClanMemberLeft(ClanMemberLeft event)
{ {
final ClanMember member = event.getMember(); final ClanMember member = event.getMember();
@@ -275,8 +294,7 @@ public class ClanChatPlugin extends Plugin
} }
} }
@Subscribe private void onGameTick(GameTick gameTick)
public void onGameTick(GameTick gameTick)
{ {
if (client.getGameState() != GameState.LOGGED_IN) if (client.getGameState() != GameState.LOGGED_IN)
{ {
@@ -414,8 +432,7 @@ public class ClanChatPlugin extends Plugin
clanJoinMessages.addLast(clanJoinMessage); clanJoinMessages.addLast(clanJoinMessage);
} }
@Subscribe private void onVarClientStrChanged(VarClientStrChanged strChanged)
public void onVarClientStrChanged(VarClientStrChanged strChanged)
{ {
if (strChanged.getIndex() == VarClientStr.RECENT_CLAN_CHAT.getIndex() && this.recentChats) if (strChanged.getIndex() == VarClientStr.RECENT_CLAN_CHAT.getIndex() && this.recentChats)
{ {
@@ -423,8 +440,7 @@ public class ClanChatPlugin extends Plugin
} }
} }
@Subscribe private void onChatMessage(ChatMessage chatMessage)
public void onChatMessage(ChatMessage chatMessage)
{ {
if (client.getGameState() != GameState.LOADING && client.getGameState() != GameState.LOGGED_IN) if (client.getGameState() != GameState.LOADING && client.getGameState() != GameState.LOGGED_IN)
{ {
@@ -465,8 +481,7 @@ public class ClanChatPlugin extends Plugin
insertClanRankIcon(chatMessage); insertClanRankIcon(chatMessage);
} }
@Subscribe private void onGameStateChanged(GameStateChanged state)
public void onGameStateChanged(GameStateChanged state)
{ {
GameState gameState = state.getGameState(); GameState gameState = state.getGameState();
@@ -479,8 +494,7 @@ public class ClanChatPlugin extends Plugin
} }
} }
@Subscribe private void onPlayerSpawned(PlayerSpawned event)
public void onPlayerSpawned(PlayerSpawned event)
{ {
final Player local = client.getLocalPlayer(); final Player local = client.getLocalPlayer();
final Player player = event.getPlayer(); final Player player = event.getPlayer();
@@ -492,8 +506,7 @@ public class ClanChatPlugin extends Plugin
} }
} }
@Subscribe private void onPlayerDespawned(PlayerDespawned event)
public void onPlayerDespawned(PlayerDespawned event)
{ {
if (clanMembers.remove(event.getPlayer()) && clanMembers.isEmpty()) if (clanMembers.remove(event.getPlayer()) && clanMembers.isEmpty())
{ {
@@ -501,8 +514,7 @@ public class ClanChatPlugin extends Plugin
} }
} }
@Subscribe private void onClanChanged(ClanChanged event)
public void onClanChanged(ClanChanged event)
{ {
if (event.isJoined()) if (event.isJoined())
{ {
@@ -517,8 +529,7 @@ public class ClanChatPlugin extends Plugin
activityBuffer.clear(); activityBuffer.clear();
} }
@Subscribe private void onScriptCallbackEvent(ScriptCallbackEvent scriptCallbackEvent)
public void onScriptCallbackEvent(ScriptCallbackEvent scriptCallbackEvent)
{ {
if (!scriptCallbackEvent.getEventName().equalsIgnoreCase("clanchatInput")) if (!scriptCallbackEvent.getEventName().equalsIgnoreCase("clanchatInput"))
{ {

View File

@@ -18,7 +18,7 @@ import net.runelite.api.events.ConfigChanged;
import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.GameStateChanged;
import net.runelite.api.events.GameTick; import net.runelite.api.events.GameTick;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.plugins.PluginType; import net.runelite.client.plugins.PluginType;
@@ -52,6 +52,9 @@ public class ClanManModePlugin extends Plugin
@Inject @Inject
private Client client; private Client client;
@Inject
private EventBus eventBus;
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
private boolean highlightAttackable; private boolean highlightAttackable;
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
@@ -100,6 +103,7 @@ public class ClanManModePlugin extends Plugin
protected void startUp() throws Exception protected void startUp() throws Exception
{ {
updateConfig(); updateConfig();
addSubscriptions();
overlayManager.add(ClanManModeOverlay); overlayManager.add(ClanManModeOverlay);
overlayManager.add(ClanManModeTileOverlay); overlayManager.add(ClanManModeTileOverlay);
@@ -109,6 +113,8 @@ public class ClanManModePlugin extends Plugin
@Override @Override
protected void shutDown() throws Exception protected void shutDown() throws Exception
{ {
eventBus.unregister(this);
overlayManager.remove(ClanManModeOverlay); overlayManager.remove(ClanManModeOverlay);
overlayManager.remove(ClanManModeTileOverlay); overlayManager.remove(ClanManModeTileOverlay);
overlayManager.remove(ClanManModeMinimapOverlay); overlayManager.remove(ClanManModeMinimapOverlay);
@@ -120,7 +126,13 @@ public class ClanManModePlugin extends Plugin
inwildy = 0; inwildy = 0;
} }
@Subscribe private void addSubscriptions()
{
eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
eventBus.subscribe(GameStateChanged.class, this, this::onGameStateChanged);
eventBus.subscribe(GameTick.class, this, this::onGameTick);
}
private void onConfigChanged(ConfigChanged event) private void onConfigChanged(ConfigChanged event)
{ {
if (!"clanmanmode".equals(event.getGroup())) if (!"clanmanmode".equals(event.getGroup()))
@@ -131,8 +143,7 @@ public class ClanManModePlugin extends Plugin
updateConfig(); updateConfig();
} }
@Subscribe private void onGameStateChanged(GameStateChanged gameStateChanged)
public void onGameStateChanged(GameStateChanged gameStateChanged)
{ {
if (gameStateChanged.getGameState() == GameState.LOGIN_SCREEN || gameStateChanged.getGameState() == GameState.HOPPING) if (gameStateChanged.getGameState() == GameState.LOGIN_SCREEN || gameStateChanged.getGameState() == GameState.HOPPING)
{ {
@@ -140,8 +151,7 @@ public class ClanManModePlugin extends Plugin
} }
} }
@Subscribe private void onGameTick(GameTick event)
public void onGameTick(GameTick event)
{ {
ticks++; ticks++;
final Player localPlayer = client.getLocalPlayer(); final Player localPlayer = client.getLocalPlayer();

View File

@@ -72,7 +72,7 @@ import net.runelite.api.widgets.Widget;
import net.runelite.api.widgets.WidgetID; import net.runelite.api.widgets.WidgetID;
import net.runelite.api.widgets.WidgetInfo; import net.runelite.api.widgets.WidgetInfo;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.game.ItemManager; import net.runelite.client.game.ItemManager;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
@@ -158,6 +158,9 @@ public class ClueScrollPlugin extends Plugin
@Inject @Inject
private WorldMapPointManager worldMapPointManager; private WorldMapPointManager worldMapPointManager;
@Inject
private EventBus eventBus;
private BufferedImage emoteImage; private BufferedImage emoteImage;
private BufferedImage mapArrow; private BufferedImage mapArrow;
private Integer clueItemId; private Integer clueItemId;
@@ -182,6 +185,8 @@ public class ClueScrollPlugin extends Plugin
@Override @Override
protected void startUp() throws Exception protected void startUp() throws Exception
{ {
addSubscriptions();
this.displayHintArrows = config.displayHintArrows(); this.displayHintArrows = config.displayHintArrows();
overlayManager.add(clueScrollOverlay); overlayManager.add(clueScrollOverlay);
overlayManager.add(clueScrollEmoteOverlay); overlayManager.add(clueScrollEmoteOverlay);
@@ -192,6 +197,8 @@ public class ClueScrollPlugin extends Plugin
@Override @Override
protected void shutDown() throws Exception protected void shutDown() throws Exception
{ {
eventBus.unregister(this);
overlayManager.remove(clueScrollOverlay); overlayManager.remove(clueScrollOverlay);
overlayManager.remove(clueScrollEmoteOverlay); overlayManager.remove(clueScrollEmoteOverlay);
overlayManager.remove(clueScrollWorldOverlay); overlayManager.remove(clueScrollWorldOverlay);
@@ -202,8 +209,20 @@ public class ClueScrollPlugin extends Plugin
resetClue(true); resetClue(true);
} }
@Subscribe private void addSubscriptions()
public void onChatMessage(ChatMessage event) {
eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
eventBus.subscribe(ChatMessage.class, this, this::onChatMessage);
eventBus.subscribe(MenuOptionClicked.class, this, this::onMenuOptionClicked);
eventBus.subscribe(ItemContainerChanged.class, this, this::onItemContainerChanged);
eventBus.subscribe(NpcSpawned.class, this, this::onNpcSpawned);
eventBus.subscribe(NpcDespawned.class, this, this::onNpcDespawned);
eventBus.subscribe(GameStateChanged.class, this, this::onGameStateChanged);
eventBus.subscribe(GameTick.class, this, this::onGameTick);
eventBus.subscribe(WidgetLoaded.class, this, this::onWidgetLoaded);
}
private void onChatMessage(ChatMessage event)
{ {
if (event.getType() != ChatMessageType.GAMEMESSAGE && event.getType() != ChatMessageType.SPAM) if (event.getType() != ChatMessageType.GAMEMESSAGE && event.getType() != ChatMessageType.SPAM)
{ {
@@ -224,8 +243,7 @@ public class ClueScrollPlugin extends Plugin
resetClue(true); resetClue(true);
} }
@Subscribe private void onMenuOptionClicked(final MenuOptionClicked event)
public void onMenuOptionClicked(final MenuOptionClicked event)
{ {
if ("read".equalsIgnoreCase(event.getOption())) if ("read".equalsIgnoreCase(event.getOption()))
{ {
@@ -239,8 +257,7 @@ public class ClueScrollPlugin extends Plugin
} }
} }
@Subscribe private void onItemContainerChanged(final ItemContainerChanged event)
public void onItemContainerChanged(final ItemContainerChanged event)
{ {
if (event.getItemContainer() == client.getItemContainer(InventoryID.EQUIPMENT)) if (event.getItemContainer() == client.getItemContainer(InventoryID.EQUIPMENT))
{ {
@@ -280,15 +297,13 @@ public class ClueScrollPlugin extends Plugin
} }
} }
@Subscribe private void onNpcSpawned(final NpcSpawned event)
public void onNpcSpawned(final NpcSpawned event)
{ {
final NPC npc = event.getNpc(); final NPC npc = event.getNpc();
checkClueNPCs(clue, npc); checkClueNPCs(clue, npc);
} }
@Subscribe private void onNpcDespawned(final NpcDespawned event)
public void onNpcDespawned(final NpcDespawned event)
{ {
final boolean removed = npcsToMark.remove(event.getNpc()); final boolean removed = npcsToMark.remove(event.getNpc());
@@ -306,8 +321,7 @@ public class ClueScrollPlugin extends Plugin
} }
} }
@Subscribe private void onConfigChanged(ConfigChanged event)
public void onConfigChanged(ConfigChanged event)
{ {
if (event.getGroup().equals("cluescroll")) if (event.getGroup().equals("cluescroll"))
{ {
@@ -319,8 +333,7 @@ public class ClueScrollPlugin extends Plugin
} }
} }
@Subscribe private void onGameStateChanged(final GameStateChanged event)
public void onGameStateChanged(final GameStateChanged event)
{ {
if (event.getGameState() == GameState.LOGIN_SCREEN) if (event.getGameState() == GameState.LOGIN_SCREEN)
{ {
@@ -328,8 +341,7 @@ public class ClueScrollPlugin extends Plugin
} }
} }
@Subscribe private void onGameTick(final GameTick event)
public void onGameTick(final GameTick event)
{ {
objectsToMark.clear(); objectsToMark.clear();
@@ -392,8 +404,7 @@ public class ClueScrollPlugin extends Plugin
updateClue(findClueScroll()); updateClue(findClueScroll());
} }
@Subscribe private void onWidgetLoaded(WidgetLoaded event)
public void onWidgetLoaded(WidgetLoaded event)
{ {
if (event.getGroupId() < WidgetID.BEGINNER_CLUE_MAP_CHAMPIONS_GUILD if (event.getGroupId() < WidgetID.BEGINNER_CLUE_MAP_CHAMPIONS_GUILD
|| event.getGroupId() > WidgetID.BEGINNER_CLUE_MAP_WIZARDS_TOWER) || event.getGroupId() > WidgetID.BEGINNER_CLUE_MAP_WIZARDS_TOWER)

View File

@@ -96,7 +96,7 @@ public class CoordinateClue extends ClueScroll implements TextClueScroll, Locati
.put(new WorldPoint(2542, 3031, 0), "Gu'Tanoth.") .put(new WorldPoint(2542, 3031, 0), "Gu'Tanoth.")
.put(new WorldPoint(2581, 3030, 0), "Gu'Tanoth island, enter cave north-west of Feldip Hills (AKS).") .put(new WorldPoint(2581, 3030, 0), "Gu'Tanoth island, enter cave north-west of Feldip Hills (AKS).")
.put(new WorldPoint(2961, 3024, 0), "Ship yard (DKP).") .put(new WorldPoint(2961, 3024, 0), "Ship yard (DKP).")
.put(new WorldPoint(2339, 3311, 0), "East of Tirannwn on Arandar mountain pass.") .put(new WorldPoint(2339, 3311, 0), "East of Prifddinas on Arandar mountain pass.")
.put(new WorldPoint(3440, 3341, 0), "Nature Spirit's grotto.") .put(new WorldPoint(3440, 3341, 0), "Nature Spirit's grotto.")
.put(new WorldPoint(2763, 2974, 0), "Cairn Isle, west of Shilo Village.") .put(new WorldPoint(2763, 2974, 0), "Cairn Isle, west of Shilo Village.")
.put(new WorldPoint(3138, 2969, 0), "West of Bandit Camp.") .put(new WorldPoint(3138, 2969, 0), "West of Bandit Camp.")

View File

@@ -204,7 +204,7 @@ public class CrypticClue extends ClueScroll implements TextClueScroll, NpcClueSc
new CrypticClue("Search the drawers upstairs in Falador's shield shop.", DRAWERS, new WorldPoint(2971, 3386, 1), "Cassie's Shield Shop at the northern Falador entrance."), new CrypticClue("Search the drawers upstairs in Falador's shield shop.", DRAWERS, new WorldPoint(2971, 3386, 1), "Cassie's Shield Shop at the northern Falador entrance."),
new CrypticClue("Go to this building to be illuminated, and check the drawers while you are there.", "Market Guard", DRAWERS_350 , new WorldPoint(2512, 3641, 1), "Search the drawers in the first floor of the Lighthouse. Kill a Rellekka marketplace guard to obtain the key."), new CrypticClue("Go to this building to be illuminated, and check the drawers while you are there.", "Market Guard", DRAWERS_350 , new WorldPoint(2512, 3641, 1), "Search the drawers in the first floor of the Lighthouse. Kill a Rellekka marketplace guard to obtain the key."),
new CrypticClue("Dig near some giant mushrooms, behind the Grand Tree.", new WorldPoint(2458, 3504, 0), "Dig near the red mushrooms northwest of the Grand Tree."), new CrypticClue("Dig near some giant mushrooms, behind the Grand Tree.", new WorldPoint(2458, 3504, 0), "Dig near the red mushrooms northwest of the Grand Tree."),
new CrypticClue("Pentagrams and demons, burnt bones and remains, I wonder what the blood contains.", new WorldPoint(3297, 3890, 0), "Dig under the blood rune spawn next the the Demonic Ruins."), new CrypticClue("Pentagrams and demons, burnt bones and remains, I wonder what the blood contains.", new WorldPoint(3297, 3890, 0), "Dig under the blood rune spawn next to the Demonic Ruins."),
new CrypticClue("Search the drawers above Varrock's shops.", DRAWERS_7194, new WorldPoint(3206, 3419, 1), "Located upstairs in Thessalia's Fine Clothes shop in Varrock."), new CrypticClue("Search the drawers above Varrock's shops.", DRAWERS_7194, new WorldPoint(3206, 3419, 1), "Located upstairs in Thessalia's Fine Clothes shop in Varrock."),
new CrypticClue("Search the drawers in one of Gertrude's bedrooms.", DRAWERS_7194, new WorldPoint(3156, 3406, 0), "Kanel's bedroom (southeastern room), outside of west Varrock."), new CrypticClue("Search the drawers in one of Gertrude's bedrooms.", DRAWERS_7194, new WorldPoint(3156, 3406, 0), "Kanel's bedroom (southeastern room), outside of west Varrock."),
new CrypticClue("Under a giant robotic bird that cannot fly.", new WorldPoint(1756, 4940, 0), "Dig next to the terrorbird display in the south exhibit of Varrock Museum's basement."), new CrypticClue("Under a giant robotic bird that cannot fly.", new WorldPoint(1756, 4940, 0), "Dig next to the terrorbird display in the south exhibit of Varrock Museum's basement."),

View File

@@ -62,14 +62,17 @@ public class HotColdClue extends ClueScroll implements LocationClueScroll, Locat
private static final int HOT_COLD_PANEL_WIDTH = 200; private static final int HOT_COLD_PANEL_WIDTH = 200;
private static final HotColdClue BEGINNER_CLUE = new HotColdClue("Buried beneath the ground, who knows where it's found. Lucky for you, A man called Reldo may have a clue.", private static final HotColdClue BEGINNER_CLUE = new HotColdClue("Buried beneath the ground, who knows where it's found. Lucky for you, A man called Reldo may have a clue.",
"Reldo", "Reldo",
"Speak to Reldo to receive a strange device."); "Speak to Reldo to receive a strange device.",
new WorldPoint(3211, 3494, 0));
private static final HotColdClue MASTER_CLUE = new HotColdClue("Buried beneath the ground, who knows where it's found. Lucky for you, A man called Jorral may have a clue.", private static final HotColdClue MASTER_CLUE = new HotColdClue("Buried beneath the ground, who knows where it's found. Lucky for you, A man called Jorral may have a clue.",
"Jorral", "Jorral",
"Speak to Jorral to receive a strange device."); "Speak to Jorral to receive a strange device.",
new WorldPoint(2436, 3347, 0));
private final String text; private final String text;
private final String npc; private final String npc;
private final String solution; private final String solution;
private final WorldPoint npcLocation;
@Nullable @Nullable
private HotColdSolver hotColdSolver; private HotColdSolver hotColdSolver;
private WorldPoint location; private WorldPoint location;
@@ -90,11 +93,12 @@ public class HotColdClue extends ClueScroll implements LocationClueScroll, Locat
return null; return null;
} }
private HotColdClue(String text, String npc, String solution) private HotColdClue(String text, String npc, String solution, WorldPoint npcLocation)
{ {
this.text = text; this.text = text;
this.npc = npc; this.npc = npc;
this.solution = solution; this.solution = solution;
this.npcLocation = npcLocation;
setRequiresSpade(true); setRequiresSpade(true);
initializeSolver(); initializeSolver();
} }
@@ -107,7 +111,14 @@ public class HotColdClue extends ClueScroll implements LocationClueScroll, Locat
return new WorldPoint[0]; return new WorldPoint[0];
} }
return hotColdSolver.getPossibleLocations().stream().map(HotColdLocation::getWorldPoint).toArray(WorldPoint[]::new); if (hotColdSolver.getLastWorldPoint() == null)
{
return new WorldPoint[] {npcLocation};
}
else
{
return hotColdSolver.getPossibleLocations().stream().map(HotColdLocation::getWorldPoint).toArray(WorldPoint[]::new);
}
} }
@Override @Override

View File

@@ -103,7 +103,7 @@ public enum STASHUnit
ENTRANCE_OF_THE_CAVE_OF_DAMIS(NullObjectID.NULL_29027, new WorldPoint(2629, 5070, 0)), ENTRANCE_OF_THE_CAVE_OF_DAMIS(NullObjectID.NULL_29027, new WorldPoint(2629, 5070, 0)),
WARRIORS_GUILD_BANK(NullObjectID.NULL_29028, new WorldPoint(2844, 3537, 0)), WARRIORS_GUILD_BANK(NullObjectID.NULL_29028, new WorldPoint(2844, 3537, 0)),
SOUTHEAST_CORNER_OF_THE_MONASTERY(NullObjectID.NULL_29029, new WorldPoint(3056, 3482, 0)), SOUTHEAST_CORNER_OF_THE_MONASTERY(NullObjectID.NULL_29029, new WorldPoint(3056, 3482, 0)),
SOUTHEAST_CORNER_OF_THE_FISHING_PLATFORM(NullObjectID.NULL_29030, new WorldPoint(2787, 3277, 1)), SOUTHEAST_CORNER_OF_THE_FISHING_PLATFORM(NullObjectID.NULL_29030, new WorldPoint(2787, 3277, 0)),
OUTSIDE_THE_SLAYER_TOWER_GARGOYLE_ROOM(NullObjectID.NULL_29031, new WorldPoint(3423, 3534, 2)), OUTSIDE_THE_SLAYER_TOWER_GARGOYLE_ROOM(NullObjectID.NULL_29031, new WorldPoint(3423, 3534, 2)),
ON_TOP_OF_TROLLHEIM_MOUNTAIN(NullObjectID.NULL_29032, new WorldPoint(2886, 3676, 0)), ON_TOP_OF_TROLLHEIM_MOUNTAIN(NullObjectID.NULL_29032, new WorldPoint(2886, 3676, 0)),
FOUNTAIN_OF_HEROES(NullObjectID.NULL_29033, new WorldPoint(2916, 9891, 0)), FOUNTAIN_OF_HEROES(NullObjectID.NULL_29033, new WorldPoint(2916, 9891, 0)),

View File

@@ -56,7 +56,7 @@ import net.runelite.api.events.GameTick;
import net.runelite.api.events.HitsplatApplied; import net.runelite.api.events.HitsplatApplied;
import net.runelite.api.kit.KitType; import net.runelite.api.kit.KitType;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.plugins.PluginType; import net.runelite.client.plugins.PluginType;
@@ -89,6 +89,9 @@ public class CombatCounter extends Plugin
@Inject @Inject
private CombatCounterConfig config; private CombatCounterConfig config;
@Inject
private EventBus eventBus;
private boolean instanced = false; private boolean instanced = false;
@Setter(AccessLevel.PACKAGE) @Setter(AccessLevel.PACKAGE)
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
@@ -236,6 +239,7 @@ public class CombatCounter extends Plugin
protected void startUp() throws Exception protected void startUp() throws Exception
{ {
updateConfig(); updateConfig();
addSubscriptions();
overlayManager.add(tickOverlay); overlayManager.add(tickOverlay);
overlayManager.add(damageOverlay); overlayManager.add(damageOverlay);
@@ -249,6 +253,8 @@ public class CombatCounter extends Plugin
@Override @Override
protected void shutDown() throws Exception protected void shutDown() throws Exception
{ {
eventBus.unregister(this);
overlayManager.remove(tickOverlay); overlayManager.remove(tickOverlay);
overlayManager.remove(damageOverlay); overlayManager.remove(damageOverlay);
@@ -258,8 +264,15 @@ public class CombatCounter extends Plugin
this.playerDamage.clear(); this.playerDamage.clear();
} }
@Subscribe private void addSubscriptions()
public void onAnimationChanged(AnimationChanged event) {
eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
eventBus.subscribe(AnimationChanged.class, this, this::onAnimationChanged);
eventBus.subscribe(GameTick.class, this, this::onGameTick);
eventBus.subscribe(HitsplatApplied.class, this, this::onHitsplatApplied);
}
private void onAnimationChanged(AnimationChanged event)
{ {
Actor actor = event.getActor(); Actor actor = event.getActor();
@@ -403,8 +416,7 @@ public class CombatCounter extends Plugin
} }
} }
@Subscribe private void onGameTick(GameTick event)
public void onGameTick(GameTick event)
{ {
if (this.resetOnNewInstance) if (this.resetOnNewInstance)
{ {
@@ -554,9 +566,7 @@ public class CombatCounter extends Plugin
} }
} }
private void onHitsplatApplied(HitsplatApplied event)
@Subscribe
public void onHitsplatApplied(HitsplatApplied event)
{ {
Actor actor = event.getActor(); Actor actor = event.getActor();
@@ -644,8 +654,7 @@ public class CombatCounter extends Plugin
return 2 + (int) Math.floor((3d + distance) / 6d); return 2 + (int) Math.floor((3d + distance) / 6d);
} }
@Subscribe private void onConfigChanged(ConfigChanged event)
public void onConfigChanged(ConfigChanged event)
{ {
if (event.getGroup().equals("combatcounter")) if (event.getGroup().equals("combatcounter"))
{ {

View File

@@ -45,7 +45,7 @@ import net.runelite.api.widgets.Widget;
import net.runelite.api.widgets.WidgetInfo; import net.runelite.api.widgets.WidgetInfo;
import net.runelite.client.callback.ClientThread; import net.runelite.client.callback.ClientThread;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.ui.overlay.OverlayManager;
@@ -84,6 +84,9 @@ public class CombatLevelPlugin extends Plugin
@Inject @Inject
private OverlayManager overlayManager; private OverlayManager overlayManager;
@Inject
private EventBus eventBus;
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
private boolean showLevelsUntil; private boolean showLevelsUntil;
private boolean wildernessAttackLevelRange; private boolean wildernessAttackLevelRange;
@@ -98,6 +101,7 @@ public class CombatLevelPlugin extends Plugin
protected void startUp() throws Exception protected void startUp() throws Exception
{ {
updateConfig(); updateConfig();
addSubscriptions();
overlayManager.add(overlay); overlayManager.add(overlay);
@@ -110,6 +114,8 @@ public class CombatLevelPlugin extends Plugin
@Override @Override
protected void shutDown() throws Exception protected void shutDown() throws Exception
{ {
eventBus.unregister(this);
overlayManager.remove(overlay); overlayManager.remove(overlay);
Widget combatLevelWidget = client.getWidget(WidgetInfo.COMBAT_LEVEL); Widget combatLevelWidget = client.getWidget(WidgetInfo.COMBAT_LEVEL);
@@ -126,8 +132,14 @@ public class CombatLevelPlugin extends Plugin
shutDownAttackLevelRange(); shutDownAttackLevelRange();
} }
@Subscribe private void addSubscriptions()
public void onGameTick(GameTick event) {
eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
eventBus.subscribe(GameTick.class, this, this::onGameTick);
eventBus.subscribe(ScriptCallbackEvent.class, this, this::onScriptCallbackEvent);
}
private void onGameTick(GameTick event)
{ {
if (client.getGameState() != GameState.LOGGED_IN) if (client.getGameState() != GameState.LOGGED_IN)
{ {
@@ -153,8 +165,7 @@ public class CombatLevelPlugin extends Plugin
combatLevelWidget.setText("Combat Lvl: " + DECIMAL_FORMAT.format(combatLevelPrecise)); combatLevelWidget.setText("Combat Lvl: " + DECIMAL_FORMAT.format(combatLevelPrecise));
} }
@Subscribe private void onConfigChanged(ConfigChanged event)
public void onConfigChanged(ConfigChanged event)
{ {
if (!CONFIG_GROUP.equals(event.getGroup()) || !ATTACK_RANGE_CONFIG_KEY.equals(event.getKey())) if (!CONFIG_GROUP.equals(event.getGroup()) || !ATTACK_RANGE_CONFIG_KEY.equals(event.getKey()))
{ {
@@ -173,8 +184,7 @@ public class CombatLevelPlugin extends Plugin
} }
} }
@Subscribe private void onScriptCallbackEvent(ScriptCallbackEvent event)
public void onScriptCallbackEvent(ScriptCallbackEvent event)
{ {
if (this.wildernessAttackLevelRange if (this.wildernessAttackLevelRange
&& "wildernessWidgetTextSet".equals(event.getEventName())) && "wildernessWidgetTextSet".equals(event.getEventName()))

View File

@@ -30,17 +30,15 @@ import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics; import java.awt.FontMetrics;
import java.awt.Insets; import java.awt.Insets;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.Font;
import java.awt.event.FocusAdapter; import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent; import java.awt.event.FocusEvent;
import java.awt.event.ItemEvent; import java.awt.event.ItemEvent;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
@@ -108,6 +106,7 @@ import net.runelite.client.ui.PluginPanel;
import net.runelite.client.ui.components.ComboBoxListRenderer; import net.runelite.client.ui.components.ComboBoxListRenderer;
import net.runelite.client.ui.components.IconButton; import net.runelite.client.ui.components.IconButton;
import net.runelite.client.ui.components.IconTextField; import net.runelite.client.ui.components.IconTextField;
import net.runelite.client.ui.components.colorpicker.ColorPickerManager;
import net.runelite.client.ui.components.colorpicker.RuneliteColorPicker; import net.runelite.client.ui.components.colorpicker.RuneliteColorPicker;
import net.runelite.client.util.ColorUtil; import net.runelite.client.util.ColorUtil;
import net.runelite.client.util.ImageUtil; import net.runelite.client.util.ImageUtil;
@@ -136,6 +135,7 @@ public class ConfigPanel extends PluginPanel
private final RuneLiteConfig runeLiteConfig; private final RuneLiteConfig runeLiteConfig;
private final RuneLitePlusConfig runeLitePlusConfig; private final RuneLitePlusConfig runeLitePlusConfig;
private final ChatColorConfig chatColorConfig; private final ChatColorConfig chatColorConfig;
private final ColorPickerManager colorPickerManager;
public static List<PluginListItem> pluginList = new ArrayList<>(); public static List<PluginListItem> pluginList = new ArrayList<>();
private final IconTextField searchBar = new IconTextField(); private final IconTextField searchBar = new IconTextField();
@@ -154,7 +154,8 @@ public class ConfigPanel extends PluginPanel
} }
ConfigPanel(PluginManager pluginManager, ConfigManager configManager, ScheduledExecutorService executorService, ConfigPanel(PluginManager pluginManager, ConfigManager configManager, ScheduledExecutorService executorService,
RuneLiteConfig runeLiteConfig, RuneLitePlusConfig runeLitePlusConfig, ChatColorConfig chatColorConfig) RuneLiteConfig runeLiteConfig, RuneLitePlusConfig runeLitePlusConfig, ChatColorConfig chatColorConfig,
ColorPickerManager colorPickerManager)
{ {
super(false); super(false);
this.pluginManager = pluginManager; this.pluginManager = pluginManager;
@@ -163,6 +164,7 @@ public class ConfigPanel extends PluginPanel
this.runeLiteConfig = runeLiteConfig; this.runeLiteConfig = runeLiteConfig;
this.runeLitePlusConfig = runeLitePlusConfig; this.runeLitePlusConfig = runeLitePlusConfig;
this.chatColorConfig = chatColorConfig; this.chatColorConfig = chatColorConfig;
this.colorPickerManager = colorPickerManager;
searchBar.setIcon(IconTextField.Icon.SEARCH); searchBar.setIcon(IconTextField.Icon.SEARCH);
searchBar.setPreferredSize(new Dimension(PluginPanel.PANEL_WIDTH - 20, 30)); searchBar.setPreferredSize(new Dimension(PluginPanel.PANEL_WIDTH - 20, 30));
@@ -250,7 +252,7 @@ public class ConfigPanel extends PluginPanel
} }
lines.add(sb.toString()); lines.add(sb.toString());
return new Dimension(WIDTH, (lines.size() * fontMetrics.getHeight()) + HEIGHT_PADDING); return new Dimension(WIDTH, (lines.size() * fontMetrics.getHeight()) + HEIGHT_PADDING);
} }
} }
@@ -910,8 +912,11 @@ public class ConfigPanel extends PluginPanel
@Override @Override
public void mouseClicked(MouseEvent e) public void mouseClicked(MouseEvent e)
{ {
RuneliteColorPicker colorPicker = new RuneliteColorPicker(SwingUtilities.windowForComponent(ConfigPanel.this), RuneliteColorPicker colorPicker = colorPickerManager.create(
colorPickerBtn.getBackground(), cid.getItem().name(), cid.getAlpha() == null); SwingUtilities.windowForComponent(ConfigPanel.this),
colorPickerBtn.getBackground(),
cid.getItem().name(),
cid.getAlpha() == null);
colorPicker.setLocation(getLocationOnScreen()); colorPicker.setLocation(getLocationOnScreen());
colorPicker.setOnColorChange(c -> colorPicker.setOnColorChange(c ->
{ {
@@ -919,14 +924,7 @@ public class ConfigPanel extends PluginPanel
colorPickerBtn.setText(ColorUtil.toHexColor(c).toUpperCase()); colorPickerBtn.setText(ColorUtil.toHexColor(c).toUpperCase());
}); });
colorPicker.addWindowListener(new WindowAdapter() colorPicker.setOnClose(c -> changeConfiguration(listItem, config, colorPicker, cd, cid));
{
@Override
public void windowClosing(WindowEvent e)
{
changeConfiguration(listItem, config, colorPicker, cd, cid);
}
});
colorPicker.setVisible(true); colorPicker.setVisible(true);
} }
}); });

View File

@@ -37,7 +37,7 @@ import net.runelite.client.config.ChatColorConfig;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.config.RuneLiteConfig; import net.runelite.client.config.RuneLiteConfig;
import net.runelite.client.config.RuneLitePlusConfig; import net.runelite.client.config.RuneLitePlusConfig;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.events.OverlayMenuClicked; import net.runelite.client.events.OverlayMenuClicked;
import net.runelite.client.events.PluginChanged; import net.runelite.client.events.PluginChanged;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
@@ -46,6 +46,7 @@ import net.runelite.client.plugins.PluginManager;
import net.runelite.client.ui.ClientToolbar; import net.runelite.client.ui.ClientToolbar;
import net.runelite.client.ui.ClientUI; import net.runelite.client.ui.ClientUI;
import net.runelite.client.ui.NavigationButton; import net.runelite.client.ui.NavigationButton;
import net.runelite.client.ui.components.colorpicker.ColorPickerManager;
import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayMenuEntry; import net.runelite.client.ui.overlay.OverlayMenuEntry;
import net.runelite.client.util.ImageUtil; import net.runelite.client.util.ImageUtil;
@@ -80,13 +81,21 @@ public class ConfigPlugin extends Plugin
@Inject @Inject
private ChatColorConfig chatColorConfig; private ChatColorConfig chatColorConfig;
@Inject
private ColorPickerManager colorPickerManager;
@Inject
private EventBus eventBus;
private ConfigPanel configPanel; private ConfigPanel configPanel;
private NavigationButton navButton; private NavigationButton navButton;
@Override @Override
protected void startUp() throws Exception protected void startUp() throws Exception
{ {
configPanel = new ConfigPanel(pluginManager, configManager, executorService, runeLiteConfig, runeLitePlusConfig, chatColorConfig); addSubscriptions();
configPanel = new ConfigPanel(pluginManager, configManager, executorService, runeLiteConfig, runeLitePlusConfig, chatColorConfig, colorPickerManager);
final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "config_icon.png"); final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "config_icon.png");
@@ -103,6 +112,8 @@ public class ConfigPlugin extends Plugin
@Override @Override
public void shutDown() throws Exception public void shutDown() throws Exception
{ {
eventBus.unregister(this);
clientToolbar.removeNavigation(navButton); clientToolbar.removeNavigation(navButton);
RuneLite.getInjector().getInstance(ClientThread.class).invokeLater(() -> RuneLite.getInjector().getInstance(ClientThread.class).invokeLater(() ->
{ {
@@ -122,14 +133,18 @@ public class ConfigPlugin extends Plugin
}); });
} }
@Subscribe private void addSubscriptions()
public void onPluginChanged(PluginChanged event) {
eventBus.subscribe(PluginChanged.class, this, this::onPluginChanged);
eventBus.subscribe(OverlayMenuClicked.class, this, this::onOverlayMenuClicked);
}
private void onPluginChanged(PluginChanged event)
{ {
SwingUtilities.invokeLater(configPanel::refreshPluginList); SwingUtilities.invokeLater(configPanel::refreshPluginList);
} }
@Subscribe private void onOverlayMenuClicked(OverlayMenuClicked overlayMenuClicked)
public void onOverlayMenuClicked(OverlayMenuClicked overlayMenuClicked)
{ {
OverlayMenuEntry overlayMenuEntry = overlayMenuClicked.getEntry(); OverlayMenuEntry overlayMenuEntry = overlayMenuClicked.getEntry();
if (overlayMenuEntry.getMenuAction() == MenuAction.RUNELITE_OVERLAY_CONFIG) if (overlayMenuEntry.getMenuAction() == MenuAction.RUNELITE_OVERLAY_CONFIG)

View File

@@ -44,7 +44,7 @@ import net.runelite.api.events.ConfigChanged;
import net.runelite.api.events.GameTick; import net.runelite.api.events.GameTick;
import net.runelite.api.events.SpotAnimationChanged; import net.runelite.api.events.SpotAnimationChanged;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.game.ItemManager; import net.runelite.client.game.ItemManager;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDependency; import net.runelite.client.plugins.PluginDependency;
@@ -80,6 +80,9 @@ public class CookingPlugin extends Plugin
@Inject @Inject
private ItemManager itemManager; private ItemManager itemManager;
@Inject
private EventBus eventBus;
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
private CookingSession session; private CookingSession session;
@@ -97,6 +100,8 @@ public class CookingPlugin extends Plugin
protected void startUp() throws Exception protected void startUp() throws Exception
{ {
updateConfig(); updateConfig();
addSubscriptions();
session = null; session = null;
overlayManager.add(overlay); overlayManager.add(overlay);
} }
@@ -104,13 +109,22 @@ public class CookingPlugin extends Plugin
@Override @Override
protected void shutDown() throws Exception protected void shutDown() throws Exception
{ {
eventBus.unregister(this);
infoBoxManager.removeIf(FermentTimer.class::isInstance); infoBoxManager.removeIf(FermentTimer.class::isInstance);
overlayManager.remove(overlay); overlayManager.remove(overlay);
session = null; session = null;
} }
@Subscribe private void addSubscriptions()
public void onGameTick(GameTick gameTick) {
eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
eventBus.subscribe(GameTick.class, this, this::onGameTick);
eventBus.subscribe(SpotAnimationChanged.class, this, this::onSpotAnimationChanged);
eventBus.subscribe(ChatMessage.class, this, this::onChatMessage);
}
private void onGameTick(GameTick gameTick)
{ {
if (session == null || this.statTimeout == 0) if (session == null || this.statTimeout == 0)
{ {
@@ -126,8 +140,7 @@ public class CookingPlugin extends Plugin
} }
} }
@Subscribe void onSpotAnimationChanged(SpotAnimationChanged graphicChanged)
public void onSpotAnimationChanged(SpotAnimationChanged graphicChanged)
{ {
Player player = client.getLocalPlayer(); Player player = client.getLocalPlayer();
@@ -156,8 +169,7 @@ public class CookingPlugin extends Plugin
} }
} }
@Subscribe void onChatMessage(ChatMessage event)
public void onChatMessage(ChatMessage event)
{ {
if (event.getType() != ChatMessageType.SPAM) if (event.getType() != ChatMessageType.SPAM)
{ {
@@ -194,8 +206,7 @@ public class CookingPlugin extends Plugin
} }
} }
@Subscribe private void onConfigChanged(ConfigChanged configChanged)
public void onConfigChanged(ConfigChanged configChanged)
{ {
if (configChanged.getGroup().equals("cooking")) if (configChanged.getGroup().equals("cooking"))
{ {

View File

@@ -25,7 +25,7 @@
package net.runelite.client.plugins.cooking; package net.runelite.client.plugins.cooking;
import java.awt.Color; import java.awt.Color;
import java.awt.Image; import java.awt.image.BufferedImage;
import java.time.Duration; import java.time.Duration;
import java.time.Instant; import java.time.Instant;
import javax.inject.Singleton; import javax.inject.Singleton;
@@ -39,7 +39,7 @@ final class FermentTimer extends InfoBox
private Instant fermentTime; private Instant fermentTime;
FermentTimer(Image image, Plugin plugin) FermentTimer(BufferedImage image, Plugin plugin)
{ {
super(image, plugin); super(image, plugin);
reset(); reset();

View File

@@ -53,7 +53,7 @@ import net.runelite.client.chat.ChatMessageBuilder;
import net.runelite.client.chat.ChatMessageManager; import net.runelite.client.chat.ChatMessageManager;
import net.runelite.client.chat.QueuedMessage; import net.runelite.client.chat.QueuedMessage;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.ui.overlay.OverlayManager;
@@ -102,6 +102,9 @@ public class CorpPlugin extends Plugin
@Inject @Inject
private CorpConfig config; private CorpConfig config;
@Inject
private EventBus eventBus;
private boolean leftClickCore; private boolean leftClickCore;
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
private boolean showDamage; private boolean showDamage;
@@ -116,6 +119,7 @@ public class CorpPlugin extends Plugin
protected void startUp() throws Exception protected void startUp() throws Exception
{ {
updateConfig(); updateConfig();
addSubscriptions();
overlayManager.add(corpOverlay); overlayManager.add(corpOverlay);
overlayManager.add(coreOverlay); overlayManager.add(coreOverlay);
@@ -124,6 +128,8 @@ public class CorpPlugin extends Plugin
@Override @Override
protected void shutDown() throws Exception protected void shutDown() throws Exception
{ {
eventBus.unregister(this);
overlayManager.remove(corpOverlay); overlayManager.remove(corpOverlay);
overlayManager.remove(coreOverlay); overlayManager.remove(coreOverlay);
@@ -133,8 +139,18 @@ public class CorpPlugin extends Plugin
players.clear(); players.clear();
} }
@Subscribe private void addSubscriptions()
public void onGameStateChanged(GameStateChanged gameStateChanged) {
eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
eventBus.subscribe(GameStateChanged.class, this, this::onGameStateChanged);
eventBus.subscribe(NpcSpawned.class, this, this::onNpcSpawned);
eventBus.subscribe(NpcDespawned.class, this, this::onNpcDespawned);
eventBus.subscribe(HitsplatApplied.class, this, this::onHitsplatApplied);
eventBus.subscribe(InteractingChanged.class, this, this::onInteractingChanged);
eventBus.subscribe(MenuEntryAdded.class, this, this::onMenuEntryAdded);
}
private void onGameStateChanged(GameStateChanged gameStateChanged)
{ {
if (gameStateChanged.getGameState() == GameState.LOADING) if (gameStateChanged.getGameState() == GameState.LOADING)
{ {
@@ -142,8 +158,7 @@ public class CorpPlugin extends Plugin
} }
} }
@Subscribe private void onNpcSpawned(NpcSpawned npcSpawned)
public void onNpcSpawned(NpcSpawned npcSpawned)
{ {
NPC npc = npcSpawned.getNpc(); NPC npc = npcSpawned.getNpc();
@@ -162,8 +177,7 @@ public class CorpPlugin extends Plugin
} }
} }
@Subscribe private void onNpcDespawned(NpcDespawned npcDespawned)
public void onNpcDespawned(NpcDespawned npcDespawned)
{ {
NPC npc = npcDespawned.getNpc(); NPC npc = npcDespawned.getNpc();
@@ -199,8 +213,7 @@ public class CorpPlugin extends Plugin
} }
} }
@Subscribe private void onHitsplatApplied(HitsplatApplied hitsplatApplied)
public void onHitsplatApplied(HitsplatApplied hitsplatApplied)
{ {
Actor actor = hitsplatApplied.getActor(); Actor actor = hitsplatApplied.getActor();
@@ -218,8 +231,7 @@ public class CorpPlugin extends Plugin
totalDamage += hitsplatApplied.getHitsplat().getAmount(); totalDamage += hitsplatApplied.getHitsplat().getAmount();
} }
@Subscribe private void onInteractingChanged(InteractingChanged interactingChanged)
public void onInteractingChanged(InteractingChanged interactingChanged)
{ {
Actor source = interactingChanged.getSource(); Actor source = interactingChanged.getSource();
Actor target = interactingChanged.getTarget(); Actor target = interactingChanged.getTarget();
@@ -232,8 +244,7 @@ public class CorpPlugin extends Plugin
players.add(source); players.add(source);
} }
@Subscribe private void onMenuEntryAdded(MenuEntryAdded menuEntryAdded)
public void onMenuEntryAdded(MenuEntryAdded menuEntryAdded)
{ {
if (menuEntryAdded.getType() != NPC_SECTION_ACTION if (menuEntryAdded.getType() != NPC_SECTION_ACTION
|| !this.leftClickCore || !menuEntryAdded.getOption().equals(ATTACK)) || !this.leftClickCore || !menuEntryAdded.getOption().equals(ATTACK))
@@ -256,8 +267,7 @@ public class CorpPlugin extends Plugin
client.setMenuEntries(menuEntries); client.setMenuEntries(menuEntries);
} }
@Subscribe private void onConfigChanged(ConfigChanged configChanged)
public void onConfigChanged(ConfigChanged configChanged)
{ {
if (configChanged.getGroup().equals("corp")) if (configChanged.getGroup().equals("corp"))
{ {

View File

@@ -28,7 +28,6 @@ import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import javax.inject.Inject; import javax.inject.Inject;
@@ -87,7 +86,7 @@ public class CoxInfoBox extends Overlay
if (System.currentTimeMillis() < (plugin.getLastPrayTime() + 120000) && plugin.getPrayAgainstOlm() != null) if (System.currentTimeMillis() < (plugin.getLastPrayTime() + 120000) && plugin.getPrayAgainstOlm() != null)
{ {
InfoBoxComponent prayComponent = new InfoBoxComponent(); InfoBoxComponent prayComponent = new InfoBoxComponent();
Image prayImg = scaleImg(getPrayerImage(plugin.prayAgainstOlm)); BufferedImage prayImg = scaleImg(getPrayerImage(plugin.prayAgainstOlm));
prayComponent.setImage(prayImg); prayComponent.setImage(prayImg);
prayComponent.setColor(Color.WHITE); prayComponent.setColor(Color.WHITE);
prayComponent.setBackgroundColor(client.isPrayerActive(prayAgainst.getPrayer()) prayComponent.setBackgroundColor(client.isPrayerActive(prayAgainst.getPrayer())
@@ -160,7 +159,7 @@ public class CoxInfoBox extends Overlay
return null; return null;
} }
private Image scaleImg(final Image img) private BufferedImage scaleImg(final BufferedImage img)
{ {
if (img == null) if (img == null)
{ {

View File

@@ -63,7 +63,7 @@ import net.runelite.api.events.ProjectileMoved;
import net.runelite.api.events.SpotAnimationChanged; import net.runelite.api.events.SpotAnimationChanged;
import net.runelite.client.chat.ChatMessageManager; import net.runelite.client.chat.ChatMessageManager;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.plugins.PluginType; import net.runelite.client.plugins.PluginType;
@@ -105,6 +105,8 @@ public class CoxPlugin extends Plugin
private CoxConfig config; private CoxConfig config;
@Inject @Inject
private OverlayManager overlayManager; private OverlayManager overlayManager;
@Inject
private EventBus eventBus;
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
private boolean HandCripple; private boolean HandCripple;
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
@@ -207,6 +209,7 @@ public class CoxPlugin extends Plugin
protected void startUp() protected void startUp()
{ {
updateConfig(); updateConfig();
addSubscriptions();
overlayManager.add(coxOverlay); overlayManager.add(coxOverlay);
overlayManager.add(coxInfoBox); overlayManager.add(coxInfoBox);
@@ -227,12 +230,24 @@ public class CoxPlugin extends Plugin
@Override @Override
protected void shutDown() protected void shutDown()
{ {
eventBus.unregister(this);
overlayManager.remove(coxOverlay); overlayManager.remove(coxOverlay);
overlayManager.remove(coxInfoBox); overlayManager.remove(coxInfoBox);
} }
@Subscribe private void addSubscriptions()
public void onChatMessage(ChatMessage chatMessage) {
eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
eventBus.subscribe(ChatMessage.class, this, this::onChatMessage);
eventBus.subscribe(ProjectileMoved.class, this, this::onProjectileMoved);
eventBus.subscribe(SpotAnimationChanged.class, this, this::onSpotAnimationChanged);
eventBus.subscribe(NpcSpawned.class, this, this::onNpcSpawned);
eventBus.subscribe(NpcDespawned.class, this, this::onNpcDespawned);
eventBus.subscribe(GameTick.class, this, this::onGameTick);
}
private void onChatMessage(ChatMessage chatMessage)
{ {
if (inRaid()) if (inRaid())
{ {
@@ -305,8 +320,7 @@ public class CoxPlugin extends Plugin
} }
} }
@Subscribe private void onProjectileMoved(ProjectileMoved event)
public void onProjectileMoved(ProjectileMoved event)
{ {
if (inRaid()) if (inRaid())
{ {
@@ -328,8 +342,7 @@ public class CoxPlugin extends Plugin
} }
} }
@Subscribe private void onSpotAnimationChanged(SpotAnimationChanged graphicChanged)
public void onSpotAnimationChanged(SpotAnimationChanged graphicChanged)
{ {
if (inRaid()) if (inRaid())
{ {
@@ -344,8 +357,7 @@ public class CoxPlugin extends Plugin
} }
} }
@Subscribe private void onNpcSpawned(NpcSpawned npcSpawned)
public void onNpcSpawned(NpcSpawned npcSpawned)
{ {
if (inRaid()) if (inRaid())
{ {
@@ -384,8 +396,7 @@ public class CoxPlugin extends Plugin
} }
} }
@Subscribe private void onNpcDespawned(NpcDespawned event)
public void onNpcDespawned(NpcDespawned event)
{ {
if (inRaid()) if (inRaid())
{ {
@@ -429,8 +440,7 @@ public class CoxPlugin extends Plugin
} }
} }
@Subscribe private void onGameTick(GameTick event)
public void onGameTick(GameTick event)
{ {
if (!inRaid()) if (!inRaid())
{ {
@@ -696,8 +706,7 @@ public class CoxPlugin extends Plugin
return client.getVar(Varbits.IN_RAID) == 1; return client.getVar(Varbits.IN_RAID) == 1;
} }
@Subscribe private void onConfigChanged(ConfigChanged configChanged)
public void onConfigChanged(ConfigChanged configChanged)
{ {
if (configChanged.getGroup().equals("Cox")) if (configChanged.getGroup().equals("Cox"))
{ {

View File

@@ -35,7 +35,7 @@ import net.runelite.api.Player;
import net.runelite.api.Skill; import net.runelite.api.Skill;
import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.GameStateChanged;
import net.runelite.api.events.GameTick; import net.runelite.api.events.GameTick;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.http.api.RuneLiteAPI; import net.runelite.http.api.RuneLiteAPI;
@@ -64,12 +64,27 @@ public class CrystalMathLabs extends Plugin
@Inject @Inject
private Client client; private Client client;
@Inject
private EventBus eventBus;
private String lastUsername; private String lastUsername;
private boolean fetchXp; private boolean fetchXp;
private long lastXp; private long lastXp;
@Subscribe @Override
public void onGameStateChanged(GameStateChanged gameStateChanged) protected void startUp() throws Exception
{
eventBus.subscribe(GameStateChanged.class, this, this::onGameStateChanged);
eventBus.subscribe(GameTick.class, this, this::onGameTick);
}
@Override
protected void shutDown() throws Exception
{
eventBus.unregister(this);
}
private void onGameStateChanged(GameStateChanged gameStateChanged)
{ {
GameState state = gameStateChanged.getGameState(); GameState state = gameStateChanged.getGameState();
if (state == GameState.LOGGED_IN) if (state == GameState.LOGGED_IN)
@@ -98,8 +113,7 @@ public class CrystalMathLabs extends Plugin
} }
} }
@Subscribe private void onGameTick(GameTick gameTick)
public void onGameTick(GameTick gameTick)
{ {
if (fetchXp) if (fetchXp)
{ {

View File

@@ -29,7 +29,7 @@ import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.ConfigChanged;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.ui.ClientUI; import net.runelite.client.ui.ClientUI;
@@ -48,6 +48,9 @@ public class CustomCursorPlugin extends Plugin
@Inject @Inject
private CustomCursorConfig config; private CustomCursorConfig config;
@Inject
private EventBus eventBus;
@Provides @Provides
CustomCursorConfig provideConfig(ConfigManager configManager) CustomCursorConfig provideConfig(ConfigManager configManager)
{ {
@@ -57,17 +60,19 @@ public class CustomCursorPlugin extends Plugin
@Override @Override
protected void startUp() protected void startUp()
{ {
eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
updateCursor(); updateCursor();
} }
@Override @Override
protected void shutDown() protected void shutDown()
{ {
eventBus.unregister(this);
clientUI.resetCursor(); clientUI.resetCursor();
} }
@Subscribe private void onConfigChanged(ConfigChanged event)
public void onConfigChanged(ConfigChanged event)
{ {
if (event.getGroup().equals("customcursor") && event.getKey().equals("cursorStyle")) if (event.getGroup().equals("customcursor") && event.getKey().equals("cursorStyle"))
{ {

View File

@@ -44,7 +44,7 @@ import net.runelite.client.chat.ChatMessageBuilder;
import net.runelite.client.chat.ChatMessageManager; import net.runelite.client.chat.ChatMessageManager;
import net.runelite.client.chat.QueuedMessage; import net.runelite.client.chat.QueuedMessage;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
@@ -80,6 +80,9 @@ public class DailyTasksPlugin extends Plugin
@Inject @Inject
private ChatMessageManager chatMessageManager; private ChatMessageManager chatMessageManager;
@Inject
private EventBus eventBus;
private long lastReset; private long lastReset;
private boolean loggingIn; private boolean loggingIn;
@@ -103,6 +106,9 @@ public class DailyTasksPlugin extends Plugin
public void startUp() public void startUp()
{ {
updateConfig(); updateConfig();
eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
addSubscriptions();
loggingIn = true; loggingIn = true;
} }
@@ -110,11 +116,19 @@ public class DailyTasksPlugin extends Plugin
@Override @Override
public void shutDown() public void shutDown()
{ {
eventBus.unregister(this);
eventBus.unregister(this);
lastReset = 0L; lastReset = 0L;
} }
@Subscribe private void addSubscriptions()
public void onGameStateChanged(GameStateChanged event) {
eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
eventBus.subscribe(GameStateChanged.class, this, this::onGameStateChanged);
}
private void onGameStateChanged(GameStateChanged event)
{ {
if (event.getGameState() == GameState.LOGGING_IN) if (event.getGameState() == GameState.LOGGING_IN)
{ {
@@ -122,8 +136,7 @@ public class DailyTasksPlugin extends Plugin
} }
} }
@Subscribe private void onGameTick(GameTick event)
public void onGameTick(GameTick event)
{ {
long currentTime = System.currentTimeMillis(); long currentTime = System.currentTimeMillis();
boolean dailyReset = !loggingIn && currentTime - lastReset > ONE_DAY; boolean dailyReset = !loggingIn && currentTime - lastReset > ONE_DAY;
@@ -245,8 +258,9 @@ public class DailyTasksPlugin extends Plugin
private void checkArrows(boolean dailyReset) private void checkArrows(boolean dailyReset)
{ {
if ((client.getVar(Varbits.DIARY_WESTERN_EASY) == 1) if (client.getVar(Varbits.DIARY_WESTERN_EASY) == 1
&& (dailyReset || client.getVar(Varbits.DAILY_ARROWS_STATE) == 0)) && (client.getVar(Varbits.DAILY_ARROWS_STATE) == 0
|| dailyReset))
{ {
sendChatMessage(ARROWS_MESSAGE); sendChatMessage(ARROWS_MESSAGE);
} }
@@ -297,8 +311,7 @@ public class DailyTasksPlugin extends Plugin
.build()); .build());
} }
@Subscribe private void onConfigChanged(ConfigChanged configChanged)
public void onConfigChanged(ConfigChanged configChanged)
{ {
if (configChanged.getGroup().equals("dailytaskindicators")) if (configChanged.getGroup().equals("dailytaskindicators"))
{ {

View File

@@ -43,7 +43,7 @@ import net.runelite.api.events.GameStateChanged;
import net.runelite.api.events.GameTick; import net.runelite.api.events.GameTick;
import net.runelite.api.events.LocalPlayerDeath; import net.runelite.api.events.LocalPlayerDeath;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.game.ItemManager; import net.runelite.client.game.ItemManager;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
@@ -83,6 +83,9 @@ public class DeathIndicatorPlugin extends Plugin
@Inject @Inject
private ItemManager itemManager; private ItemManager itemManager;
@Inject
private EventBus eventBus;
private BufferedImage mapArrow; private BufferedImage mapArrow;
private Timer deathTimer; private Timer deathTimer;
@@ -100,6 +103,8 @@ public class DeathIndicatorPlugin extends Plugin
@Override @Override
protected void startUp() protected void startUp()
{ {
addSubscriptions();
if (!hasDied()) if (!hasDied())
{ {
return; return;
@@ -127,6 +132,8 @@ public class DeathIndicatorPlugin extends Plugin
@Override @Override
protected void shutDown() protected void shutDown()
{ {
eventBus.unregister(this);
if (client.hasHintArrow()) if (client.hasHintArrow())
{ {
client.clearHintArrow(); client.clearHintArrow();
@@ -141,8 +148,15 @@ public class DeathIndicatorPlugin extends Plugin
worldMapPointManager.removeIf(DeathWorldMapPoint.class::isInstance); worldMapPointManager.removeIf(DeathWorldMapPoint.class::isInstance);
} }
@Subscribe private void addSubscriptions()
public void onLocalPlayerDeath(LocalPlayerDeath death) {
eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
eventBus.subscribe(LocalPlayerDeath.class, this, this::onLocalPlayerDeath);
eventBus.subscribe(GameTick.class, this, this::onGameTick);
eventBus.subscribe(GameStateChanged.class, this, this::onGameStateChanged);
}
private void onLocalPlayerDeath(LocalPlayerDeath death)
{ {
if (client.isInInstancedRegion()) if (client.isInInstancedRegion())
{ {
@@ -154,8 +168,7 @@ public class DeathIndicatorPlugin extends Plugin
lastDeathTime = Instant.now(); lastDeathTime = Instant.now();
} }
@Subscribe private void onGameTick(GameTick event)
public void onGameTick(GameTick event)
{ {
// Check if player respawned in a death respawn location // Check if player respawned in a death respawn location
if (lastDeath != null && !client.getLocalPlayer().getWorldLocation().equals(lastDeath)) if (lastDeath != null && !client.getLocalPlayer().getWorldLocation().equals(lastDeath))
@@ -219,8 +232,7 @@ public class DeathIndicatorPlugin extends Plugin
} }
} }
@Subscribe private void onConfigChanged(ConfigChanged event)
public void onConfigChanged(ConfigChanged event)
{ {
if (event.getGroup().equals("deathIndicator")) if (event.getGroup().equals("deathIndicator"))
{ {
@@ -251,8 +263,7 @@ public class DeathIndicatorPlugin extends Plugin
} }
} }
@Subscribe private void onGameStateChanged(GameStateChanged event)
public void onGameStateChanged(GameStateChanged event)
{ {
if (!hasDied()) if (!hasDied())
{ {

View File

@@ -33,7 +33,7 @@ import net.runelite.api.Client;
import net.runelite.api.GameState; import net.runelite.api.GameState;
import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.GameStateChanged;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.events.SessionOpen; import net.runelite.client.events.SessionOpen;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
@@ -57,6 +57,9 @@ public class DefaultWorldPlugin extends Plugin
@Inject @Inject
private DefaultWorldConfig config; private DefaultWorldConfig config;
@Inject
private EventBus eventBus;
private final WorldClient worldClient = new WorldClient(); private final WorldClient worldClient = new WorldClient();
private int worldCache; private int worldCache;
private boolean worldChangeRequired; private boolean worldChangeRequired;
@@ -64,6 +67,8 @@ public class DefaultWorldPlugin extends Plugin
@Override @Override
protected void startUp() throws Exception protected void startUp() throws Exception
{ {
addSubscriptions();
worldChangeRequired = true; worldChangeRequired = true;
applyWorld(); applyWorld();
} }
@@ -71,25 +76,31 @@ public class DefaultWorldPlugin extends Plugin
@Override @Override
protected void shutDown() throws Exception protected void shutDown() throws Exception
{ {
eventBus.unregister(this);
worldChangeRequired = true; worldChangeRequired = true;
changeWorld(worldCache); changeWorld(worldCache);
} }
private void addSubscriptions()
{
eventBus.subscribe(SessionOpen.class, this, this::onSessionOpen);
eventBus.subscribe(GameStateChanged.class, this, this::onGameStateChanged);
}
@Provides @Provides
DefaultWorldConfig getConfig(ConfigManager configManager) DefaultWorldConfig getConfig(ConfigManager configManager)
{ {
return configManager.getConfig(DefaultWorldConfig.class); return configManager.getConfig(DefaultWorldConfig.class);
} }
@Subscribe private void onSessionOpen(SessionOpen event)
public void onSessionOpen(SessionOpen event)
{ {
worldChangeRequired = true; worldChangeRequired = true;
applyWorld(); applyWorld();
} }
@Subscribe private void onGameStateChanged(GameStateChanged event)
public void onGameStateChanged(GameStateChanged event)
{ {
applyWorld(); applyWorld();
} }

View File

@@ -24,7 +24,6 @@
*/ */
package net.runelite.client.plugins.demonicgorilla; package net.runelite.client.plugins.demonicgorilla;
import java.awt.BasicStroke;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Graphics2D; import java.awt.Graphics2D;
@@ -43,6 +42,7 @@ import net.runelite.client.game.SkillIconManager;
import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayLayer;
import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.OverlayUtil;
@Singleton @Singleton
public class DemonicGorillaOverlay extends Overlay public class DemonicGorillaOverlay extends Overlay
@@ -118,31 +118,11 @@ public class DemonicGorillaOverlay extends Overlay
int currentPosX = 0; int currentPosX = 0;
for (BufferedImage icon : icons) for (BufferedImage icon : icons)
{ {
graphics.setStroke(new BasicStroke(2)); OverlayUtil.setProgressIcon(graphics, point, icon, totalWidth, bgPadding, currentPosX,
graphics.setColor(COLOR_ICON_BACKGROUND); COLOR_ICON_BACKGROUND, OVERLAY_ICON_DISTANCE, COLOR_ICON_BORDER, COLOR_ICON_BORDER_FILL);
graphics.fillOval(
point.getX() - totalWidth / 2 + currentPosX - bgPadding,
point.getY() - icon.getHeight() / 2 - OVERLAY_ICON_DISTANCE - bgPadding,
icon.getWidth() + bgPadding * 2,
icon.getHeight() + bgPadding * 2);
graphics.setColor(COLOR_ICON_BORDER);
graphics.drawOval(
point.getX() - totalWidth / 2 + currentPosX - bgPadding,
point.getY() - icon.getHeight() / 2 - OVERLAY_ICON_DISTANCE - bgPadding,
icon.getWidth() + bgPadding * 2,
icon.getHeight() + bgPadding * 2);
graphics.drawImage(
icon,
point.getX() - totalWidth / 2 + currentPosX,
point.getY() - icon.getHeight() / 2 - OVERLAY_ICON_DISTANCE,
null);
graphics.setColor(COLOR_ICON_BORDER_FILL);
Arc2D.Double arc = new Arc2D.Double( Arc2D.Double arc = new Arc2D.Double(
point.getX() - totalWidth / 2 + currentPosX - bgPadding, point.getX() - totalWidth / 2 + currentPosX - bgPadding,
point.getY() - icon.getHeight() / 2 - OVERLAY_ICON_DISTANCE - bgPadding, point.getY() - (float) (icon.getHeight() / 2) - OVERLAY_ICON_DISTANCE - bgPadding,
icon.getWidth() + bgPadding * 2, icon.getWidth() + bgPadding * 2,
icon.getHeight() + bgPadding * 2, icon.getHeight() + bgPadding * 2,
90.0, 90.0,

View File

@@ -56,7 +56,7 @@ import net.runelite.api.events.PlayerDespawned;
import net.runelite.api.events.PlayerSpawned; import net.runelite.api.events.PlayerSpawned;
import net.runelite.api.events.ProjectileMoved; import net.runelite.api.events.ProjectileMoved;
import net.runelite.client.callback.ClientThread; import net.runelite.client.callback.ClientThread;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.ui.overlay.OverlayManager;
@@ -81,6 +81,9 @@ public class DemonicGorillaPlugin extends Plugin
@Inject @Inject
private ClientThread clientThread; private ClientThread clientThread;
@Inject
private EventBus eventBus;
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
private Map<NPC, DemonicGorilla> gorillas; private Map<NPC, DemonicGorilla> gorillas;
@@ -93,6 +96,7 @@ public class DemonicGorillaPlugin extends Plugin
@Override @Override
protected void startUp() throws Exception protected void startUp() throws Exception
{ {
addSubscriptions();
overlayManager.add(overlay); overlayManager.add(overlay);
gorillas = new HashMap<>(); gorillas = new HashMap<>();
recentBoulders = new ArrayList<>(); recentBoulders = new ArrayList<>();
@@ -104,6 +108,7 @@ public class DemonicGorillaPlugin extends Plugin
@Override @Override
protected void shutDown() throws Exception protected void shutDown() throws Exception
{ {
eventBus.unregister(this);
overlayManager.remove(overlay); overlayManager.remove(overlay);
gorillas = null; gorillas = null;
recentBoulders = null; recentBoulders = null;
@@ -111,6 +116,18 @@ public class DemonicGorillaPlugin extends Plugin
memorizedPlayers = null; memorizedPlayers = null;
} }
private void addSubscriptions()
{
eventBus.subscribe(ProjectileMoved.class, this, this::onProjectileMoved);
eventBus.subscribe(HitsplatApplied.class, this, this::onHitsplatApplied);
eventBus.subscribe(GameStateChanged.class, this, this::onGameStateChanged);
eventBus.subscribe(PlayerSpawned.class, this, this::onPlayerSpawned);
eventBus.subscribe(PlayerDespawned.class, this, this::onPlayerDespawned);
eventBus.subscribe(NpcSpawned.class, this, this::onNpcSpawned);
eventBus.subscribe(NpcDespawned.class, this, this::onNpcDespawned);
eventBus.subscribe(GameTick.class, this, this::onGameTick);
}
private void clear() private void clear()
{ {
recentBoulders.clear(); recentBoulders.clear();
@@ -528,8 +545,7 @@ public class DemonicGorillaPlugin extends Plugin
} }
} }
@Subscribe private void onProjectileMoved(ProjectileMoved event)
public void onProjectileMoved(ProjectileMoved event)
{ {
Projectile projectile = event.getProjectile(); Projectile projectile = event.getProjectile();
int projectileId = projectile.getId(); int projectileId = projectile.getId();
@@ -616,8 +632,7 @@ public class DemonicGorillaPlugin extends Plugin
} }
} }
@Subscribe private void onHitsplatApplied(HitsplatApplied event)
public void onHitsplatApplied(HitsplatApplied event)
{ {
if (gorillas.isEmpty()) if (gorillas.isEmpty())
{ {
@@ -645,8 +660,7 @@ public class DemonicGorillaPlugin extends Plugin
} }
} }
@Subscribe private void onGameStateChanged(GameStateChanged event)
public void onGameStateChanged(GameStateChanged event)
{ {
GameState gs = event.getGameState(); GameState gs = event.getGameState();
if (gs == GameState.LOGGING_IN || if (gs == GameState.LOGGING_IN ||
@@ -657,8 +671,7 @@ public class DemonicGorillaPlugin extends Plugin
} }
} }
@Subscribe private void onPlayerSpawned(PlayerSpawned event)
public void onPlayerSpawned(PlayerSpawned event)
{ {
if (gorillas.isEmpty()) if (gorillas.isEmpty())
{ {
@@ -669,8 +682,7 @@ public class DemonicGorillaPlugin extends Plugin
memorizedPlayers.put(player, new MemorizedPlayer(player)); memorizedPlayers.put(player, new MemorizedPlayer(player));
} }
@Subscribe private void onPlayerDespawned(PlayerDespawned event)
public void onPlayerDespawned(PlayerDespawned event)
{ {
if (gorillas.isEmpty()) if (gorillas.isEmpty())
{ {
@@ -680,8 +692,7 @@ public class DemonicGorillaPlugin extends Plugin
memorizedPlayers.remove(event.getPlayer()); memorizedPlayers.remove(event.getPlayer());
} }
@Subscribe private void onNpcSpawned(NpcSpawned event)
public void onNpcSpawned(NpcSpawned event)
{ {
NPC npc = event.getNpc(); NPC npc = event.getNpc();
if (isNpcGorilla(npc.getId())) if (isNpcGorilla(npc.getId()))
@@ -697,8 +708,7 @@ public class DemonicGorillaPlugin extends Plugin
} }
} }
@Subscribe private void onNpcDespawned(NpcDespawned event)
public void onNpcDespawned(NpcDespawned event)
{ {
if (gorillas.remove(event.getNpc()) != null && gorillas.isEmpty()) if (gorillas.remove(event.getNpc()) != null && gorillas.isEmpty())
{ {
@@ -706,8 +716,7 @@ public class DemonicGorillaPlugin extends Plugin
} }
} }
@Subscribe private void onGameTick(GameTick event)
public void onGameTick(GameTick event)
{ {
checkGorillaAttacks(); checkGorillaAttacks();
checkPendingAttacks(); checkPendingAttacks();

View File

@@ -42,15 +42,16 @@ import net.runelite.api.NPC;
import net.runelite.api.Player; import net.runelite.api.Player;
import net.runelite.api.Skill; import net.runelite.api.Skill;
import net.runelite.api.coords.WorldPoint; import net.runelite.api.coords.WorldPoint;
import net.runelite.api.events.AreaSoundEffectPlayed;
import net.runelite.api.events.BoostedLevelChanged; import net.runelite.api.events.BoostedLevelChanged;
import net.runelite.api.events.CommandExecuted; import net.runelite.api.events.CommandExecuted;
import net.runelite.api.events.ExperienceChanged; import net.runelite.api.events.ExperienceChanged;
import net.runelite.api.events.MenuEntryAdded; import net.runelite.api.events.MenuEntryAdded;
import net.runelite.api.events.SoundEffectPlayed;
import net.runelite.api.events.VarbitChanged; import net.runelite.api.events.VarbitChanged;
import net.runelite.api.kit.KitType; import net.runelite.api.kit.KitType;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.EventBus; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.ui.ClientToolbar; import net.runelite.client.ui.ClientToolbar;
@@ -143,6 +144,8 @@ public class DevToolsPlugin extends Plugin
@Override @Override
protected void startUp() throws Exception protected void startUp() throws Exception
{ {
addSubscriptions();
players = new DevToolsButton("Players"); players = new DevToolsButton("Players");
npcs = new DevToolsButton("NPCs"); npcs = new DevToolsButton("NPCs");
@@ -200,14 +203,13 @@ public class DevToolsPlugin extends Plugin
.build(); .build();
clientToolbar.addNavigation(navButton); clientToolbar.addNavigation(navButton);
eventBus.register(soundEffectOverlay);
} }
@Override @Override
protected void shutDown() throws Exception protected void shutDown() throws Exception
{ {
eventBus.unregister(soundEffectOverlay); eventBus.unregister(this);
overlayManager.remove(overlay); overlayManager.remove(overlay);
overlayManager.remove(locationOverlay); overlayManager.remove(locationOverlay);
overlayManager.remove(sceneOverlay); overlayManager.remove(sceneOverlay);
@@ -218,8 +220,15 @@ public class DevToolsPlugin extends Plugin
clientToolbar.removeNavigation(navButton); clientToolbar.removeNavigation(navButton);
} }
@Subscribe private void addSubscriptions()
public void onCommandExecuted(CommandExecuted commandExecuted) {
eventBus.subscribe(CommandExecuted.class, this, this::onCommandExecuted);
eventBus.subscribe(MenuEntryAdded.class, this, this::onMenuEntryAdded);
eventBus.subscribe(AreaSoundEffectPlayed.class, this, this::onAreaSoundEffectPlayed);
eventBus.subscribe(SoundEffectPlayed.class, this, this::onSoundEffectPlayed);
}
private void onCommandExecuted(CommandExecuted commandExecuted)
{ {
String[] args = commandExecuted.getArguments(); String[] args = commandExecuted.getArguments();
@@ -260,7 +269,7 @@ public class DevToolsPlugin extends Plugin
client.addChatMessage(ChatMessageType.GAMEMESSAGE, "", "Set VarPlayer " + varp + " to " + value, null); client.addChatMessage(ChatMessageType.GAMEMESSAGE, "", "Set VarPlayer " + varp + " to " + value, null);
VarbitChanged varbitChanged = new VarbitChanged(); VarbitChanged varbitChanged = new VarbitChanged();
varbitChanged.setIndex(varp); varbitChanged.setIndex(varp);
eventBus.post(varbitChanged); // fake event eventBus.post(VarbitChanged.class, varbitChanged); // fake event
break; break;
} }
case "getvarb": case "getvarb":
@@ -276,7 +285,7 @@ public class DevToolsPlugin extends Plugin
int value = Integer.parseInt(args[1]); int value = Integer.parseInt(args[1]);
client.setVarbitValue(client.getVarps(), varbit, value); client.setVarbitValue(client.getVarps(), varbit, value);
client.addChatMessage(ChatMessageType.GAMEMESSAGE, "", "Set varbit " + varbit + " to " + value, null); client.addChatMessage(ChatMessageType.GAMEMESSAGE, "", "Set varbit " + varbit + " to " + value, null);
eventBus.post(new VarbitChanged()); // fake event eventBus.post(VarbitChanged.class, new VarbitChanged()); // fake event
break; break;
} }
case "addxp": case "addxp":
@@ -295,7 +304,7 @@ public class DevToolsPlugin extends Plugin
ExperienceChanged experienceChanged = new ExperienceChanged(); ExperienceChanged experienceChanged = new ExperienceChanged();
experienceChanged.setSkill(skill); experienceChanged.setSkill(skill);
eventBus.post(experienceChanged); eventBus.post(ExperienceChanged.class, experienceChanged);
break; break;
} }
case "setstat": case "setstat":
@@ -314,11 +323,11 @@ public class DevToolsPlugin extends Plugin
ExperienceChanged experienceChanged = new ExperienceChanged(); ExperienceChanged experienceChanged = new ExperienceChanged();
experienceChanged.setSkill(skill); experienceChanged.setSkill(skill);
eventBus.post(experienceChanged); eventBus.post(ExperienceChanged.class, experienceChanged);
BoostedLevelChanged boostedLevelChanged = new BoostedLevelChanged(); BoostedLevelChanged boostedLevelChanged = new BoostedLevelChanged();
boostedLevelChanged.setSkill(skill); boostedLevelChanged.setSkill(skill);
eventBus.post(boostedLevelChanged); eventBus.post(BoostedLevelChanged.class, boostedLevelChanged);
break; break;
} }
case "anim": case "anim":
@@ -363,8 +372,7 @@ public class DevToolsPlugin extends Plugin
} }
} }
@Subscribe private void onMenuEntryAdded(MenuEntryAdded event)
public void onMenuEntryAdded(MenuEntryAdded event)
{ {
if (!examine.isActive()) if (!examine.isActive())
{ {
@@ -401,4 +409,24 @@ public class DevToolsPlugin extends Plugin
client.setMenuEntries(entries); client.setMenuEntries(entries);
} }
} }
private void onSoundEffectPlayed(SoundEffectPlayed event)
{
if (!getSoundEffects().isActive() || soundEffectOverlay == null)
{
return;
}
soundEffectOverlay.onSoundEffectPlayed(event);
}
private void onAreaSoundEffectPlayed(AreaSoundEffectPlayed event)
{
if (!getSoundEffects().isActive() || soundEffectOverlay == null)
{
return;
}
soundEffectOverlay.onAreaSoundEffectPlayed(event);
}
} }

View File

@@ -33,7 +33,6 @@ import net.runelite.api.Player;
import net.runelite.api.coords.LocalPoint; import net.runelite.api.coords.LocalPoint;
import net.runelite.api.events.AreaSoundEffectPlayed; import net.runelite.api.events.AreaSoundEffectPlayed;
import net.runelite.api.events.SoundEffectPlayed; import net.runelite.api.events.SoundEffectPlayed;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.components.LineComponent; import net.runelite.client.ui.overlay.components.LineComponent;
@@ -74,14 +73,8 @@ class SoundEffectOverlay extends Overlay
return panelComponent.render(graphics); return panelComponent.render(graphics);
} }
@Subscribe void onSoundEffectPlayed(SoundEffectPlayed event)
public void onSoundEffectPlayed(SoundEffectPlayed event)
{ {
if (!plugin.getSoundEffects().isActive())
{
return;
}
String text = String text =
"Id: " + event.getSoundId() + "Id: " + event.getSoundId() +
" - D: " + event.getDelay(); " - D: " + event.getDelay();
@@ -94,14 +87,8 @@ class SoundEffectOverlay extends Overlay
checkMaxLines(); checkMaxLines();
} }
@Subscribe void onAreaSoundEffectPlayed(AreaSoundEffectPlayed event)
public void onAreaSoundEffectPlayed(AreaSoundEffectPlayed event)
{ {
if (!plugin.getSoundEffects().isActive())
{
return;
}
Color textColor = COLOR_AREA_SOUND_EFFECT; Color textColor = COLOR_AREA_SOUND_EFFECT;
// Check if the player is within range to hear the sound // Check if the player is within range to hear the sound

View File

@@ -56,7 +56,6 @@ import net.runelite.api.events.VarClientIntChanged;
import net.runelite.api.events.VarClientStrChanged; import net.runelite.api.events.VarClientStrChanged;
import net.runelite.api.events.VarbitChanged; import net.runelite.api.events.VarbitChanged;
import net.runelite.client.eventbus.EventBus; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.ui.ClientUI; import net.runelite.client.ui.ClientUI;
import net.runelite.client.ui.ColorScheme; import net.runelite.client.ui.ColorScheme;
import net.runelite.client.ui.DynamicGridLayout; import net.runelite.client.ui.DynamicGridLayout;
@@ -115,6 +114,7 @@ class VarInspector extends JFrame
@Override @Override
public void windowClosing(WindowEvent e) public void windowClosing(WindowEvent e)
{ {
eventBus.unregister(this);
close(); close();
plugin.getVarInspector().setActive(false); plugin.getVarInspector().setActive(false);
} }
@@ -170,6 +170,7 @@ class VarInspector extends JFrame
add(trackerOpts, BorderLayout.SOUTH); add(trackerOpts, BorderLayout.SOUTH);
pack(); pack();
} }
private void addVarLog(VarType type, String name, int old, int neew) private void addVarLog(VarType type, String name, int old, int neew)
@@ -210,8 +211,7 @@ class VarInspector extends JFrame
}); });
} }
@Subscribe private void onVarbitChanged(VarbitChanged ev)
public void onVarbitChanged(VarbitChanged ev)
{ {
int[] varps = client.getVarps(); int[] varps = client.getVarps();
@@ -274,8 +274,7 @@ class VarInspector extends JFrame
System.arraycopy(client.getVarps(), 0, oldVarps2, 0, oldVarps2.length); System.arraycopy(client.getVarps(), 0, oldVarps2, 0, oldVarps2.length);
} }
@Subscribe private void onVarClientIntChanged(VarClientIntChanged e)
public void onVarClientIntChanged(VarClientIntChanged e)
{ {
int idx = e.getIndex(); int idx = e.getIndex();
int neew = (Integer) client.getVarcMap().getOrDefault(idx, 0); int neew = (Integer) client.getVarcMap().getOrDefault(idx, 0);
@@ -297,8 +296,7 @@ class VarInspector extends JFrame
} }
} }
@Subscribe private void onVarClientStrChanged(VarClientStrChanged e)
public void onVarClientStrChanged(VarClientStrChanged e)
{ {
int idx = e.getIndex(); int idx = e.getIndex();
String neew = (String) client.getVarcMap().getOrDefault(idx, ""); String neew = (String) client.getVarcMap().getOrDefault(idx, "");
@@ -348,7 +346,11 @@ class VarInspector extends JFrame
System.arraycopy(client.getVarps(), 0, oldVarps2, 0, oldVarps2.length); System.arraycopy(client.getVarps(), 0, oldVarps2, 0, oldVarps2.length);
varcs = new HashMap<>(client.getVarcMap()); varcs = new HashMap<>(client.getVarcMap());
eventBus.register(this); // eventBus.register(this);
eventBus.subscribe(VarbitChanged.class, this, this::onVarbitChanged);
eventBus.subscribe(VarClientIntChanged.class, this, this::onVarClientIntChanged);
eventBus.subscribe(VarClientStrChanged.class, this, this::onVarClientStrChanged);
setVisible(true); setVisible(true);
toFront(); toFront();
repaint(); repaint();

View File

@@ -53,7 +53,6 @@ import net.runelite.api.widgets.WidgetInfo;
import net.runelite.api.widgets.WidgetItem; import net.runelite.api.widgets.WidgetItem;
import net.runelite.client.callback.ClientThread; import net.runelite.client.callback.ClientThread;
import net.runelite.client.eventbus.EventBus; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.ui.ClientUI; import net.runelite.client.ui.ClientUI;
@Slf4j @Slf4j
@@ -86,7 +85,7 @@ class WidgetInspector extends JFrame
this.config = config; this.config = config;
this.overlay = overlay; this.overlay = overlay;
eventBus.register(this); eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
setTitle("RuneLite Widget Inspector"); setTitle("RuneLite Widget Inspector");
setIconImage(ClientUI.ICON); setIconImage(ClientUI.ICON);
@@ -97,6 +96,7 @@ class WidgetInspector extends JFrame
@Override @Override
public void windowClosing(WindowEvent e) public void windowClosing(WindowEvent e)
{ {
eventBus.unregister(this);
close(); close();
plugin.getWidgetInspector().setActive(false); plugin.getWidgetInspector().setActive(false);
} }
@@ -165,9 +165,9 @@ class WidgetInspector extends JFrame
add(split, BorderLayout.CENTER); add(split, BorderLayout.CENTER);
pack(); pack();
} }
@Subscribe
private void onConfigChanged(ConfigChanged ev) private void onConfigChanged(ConfigChanged ev)
{ {
boolean onTop = config.inspectorAlwaysOnTop(); boolean onTop = config.inspectorAlwaysOnTop();

View File

@@ -56,7 +56,7 @@ import net.runelite.client.discord.DiscordService;
import net.runelite.client.discord.events.DiscordJoinGame; import net.runelite.client.discord.events.DiscordJoinGame;
import net.runelite.client.discord.events.DiscordJoinRequest; import net.runelite.client.discord.events.DiscordJoinRequest;
import net.runelite.client.discord.events.DiscordReady; import net.runelite.client.discord.events.DiscordReady;
import net.runelite.client.eventbus.Subscribe; import net.runelite.client.eventbus.EventBus;
import net.runelite.client.events.PartyChanged; import net.runelite.client.events.PartyChanged;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
@@ -110,6 +110,9 @@ public class DiscordPlugin extends Plugin
@Inject @Inject
private WSClient wsClient; private WSClient wsClient;
@Inject
private EventBus eventBus;
private final Map<Skill, Integer> skillExp = new HashMap<>(); private final Map<Skill, Integer> skillExp = new HashMap<>();
private NavigationButton discordButton; private NavigationButton discordButton;
private boolean loginFlag; private boolean loginFlag;
@@ -137,6 +140,7 @@ public class DiscordPlugin extends Plugin
protected void startUp() throws Exception protected void startUp() throws Exception
{ {
updateConfig(); updateConfig();
addSubscriptions();
final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "discord.png"); final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "discord.png");
@@ -162,14 +166,31 @@ public class DiscordPlugin extends Plugin
@Override @Override
protected void shutDown() throws Exception protected void shutDown() throws Exception
{ {
eventBus.unregister(this);
clientToolbar.removeNavigation(discordButton); clientToolbar.removeNavigation(discordButton);
discordState.reset(); discordState.reset();
partyService.changeParty(null); partyService.changeParty(null);
wsClient.unregisterMessage(DiscordUserInfo.class); wsClient.unregisterMessage(DiscordUserInfo.class);
} }
@Subscribe private void addSubscriptions()
public void onGameStateChanged(GameStateChanged event) {
eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
eventBus.subscribe(GameStateChanged.class, this, this::onGameStateChanged);
eventBus.subscribe(ExperienceChanged.class, this, this::onExperienceChanged);
eventBus.subscribe(VarbitChanged.class, this, this::onVarbitChanged);
eventBus.subscribe(DiscordReady.class, this, this::onDiscordReady);
eventBus.subscribe(DiscordJoinRequest.class, this, this::onDiscordJoinRequest);
eventBus.subscribe(DiscordJoinGame.class, this, this::onDiscordJoinGame);
eventBus.subscribe(DiscordUserInfo.class, this, this::onDiscordUserInfo);
eventBus.subscribe(UserJoin.class, this, this::onUserJoin);
eventBus.subscribe(UserSync.class, this, this::onUserSync);
eventBus.subscribe(UserPart.class, this, this::onUserPart);
eventBus.subscribe(PartyChanged.class, this, this::onPartyChanged);
}
private void onGameStateChanged(GameStateChanged event)
{ {
switch (event.getGameState()) switch (event.getGameState())
{ {
@@ -192,8 +213,7 @@ public class DiscordPlugin extends Plugin
checkForAreaUpdate(); checkForAreaUpdate();
} }
@Subscribe private void onConfigChanged(ConfigChanged event)
public void onConfigChanged(ConfigChanged event)
{ {
if (event.getGroup().equalsIgnoreCase("discord")) if (event.getGroup().equalsIgnoreCase("discord"))
{ {
@@ -205,8 +225,7 @@ public class DiscordPlugin extends Plugin
} }
} }
@Subscribe private void onExperienceChanged(ExperienceChanged event)
public void onExperienceChanged(ExperienceChanged event)
{ {
final int exp = client.getSkillExperience(event.getSkill()); final int exp = client.getSkillExperience(event.getSkill());
final Integer previous = skillExp.put(event.getSkill(), exp); final Integer previous = skillExp.put(event.getSkill(), exp);
@@ -224,8 +243,7 @@ public class DiscordPlugin extends Plugin
} }
} }
@Subscribe private void onVarbitChanged(VarbitChanged event)
public void onVarbitChanged(VarbitChanged event)
{ {
if (!this.showRaidingActivity) if (!this.showRaidingActivity)
{ {
@@ -240,14 +258,12 @@ public class DiscordPlugin extends Plugin
} }
} }
@Subscribe private void onDiscordReady(DiscordReady event)
public void onDiscordReady(DiscordReady event)
{ {
partyService.setUsername(event.getUsername() + "#" + event.getDiscriminator()); partyService.setUsername(event.getUsername() + "#" + event.getDiscriminator());
} }
@Subscribe private void onDiscordJoinRequest(DiscordJoinRequest request)
public void onDiscordJoinRequest(DiscordJoinRequest request)
{ {
log.debug("Got discord join request {}", request); log.debug("Got discord join request {}", request);
if (partyService.isOwner() && partyService.getMembers().isEmpty()) if (partyService.isOwner() && partyService.getMembers().isEmpty())
@@ -258,8 +274,7 @@ public class DiscordPlugin extends Plugin
} }
} }
@Subscribe private void onDiscordJoinGame(DiscordJoinGame joinGame)
public void onDiscordJoinGame(DiscordJoinGame joinGame)
{ {
log.debug("Got discord join game {}", joinGame); log.debug("Got discord join game {}", joinGame);
UUID partyId = UUID.fromString(joinGame.getJoinSecret()); UUID partyId = UUID.fromString(joinGame.getJoinSecret());
@@ -267,8 +282,7 @@ public class DiscordPlugin extends Plugin
updatePresence(); updatePresence();
} }
@Subscribe private void onDiscordUserInfo(final DiscordUserInfo event)
public void onDiscordUserInfo(final DiscordUserInfo event)
{ {
final PartyMember memberById = partyService.getMemberById(event.getMemberId()); final PartyMember memberById = partyService.getMemberById(event.getMemberId());
@@ -327,14 +341,12 @@ public class DiscordPlugin extends Plugin
}); });
} }
@Subscribe private void onUserJoin(final UserJoin event)
public void onUserJoin(final UserJoin event)
{ {
updatePresence(); updatePresence();
} }
@Subscribe private void onUserSync(final UserSync event)
public void onUserSync(final UserSync event)
{ {
final PartyMember localMember = partyService.getLocalMember(); final PartyMember localMember = partyService.getLocalMember();
@@ -349,14 +361,12 @@ public class DiscordPlugin extends Plugin
} }
} }
@Subscribe private void onUserPart(final UserPart event)
public void onUserPart(final UserPart event)
{ {
updatePresence(); updatePresence();
} }
@Subscribe private void onPartyChanged(final PartyChanged event)
public void onPartyChanged(final PartyChanged event)
{ {
updatePresence(); updatePresence();
} }

Some files were not shown because too many files have changed in this diff Show More