Merge pull request #3080 from SRLJustin/revert_config

oprs: revert configs pre-upstream
This commit is contained in:
Justin
2021-12-02 17:37:15 +11:00
committed by GitHub
9 changed files with 805 additions and 611 deletions

View File

@@ -27,7 +27,7 @@ object ProjectVersions {
const val launcherVersion = "2.2.0"
const val rlVersion = "1.8.5"
const val openosrsVersion = "4.15.5"
const val openosrsVersion = "4.15.6"
const val rsversion = 201
const val cacheversion = 165

View File

@@ -40,8 +40,8 @@ class ConfigInvocationHandler implements InvocationHandler
private final ConfigManager manager;
private final Cache<Method, Object> cache = CacheBuilder.newBuilder()
.maximumSize(256)
.build();
.maximumSize(256)
.build();
ConfigInvocationHandler(ConfigManager manager)
{
@@ -99,9 +99,11 @@ class ConfigInvocationHandler implements InvocationHandler
}
// Convert value to return type
Class<?> returnType = method.getReturnType();
try
{
Object objectValue = manager.stringToObject(value, method.getGenericReturnType());
Object objectValue = ConfigManager.stringToObject(value, returnType);
cache.put(method, objectValue == null ? NULL : objectValue);
return objectValue;
}
@@ -153,7 +155,7 @@ class ConfigInvocationHandler implements InvocationHandler
}
else
{
String newValueStr = manager.objectToString(newValue);
String newValueStr = ConfigManager.objectToString(newValue);
manager.setConfiguration(group.value(), item.keyName(), newValueStr);
}
return null;
@@ -164,9 +166,9 @@ class ConfigInvocationHandler implements InvocationHandler
{
Class<?> declaringClass = method.getDeclaringClass();
return ReflectUtil.privateLookupIn(declaringClass)
.unreflectSpecial(method, declaringClass)
.bindTo(proxy)
.invokeWithArguments(args);
.unreflectSpecial(method, declaringClass)
.bindTo(proxy)
.invokeWithArguments(args);
}
void invalidate()

View File

