client: bind runelite.properties to guice

This commit is contained in:
Adam
2020-12-30 14:31:42 -05:00
parent 246b0f8a86
commit fd9626495b
14 changed files with 122 additions and 77 deletions

View File

@@ -45,6 +45,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import javax.inject.Named;
import javax.inject.Singleton; import javax.inject.Singleton;
import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem; import javax.sound.sampled.AudioSystem;
@@ -101,8 +102,6 @@ public class Notifier
private static final int MINIMUM_FLASH_DURATION_MILLIS = 2000; private static final int MINIMUM_FLASH_DURATION_MILLIS = 2000;
private static final int MINIMUM_FLASH_DURATION_TICKS = MINIMUM_FLASH_DURATION_MILLIS / Constants.CLIENT_TICK_LENGTH; private static final int MINIMUM_FLASH_DURATION_TICKS = MINIMUM_FLASH_DURATION_MILLIS / Constants.CLIENT_TICK_LENGTH;
private static final String appName = RuneLiteProperties.getTitle();
private static final File NOTIFICATION_FILE = new File(RuneLite.RUNELITE_DIR, "notification.wav"); private static final File NOTIFICATION_FILE = new File(RuneLite.RUNELITE_DIR, "notification.wav");
private static final long CLIP_MTIME_UNLOADED = -2; private static final long CLIP_MTIME_UNLOADED = -2;
private static final long CLIP_MTIME_BUILTIN = -1; private static final long CLIP_MTIME_BUILTIN = -1;
@@ -113,6 +112,7 @@ public class Notifier
private final ScheduledExecutorService executorService; private final ScheduledExecutorService executorService;
private final ChatMessageManager chatMessageManager; private final ChatMessageManager chatMessageManager;
private final EventBus eventBus; private final EventBus eventBus;
private final String appName;
private final Path notifyIconPath; private final Path notifyIconPath;
private boolean terminalNotifierAvailable; private boolean terminalNotifierAvailable;
private Instant flashStart; private Instant flashStart;
@@ -127,7 +127,9 @@ public class Notifier
final RuneLiteConfig runeliteConfig, final RuneLiteConfig runeliteConfig,
final ScheduledExecutorService executorService, final ScheduledExecutorService executorService,
final ChatMessageManager chatMessageManager, final ChatMessageManager chatMessageManager,
final EventBus eventBus) final EventBus eventBus,
@Named("runelite.title") final String appName
)
{ {
this.client = client; this.client = client;
this.clientUI = clientUI; this.clientUI = clientUI;
@@ -135,6 +137,7 @@ public class Notifier
this.executorService = executorService; this.executorService = executorService;
this.chatMessageManager = chatMessageManager; this.chatMessageManager = chatMessageManager;
this.eventBus = eventBus; this.eventBus = eventBus;
this.appName = appName;
this.notifyIconPath = RuneLite.RUNELITE_DIR.toPath().resolve("icon.png"); this.notifyIconPath = RuneLite.RUNELITE_DIR.toPath().resolve("icon.png");
// First check if we are running in launcher // First check if we are running in launcher

View File

@@ -29,6 +29,7 @@ import com.google.inject.Provides;
import com.google.inject.name.Names; import com.google.inject.name.Names;
import java.applet.Applet; import java.applet.Applet;
import java.io.File; import java.io.File;
import java.util.Properties;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import java.util.function.Supplier; import java.util.function.Supplier;
@@ -66,6 +67,12 @@ public class RuneLiteModule extends AbstractModule
@Override @Override
protected void configure() protected void configure()
{ {
Properties properties = RuneLiteProperties.getProperties();
for (String key : properties.stringPropertyNames())
{
String value = properties.getProperty(key);
bindConstant().annotatedWith(Names.named(key)).to(value);
}
bindConstant().annotatedWith(Names.named("developerMode")).to(developerMode); bindConstant().annotatedWith(Names.named("developerMode")).to(developerMode);
bindConstant().annotatedWith(Names.named("safeMode")).to(safeMode); bindConstant().annotatedWith(Names.named("safeMode")).to(safeMode);
bind(File.class).annotatedWith(Names.named("sessionfile")).toInstance(sessionfile); bind(File.class).annotatedWith(Names.named("sessionfile")).toInstance(sessionfile);

View File

@@ -28,18 +28,14 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.Properties; import java.util.Properties;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import lombok.AccessLevel;
import lombok.Getter;
import okhttp3.HttpUrl; import okhttp3.HttpUrl;
public class RuneLiteProperties public class RuneLiteProperties
{ {
private static final String RUNELITE_TITLE = "runelite.title";
private static final String RUNELITE_VERSION = "runelite.version"; private static final String RUNELITE_VERSION = "runelite.version";
private static final String RUNESCAPE_VERSION = "runescape.version";
private static final String DISCORD_APP_ID = "runelite.discord.appid";
private static final String DISCORD_INVITE = "runelite.discord.invite"; private static final String DISCORD_INVITE = "runelite.discord.invite";
private static final String GITHUB_LINK = "runelite.github.link";
private static final String WIKI_LINK = "runelite.wiki.link";
private static final String PATREON_LINK = "runelite.patreon.link";
private static final String LAUNCHER_VERSION_PROPERTY = "runelite.launcher.version"; private static final String LAUNCHER_VERSION_PROPERTY = "runelite.launcher.version";
private static final String INSECURE_SKIP_TLS_VERIFICATION_PROPERTY = "runelite.insecure-skip-tls-verification"; private static final String INSECURE_SKIP_TLS_VERIFICATION_PROPERTY = "runelite.insecure-skip-tls-verification";
private static final String TROUBLESHOOTING_LINK = "runelite.wiki.troubleshooting.link"; private static final String TROUBLESHOOTING_LINK = "runelite.wiki.troubleshooting.link";
@@ -49,8 +45,8 @@ public class RuneLiteProperties
private static final String JAV_CONFIG_BACKUP = "runelite.jav_config_backup"; private static final String JAV_CONFIG_BACKUP = "runelite.jav_config_backup";
private static final String PLUGINHUB_BASE = "runelite.pluginhub.url"; private static final String PLUGINHUB_BASE = "runelite.pluginhub.url";
private static final String PLUGINHUB_VERSION = "runelite.pluginhub.version"; private static final String PLUGINHUB_VERSION = "runelite.pluginhub.version";
private static final String IMGUR_CLIENT_ID = "runelite.imgur.client.id";
@Getter(AccessLevel.PACKAGE)
private static final Properties properties = new Properties(); private static final Properties properties = new Properties();
static static
@@ -65,46 +61,16 @@ public class RuneLiteProperties
} }
} }
public static String getTitle()
{
return properties.getProperty(RUNELITE_TITLE);
}
public static String getVersion() public static String getVersion()
{ {
return properties.getProperty(RUNELITE_VERSION); return properties.getProperty(RUNELITE_VERSION);
} }
public static String getRunescapeVersion()
{
return properties.getProperty(RUNESCAPE_VERSION);
}
public static String getDiscordAppId()
{
return properties.getProperty(DISCORD_APP_ID);
}
public static String getDiscordInvite() public static String getDiscordInvite()
{ {
return properties.getProperty(DISCORD_INVITE); return properties.getProperty(DISCORD_INVITE);
} }
public static String getGithubLink()
{
return properties.getProperty(GITHUB_LINK);
}
public static String getWikiLink()
{
return properties.getProperty(WIKI_LINK);
}
public static String getPatreonLink()
{
return properties.getProperty(PATREON_LINK);
}
@Nullable @Nullable
public static String getLauncherVersion() public static String getLauncherVersion()
{ {
@@ -146,9 +112,4 @@ public class RuneLiteProperties
String version = System.getProperty(PLUGINHUB_VERSION, properties.getProperty(PLUGINHUB_VERSION)); String version = System.getProperty(PLUGINHUB_VERSION, properties.getProperty(PLUGINHUB_VERSION));
return HttpUrl.parse(properties.get(PLUGINHUB_BASE) + "/" + version); return HttpUrl.parse(properties.get(PLUGINHUB_BASE) + "/" + version);
} }
public static String getImgurClientId()
{
return properties.getProperty(IMGUR_CLIENT_ID);
}
} }

