defaultworld: add option to use last world as default

This commit is contained in:
BenDol
2018-09-06 10:08:12 +12:00
committed by Adam
parent e12d0bd23b
commit 87c6811819
2 changed files with 37 additions and 2 deletions

View File

@@ -28,9 +28,11 @@ import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem;
@ConfigGroup("defaultworld")
@ConfigGroup(DefaultWorldConfig.GROUP)
public interface DefaultWorldConfig extends Config
{
final String GROUP = "defaultworld";
@ConfigItem(
keyName = "defaultWorld",
name = "Default world",
@@ -40,4 +42,32 @@ public interface DefaultWorldConfig extends Config
{
return 0;
}
@ConfigItem(
keyName = "useLastWorld",
name = "Use Last World",
description = "Use the last world you used as the default"
)
default boolean useLastWorld()
{
return false;
}
@ConfigItem(
keyName = "lastWorld",
name = "",
description = "",
hidden = true
)
default int lastWorld()
{
return 0;
}
@ConfigItem(
keyName = "lastWorld",
name = "",
description = ""
)
void lastWorld(int lastWorld);
}

View File

@@ -91,6 +91,11 @@ public class DefaultWorldPlugin extends Plugin
@Subscribe
public void onGameStateChanged(GameStateChanged event)
{
if (event.getGameState() == GameState.LOGGED_IN)
{
config.lastWorld(client.getWorld());
}
applyWorld();
}
@@ -155,7 +160,7 @@ public class DefaultWorldPlugin extends Plugin
log.debug("Stored old world {}", worldCache);
}
final int newWorld = config.getWorld();
final int newWorld = !config.useLastWorld() ? config.getWorld() : config.lastWorld();
changeWorld(newWorld);
}
}