Add herbiboar plugin

This commit is contained in:
Tyler Hardy
2018-02-24 16:23:26 -06:00
committed by Adam
parent 38726e53a6
commit 6bfe2ef122
4 changed files with 742 additions and 0 deletions

View File

@@ -0,0 +1,137 @@
/*
* Copyright (c) 2017, Tyler <https://github.com/tylerthardy>
* 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.client.plugins.herbiboars;
import java.awt.Color;
import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem;
@ConfigGroup(
keyName = "herbiboar",
name = "Herbiboar",
description = "Configuration for the herbiboar plugin"
)
public interface HerbiboarConfig extends Config
{
@ConfigItem(
position = 0,
keyName = "showStart",
name = "Show Start Objects",
description = "Show highlights for starting rocks and logs"
)
default boolean isStartShown()
{
return true;
}
@ConfigItem(
position = 1,
keyName = "showClickboxes",
name = "Show Clickboxes",
description = "Show clickboxes on trail objects and tunnels instead of tiles"
)
default boolean showClickBoxes()
{
return false;
}
@ConfigItem(
position = 2,
keyName = "colorStart",
name = "Start Color",
description = "Color for rocks that start the trails"
)
default Color getStartColor()
{
return Color.CYAN;
}
@ConfigItem(
position = 3,
keyName = "showTunnel",
name = "Show End Tunnels",
description = "Show highlights for tunnels with herbiboars"
)
default boolean isTunnelShown()
{
return true;
}
@ConfigItem(
position = 4,
keyName = "colorTunnel",
name = "Tunnel Color",
description = "Color for tunnels with herbiboars"
)
default Color getTunnelColor()
{
return Color.GREEN;
}
@ConfigItem(
position = 5,
keyName = "showObject",
name = "Show Trail Objects",
description = "Show highlights for mushrooms, mud, seaweed, etc"
)
default boolean isObjectShown()
{
return true;
}
@ConfigItem(
position = 6,
keyName = "colorGameObject",
name = "Trail Object Color",
description = "Color for mushrooms, mud, seaweed, etc"
)
default Color getObjectColor()
{
return Color.CYAN;
}
@ConfigItem(
position = 7,
keyName = "showTrail",
name = "Show Trail",
description = "Show highlights for trail prints"
)
default boolean isTrailShown()
{
return true;
}
@ConfigItem(
position = 8,
keyName = "colorTrail",
name = "Trail Color",
description = "Color for mushrooms, mud, seaweed, etc"
)
default Color getTrailColor()
{
return Color.WHITE;
}
}

View File

@@ -0,0 +1,109 @@
/*
* Copyright (c) 2017, Tyler <https://github.com/tylerthardy>
* 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.client.plugins.herbiboars;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import lombok.AllArgsConstructor;
import lombok.Getter;
import net.runelite.api.Varbits;
import net.runelite.api.coords.WorldPoint;
//Location of GameObjects which show TRAIL_xxxxx when used
@AllArgsConstructor
public enum HerbiboarTrail
{
TRAIL_31303(31303, Varbits.HB_TRAIL_31303, null, new WorldPoint(3697, 3875, 0), null, new WorldPoint(3699, 3875, 0)),
TRAIL_31306(31306, Varbits.HB_TRAIL_31306, null, new WorldPoint(3672, 3890, 0), null, new WorldPoint(3670, 3889, 0)),
TRAIL_31309(31309, Varbits.HB_TRAIL_31309, null, new WorldPoint(3681, 3859, 0), null, new WorldPoint(3681, 3860, 0)),
TRAIL_31312(31312, Varbits.HB_TRAIL_31312, new WorldPoint(3699, 3875, 0), new WorldPoint(3710, 3877, 0), new WorldPoint(3697, 3875, 0), new WorldPoint(3708, 3876, 0)),
TRAIL_31315(31315, Varbits.HB_TRAIL_31315, new WorldPoint(3699, 3875, 0), new WorldPoint(3728, 3893, 0), new WorldPoint(3697, 3875, 0), null),
TRAIL_31318(31318, Varbits.HB_TRAIL_31318, new WorldPoint(3670, 3889, 0), new WorldPoint(3728, 3893, 0), new WorldPoint(3672, 3890, 0), null),
TRAIL_31321(31321, Varbits.HB_TRAIL_31321, new WorldPoint(3670, 3889, 0), new WorldPoint(3667, 3862, 0), new WorldPoint(3672, 3890, 0), new WorldPoint(3668, 3865, 0)),
TRAIL_31324(31324, Varbits.HB_TRAIL_31324, new WorldPoint(3681, 3860, 0), new WorldPoint(3680, 3836, 0), new WorldPoint(3681, 3859, 0), new WorldPoint(3680, 3838, 0)),
TRAIL_31327(31327, Varbits.HB_TRAIL_31327, new WorldPoint(3681, 3860, 0), new WorldPoint(3698, 3847, 0), new WorldPoint(3681, 3859, 0), new WorldPoint(3694, 3847, 0)),
TRAIL_31330(31330, Varbits.HB_TRAIL_31330, new WorldPoint(3708, 3876, 0), new WorldPoint(3713, 3850, 0), new WorldPoint(3710, 3877, 0), new WorldPoint(3715, 3851, 0)),
TRAIL_31333(31333, Varbits.HB_TRAIL_31333, new WorldPoint(3708, 3876, 0), new WorldPoint(3694, 3847, 0), new WorldPoint(3710, 3877, 0), new WorldPoint(3698, 3847, 0)),
TRAIL_31336(31336, Varbits.HB_TRAIL_31336, new WorldPoint(3728, 3893, 0), null, null, null),
TRAIL_31339(31339, Varbits.HB_TRAIL_31339, new WorldPoint(3728, 3893, 0), new WorldPoint(3710, 3877, 0), null, new WorldPoint(3708, 3876, 0)),
TRAIL_31342(31342, Varbits.HB_TRAIL_31342, new WorldPoint(3668, 3865, 0), new WorldPoint(3681, 3860, 0), new WorldPoint(3667, 3862, 0), new WorldPoint(3681, 3859, 0)),
TRAIL_31345(31345, Varbits.HB_TRAIL_31345, new WorldPoint(3668, 3865, 0), new WorldPoint(3680, 3836, 0), new WorldPoint(3667, 3862, 0), new WorldPoint(3680, 3838, 0)),
TRAIL_31348(31348, Varbits.HB_TRAIL_31348, new WorldPoint(3680, 3838, 0), new WorldPoint(3706, 3811, 0), new WorldPoint(3680, 3836, 0), null),
TRAIL_31351(31351, Varbits.HB_TRAIL_31351, new WorldPoint(3680, 3838, 0), null, new WorldPoint(3680, 3836, 0), null),
TRAIL_31354(31354, Varbits.HB_TRAIL_31354, new WorldPoint(3694, 3847, 0), null, new WorldPoint(3698, 3847, 0), null),
TRAIL_31357(31357, Varbits.HB_TRAIL_31357, new WorldPoint(3715, 3851, 0), new WorldPoint(3713, 3840, 0), new WorldPoint(3713, 3850, 0), null),
TRAIL_31360(31360, Varbits.HB_TRAIL_31360, new WorldPoint(3715, 3851, 0), null, new WorldPoint(3713, 3850, 0), null),
TRAIL_31363(31363, Varbits.HB_TRAIL_31363, new WorldPoint(3713, 3850, 0), null, new WorldPoint(3715, 3851, 0), null),
TRAIL_31366(31366, Varbits.HB_TRAIL_31366, null, null, null, null),
TRAIL_31369(31369, Varbits.HB_TRAIL_31369, new WorldPoint(3706, 3811, 0), null, null, null),
TRAIL_31372(31372, Varbits.HB_TRAIL_31372, new WorldPoint(3713, 3840, 0), null, null, null);
@Getter
private final int trailId;
@Getter
private final Varbits varbit;
private final WorldPoint objectLoc1;
private final WorldPoint objectLoc2;
private final WorldPoint objectLoc3;
private final WorldPoint objectLoc4;
@Getter
private static Set<Integer> trailIds = new HashSet<>();
@Getter
private static Set<WorldPoint> allObjectLocs = new HashSet<>();
static
{
for (HerbiboarTrail trail : values())
{
trailIds.add(trail.trailId);
trailIds.add(trail.trailId + 1);
allObjectLocs.addAll(Arrays.asList(trail.getObjectLocs(1)));
allObjectLocs.addAll(Arrays.asList(trail.getObjectLocs(2)));
}
}
public WorldPoint[] getObjectLocs(int varbitValue)
{
switch (varbitValue)
{
case 1:
return new WorldPoint[]{objectLoc1, objectLoc3};
case 2:
return new WorldPoint[]{objectLoc2, objectLoc4};
case 0:
default:
return new WorldPoint[]{};
}
}
@Override
public String toString()
{
return String.format("trailId=%s obj1=%s obj2=%s obj3=%s obj4=%s", trailId, objectLoc1, objectLoc2, objectLoc3, objectLoc4);
}
}

View File

@@ -0,0 +1,339 @@
/*
* Copyright (c) 2017, Tyler <https://github.com/tylerthardy>
* 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.client.plugins.herbiboars;
import com.google.common.eventbus.Subscribe;
import com.google.inject.Provides;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.inject.Inject;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Client;
import static net.runelite.api.ObjectID.DRIFTWOOD_30523;
import static net.runelite.api.ObjectID.MUSHROOM_30520;
import static net.runelite.api.ObjectID.ROCK_30519;
import static net.runelite.api.ObjectID.ROCK_30521;
import static net.runelite.api.ObjectID.ROCK_30522;
import net.runelite.api.Tile;
import net.runelite.api.TileObject;
import net.runelite.api.Varbits;
import net.runelite.api.coords.WorldPoint;
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.GroundObjectChanged;
import net.runelite.api.events.GroundObjectDespawned;
import net.runelite.api.events.GroundObjectSpawned;
import net.runelite.api.events.VarbitChanged;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.ui.overlay.Overlay;
@Slf4j
@PluginDescriptor(
name = "Herbiboars"
)
public class Herbiboars extends Plugin
{
private static final List<WorldPoint> END_LOCATIONS = Arrays.asList(
new WorldPoint(3693, 3798, 0),
new WorldPoint(3702, 3808, 0),
new WorldPoint(3703, 3826, 0),
new WorldPoint(3710, 3881, 0),
new WorldPoint(3700, 3877, 0),
new WorldPoint(3715, 3840, 0),
new WorldPoint(3751, 3849, 0),
new WorldPoint(3685, 3869, 0),
new WorldPoint(3681, 3863, 0)
);
private static final List<Integer> START_OBJECT_IDS = Arrays.asList(
ROCK_30519,
MUSHROOM_30520,
ROCK_30521,
ROCK_30522,
DRIFTWOOD_30523
);
private static final int[] HERBIBOAR_REGIONS = {
14652,
14651,
14908,
14907
};
@Inject
private Client client;
@Inject
private HerbiboarsOverlay overlay;
@Inject
private HerbiboarConfig config;;
@Override
public Overlay getOverlay()
{
return overlay;
}
@Provides
HerbiboarConfig getConfig(ConfigManager configManager)
{
return configManager.getConfig(HerbiboarConfig.class);
}
@Getter
private boolean inHerbiboarArea;
@Getter
private Map<TileObject, Tile> trails = new HashMap<>();
@Getter
private Map<TileObject, Tile> tunnels = new HashMap<>();
@Getter
private Map<TileObject, Tile> starts = new HashMap<>();
@Getter
private Map<TileObject, Tile> trailObjects = new HashMap<>();
@Getter
@Setter
private Set<Integer> shownTrails = new HashSet<>();
@Getter
@Setter
private HerbiboarTrail currentTrail;
@Getter
@Setter
private int currentPath;
@Getter
@Setter
private int finishId;
@Override
protected void startUp() throws Exception
{
inHerbiboarArea = checkArea();
}
private void updateTrailData()
{
currentTrail = null;
currentPath = -1;
//TODO: REGION CHECK
// Get trail data
for (HerbiboarTrail trail : HerbiboarTrail.values())
{
int trailId = trail.getTrailId();
int value = client.getSetting(trail.getVarbit());
if (value > 0)
{
shownTrails.add(trailId);
shownTrails.add(trailId + 1);
}
if (value == 1 || value == 2)
{
currentTrail = trail;
currentPath = value;
}
}
// Get finish data
finishId = client.getSetting(Varbits.HB_FINISH);
if (finishId > 0 && currentTrail != null)
{
shownTrails.add(currentTrail.getTrailId());
shownTrails.add(currentTrail.getTrailId() + 1);
currentTrail = null;
currentPath = -1;
}
int started = client.getSetting(Varbits.HB_STARTED);
if (currentPath == -1 && finishId == 0 && started == 0)
{
resetTrailData();
}
}
private void resetTrailData()
{
currentPath = 0;
currentTrail = null;
finishId = 0;
shownTrails.clear();
}
private void clearCache()
{
starts.clear();
trailObjects.clear();
trails.clear();
tunnels.clear();
}
@Subscribe
public void onGameStateChange(GameStateChanged event)
{
switch (event.getGameState())
{
case HOPPING:
case LOGGING_IN:
resetTrailData();
inHerbiboarArea = checkArea();
break;
case LOADING:
clearCache();
default:
break;
}
}
@Subscribe
public void onVarbitChanged(VarbitChanged event)
{
updateTrailData();
}
@Subscribe
public void GameObjectSpawned(GameObjectSpawned event)
{
onGameObject(event.getTile(), null, event.getGameObject());
}
@Subscribe
public void GameObjectChanged(GameObjectChanged event)
{
onGameObject(event.getTile(), event.getPrevious(), event.getGameObject());
}
@Subscribe
public void GameObjectDeSpawned(GameObjectDespawned event)
{
onGameObject(event.getTile(), event.getGameObject(), null);
}
@Subscribe
public void GroundObjectSpawned(GroundObjectSpawned event)
{
onGroundObject(event.getTile(), null, event.getGroundObject());
}
@Subscribe
public void GroundObjectChanged(GroundObjectChanged event)
{
onGroundObject(event.getTile(), event.getPrevious(), event.getGroundObject());
}
@Subscribe
public void GroundObjectDeSpawned(GroundObjectDespawned event)
{
onGroundObject(event.getTile(), event.getGroundObject(), null);
}
// Store relevant GameObjects (starts, objects used to trigger next trails, and some tunnels)
private void onGameObject(Tile tile, TileObject oldObject, TileObject newObject)
{
trailObjects.remove(oldObject);
tunnels.remove(oldObject);
starts.remove(oldObject);
if (newObject == null)
{
return;
}
// Starts
if (START_OBJECT_IDS.contains(newObject.getId()))
{
starts.put(newObject, tile);
return;
}
// GameObject to trigger next trail (mushrooms, mud, seaweed, etc)
if (HerbiboarTrail.getAllObjectLocs().contains(newObject.getWorldLocation()))
{
trailObjects.put(newObject, tile);
return;
}
// Herbiboar tunnel
if (END_LOCATIONS.contains(newObject.getWorldLocation()))
{
tunnels.put(newObject, tile);
}
}
// Store relevant GroundObjects (tracks on trails, and some tunnels)
private void onGroundObject(Tile tile, TileObject oldObject, TileObject newObject)
{
trails.remove(oldObject);
tunnels.remove(oldObject);
if (newObject == null)
{
return;
}
//Trails
if (HerbiboarTrail.getTrailIds().contains(newObject.getId()))
{
trails.put(newObject, tile);
return;
}
//Herbiboar tunnel
if (END_LOCATIONS.contains(newObject.getWorldLocation()))
{
tunnels.put(newObject, tile);
}
}
private boolean checkArea()
{
return Arrays.stream(client.getMapRegions())
.filter(x -> Arrays.stream(HERBIBOAR_REGIONS).anyMatch(y -> y == x))
.toArray().length > 0;
}
public List<WorldPoint> getEndLocations()
{
return END_LOCATIONS;
}
}

View File

@@ -0,0 +1,157 @@
/*
* Copyright (c) 2017, Tyler <https://github.com/tylerthardy>
* 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.client.plugins.herbiboars;
import com.google.inject.Inject;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.geom.Area;
import java.util.Map;
import java.util.Set;
import net.runelite.api.Client;
import net.runelite.api.Tile;
import net.runelite.api.TileObject;
import net.runelite.api.coords.WorldPoint;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayLayer;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.OverlayUtil;
class HerbiboarsOverlay extends Overlay
{
private final Client client;
private final Herbiboars plugin;
private final HerbiboarConfig config;
@Inject
public HerbiboarsOverlay(Client client, Herbiboars plugin, HerbiboarConfig config)
{
setPosition(OverlayPosition.DYNAMIC);
setLayer(OverlayLayer.ABOVE_WIDGETS);
this.client = client;
this.plugin = plugin;
this.config = config;
}
@Override
public Dimension render(Graphics2D graphics, java.awt.Point parent)
{
if (!plugin.isInHerbiboarArea())
{
return null;
}
HerbiboarTrail currentTrail = plugin.getCurrentTrail();
int finishId = plugin.getFinishId();
// Draw start objects
if (config.isStartShown() && (currentTrail == null && finishId == 0))
{
plugin.getStarts().keySet().forEach((obj) ->
{
OverlayUtil.renderTileOverlay(graphics, obj, "", config.getStartColor());
});
}
// Draw trails
if (config.isTrailShown())
{
Set<Integer> shownTrailIds = plugin.getShownTrails();
plugin.getTrails().keySet().forEach((x) ->
{
int id = x.getId();
if (shownTrailIds.contains(id) && (finishId > 0 || (currentTrail != null && currentTrail.getTrailId() != id && currentTrail.getTrailId() + 1 != id)))
{
OverlayUtil.renderTileOverlay(graphics, x, "", config.getTrailColor());
}
});
}
// Draw trail objects (mushrooms, mud, etc)
if (config.isObjectShown() && currentTrail != null)
{
int currentPath = plugin.getCurrentPath();
plugin.getTrailObjects().keySet().forEach((obj) ->
{
WorldPoint loc = obj.getWorldLocation();
WorldPoint[] trailLocs = currentTrail.getObjectLocs(currentPath);
for (WorldPoint trailLoc : trailLocs)
{
if (trailLoc == null)
{
continue;
}
if (trailLoc.equals(loc))
{
if (config.showClickBoxes())
{
Area clickbox = obj.getClickbox();
graphics.setColor(config.getObjectColor());
graphics.draw(clickbox);
graphics.setColor(new Color(255, 0, 255, 20));
graphics.fill(clickbox);
}
else
{
OverlayUtil.renderTileOverlay(graphics, obj, "", config.getObjectColor());
}
}
}
});
}
// Draw finish tunnels
if (config.isTunnelShown() && finishId > 0)
{
WorldPoint finishLoc = plugin.getEndLocations().get(finishId - 1);
Map<TileObject, Tile> tunnels = plugin.getTunnels();
tunnels.keySet().forEach((obj) ->
{
WorldPoint loc = obj.getWorldLocation();
if (finishLoc.equals(loc))
{
if (config.showClickBoxes())
{
Area clickbox = obj.getClickbox();
Color col = config.getObjectColor();
graphics.setColor(col);
graphics.draw(clickbox);
graphics.setColor(new Color(col.getRed(), col.getGreen(), col.getBlue(), 20));
graphics.fill(clickbox);
}
else
{
OverlayUtil.renderTileOverlay(graphics, obj, "", config.getTunnelColor());
}
}
});
}
return null;
}
}