View File

@@ -28,10 +28,10 @@ import com.google.common.base.Strings;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton; import javax.inject.Singleton;
import lombok.Getter; import lombok.Getter;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.runelite.client.RuneLiteProperties;
import net.runelite.client.discord.events.DiscordDisconnected; import net.runelite.client.discord.events.DiscordDisconnected;
import net.runelite.client.discord.events.DiscordErrored; import net.runelite.client.discord.events.DiscordErrored;
import net.runelite.client.discord.events.DiscordJoinGame; import net.runelite.client.discord.events.DiscordJoinGame;
@@ -50,6 +50,7 @@ public class DiscordService implements AutoCloseable
{ {
private final EventBus eventBus; private final EventBus eventBus;
private final ScheduledExecutorService executorService; private final ScheduledExecutorService executorService;
private final String discordAppId;
private final DiscordRPC discordRPC; private final DiscordRPC discordRPC;
// Hold a reference to the event handlers to prevent the garbage collector from deleting them // Hold a reference to the event handlers to prevent the garbage collector from deleting them
@@ -61,11 +62,14 @@ public class DiscordService implements AutoCloseable
@Inject @Inject
private DiscordService( private DiscordService(
final EventBus eventBus, final EventBus eventBus,
final ScheduledExecutorService executorService) final ScheduledExecutorService executorService,
@Named("runelite.discord.appid") final String discordAppId
)
{ {
this.eventBus = eventBus; this.eventBus = eventBus;
this.executorService = executorService; this.executorService = executorService;
this.discordAppId = discordAppId;
DiscordRPC discordRPC = null; DiscordRPC discordRPC = null;
DiscordEventHandlers discordEventHandlers = null; DiscordEventHandlers discordEventHandlers = null;
@@ -103,7 +107,7 @@ public class DiscordService implements AutoCloseable
discordEventHandlers.joinGame = this::joinGame; discordEventHandlers.joinGame = this::joinGame;
discordEventHandlers.spectateGame = this::spectateGame; discordEventHandlers.spectateGame = this::spectateGame;
discordEventHandlers.joinRequest = this::joinRequest; discordEventHandlers.joinRequest = this::joinRequest;
discordRPC.Discord_Initialize(RuneLiteProperties.getDiscordAppId(), discordEventHandlers, true, null); discordRPC.Discord_Initialize(discordAppId, discordEventHandlers, true, null);
executorService.scheduleAtFixedRate(discordRPC::Discord_RunCallbacks, 0, 2, TimeUnit.SECONDS); executorService.scheduleAtFixedRate(discordRPC::Discord_RunCallbacks, 0, 2, TimeUnit.SECONDS);
} }

View File

@@ -34,13 +34,13 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named;
import net.runelite.api.ChatMessageType; import net.runelite.api.ChatMessageType;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.MessageNode; import net.runelite.api.MessageNode;
import net.runelite.api.events.ChatMessage; import net.runelite.api.events.ChatMessage;
import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.GameStateChanged;
import net.runelite.client.Notifier; import net.runelite.client.Notifier;
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;
@@ -70,6 +70,10 @@ public class ChatNotificationsPlugin extends Plugin
@Inject @Inject
private Notifier notifier; private Notifier notifier;
@Inject
@Named("runelite.title")
private String runeliteTitle;
//Custom Highlights //Custom Highlights
private Pattern usernameMatcher = null; private Pattern usernameMatcher = null;
private String usernameReplacer = ""; private String usernameReplacer = "";
@@ -163,7 +167,7 @@ public class ChatNotificationsPlugin extends Plugin
break; break;
case CONSOLE: case CONSOLE:
// Don't notify for notification messages // Don't notify for notification messages
if (chatMessage.getName().equals(RuneLiteProperties.getTitle())) if (chatMessage.getName().equals(runeliteTitle))
{ {
return; return;
} }

View File

@@ -37,6 +37,7 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import javax.inject.Named;
import lombok.extern.slf4j.Slf4j; 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;
@@ -46,7 +47,6 @@ import net.runelite.api.coords.WorldPoint;
import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.GameStateChanged;
import net.runelite.api.events.StatChanged; import net.runelite.api.events.StatChanged;
import net.runelite.api.events.VarbitChanged; import net.runelite.api.events.VarbitChanged;
import net.runelite.client.RuneLiteProperties;
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.discord.events.DiscordJoinGame; import net.runelite.client.discord.events.DiscordJoinGame;
@@ -106,6 +106,10 @@ public class DiscordPlugin extends Plugin
@Inject @Inject
private OkHttpClient okHttpClient; private OkHttpClient okHttpClient;
@Inject
@Named("runelite.discord.invite")
private String discordInvite;
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;
@@ -125,7 +129,7 @@ public class DiscordPlugin extends Plugin
.tab(false) .tab(false)
.tooltip("Join Discord") .tooltip("Join Discord")
.icon(icon) .icon(icon)
.onClick(() -> LinkBrowser.browse(RuneLiteProperties.getDiscordInvite())) .onClick(() -> LinkBrowser.browse(discordInvite))
.build(); .build();
clientToolbar.addNavigation(discordButton); clientToolbar.addNavigation(discordButton);

View File

@@ -35,8 +35,8 @@ import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named;
import lombok.Data; import lombok.Data;
import net.runelite.client.RuneLiteProperties;
import net.runelite.client.discord.DiscordPresence; import net.runelite.client.discord.DiscordPresence;
import net.runelite.client.discord.DiscordService; import net.runelite.client.discord.DiscordService;
import net.runelite.client.ws.PartyService; import net.runelite.client.ws.PartyService;
@@ -60,14 +60,24 @@ class DiscordState
private final DiscordService discordService; private final DiscordService discordService;
private final DiscordConfig config; private final DiscordConfig config;
private final PartyService party; private final PartyService party;
private final String runeliteTitle;
private final String runeliteVersion;
private DiscordPresence lastPresence; private DiscordPresence lastPresence;
@Inject @Inject
private DiscordState(final DiscordService discordService, final DiscordConfig config, final PartyService party) private DiscordState(
final DiscordService discordService,
final DiscordConfig config,
final PartyService party,
@Named("runelite.title") final String runeliteTitle,
@Named("runelite.version") final String runeliteVersion
)
{ {
this.discordService = discordService; this.discordService = discordService;
this.config = config; this.config = config;
this.party = party; this.party = party;
this.runeliteTitle = runeliteTitle;
this.runeliteVersion = runeliteVersion;
} }
/** /**
@@ -188,12 +198,12 @@ class DiscordState
} }
// Replace snapshot with + to make tooltip shorter (so it will span only 1 line) // Replace snapshot with + to make tooltip shorter (so it will span only 1 line)
final String versionShortHand = RuneLiteProperties.getVersion().replace("-SNAPSHOT", "+"); final String versionShortHand = runeliteVersion.replace("-SNAPSHOT", "+");
final DiscordPresence.DiscordPresenceBuilder presenceBuilder = DiscordPresence.builder() final DiscordPresence.DiscordPresenceBuilder presenceBuilder = DiscordPresence.builder()
.state(MoreObjects.firstNonNull(state, "")) .state(MoreObjects.firstNonNull(state, ""))
.details(MoreObjects.firstNonNull(details, "")) .details(MoreObjects.firstNonNull(details, ""))
.largeImageText(RuneLiteProperties.getTitle() + " v" + versionShortHand) .largeImageText(runeliteTitle + " v" + versionShortHand)
.smallImageKey(imageKey) .smallImageKey(imageKey)
.partyMax(PARTY_MAX) .partyMax(PARTY_MAX)
.partySize(party.getMembers().size()); .partySize(party.getMembers().size());

View File

@@ -36,6 +36,7 @@ import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import javax.inject.Named;
import javax.inject.Singleton; import javax.inject.Singleton;
import javax.swing.Box; import javax.swing.Box;
import javax.swing.ImageIcon; import javax.swing.ImageIcon;
@@ -91,6 +92,26 @@ public class InfoPanel extends PluginPanel
@Inject @Inject
private ConfigManager configManager; private ConfigManager configManager;
@Inject
@Named("runelite.version")
private String runeliteVersion;
@Inject
@Named("runelite.github.link")
private String githubLink;
@Inject
@Named("runelite.discord.invite")
private String discordInvite;
@Inject
@Named("runelite.patreon.link")
private String patreonLink;
@Inject
@Named("runelite.wiki.link")
private String wikiLink;
static static
{ {
ARROW_RIGHT_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(InfoPanel.class, "/util/arrow_right.png")); ARROW_RIGHT_ICON = new ImageIcon(ImageUtil.getResourceStreamFromClass(InfoPanel.class, "/util/arrow_right.png"));
@@ -114,7 +135,7 @@ public class InfoPanel extends PluginPanel
final Font smallFont = FontManager.getRunescapeSmallFont(); final Font smallFont = FontManager.getRunescapeSmallFont();
JLabel version = new JLabel(htmlLabel("RuneLite version: ", RuneLiteProperties.getVersion())); JLabel version = new JLabel(htmlLabel("RuneLite version: ", runeliteVersion));
version.setFont(smallFont); version.setFont(smallFont);
JLabel revision = new JLabel(); JLabel revision = new JLabel();
@@ -173,10 +194,10 @@ public class InfoPanel extends PluginPanel
} }
}); });
actionsContainer.add(buildLinkPanel(GITHUB_ICON, "Report an issue or", "make a suggestion", RuneLiteProperties.getGithubLink())); actionsContainer.add(buildLinkPanel(GITHUB_ICON, "Report an issue or", "make a suggestion", githubLink));
actionsContainer.add(buildLinkPanel(DISCORD_ICON, "Talk to us on our", "Discord server", RuneLiteProperties.getDiscordInvite())); actionsContainer.add(buildLinkPanel(DISCORD_ICON, "Talk to us on our", "Discord server", discordInvite));
actionsContainer.add(buildLinkPanel(PATREON_ICON, "Become a patron to", "help support RuneLite", RuneLiteProperties.getPatreonLink())); actionsContainer.add(buildLinkPanel(PATREON_ICON, "Become a patron to", "help support RuneLite", patreonLink));
actionsContainer.add(buildLinkPanel(WIKI_ICON, "Information about", "RuneLite and plugins", RuneLiteProperties.getWikiLink())); actionsContainer.add(buildLinkPanel(WIKI_ICON, "Information about", "RuneLite and plugins", wikiLink));
add(versionPanel, BorderLayout.NORTH); add(versionPanel, BorderLayout.NORTH);
add(actionsContainer, BorderLayout.CENTER); add(actionsContainer, BorderLayout.CENTER);

View File

@@ -71,7 +71,6 @@ import net.runelite.api.Point;
import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.GameStateChanged;
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.RuneLiteProperties;
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.config.ExpandResizeType; import net.runelite.client.config.ExpandResizeType;
@@ -122,6 +121,7 @@ public class ClientUI
private final Provider<ClientThread> clientThreadProvider; private final Provider<ClientThread> clientThreadProvider;
private final EventBus eventBus; private final EventBus eventBus;
private final boolean safeMode; private final boolean safeMode;
private final String title;
private final CardLayout cardLayout = new CardLayout(); private final CardLayout cardLayout = new CardLayout();
private final Rectangle sidebarButtonPosition = new Rectangle(); private final Rectangle sidebarButtonPosition = new Rectangle();
@@ -151,7 +151,9 @@ public class ClientUI
ConfigManager configManager, ConfigManager configManager,
Provider<ClientThread> clientThreadProvider, Provider<ClientThread> clientThreadProvider,
EventBus eventBus, EventBus eventBus,
@Named("safeMode") boolean safeMode) @Named("safeMode") boolean safeMode,
@Named("runelite.title") String title
)
{ {
this.config = config; this.config = config;
this.keyManager = keyManager; this.keyManager = keyManager;
@@ -161,6 +163,7 @@ public class ClientUI
this.clientThreadProvider = clientThreadProvider; this.clientThreadProvider = clientThreadProvider;
this.eventBus = eventBus; this.eventBus = eventBus;
this.safeMode = safeMode; this.safeMode = safeMode;
this.title = title;
} }
@Subscribe @Subscribe
@@ -293,7 +296,7 @@ public class ClientUI
return false; return false;
} }
frame.setTitle(RuneLiteProperties.getTitle() + " - " + name); frame.setTitle(title + " - " + name);
return true; return true;
}); });
} }
@@ -320,7 +323,7 @@ public class ClientUI
// Try to enable fullscreen on OSX // Try to enable fullscreen on OSX
OSXUtil.tryEnableFullscreen(frame); OSXUtil.tryEnableFullscreen(frame);
frame.setTitle(RuneLiteProperties.getTitle()); frame.setTitle(title);
frame.setIconImage(ICON); frame.setIconImage(ICON);
frame.getLayeredPane().setCursor(Cursor.getDefaultCursor()); // Prevent substance from using a resize cursor for pointing frame.getLayeredPane().setCursor(Cursor.getDefaultCursor()); // Prevent substance from using a resize cursor for pointing
frame.setLocationRelativeTo(frame.getOwner()); frame.setLocationRelativeTo(frame.getOwner());
@@ -506,7 +509,7 @@ public class ClientUI
frame.revalidateMinimumSize(); frame.revalidateMinimumSize();
// Create tray icon (needs to be created after frame is packed) // Create tray icon (needs to be created after frame is packed)
trayIcon = SwingUtil.createTrayIcon(ICON, RuneLiteProperties.getTitle(), frame); trayIcon = SwingUtil.createTrayIcon(ICON, title, frame);
// Move frame around (needs to be done after frame is packed) // Move frame around (needs to be done after frame is packed)
if (config.rememberScreenBounds() && !safeMode) if (config.rememberScreenBounds() && !safeMode)
@@ -1033,12 +1036,12 @@ public class ClientUI
if (player != null && player.getName() != null) if (player != null && player.getName() != null)
{ {
frame.setTitle(RuneLiteProperties.getTitle() + " - " + player.getName()); frame.setTitle(title + " - " + player.getName());
} }
} }
else else
{ {
frame.setTitle(RuneLiteProperties.getTitle()); frame.setTitle(title);
} }
if (frame.isAlwaysOnTopSupported()) if (frame.isAlwaysOnTopSupported())

View File

@@ -45,6 +45,7 @@ import java.util.EnumSet;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton; import javax.inject.Singleton;
import lombok.Data; import lombok.Data;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -53,7 +54,6 @@ import net.runelite.api.GameState;
import net.runelite.api.WorldType; import net.runelite.api.WorldType;
import net.runelite.client.Notifier; import net.runelite.client.Notifier;
import static net.runelite.client.RuneLite.SCREENSHOT_DIR; import static net.runelite.client.RuneLite.SCREENSHOT_DIR;
import net.runelite.client.RuneLiteProperties;
import net.runelite.http.api.RuneLiteAPI; import net.runelite.http.api.RuneLiteAPI;
import okhttp3.Call; import okhttp3.Call;
import okhttp3.Callback; import okhttp3.Callback;
@@ -72,14 +72,24 @@ public class ImageCapture
private static final HttpUrl IMGUR_IMAGE_UPLOAD_URL = HttpUrl.parse("https://api.imgur.com/3/image"); private static final HttpUrl IMGUR_IMAGE_UPLOAD_URL = HttpUrl.parse("https://api.imgur.com/3/image");
private static final MediaType JSON = MediaType.parse("application/json"); private static final MediaType JSON = MediaType.parse("application/json");
@Inject private final Client client;
private Client client; private final Notifier notifier;
private final OkHttpClient okHttpClient;
private final String imgurClientId;
@Inject @Inject
private Notifier notifier; private ImageCapture(
final Client client,
@Inject final Notifier notifier,
private OkHttpClient okHttpClient; final OkHttpClient okHttpClient,
@Named("runelite.imgur.client.id") final String imgurClientId
)
{
this.client = client;
this.notifier = notifier;
this.okHttpClient = okHttpClient;
this.imgurClientId = imgurClientId;
}
/** /**
* Saves a screenshot of the client window to the screenshot folder as a PNG, * Saves a screenshot of the client window to the screenshot folder as a PNG,
@@ -198,7 +208,7 @@ public class ImageCapture
Request request = new Request.Builder() Request request = new Request.Builder()
.url(IMGUR_IMAGE_UPLOAD_URL) .url(IMGUR_IMAGE_UPLOAD_URL)
.addHeader("Authorization", "Client-ID " + RuneLiteProperties.getImgurClientId()) .addHeader("Authorization", "Client-ID " + imgurClientId)
.post(RequestBody.create(JSON, json)) .post(RequestBody.create(JSON, json))
.build(); .build();

View File

@@ -1,6 +1,5 @@
runelite.title=RuneLite runelite.title=RuneLite
runelite.version=${project.version} runelite.version=${project.version}
runescape.version=${rs.version}
runelite.discord.appid=409416265891971072 runelite.discord.appid=409416265891971072
runelite.discord.invite=https://discord.gg/R4BQ8tU runelite.discord.invite=https://discord.gg/R4BQ8tU
runelite.github.link=https://github.com/runelite runelite.github.link=https://github.com/runelite

View File

@@ -30,6 +30,7 @@ import com.google.inject.testing.fieldbinder.BoundFieldModule;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named;
import net.runelite.api.ChatMessageType; import net.runelite.api.ChatMessageType;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.MessageNode; import net.runelite.api.MessageNode;
@@ -67,6 +68,10 @@ public class ChatNotificationsPluginTest
@Bind @Bind
private Notifier notifier; private Notifier notifier;
@Bind
@Named("runelite.title")
private String runeliteTitle = "RuneLite";
@Inject @Inject
private ChatNotificationsPlugin chatNotificationsPlugin; private ChatNotificationsPlugin chatNotificationsPlugin;

View File

@@ -31,6 +31,7 @@ import java.nio.charset.StandardCharsets;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.client.discord.DiscordPresence; import net.runelite.client.discord.DiscordPresence;
import net.runelite.client.discord.DiscordService; import net.runelite.client.discord.DiscordService;
@@ -70,6 +71,14 @@ public class DiscordStateTest
@Bind @Bind
PartyService partyService; PartyService partyService;
@Bind
@Named("runelite.title")
private String runeliteTitle = "RuneLite";
@Bind
@Named("runelite.version")
private String runeliteVersion = "version";
@Before @Before
public void before() public void before()
{ {

View File

@@ -46,6 +46,7 @@ import net.runelite.client.ui.ClientUI;
import net.runelite.client.ui.DrawManager; import net.runelite.client.ui.DrawManager;
import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.ui.overlay.OverlayManager;
import net.runelite.client.ui.overlay.infobox.InfoBoxManager; import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
import net.runelite.client.util.ImageCapture;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@@ -110,6 +111,10 @@ public class ScreenshotPluginTest
@Bind @Bind
private InfoBoxManager infoBoxManager; private InfoBoxManager infoBoxManager;
@Mock
@Bind
private ImageCapture imageCapture;
@Before @Before
public void before() public void before()
{ {