@@ -47,17 +47,8 @@ public class XteaClient
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(XteaClient.class);
|
||||
|
||||
public void submit(int revision, int region, int[] keys)
|
||||
public void submit(XteaRequest xteaRequest)
|
||||
{
|
||||
XteaRequest xteaRequest = new XteaRequest();
|
||||
xteaRequest.setRevision(revision);
|
||||
|
||||
XteaKey xteaKey = new XteaKey();
|
||||
xteaKey.setRegion(region);
|
||||
xteaKey.setKeys(keys);
|
||||
|
||||
xteaRequest.addKey(xteaKey);
|
||||
|
||||
String json = RuneLiteAPI.GSON.toJson(xteaRequest);
|
||||
|
||||
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.api.events;
|
||||
|
||||
import lombok.Data;
|
||||
import net.runelite.api.Client;
|
||||
|
||||
/**
|
||||
* An event where a map region has been modified.
|
||||
* <p>
|
||||
* This event exposes the index into the map that is changing,
|
||||
* the value of which can be obtained by using the index with
|
||||
* the {@link Client#getMapRegions()} array.
|
||||
*/
|
||||
@Data
|
||||
public class MapRegionChanged
|
||||
{
|
||||
/**
|
||||
* The map region index.
|
||||
*/
|
||||
private int index;
|
||||
}
|
||||
@@ -37,7 +37,6 @@ import net.runelite.api.SpritePixels;
|
||||
import net.runelite.api.Tile;
|
||||
import net.runelite.api.coords.LocalPoint;
|
||||
import net.runelite.api.events.GameStateChanged;
|
||||
import net.runelite.api.events.MapRegionChanged;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.ui.overlay.OverlayLayer;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
@@ -214,16 +213,6 @@ class InstanceMapOverlay extends Overlay
|
||||
graphics.drawRect(x, y, PLAYER_MARKER_SIZE, PLAYER_MARKER_SIZE);//outline
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles region changes and re-draws the map
|
||||
*
|
||||
* @param event The region change event
|
||||
*/
|
||||
public void onRegionChange(MapRegionChanged event)
|
||||
{
|
||||
mapImage = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles game state changes and re-draws the map
|
||||
*
|
||||
|
||||
@@ -28,7 +28,6 @@ import com.google.common.eventbus.Subscribe;
|
||||
import com.google.inject.Binder;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.events.GameStateChanged;
|
||||
import net.runelite.api.events.MapRegionChanged;
|
||||
import net.runelite.api.events.WidgetMenuOptionClicked;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import static net.runelite.api.widgets.WidgetInfo.WORLD_MAP_OPTION;
|
||||
@@ -96,12 +95,6 @@ public class InstanceMapPlugin extends Plugin
|
||||
mouseManager.unregisterMouseWheelListener(inputListener);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void regionChange(MapRegionChanged event)
|
||||
{
|
||||
overlay.onRegionChange(event);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void gameStateChange(GameStateChanged event)
|
||||
{
|
||||
|
||||
@@ -62,7 +62,6 @@ import net.runelite.api.events.GameObjectChanged;
|
||||
import net.runelite.api.events.GameObjectDespawned;
|
||||
import net.runelite.api.events.GameObjectSpawned;
|
||||
import net.runelite.api.events.GameStateChanged;
|
||||
import net.runelite.api.events.MapRegionChanged;
|
||||
import net.runelite.api.events.VarbitChanged;
|
||||
import net.runelite.api.events.WallObjectChanged;
|
||||
import net.runelite.api.events.WallObjectDespawned;
|
||||
@@ -334,12 +333,6 @@ public class MotherlodePlugin extends Plugin
|
||||
rocks.remove(gameObject);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onRegionChanged(MapRegionChanged event)
|
||||
{
|
||||
inMlm = checkInMlm();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onGameStateChanged(GameStateChanged event)
|
||||
{
|
||||
|
||||
@@ -30,10 +30,13 @@ import java.util.Set;
|
||||
import javax.inject.Inject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.events.MapRegionChanged;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.events.GameStateChanged;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.http.api.xtea.XteaClient;
|
||||
import net.runelite.http.api.xtea.XteaKey;
|
||||
import net.runelite.http.api.xtea.XteaRequest;
|
||||
|
||||
@PluginDescriptor(
|
||||
name = "Xtea",
|
||||
@@ -50,32 +53,45 @@ public class XteaPlugin extends Plugin
|
||||
private Client client;
|
||||
|
||||
@Subscribe
|
||||
public void onMapRegionChanged(MapRegionChanged event)
|
||||
public void onGameStateChanged(GameStateChanged gameStateChanged)
|
||||
{
|
||||
int idx = event.getIndex();
|
||||
|
||||
if (idx == -1)
|
||||
if (gameStateChanged.getGameState() != GameState.LOGGED_IN)
|
||||
{
|
||||
return; // this is the new array being assigned to the field
|
||||
return;
|
||||
}
|
||||
|
||||
int revision = client.getRevision();
|
||||
int[] regions = client.getMapRegions();
|
||||
int[][] xteaKeys = client.getXteaKeys();
|
||||
|
||||
int region = regions[idx];
|
||||
int[] keys = xteaKeys[idx];
|
||||
XteaRequest xteaRequest = new XteaRequest();
|
||||
xteaRequest.setRevision(revision);
|
||||
|
||||
log.debug("Region {} keys {}, {}, {}, {}", region, keys[0], keys[1], keys[2], keys[3]);
|
||||
for (int idx = 0; idx < regions.length; ++idx)
|
||||
{
|
||||
int region = regions[idx];
|
||||
int[] keys = xteaKeys[idx];
|
||||
|
||||
// No need to ever send more than once
|
||||
if (sentRegions.contains(region))
|
||||
if (sentRegions.contains(region))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
sentRegions.add(region);
|
||||
|
||||
log.debug("Region {} keys {}, {}, {}, {}", region, keys[0], keys[1], keys[2], keys[3]);
|
||||
|
||||
XteaKey xteaKey = new XteaKey();
|
||||
xteaKey.setRegion(region);
|
||||
xteaKey.setKeys(keys);
|
||||
xteaRequest.addKey(xteaKey);
|
||||
}
|
||||
|
||||
if (xteaRequest.getKeys().isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
sentRegions.add(region);
|
||||
|
||||
xteaClient.submit(revision, region, keys);
|
||||
xteaClient.submit(xteaRequest);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,6 @@ import net.runelite.api.events.DraggingWidgetChanged;
|
||||
import net.runelite.api.events.ExperienceChanged;
|
||||
import net.runelite.api.events.GameStateChanged;
|
||||
import net.runelite.api.events.GrandExchangeOfferChanged;
|
||||
import net.runelite.api.events.MapRegionChanged;
|
||||
import net.runelite.api.events.MenuEntryAdded;
|
||||
import net.runelite.api.events.NpcSpawned;
|
||||
import net.runelite.api.events.PlayerDespawned;
|
||||
@@ -735,15 +734,6 @@ public abstract class RSClientMixin implements RSClient
|
||||
}
|
||||
}
|
||||
|
||||
@FieldHook("mapRegions")
|
||||
@Inject
|
||||
public static void mapRegionsChanged(int idx)
|
||||
{
|
||||
MapRegionChanged regionChanged = new MapRegionChanged();
|
||||
regionChanged.setIndex(idx);
|
||||
eventBus.post(regionChanged);
|
||||
}
|
||||
|
||||
@FieldHook("playerOptions")
|
||||
@Inject
|
||||
public static void playerOptionsChanged(int idx)
|
||||
|
||||
Reference in New Issue
Block a user