antidrag: unregister keylistener on login screen (#1088)
This commit is contained in:
@@ -34,6 +34,7 @@ import lombok.Getter;
|
|||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.events.ConfigChanged;
|
import net.runelite.api.events.ConfigChanged;
|
||||||
import net.runelite.api.events.FocusChanged;
|
import net.runelite.api.events.FocusChanged;
|
||||||
|
import net.runelite.api.events.GameStateChanged;
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
import net.runelite.client.config.Keybind;
|
import net.runelite.client.config.Keybind;
|
||||||
import net.runelite.client.eventbus.EventBus;
|
import net.runelite.client.eventbus.EventBus;
|
||||||
@@ -130,6 +131,7 @@ public class AntiDragPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
|
eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
|
||||||
eventBus.subscribe(FocusChanged.class, this, this::onFocusChanged);
|
eventBus.subscribe(FocusChanged.class, this, this::onFocusChanged);
|
||||||
|
eventBus.subscribe(GameStateChanged.class, this, this::onGameStateChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onConfigChanged(ConfigChanged event)
|
private void onConfigChanged(ConfigChanged event)
|
||||||
@@ -160,6 +162,21 @@ public class AntiDragPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void onGameStateChanged(GameStateChanged event)
|
||||||
|
{
|
||||||
|
switch (event.getGameState())
|
||||||
|
{
|
||||||
|
case LOGGED_IN:
|
||||||
|
if (keybind)
|
||||||
|
{
|
||||||
|
keyManager.registerKeyListener(hotkeyListener);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case LOGIN_SCREEN:
|
||||||
|
keyManager.unregisterKeyListener(hotkeyListener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void updateConfig()
|
private void updateConfig()
|
||||||
{
|
{
|
||||||
this.alwaysOn = config.alwaysOn();
|
this.alwaysOn = config.alwaysOn();
|
||||||
@@ -187,8 +204,11 @@ public class AntiDragPlugin extends Plugin
|
|||||||
@Override
|
@Override
|
||||||
public void hotkeyPressed()
|
public void hotkeyPressed()
|
||||||
{
|
{
|
||||||
if (!alwaysOn)
|
if (alwaysOn)
|
||||||
{
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
toggleDrag = !toggleDrag;
|
toggleDrag = !toggleDrag;
|
||||||
if (toggleDrag)
|
if (toggleDrag)
|
||||||
{
|
{
|
||||||
@@ -214,6 +234,5 @@ public class AntiDragPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user