project: Add modernizer

This commit is contained in:
Owain van Brakel
2020-04-08 15:16:38 +02:00
parent 3c6e2b057b
commit 05513a6bed
14 changed files with 36 additions and 34 deletions

View File

@@ -29,6 +29,7 @@ import org.ajoberstar.grgit.Grgit
buildscript {
repositories {
gradlePluginPortal()
mavenLocal()
maven(url = "https://raw.githubusercontent.com/open-osrs/hosting/master")
}
dependencies {
@@ -43,6 +44,7 @@ plugins {
id(Plugins.versions.first) version Plugins.versions.second
id(Plugins.latestVersion.first) version Plugins.latestVersion.second
id(Plugins.grgit.first) version Plugins.grgit.second
id("com.simonharrer.modernizer") version "1.8.0-1" apply false
application
}
@@ -112,6 +114,9 @@ subprojects {
isIgnoreFailures = false
}
}
if (this.name == "runelite-client" || this.name == "runelite-api") {
apply(plugin = "com.simonharrer.modernizer")
}
configure<PublishingExtension> {
repositories {

View File

@@ -27,7 +27,6 @@ package net.runelite.client.chat;
import com.google.common.base.MoreObjects;
import com.google.common.base.Strings;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Multimap;
import java.awt.Color;
import java.util.Arrays;
@@ -59,7 +58,7 @@ import net.runelite.client.util.ColorUtil;
@Singleton
public class ChatMessageManager
{
private static final Set<Integer> TUTORIAL_ISLAND_REGIONS = ImmutableSet.of(12336, 12335, 12592, 12080, 12079, 12436);
private static final Set<Integer> TUTORIAL_ISLAND_REGIONS = Set.of(12336, 12335, 12592, 12080, 12079, 12436);
private final Multimap<ChatMessageType, ChatColor> colorCache = HashMultimap.create();
private final Client client;
@@ -593,7 +592,7 @@ public class ChatMessageManager
// Update the message with RuneLite additions
line.setRuneLiteFormatMessage(message.getRuneLiteFormattedMessage());
if (message.getTimestamp() != 0)
{
line.setTimestamp(message.getTimestamp());

View File

@@ -26,7 +26,6 @@ package net.runelite.client.config;
import com.google.common.base.Strings;
import com.google.common.collect.ComparisonChain;
import com.google.common.collect.ImmutableMap;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Point;
@@ -384,7 +383,7 @@ public class ConfigManager
return;
}
@SuppressWarnings("unchecked") final Map<String, String> copy = (Map) ImmutableMap.copyOf(this.properties);
@SuppressWarnings("unchecked") final Map<String, String> copy = (Map) Map.copyOf(this.properties);
copy.forEach((groupAndKey, value) ->
{
if (!properties.containsKey(groupAndKey))
@@ -443,7 +442,7 @@ public class ConfigManager
try
{
@SuppressWarnings("unchecked") Map<String, String> copy = (Map) ImmutableMap.copyOf(properties);
@SuppressWarnings("unchecked") Map<String, String> copy = (Map) Map.copyOf(properties);
copy.forEach((groupAndKey, value) ->
{
final String[] split = groupAndKey.split("\\.", 2);

View File

@@ -137,7 +137,7 @@ public class ItemManager
private final LoadingCache<Integer, ItemDefinition> itemDefinitions;
private final LoadingCache<OutlineKey, BufferedImage> itemOutlines;
private Map<Integer, ItemPrice> itemPrices = Collections.emptyMap();
private ImmutableMap<Integer, ItemStats> itemStats = ImmutableMap.of();
private Map<Integer, ItemStats> itemStats = Map.of();
@Inject
public ItemManager(

View File

@@ -88,7 +88,7 @@ public class ChatboxTextInput extends ChatboxInput implements KeyListener, Mouse
@Getter
private int lines;
private StringBuffer value = new StringBuffer();
private StringBuilder value = new StringBuilder();
@Getter
private int cursorStart = 0;
@@ -157,7 +157,7 @@ public class ChatboxTextInput extends ChatboxInput implements KeyListener, Mouse
public ChatboxTextInput value(String value)
{
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
for (char c : value.toCharArray())
{
if (charValidator.test(c))

View File

@@ -25,7 +25,6 @@
*/
package net.runelite.client.menus;
import com.google.common.base.Preconditions;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
@@ -39,6 +38,7 @@ import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
@@ -327,7 +327,7 @@ public class MenuManager
public void addPlayerMenuItem(String menuText)
{
Preconditions.checkNotNull(menuText);
Objects.requireNonNull(menuText);
int playerMenuIndex = findEmptyPlayerMenuIndex();
if (playerMenuIndex == IDX_UPPER)
@@ -340,7 +340,8 @@ public class MenuManager
public void removePlayerMenuItem(String menuText)
{
Preconditions.checkNotNull(menuText);
Objects.requireNonNull(menuText);
for (Map.Entry<Integer, String> entry : playerMenuIndexMap.entrySet())
{
if (entry.getValue().equalsIgnoreCase(menuText))

View File

@@ -24,7 +24,6 @@
*/
package net.runelite.client.plugins;
import com.google.common.collect.ImmutableList;
import com.google.inject.Binder;
import com.google.inject.CreationException;
import com.google.inject.Injector;
@@ -913,7 +912,7 @@ public class ExternalPluginManager
private Path stopPlugin(String pluginId)
{
List<PluginWrapper> startedPlugins = ImmutableList.copyOf(getStartedPlugins());
List<PluginWrapper> startedPlugins = List.copyOf(getStartedPlugins());
for (PluginWrapper pluginWrapper : startedPlugins)
{
@@ -1138,7 +1137,7 @@ public class ExternalPluginManager
externalPluginManager.loadPlugins();
externalPluginManager.startPlugin(pluginId);
List<PluginWrapper> startedPlugins = ImmutableList.copyOf(getStartedPlugins());
List<PluginWrapper> startedPlugins = List.copyOf(getStartedPlugins());
List<Plugin> scannedPlugins = new ArrayList<>();
for (PluginWrapper pluginWrapper : startedPlugins)
@@ -1181,7 +1180,7 @@ public class ExternalPluginManager
externalPluginManager.loadPlugins();
externalPluginManager.startPlugin(pluginId);
List<PluginWrapper> startedPlugins = ImmutableList.copyOf(getStartedPlugins());
List<PluginWrapper> startedPlugins = List.copyOf(getStartedPlugins());
List<Plugin> scannedPlugins = new ArrayList<>();
for (PluginWrapper pluginWrapper : startedPlugins)

View File

@@ -24,7 +24,6 @@
*/
package net.runelite.client.plugins.config;
import com.google.common.collect.ImmutableList;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
@@ -105,7 +104,7 @@ public class PluginListPanel extends PluginPanel
private static final String PINNED_PLUGINS_CONFIG_KEY = "pinnedPlugins";
private static final List<String> colorOptions = Arrays.asList("enabledColors", "pvmColor", "pvpColor", "skillingColor", "utilityColor", "minigameColor", "miscellaneousColor", "gamemodeColor");
private static final ImmutableList<PluginType> definedOrder = ImmutableList.of(PluginType.IMPORTANT, PluginType.PVM, PluginType.SKILLING, PluginType.PVP, PluginType.UTILITY, PluginType.MINIGAME, PluginType.MISCELLANEOUS, PluginType.GAMEMODE, PluginType.EXTERNAL, PluginType.UNCATEGORIZED);
private static final List<PluginType> definedOrder = List.of(PluginType.IMPORTANT, PluginType.PVM, PluginType.SKILLING, PluginType.PVP, PluginType.UTILITY, PluginType.MINIGAME, PluginType.MISCELLANEOUS, PluginType.GAMEMODE, PluginType.EXTERNAL, PluginType.UNCATEGORIZED);
private static final Comparator<PluginListItem> categoryComparator = Comparator.comparing(plugin -> definedOrder.indexOf(plugin.getPluginType()));
private final ConfigManager configManager;

View File

@@ -24,7 +24,6 @@
*/
package net.runelite.client.ui.overlay.infobox;
import com.google.common.base.Preconditions;
import com.google.common.collect.ComparisonChain;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
@@ -32,6 +31,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.function.Predicate;
import javax.inject.Inject;
import javax.inject.Singleton;
@@ -67,7 +67,7 @@ public class InfoBoxManager
public void addInfoBox(InfoBox infoBox)
{
Preconditions.checkNotNull(infoBox);
Objects.requireNonNull(infoBox);
log.debug("Adding InfoBox {}", infoBox);
updateInfoBoxImage(infoBox);

View File

@@ -34,23 +34,23 @@ public class WildcardMatcher
public static boolean matches(String pattern, String text)
{
final Matcher matcher = WILDCARD_PATTERN.matcher(pattern);
final StringBuffer buffer = new StringBuffer();
final StringBuilder sb = new StringBuilder();
buffer.append("(?i)");
sb.append("(?i)");
while (matcher.find())
{
if (matcher.group(1) != null)
{
matcher.appendReplacement(buffer, ".*");
matcher.appendReplacement(sb, ".*");
}
else
{
matcher.appendReplacement(buffer, "\\\\Q" + matcher.group(0) + "\\\\E");
matcher.appendReplacement(sb, "\\\\Q" + matcher.group(0) + "\\\\E");
}
}
matcher.appendTail(buffer);
final String replaced = buffer.toString();
matcher.appendTail(sb);
final String replaced = sb.toString();
return text.matches(replaced);
}

View File

@@ -40,6 +40,7 @@ import java.io.IOException;
import java.io.PrintWriter;
import java.lang.invoke.MethodHandles;
import java.lang.reflect.Method;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
@@ -150,7 +151,7 @@ public class PluginManagerTest
modules.addAll(pluginManager.getPlugins());
File file = folder.newFile();
try (PrintWriter out = new PrintWriter(file, "UTF-8"))
try (PrintWriter out = new PrintWriter(file, StandardCharsets.UTF_8))
{
Injector injector = Guice.createInjector(modules);
GraphvizGrapher grapher = injector.getInstance(GraphvizGrapher.class);

View File

@@ -24,11 +24,11 @@
*/
package net.runelite.client.rs;
import com.google.common.base.Charsets;
import com.google.common.io.CharStreams;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
import org.junit.After;
@@ -47,7 +47,7 @@ public class ClientConfigLoaderTest
try (InputStream in = getClass().getResourceAsStream("jav_config.ws"))
{
response = CharStreams.toString(new InputStreamReader(
in, Charsets.UTF_8));
in, StandardCharsets.UTF_8));
}
server.enqueue(new MockResponse().setBody(response));

View File

@@ -24,7 +24,6 @@
*/
package net.runelite.client.util;
import com.google.common.collect.ImmutableSet;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@@ -43,9 +42,9 @@ import static org.mockito.Mockito.when;
public class ItemUtilTest
{
private static final Set<Integer> SOME_IDS = ImmutableSet.of(ItemID.MITHRIL_BAR, ItemID.DRAGON_BONES);
private static final Set<Integer> WRONG_IDS = ImmutableSet.of(ItemID.SCYTHE_OF_VITUR, ItemID.TWISTED_BOW);
private static final Set<Integer> MIX_IDS = ImmutableSet.of(
private static final Set<Integer> SOME_IDS = Set.of(ItemID.MITHRIL_BAR, ItemID.DRAGON_BONES);
private static final Set<Integer> WRONG_IDS = Set.of(ItemID.SCYTHE_OF_VITUR, ItemID.TWISTED_BOW);
private static final Set<Integer> MIX_IDS = Set.of(
ItemID.MITHRIL_BAR, ItemID.DRAGON_BONES,
ItemID.SCYTHE_OF_VITUR, ItemID.TWISTED_BOW
);

View File

@@ -39,7 +39,7 @@ include(":runelite-script-assembler-plugin")
include(":runelite-client")
include(":runelite-mixins")
include(":injected-client")
include("injection-annotations")
include(":injection-annotations")
include(":runelite-plugin-archetype")
include(":wiki-scraper")