runelite-client: Make RuneLiteProperties fully static

This commit is contained in:
Max Weber
2019-08-07 02:58:57 -06:00
parent 3757c3bae6
commit 944064b1b5
9 changed files with 30 additions and 55 deletions

View File

@@ -73,8 +73,9 @@ public class Notifier
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 String appName = RuneLiteProperties.getTitle();
private final Client client;
private final String appName;
private final RuneLiteConfig runeLiteConfig;
private final ClientUI clientUI;
private final ScheduledExecutorService executorService;
@@ -89,12 +90,10 @@ public class Notifier
final ClientUI clientUI,
final Client client,
final RuneLiteConfig runeliteConfig,
final RuneLiteProperties runeLiteProperties,
final ScheduledExecutorService executorService,
final ChatMessageManager chatMessageManager)
{
this.client = client;
this.appName = runeLiteProperties.getTitle();
this.clientUI = clientUI;
this.runeLiteConfig = runeliteConfig;
this.executorService = executorService;

View File

@@ -75,7 +75,6 @@ public class RuneLiteModule extends AbstractModule
bind(ItemManager.class);
bind(Scheduler.class);
bind(PluginManager.class);
bind(RuneLiteProperties.class);
bind(SessionManager.class);
bind(Callbacks.class).to(Hooks.class);

View File

@@ -28,12 +28,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import javax.annotation.Nullable;
import javax.inject.Inject;
import javax.inject.Singleton;
import lombok.extern.slf4j.Slf4j;
@Singleton
@Slf4j
public class RuneLiteProperties
{
private static final String RUNELITE_TITLE = "runelite.title";
@@ -46,57 +41,56 @@ public class RuneLiteProperties
private static final String PATREON_LINK = "runelite.patreon.link";
private static final String LAUNCHER_VERSION_PROPERTY = "runelite.launcher.version";
private final Properties properties = new Properties();
private static final Properties properties = new Properties();
@Inject
public RuneLiteProperties()
static
{
try (InputStream in = getClass().getResourceAsStream("runelite.properties"))
try (InputStream in = RuneLiteProperties.class.getResourceAsStream("runelite.properties"))
{
properties.load(in);
}
catch (IOException ex)
{
log.warn("unable to load propertries", ex);
throw new RuntimeException(ex);
}
}
public String getTitle()
public static String getTitle()
{
return properties.getProperty(RUNELITE_TITLE);
}
public String getVersion()
public static String getVersion()
{
return properties.getProperty(RUNELITE_VERSION);
}
public String getRunescapeVersion()
public static String getRunescapeVersion()
{
return properties.getProperty(RUNESCAPE_VERSION);
}
public String getDiscordAppId()
public static String getDiscordAppId()
{
return properties.getProperty(DISCORD_APP_ID);
}
public String getDiscordInvite()
public static String getDiscordInvite()
{
return properties.getProperty(DISCORD_INVITE);
}
public String getGithubLink()
public static String getGithubLink()
{
return properties.getProperty(GITHUB_LINK);
}
public String getWikiLink()
public static String getWikiLink()
{
return properties.getProperty(WIKI_LINK);
}
public String getPatreonLink()
public static String getPatreonLink()
{
return properties.getProperty(PATREON_LINK);
}

View File

@@ -49,7 +49,6 @@ import net.runelite.discord.DiscordUser;
public class DiscordService implements AutoCloseable
{
private final EventBus eventBus;
private final RuneLiteProperties runeLiteProperties;
private final ScheduledExecutorService executorService;
private final DiscordRPC discordRPC;
@@ -62,12 +61,10 @@ public class DiscordService implements AutoCloseable
@Inject
private DiscordService(
final EventBus eventBus,
final RuneLiteProperties runeLiteProperties,
final ScheduledExecutorService executorService)
{
this.eventBus = eventBus;
this.runeLiteProperties = runeLiteProperties;
this.executorService = executorService;
DiscordRPC discordRPC = null;
@@ -106,7 +103,7 @@ public class DiscordService implements AutoCloseable
discordEventHandlers.joinGame = this::joinGame;
discordEventHandlers.spectateGame = this::spectateGame;
discordEventHandlers.joinRequest = this::joinRequest;
discordRPC.Discord_Initialize(runeLiteProperties.getDiscordAppId(), discordEventHandlers, true, null);
discordRPC.Discord_Initialize(RuneLiteProperties.getDiscordAppId(), discordEventHandlers, true, null);
executorService.scheduleAtFixedRate(discordRPC::Discord_RunCallbacks, 0, 2, TimeUnit.SECONDS);
}

View File

@@ -68,9 +68,6 @@ public class ChatNotificationsPlugin extends Plugin
@Inject
private Notifier notifier;
@Inject
private RuneLiteProperties runeLiteProperties;
//Custom Highlights
private Pattern usernameMatcher = null;
private String usernameReplacer = "";
@@ -148,7 +145,7 @@ public class ChatNotificationsPlugin extends Plugin
break;
case CONSOLE:
// Don't notify for notification messages
if (chatMessage.getName().equals(runeLiteProperties.getTitle()))
if (chatMessage.getName().equals(RuneLiteProperties.getTitle()))
{
return;
}

View File

@@ -91,9 +91,6 @@ public class DiscordPlugin extends Plugin
@Inject
private ClientToolbar clientToolbar;
@Inject
private RuneLiteProperties properties;
@Inject
private DiscordState discordState;
@@ -125,7 +122,7 @@ public class DiscordPlugin extends Plugin
.tab(false)
.tooltip("Join Discord")
.icon(icon)
.onClick(() -> LinkBrowser.browse(properties.getDiscordInvite()))
.onClick(() -> LinkBrowser.browse(RuneLiteProperties.getDiscordInvite()))
.build();
clientToolbar.addNavigation(discordButton);

View File

@@ -58,16 +58,14 @@ class DiscordState
private final DiscordService discordService;
private final DiscordConfig config;
private PartyService party;
private final RuneLiteProperties properties;
private DiscordPresence lastPresence;
@Inject
private DiscordState(final DiscordService discordService, final DiscordConfig config, final PartyService party, final RuneLiteProperties properties)
private DiscordState(final DiscordService discordService, final DiscordConfig config, final PartyService party)
{
this.discordService = discordService;
this.config = config;
this.party = party;
this.properties = properties;
}
/**
@@ -173,12 +171,12 @@ class DiscordState
}
// Replace snapshot with + to make tooltip shorter (so it will span only 1 line)
final String versionShortHand = properties.getVersion().replace("-SNAPSHOT", "+");
final String versionShortHand = RuneLiteProperties.getVersion().replace("-SNAPSHOT", "+");
final DiscordPresence.DiscordPresenceBuilder presenceBuilder = DiscordPresence.builder()
.state(MoreObjects.firstNonNull(state, ""))
.details(MoreObjects.firstNonNull(details, ""))
.largeImageText(properties.getTitle() + " v" + versionShortHand)
.largeImageText(RuneLiteProperties.getTitle() + " v" + versionShortHand)
.startTimestamp(event.getStart())
.smallImageKey(imageKey)
.partyMax(PARTY_MAX)

View File

@@ -79,9 +79,6 @@ public class InfoPanel extends PluginPanel
@Nullable
private Client client;
@Inject
private RuneLiteProperties runeLiteProperties;
@Inject
private EventBus eventBus;
@@ -117,7 +114,7 @@ public class InfoPanel extends PluginPanel
final Font smallFont = FontManager.getRunescapeSmallFont();
JLabel version = new JLabel(htmlLabel("RuneLite version: ", runeLiteProperties.getVersion()));
JLabel version = new JLabel(htmlLabel("RuneLite version: ", RuneLiteProperties.getVersion()));
version.setFont(smallFont);
JLabel revision = new JLabel();
@@ -176,10 +173,10 @@ public class InfoPanel extends PluginPanel
}
});
actionsContainer.add(buildLinkPanel(GITHUB_ICON, "Report an issue or", "make a suggestion", runeLiteProperties.getGithubLink()));
actionsContainer.add(buildLinkPanel(DISCORD_ICON, "Talk to us on our", "discord server", runeLiteProperties.getDiscordInvite()));
actionsContainer.add(buildLinkPanel(PATREON_ICON, "Become a patron to", "help support RuneLite", runeLiteProperties.getPatreonLink()));
actionsContainer.add(buildLinkPanel(WIKI_ICON, "Information about", "RuneLite and plugins", runeLiteProperties.getWikiLink()));
actionsContainer.add(buildLinkPanel(GITHUB_ICON, "Report an issue or", "make a suggestion", RuneLiteProperties.getGithubLink()));
actionsContainer.add(buildLinkPanel(DISCORD_ICON, "Talk to us on our", "discord server", RuneLiteProperties.getDiscordInvite()));
actionsContainer.add(buildLinkPanel(PATREON_ICON, "Become a patron to", "help support RuneLite", RuneLiteProperties.getPatreonLink()));
actionsContainer.add(buildLinkPanel(WIKI_ICON, "Information about", "RuneLite and plugins", RuneLiteProperties.getWikiLink()));
add(versionPanel, BorderLayout.NORTH);
add(actionsContainer, BorderLayout.CENTER);

View File

@@ -111,7 +111,6 @@ public class ClientUI
@Getter
private TrayIcon trayIcon;
private final RuneLiteProperties properties;
private final RuneLiteConfig config;
private final KeyManager keyManager;
private final MouseManager mouseManager;
@@ -138,7 +137,6 @@ public class ClientUI
@Inject
private ClientUI(
RuneLiteProperties properties,
RuneLiteConfig config,
KeyManager keyManager,
MouseManager mouseManager,
@@ -146,7 +144,6 @@ public class ClientUI
ConfigManager configManager,
Provider<ClientThread> clientThreadProvider)
{
this.properties = properties;
this.config = config;
this.keyManager = keyManager;
this.mouseManager = mouseManager;
@@ -286,7 +283,7 @@ public class ClientUI
return false;
}
frame.setTitle(properties.getTitle() + " - " + name);
frame.setTitle(RuneLiteProperties.getTitle() + " - " + name);
return true;
});
}
@@ -315,7 +312,7 @@ public class ClientUI
// Try to enable fullscreen on OSX
OSXUtil.tryEnableFullscreen(frame);
frame.setTitle(properties.getTitle());
frame.setTitle(RuneLiteProperties.getTitle());
frame.setIconImage(ICON);
frame.getLayeredPane().setCursor(Cursor.getDefaultCursor()); // Prevent substance from using a resize cursor for pointing
frame.setLocationRelativeTo(frame.getOwner());
@@ -464,7 +461,7 @@ public class ClientUI
frame.revalidateMinimumSize();
// Create tray icon (needs to be created after frame is packed)
trayIcon = SwingUtil.createTrayIcon(ICON, properties.getTitle(), frame);
trayIcon = SwingUtil.createTrayIcon(ICON, RuneLiteProperties.getTitle(), frame);
// Move frame around (needs to be done after frame is packed)
if (config.rememberScreenBounds())
@@ -844,12 +841,12 @@ public class ClientUI
if (player != null && player.getName() != null)
{
frame.setTitle(properties.getTitle() + " - " + player.getName());
frame.setTitle(RuneLiteProperties.getTitle() + " - " + player.getName());
}
}
else
{
frame.setTitle(properties.getTitle());
frame.setTitle(RuneLiteProperties.getTitle());
}
if (frame.isAlwaysOnTopSupported())