@@ -24,14 +24,13 @@
*/
package net.runelite.client.config;
import java.lang.reflect.Type;
import lombok.Value;
@Value
public class ConfigItemDescriptor implements ConfigObject
{
private final ConfigItem item;
private final Type type;
private final Class<?> type;
private final Range range;
private final Alpha alpha;
private final Units units;

View File

@@ -30,7 +30,6 @@ import com.google.common.collect.ComparisonChain;
import com.google.common.collect.ImmutableSet;
import com.google.common.hash.Hasher;
import com.google.common.hash.Hashing;
import com.google.gson.Gson;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Point;
@@ -45,9 +44,7 @@ import java.io.OutputStreamWriter;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Proxy;
import java.lang.reflect.Type;
import java.nio.channels.FileChannel;
import java.nio.charset.StandardCharsets;
import java.nio.file.AtomicMoveNotSupportedException;
@@ -131,7 +128,6 @@ public class ConfigManager
private final File settingsFileInput;
private final EventBus eventBus;
private final OkHttpClient okHttpClient;
private final Gson gson;
private AccountSession session;
private ConfigClient configClient;
@@ -152,19 +148,17 @@ public class ConfigManager
@Inject
public ConfigManager(
@Named("config") File config,
ScheduledExecutorService scheduledExecutorService,
EventBus eventBus,
OkHttpClient okHttpClient,
@Nullable Client client,
Gson gson)
@Named("config") File config,
ScheduledExecutorService scheduledExecutorService,
EventBus eventBus,
OkHttpClient okHttpClient,
@Nullable Client client)
{
this.settingsFileInput = config;
this.eventBus = eventBus;
this.okHttpClient = okHttpClient;
this.client = client;
this.propertiesFile = getPropertiesFile();
this.gson = gson;
scheduledExecutorService.scheduleWithFixedDelay(this::sendConfig, 30, 30, TimeUnit.SECONDS);
}
@@ -373,9 +367,9 @@ public class ConfigManager
}
T t = (T) Proxy.newProxyInstance(clazz.getClassLoader(), new Class<?>[]
{
clazz
}, handler);
{
clazz
}, handler);
return t;
}
@@ -418,17 +412,12 @@ public class ConfigManager
return properties.getProperty(getWholeKey(groupName, profile, key));
}
public <T> T getConfiguration(String groupName, String key, Type clazz)
{
return getConfiguration(groupName, null, key, clazz);
}
public <T> T getConfiguration(String groupName, String key, Class<T> clazz)
{
return getConfiguration(groupName, null, key, clazz);
}
public <T> T getRSProfileConfiguration(String groupName, String key, Type clazz)
public <T> T getRSProfileConfiguration(String groupName, String key, Class<T> clazz)
{
String rsProfileKey = this.rsProfileKey;
if (rsProfileKey == null)
@@ -439,14 +428,14 @@ public class ConfigManager
return getConfiguration(groupName, rsProfileKey, key, clazz);
}
public <T> T getConfiguration(String groupName, String profile, String key, Type type)
public <T> T getConfiguration(String groupName, String profile, String key, Class<T> clazz)
{
String value = getConfiguration(groupName, profile, key);
if (!Strings.isNullOrEmpty(value))
{
try
{
return (T) stringToObject(value, type);
return (T) stringToObject(value, clazz);
}
catch (Exception e)
{
@@ -499,12 +488,12 @@ public class ConfigManager
eventBus.post(configChanged);
}
public <T> void setConfiguration(String groupName, String profile, String key, T value)
public void setConfiguration(String groupName, String profile, String key, Object value)
{
setConfiguration(groupName, profile, key, objectToString(value));
}
public <T> void setConfiguration(String groupName, String key, T value)
public void setConfiguration(String groupName, String key, Object value)
{
// do not save consumers for buttons, they cannot be changed anyway
if (value instanceof Consumer)
@@ -515,7 +504,7 @@ public class ConfigManager
setConfiguration(groupName, null, key, value);
}
public <T> void setRSProfileConfiguration(String groupName, String key, T value)
public void setRSProfileConfiguration(String groupName, String key, Object value)
{
String rsProfileKey = this.rsProfileKey;
if (rsProfileKey == null)
@@ -610,67 +599,67 @@ public class ConfigManager
}
final List<ConfigSectionDescriptor> sections = getAllDeclaredInterfaceFields(inter).stream()
.filter(m -> m.isAnnotationPresent(ConfigSection.class) && m.getType() == String.class)
.map(m ->
{
try
.filter(m -> m.isAnnotationPresent(ConfigSection.class) && m.getType() == String.class)
.map(m ->
{
return new ConfigSectionDescriptor(
String.valueOf(m.get(inter)),
m.getDeclaredAnnotation(ConfigSection.class)
);
}
catch (IllegalAccessException e)
{
log.warn("Unable to load section {}::{}", inter.getSimpleName(), m.getName());
return null;
}
})
.filter(Objects::nonNull)
.sorted((a, b) -> ComparisonChain.start()
.compare(a.getSection().position(), b.getSection().position())
.compare(a.getSection().name(), b.getSection().name())
.result())
.collect(Collectors.toList());
try
{
return new ConfigSectionDescriptor(
String.valueOf(m.get(inter)),
m.getDeclaredAnnotation(ConfigSection.class)
);
}
catch (IllegalAccessException e)
{
log.warn("Unable to load section {}::{}", inter.getSimpleName(), m.getName());
return null;
}
})
.filter(Objects::nonNull)
.sorted((a, b) -> ComparisonChain.start()
.compare(a.getSection().position(), b.getSection().position())
.compare(a.getSection().name(), b.getSection().name())
.result())
.collect(Collectors.toList());
final List<ConfigTitleDescriptor> titles = getAllDeclaredInterfaceFields(inter).stream()
.filter(m -> m.isAnnotationPresent(ConfigTitle.class) && m.getType() == String.class)
.map(m ->
{
try
.filter(m -> m.isAnnotationPresent(ConfigTitle.class) && m.getType() == String.class)
.map(m ->
{
return new ConfigTitleDescriptor(
String.valueOf(m.get(inter)),
m.getDeclaredAnnotation(ConfigTitle.class)
);
}
catch (IllegalAccessException e)
{
log.warn("Unable to load title {}::{}", inter.getSimpleName(), m.getName());
return null;
}
})
.filter(Objects::nonNull)
.sorted((a, b) -> ComparisonChain.start()
.compare(a.getTitle().position(), b.getTitle().position())
.compare(a.getTitle().name(), b.getTitle().name())
.result())
.collect(Collectors.toList());
try
{
return new ConfigTitleDescriptor(
String.valueOf(m.get(inter)),
m.getDeclaredAnnotation(ConfigTitle.class)
);
}
catch (IllegalAccessException e)
{
log.warn("Unable to load title {}::{}", inter.getSimpleName(), m.getName());
return null;
}
})
.filter(Objects::nonNull)
.sorted((a, b) -> ComparisonChain.start()
.compare(a.getTitle().position(), b.getTitle().position())
.compare(a.getTitle().name(), b.getTitle().name())
.result())
.collect(Collectors.toList());
final List<ConfigItemDescriptor> items = Arrays.stream(inter.getMethods())
.filter(m -> m.getParameterCount() == 0 && m.isAnnotationPresent(ConfigItem.class))
.map(m -> new ConfigItemDescriptor(
m.getDeclaredAnnotation(ConfigItem.class),
m.getGenericReturnType(),
m.getDeclaredAnnotation(Range.class),
m.getDeclaredAnnotation(Alpha.class),
m.getDeclaredAnnotation(Units.class)
))
.sorted((a, b) -> ComparisonChain.start()
.compare(a.getItem().position(), b.getItem().position())
.compare(a.getItem().name(), b.getItem().name())
.result())
.collect(Collectors.toList());
.filter(m -> m.getParameterCount() == 0 && m.isAnnotationPresent(ConfigItem.class))
.map(m -> new ConfigItemDescriptor(
m.getDeclaredAnnotation(ConfigItem.class),
m.getReturnType(),
m.getDeclaredAnnotation(Range.class),
m.getDeclaredAnnotation(Alpha.class),
m.getDeclaredAnnotation(Units.class)
))
.sorted((a, b) -> ComparisonChain.start()
.compare(a.getItem().position(), b.getItem().position())
.compare(a.getItem().name(), b.getItem().name())
.result())
.collect(Collectors.toList());
return new ConfigDescriptor(group, sections, titles, items);
}
@@ -732,16 +721,16 @@ public class ConfigManager
continue;
}
if (!override)
{
// This checks if it is set and is also unmarshallable to the correct type; so
// we will overwrite invalid config values with the default
Object current = getConfiguration(group.value(), item.keyName(), method.getGenericReturnType());
if (current != null)
if (!override)
{
continue; // something else is already set
// This checks if it is set and is also unmarshallable to the correct type; so
// we will overwrite invalid config values with the default
Object current = getConfiguration(group.value(), item.keyName(), method.getReturnType());
if (current != null)
{
continue; // something else is already set
}
}
}
Object defaultValue;
try
@@ -771,7 +760,7 @@ public class ConfigManager
}
}
Object stringToObject(String str, Type type)
static Object stringToObject(String str, Class<?> type)
{
if (type == boolean.class || type == Boolean.class)
{
@@ -812,7 +801,7 @@ public class ConfigManager
int height = Integer.parseInt(splitStr[3]);
return new Rectangle(x, y, width, height);
}
if (type instanceof Class && ((Class<?>) type).isEnum())
if (type.isEnum())
{
return Enum.valueOf((Class<? extends Enum>) type, str);
}
@@ -847,14 +836,6 @@ public class ConfigManager
{
return Base64.getUrlDecoder().decode(str);
}
if (type instanceof ParameterizedType)
{
ParameterizedType parameterizedType = (ParameterizedType) type;
if (parameterizedType.getRawType() == Set.class)
{
return gson.fromJson(str, parameterizedType);
}
}
if (type == EnumSet.class)
{
try
@@ -894,7 +875,7 @@ public class ConfigManager
}
@Nullable
String objectToString(Object object)
static String objectToString(Object object)
{
if (object instanceof Color)
{
@@ -941,10 +922,6 @@ public class ConfigManager
{
return Base64.getUrlEncoder().encodeToString((byte[]) object);
}
if (object instanceof Set)
{
return gson.toJson(object, Set.class);
}
if (object instanceof EnumSet)
{
if (((EnumSet) object).size() == 0)
@@ -1073,8 +1050,8 @@ public class ConfigManager
if (configClient != null)
{
Configuration patch = new Configuration(pendingChanges.entrySet().stream()
.map(e -> new ConfigEntry(e.getKey(), e.getValue()))
.collect(Collectors.toList()));
.map(e -> new ConfigEntry(e.getKey(), e.getValue()))
.collect(Collectors.toList()));
future = configClient.patch(patch);
}
@@ -1116,18 +1093,18 @@ public class ConfigManager
}
return profileKeys.stream()
.map(key ->
{
RuneScapeProfile prof = new RuneScapeProfile(
getConfiguration(RSPROFILE_GROUP, key, RSPROFILE_DISPLAY_NAME),
getConfiguration(RSPROFILE_GROUP, key, RSPROFILE_TYPE, RuneScapeProfileType.class),
getConfiguration(RSPROFILE_GROUP, key, RSPROFILE_LOGIN_HASH, byte[].class),
key
);
.map(key ->
{
RuneScapeProfile prof = new RuneScapeProfile(
getConfiguration(RSPROFILE_GROUP, key, RSPROFILE_DISPLAY_NAME),
getConfiguration(RSPROFILE_GROUP, key, RSPROFILE_TYPE, RuneScapeProfileType.class),
getConfiguration(RSPROFILE_GROUP, key, RSPROFILE_LOGIN_HASH, byte[].class),
key
);
return prof;
})
.collect(Collectors.toList());
return prof;
})
.collect(Collectors.toList());
}
private synchronized RuneScapeProfile findRSProfile(List<RuneScapeProfile> profiles, String username, RuneScapeProfileType type, String displayName, boolean create)
@@ -1137,7 +1114,7 @@ public class ConfigManager
{
salt = new byte[15];
new SecureRandom()
.nextBytes(salt);
.nextBytes(salt);
log.info("creating new salt as there is no existing one {}", Base64.getUrlEncoder().encodeToString(salt));
setConfiguration(RSPROFILE_GROUP, RSPROFILE_LOGIN_SALT, salt);
}
@@ -1148,8 +1125,8 @@ public class ConfigManager
byte[] loginHash = h.hash().asBytes();
Set<RuneScapeProfile> matches = profiles.stream()
.filter(p -> Arrays.equals(p.getLoginHash(), loginHash) && p.getType() == type)
.collect(Collectors.toSet());
.filter(p -> Arrays.equals(p.getLoginHash(), loginHash) && p.getType() == type)
.collect(Collectors.toSet());
if (matches.size() > 1)
{
@@ -1273,19 +1250,19 @@ public class ConfigManager
AtomicInteger changes = new AtomicInteger();
List<Predicate<String>> migrators = new ArrayList<>();
for (String[] tpl : new String[][]
{
{"(grandexchange)\\.buylimit_(%)\\.(#)", "$1.buylimit.$3"},
{"(timetracking)\\.(%)\\.(autoweed|contract)", "$1.$3"},
{"(timetracking)\\.(%)\\.(#\\.#)", "$1.$3"},
{"(timetracking)\\.(%)\\.(birdhouse)\\.(#)", "$1.$3.$4"},
{"(killcount|personalbest)\\.(%)\\.([^.]+)", "$1.$3"},
{"(geoffer)\\.(%)\\.(#)", "$1.$3"},
})
{
{"(grandexchange)\\.buylimit_(%)\\.(#)", "$1.buylimit.$3"},
{"(timetracking)\\.(%)\\.(autoweed|contract)", "$1.$3"},
{"(timetracking)\\.(%)\\.(#\\.#)", "$1.$3"},
{"(timetracking)\\.(%)\\.(birdhouse)\\.(#)", "$1.$3.$4"},
{"(killcount|personalbest)\\.(%)\\.([^.]+)", "$1.$3"},
{"(geoffer)\\.(%)\\.(#)", "$1.$3"},
})
{
String replace = tpl[1];
String pat = ("^" + tpl[0] + "$")
.replace("#", "-?[0-9]+")
.replace("(%)", "(?<login>.*)");
.replace("#", "-?[0-9]+")
.replace("(%)", "(?<login>.*)");
Pattern p = Pattern.compile(pat);
migrators.add(oldkey ->
@@ -1305,7 +1282,7 @@ public class ConfigManager
}
String profKey = profiles.computeIfAbsent(username, u ->
findRSProfile(getRSProfiles(), u, RuneScapeProfileType.STANDARD, u, true).getKey());
findRSProfile(getRSProfiles(), u, RuneScapeProfileType.STANDARD, u, true).getKey());
String[] oldKeySplit = splitKey(oldkey);
if (oldKeySplit == null)

View File

@@ -24,49 +24,35 @@
*/
package net.runelite.client.plugins.worldhopper;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.NoArgsConstructor;
import net.runelite.http.api.worlds.WorldRegion;
@RequiredArgsConstructor
enum RegionFilterMode
@NoArgsConstructor
@AllArgsConstructor
public enum RegionFilterMode
{
NONE,
AUSTRALIA(WorldRegion.AUSTRALIA),
GERMANY(WorldRegion.GERMANY),
UNITED_KINGDOM(WorldRegion.UNITED_KINGDOM)
{
@Override
public String toString()
{
return "U.K.";
}
},
@Override
public String toString()
{
return "U.K.";
}
},
UNITED_STATES(WorldRegion.UNITED_STATES_OF_AMERICA)
{
@Override
public String toString()
{
return "USA";
}
};
@Override
public String toString()
{
return "USA";
}
};
@Getter
private final WorldRegion region;
static RegionFilterMode of(WorldRegion region)
{
switch (region)
{
case UNITED_STATES_OF_AMERICA:
return UNITED_STATES;
case UNITED_KINGDOM:
return UNITED_KINGDOM;
case AUSTRALIA:
return AUSTRALIA;
case GERMANY:
return GERMANY;
default:
throw new IllegalStateException();
}
}
private WorldRegion region;
}

View File

@@ -27,8 +27,6 @@ package net.runelite.client.plugins.worldhopper;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.util.Collections;
import java.util.Set;
import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem;
@@ -40,10 +38,10 @@ public interface WorldHopperConfig extends Config
String GROUP = "worldhopper";
@ConfigItem(
keyName = "previousKey",
name = "Quick-hop previous",
description = "When you press this key you'll hop to the previous world",
position = 0
keyName = "previousKey",
name = "Quick-hop previous",
description = "When you press this key you'll hop to the previous world",
position = 0
)
default Keybind previousKey()
{
@@ -51,10 +49,10 @@ public interface WorldHopperConfig extends Config
}
@ConfigItem(
keyName = "nextKey",
name = "Quick-hop next",
description = "When you press this key you'll hop to the next world",
position = 1
keyName = "nextKey",
name = "Quick-hop next",
description = "When you press this key you'll hop to the next world",
position = 1
)
default Keybind nextKey()
{
@@ -62,10 +60,10 @@ public interface WorldHopperConfig extends Config
}
@ConfigItem(
keyName = "quickhopOutOfDanger",
name = "Quick-hop out of dangerous worlds",
description = "Don't hop to a PVP/high risk world when quick-hopping",
position = 2
keyName = "quickhopOutOfDanger",
name = "Quick-hop out of dangerous worlds",
description = "Don't hop to a PVP/high risk world when quick-hopping",
position = 2
)
default boolean quickhopOutOfDanger()
{
@@ -73,21 +71,21 @@ public interface WorldHopperConfig extends Config
}
@ConfigItem(
keyName = "quickHopRegionFilter",
name = "Quick-hop region",
description = "Limit quick-hopping to worlds of a specific region",
position = 3
keyName = "quickHopRegionFilter",
name = "Quick-hop region",
description = "Limit quick-hopping to worlds of a specific region",
position = 3
)
default Set<RegionFilterMode> quickHopRegionFilter()
default RegionFilterMode quickHopRegionFilter()
{
return Collections.emptySet();
return RegionFilterMode.NONE;
}
@ConfigItem(
keyName = "showSidebar",
name = "Show world switcher sidebar",
description = "Show sidebar containing all worlds that mimics in-game interface",
position = 4
keyName = "showSidebar",
name = "Show world switcher sidebar",
description = "Show sidebar containing all worlds that mimics in-game interface",
position = 4
)
default boolean showSidebar()
{
@@ -95,10 +93,10 @@ public interface WorldHopperConfig extends Config
}
@ConfigItem(
keyName = "ping",
name = "Show world ping",
description = "Shows ping to each game world",
position = 5
keyName = "ping",
name = "Show world ping",
description = "Shows ping to each game world",
position = 5
)
default boolean ping()
{
@@ -106,10 +104,10 @@ public interface WorldHopperConfig extends Config
}
@ConfigItem(
keyName = "showMessage",
name = "Show world hop message in chat",
description = "Shows what world is being hopped to in the chat",
position = 6
keyName = "showMessage",
name = "Show world hop message in chat",
description = "Shows what world is being hopped to in the chat",
position = 6
)
default boolean showWorldHopMessage()
{
@@ -117,10 +115,10 @@ public interface WorldHopperConfig extends Config
}
@ConfigItem(
keyName = "menuOption",
name = "Show Hop-to menu option",
description = "Adds Hop-to menu option to the friends list and friends chat members list",
position = 7
keyName = "menuOption",
name = "Show Hop-to menu option",
description = "Adds Hop-to menu option to the friends list and friends chat members list",
position = 7
)
default boolean menuOption()
{
@@ -128,10 +126,10 @@ public interface WorldHopperConfig extends Config
}
@ConfigItem(
keyName = "subscriptionFilter",
name = "Show subscription types",
description = "Only show free worlds, member worlds, or both types of worlds in sidebar",
position = 8
keyName = "subscriptionFilter",
name = "Show subscription types",
description = "Only show free worlds, member worlds, or both types of worlds in sidebar",
position = 8
)
default SubscriptionFilterMode subscriptionFilter()
{
@@ -139,21 +137,21 @@ public interface WorldHopperConfig extends Config
}
@ConfigItem(
keyName = "regionFilter",
name = "Filter worlds by region",
description = "Restrict sidebar worlds to one region",
position = 8
keyName = "regionFilter",
name = "Filter worlds by region",
description = "Restrict sidebar worlds to one region",
position = 8
)
default Set<RegionFilterMode> regionFilter()
default RegionFilterMode regionFilter()
{
return Collections.emptySet();
return RegionFilterMode.NONE;
}
@ConfigItem(
keyName = "displayPing",
name = "Display current ping",
description = "Displays ping to current game world",
position = 9
keyName = "displayPing",
name = "Display current ping",
description = "Displays ping to current game world",
position = 9
)
default boolean displayPing()
{

View File

@@ -36,7 +36,6 @@ import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
@@ -95,9 +94,9 @@ import net.runelite.http.api.worlds.WorldType;
import org.apache.commons.lang3.ArrayUtils;
@PluginDescriptor(
name = "World Hopper",
description = "Allows you to quickly hop worlds",
tags = {"ping", "switcher"}
name = "World Hopper",
description = "Allows you to quickly hop worlds",
tags = {"ping", "switcher"}
)
@Slf4j
public class WorldHopperPlugin extends Plugin
@@ -199,11 +198,11 @@ public class WorldHopperPlugin extends Plugin
BufferedImage icon = ImageUtil.loadImageResource(WorldHopperPlugin.class, "icon.png");
navButton = NavigationButton.builder()
.tooltip("World Switcher")
.icon(icon)
.priority(3)
.panel(panel)
.build();
.tooltip("World Switcher")
.icon(icon)
.priority(3)
.panel(panel)
.build();
if (config.showSidebar())
{
@@ -361,7 +360,7 @@ public class WorldHopperPlugin extends Plugin
String option = event.getOption();
if (groupId == WidgetInfo.FRIENDS_LIST.getGroupId() || groupId == WidgetInfo.FRIENDS_CHAT.getGroupId()
|| componentId == WidgetInfo.CLAN_MEMBER_LIST.getId() || componentId == WidgetInfo.CLAN_GUEST_MEMBER_LIST.getId())
|| componentId == WidgetInfo.CLAN_MEMBER_LIST.getId() || componentId == WidgetInfo.CLAN_GUEST_MEMBER_LIST.getId())
{
boolean after;
@@ -383,7 +382,7 @@ public class WorldHopperPlugin extends Plugin
WorldResult worldResult = worldService.getWorlds();
if (player == null || player.getWorld() == 0 || player.getWorld() == client.getWorld()
|| worldResult == null)
|| worldResult == null)
{
return;
}
@@ -391,7 +390,7 @@ public class WorldHopperPlugin extends Plugin
World currentWorld = worldResult.findWorld(client.getWorld());
World targetWorld = worldResult.findWorld(player.getWorld());
if (targetWorld == null || currentWorld == null
|| (!currentWorld.getTypes().contains(WorldType.PVP) && targetWorld.getTypes().contains(WorldType.PVP)))
|| (!currentWorld.getTypes().contains(WorldType.PVP) && targetWorld.getTypes().contains(WorldType.PVP)))
{
// Disable Hop-to a PVP world from a regular world
return;
@@ -534,8 +533,6 @@ public class WorldHopperPlugin extends Plugin
int worldIdx = worlds.indexOf(currentWorld);
int totalLevel = client.getTotalLevel();
final Set<RegionFilterMode> regionFilter = config.quickHopRegionFilter();
World world;
do
{
@@ -567,7 +564,7 @@ public class WorldHopperPlugin extends Plugin
world = worlds.get(worldIdx);
// Check world region if filter is enabled
if (!regionFilter.isEmpty() && !regionFilter.contains(RegionFilterMode.of(world.getRegion())))
if (config.quickHopRegionFilter() != RegionFilterMode.NONE && world.getRegion() != config.quickHopRegionFilter().getRegion())
{
continue;
}
@@ -612,14 +609,14 @@ public class WorldHopperPlugin extends Plugin
if (world == currentWorld)
{
String chatMessage = new ChatMessageBuilder()
.append(ChatColorType.NORMAL)
.append("Couldn't find a world to quick-hop to.")
.build();
.append(ChatColorType.NORMAL)
.append("Couldn't find a world to quick-hop to.")
.build();
chatMessageManager.queue(QueuedMessage.builder()
.type(ChatMessageType.CONSOLE)
.runeLiteFormattedMessage(chatMessage)
.build());
.type(ChatMessageType.CONSOLE)
.runeLiteFormattedMessage(chatMessage)
.build());
}
else
{
@@ -657,19 +654,19 @@ public class WorldHopperPlugin extends Plugin
if (config.showWorldHopMessage())
{
String chatMessage = new ChatMessageBuilder()
.append(ChatColorType.NORMAL)
.append("Quick-hopping to World ")
.append(ChatColorType.HIGHLIGHT)
.append(Integer.toString(world.getId()))
.append(ChatColorType.NORMAL)
.append("..")
.build();
.append(ChatColorType.NORMAL)
.append("Quick-hopping to World ")
.append(ChatColorType.HIGHLIGHT)
.append(Integer.toString(world.getId()))
.append(ChatColorType.NORMAL)
.append("..")
.build();
chatMessageManager
.queue(QueuedMessage.builder()
.type(ChatMessageType.CONSOLE)
.runeLiteFormattedMessage(chatMessage)
.build());
.queue(QueuedMessage.builder()
.type(ChatMessageType.CONSOLE)
.runeLiteFormattedMessage(chatMessage)
.build());
}
quickHopTargetWorld = rsWorld;
@@ -691,19 +688,19 @@ public class WorldHopperPlugin extends Plugin
if (++displaySwitcherAttempts >= DISPLAY_SWITCHER_MAX_ATTEMPTS)
{
String chatMessage = new ChatMessageBuilder()
.append(ChatColorType.NORMAL)
.append("Failed to quick-hop after ")
.append(ChatColorType.HIGHLIGHT)
.append(Integer.toString(displaySwitcherAttempts))
.append(ChatColorType.NORMAL)
.append(" attempts.")
.build();
.append(ChatColorType.NORMAL)
.append("Failed to quick-hop after ")
.append(ChatColorType.HIGHLIGHT)
.append(Integer.toString(displaySwitcherAttempts))
.append(ChatColorType.NORMAL)
.append(" attempts.")
.build();
chatMessageManager
.queue(QueuedMessage.builder()
.type(ChatMessageType.CONSOLE)
.runeLiteFormattedMessage(chatMessage)
.build());
.queue(QueuedMessage.builder()
.type(ChatMessageType.CONSOLE)
.runeLiteFormattedMessage(chatMessage)
.build());
resetQuickHopper();
}

View File

@@ -34,7 +34,6 @@ import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Function;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
@@ -69,7 +68,7 @@ class WorldSwitcherPanel extends PluginPanel
@Setter(AccessLevel.PACKAGE)
private SubscriptionFilterMode subscriptionFilterMode;
@Setter(AccessLevel.PACKAGE)
private Set<RegionFilterMode> regionFilterMode;
private RegionFilterMode regionFilterMode;
WorldSwitcherPanel(WorldHopperPlugin plugin)
{
@@ -250,7 +249,7 @@ class WorldSwitcherPanel extends PluginPanel
break;
}
if (!regionFilterMode.isEmpty() && !regionFilterMode.contains(RegionFilterMode.of(world.getRegion())))
if (regionFilterMode.getRegion() != null && !regionFilterMode.getRegion().equals(world.getRegion()))
{
continue;
}
@@ -378,20 +377,20 @@ class WorldSwitcherPanel extends PluginPanel
private WorldTableRow buildRow(World world, boolean stripe, boolean current, boolean favorite)
{
WorldTableRow row = new WorldTableRow(world, current, favorite, plugin.getStoredPing(world),
plugin::hopTo,
(world12, add) ->
{
if (add)
plugin::hopTo,
(world12, add) ->
{
plugin.addToFavorites(world12);
}
else
{
plugin.removeFromFavorites(world12);
}
if (add)
{
plugin.addToFavorites(world12);
}
else
{
plugin.removeFromFavorites(world12);
}
updateList();
}
updateList();
}
);
row.setBackground(stripe ? ODD_ROW : ColorScheme.DARK_GRAY_COLOR);
return row;