Make Discord plugin more extensible/support region

- Simplify DiscordState to support more scenarious and use simple
list-based system for determining last event and timeout each event
separately
- Remove actionDelay as that functionality is no longer present
- Add debug log output to DiscordService
- Cleanup DiscordGameEventType to follow new simple DiscordState logic
and add proper priorities to events
- Add support for different type of regions

Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
Tomas Slusny
2018-05-19 01:53:51 +02:00
parent 68489b2a4c
commit 896f70d7a5
5 changed files with 347 additions and 201 deletions

View File

@@ -0,0 +1,33 @@
/*
* Copyright (c) 2018, PandahRS <https://github.com/PandahRS>
* 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.discord;
enum DiscordAreaType
{
BOSSES,
CITIES,
DUNGEONS,
MINIGAMES;
}

View File

@@ -34,23 +34,14 @@ public interface DiscordConfig extends Config
@ConfigItem( @ConfigItem(
keyName = "actionTimeout", keyName = "actionTimeout",
name = "Action timeout (minutes)", name = "Action timeout (minutes)",
description = "Configures after how long of not updating status will be reset (in minutes)" description = "Configures after how long of not updating status will be reset (in minutes)",
position = 1
) )
default int actionTimeout() default int actionTimeout()
{ {
return 5; return 5;
} }
@ConfigItem(
keyName = "actionDelay",
name = "New action delay (seconds)",
description = "Configures the delay before new action will be considered as valid"
)
default int actionDelay()
{
return 10;
}
@ConfigItem( @ConfigItem(
keyName = "showSkillActivity", keyName = "showSkillActivity",
name = "Show activity while skilling", name = "Show activity while skilling",

View File

@@ -1,5 +1,6 @@
/* /*
* Copyright (c) 2018, Tomas Slusny <slusnucky@gmail.com> * Copyright (c) 2018, Tomas Slusny <slusnucky@gmail.com>
* Copyright (c) 2018, PandahRS <https://github.com/PandahRS>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -24,103 +25,100 @@
*/ */
package net.runelite.client.plugins.discord; package net.runelite.client.plugins.discord;
import com.google.common.collect.ImmutableSet; import java.util.HashMap;
import java.util.Set; import java.util.Map;
import java.util.function.Function;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import lombok.RequiredArgsConstructor;
import net.runelite.api.Skill; import net.runelite.api.Skill;
import static net.runelite.api.Skill.AGILITY;
import static net.runelite.api.Skill.ATTACK;
import static net.runelite.api.Skill.CONSTRUCTION;
import static net.runelite.api.Skill.COOKING;
import static net.runelite.api.Skill.CRAFTING;
import static net.runelite.api.Skill.DEFENCE;
import static net.runelite.api.Skill.FARMING;
import static net.runelite.api.Skill.FIREMAKING;
import static net.runelite.api.Skill.FISHING;
import static net.runelite.api.Skill.FLETCHING;
import static net.runelite.api.Skill.HERBLORE;
import static net.runelite.api.Skill.HITPOINTS;
import static net.runelite.api.Skill.HUNTER;
import static net.runelite.api.Skill.MAGIC;
import static net.runelite.api.Skill.MINING;
import static net.runelite.api.Skill.PRAYER;
import static net.runelite.api.Skill.RANGED;
import static net.runelite.api.Skill.RUNECRAFT;
import static net.runelite.api.Skill.SLAYER;
import static net.runelite.api.Skill.SMITHING;
import static net.runelite.api.Skill.STRENGTH;
import static net.runelite.api.Skill.THIEVING;
import static net.runelite.api.Skill.WOODCUTTING;
@RequiredArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@Getter @Getter
public enum DiscordGameEventType enum DiscordGameEventType
{ {
IN_GAME("In Game", false),
IN_MENU("In Menu", false),
TRAINING_ATTACK(ATTACK, DiscordGameEventType::combatSkillChanged),
TRAINING_DEFENCE(DEFENCE, DiscordGameEventType::combatSkillChanged),
TRAINING_STRENGTH(STRENGTH, DiscordGameEventType::combatSkillChanged),
TRAINING_HITPOINTS(HITPOINTS, DiscordGameEventType::combatSkillChanged),
TRAINING_SLAYER(SLAYER, 1, DiscordGameEventType::combatSkillChanged),
TRAINING_RANGED(RANGED, DiscordGameEventType::combatSkillChanged),
TRAINING_MAGIC(MAGIC, DiscordGameEventType::combatSkillChanged),
TRAINING_PRAYER(PRAYER),
TRAINING_COOKING(COOKING),
TRAINING_WOODCUTTING(WOODCUTTING),
TRAINING_FLETCHING(FLETCHING),
TRAINING_FISHING(FISHING),
TRAINING_FIREMAKING(FIREMAKING),
TRAINING_CRAFTING(CRAFTING),
TRAINING_SMITHING(SMITHING),
TRAINING_MINING(MINING),
TRAINING_HERBLORE(HERBLORE),
TRAINING_AGILITY(AGILITY),
TRAINING_THIEVING(THIEVING),
TRAINING_FARMING(FARMING),
TRAINING_RUNECRAFT(RUNECRAFT),
TRAINING_HUNTER(HUNTER),
TRAINING_CONSTRUCTION(CONSTRUCTION);
private static final Set<Skill> COMBAT_SKILLS = ImmutableSet.of(ATTACK, STRENGTH, DEFENCE, HITPOINTS, SLAYER, RANGED, MAGIC); IN_GAME("In Game", -3),
IN_MENU("In Menu", -3),
TRAINING_ATTACK(Skill.ATTACK),
TRAINING_DEFENCE(Skill.DEFENCE),
TRAINING_STRENGTH(Skill.STRENGTH),
TRAINING_HITPOINTS(Skill.HITPOINTS, -1),
TRAINING_SLAYER(Skill.SLAYER, 1),
TRAINING_RANGED(Skill.RANGED),
TRAINING_MAGIC(Skill.MAGIC),
TRAINING_PRAYER(Skill.PRAYER),
TRAINING_COOKING(Skill.COOKING),
TRAINING_WOODCUTTING(Skill.WOODCUTTING),
TRAINING_FLETCHING(Skill.FLETCHING),
TRAINING_FISHING(Skill.FISHING),
TRAINING_FIREMAKING(Skill.FIREMAKING),
TRAINING_CRAFTING(Skill.CRAFTING),
TRAINING_SMITHING(Skill.SMITHING),
TRAINING_MINING(Skill.MINING),
TRAINING_HERBLORE(Skill.HERBLORE),
TRAINING_AGILITY(Skill.AGILITY),
TRAINING_THIEVING(Skill.THIEVING),
TRAINING_FARMING(Skill.FARMING),
TRAINING_RUNECRAFT(Skill.RUNECRAFT),
TRAINING_HUNTER(Skill.HUNTER),
TRAINING_CONSTRUCTION(Skill.CONSTRUCTION);
private final String state; private static final Map<Integer, DiscordGameEventType> FROM_REGION = new HashMap<>();
private final String imageKey;
static
{
for (DiscordGameEventType discordGameEventType : DiscordGameEventType.values())
{
if (discordGameEventType.getRegionIds() == null)
{
continue;
}
for (int region : discordGameEventType.getRegionIds())
{
assert !FROM_REGION.containsKey(region);
FROM_REGION.put(region, discordGameEventType);
}
}
}
private String imageKey;
private String state;
private String details; private String details;
private boolean considerDelay = true; private int priority;
private Function<DiscordGameEventType, Boolean> isChanged = (l) -> true; private boolean shouldClear;
private int priority = 0; private boolean shouldTimeout;
DiscordGameEventType(String state, boolean considerDelay) private DiscordAreaType discordAreaType;
{ private int[] regionIds;
this.state = state;
this.imageKey = "default";
this.considerDelay = considerDelay;
}
DiscordGameEventType(Skill skill, int priority, Function<DiscordGameEventType, Boolean> isChanged)
{
this.state = training(skill);
this.imageKey = imageKeyOf(skill);
this.priority = priority;
this.isChanged = isChanged;
}
DiscordGameEventType(Skill skill, Function<DiscordGameEventType, Boolean> isChanged)
{
this.state = training(skill);
this.imageKey = imageKeyOf(skill);
this.isChanged = isChanged;
}
DiscordGameEventType(Skill skill) DiscordGameEventType(Skill skill)
{
this(skill, 0);
}
DiscordGameEventType(Skill skill, int priority)
{ {
this.state = training(skill); this.state = training(skill);
this.priority = priority;
this.imageKey = imageKeyOf(skill); this.imageKey = imageKeyOf(skill);
this.priority = priority;
this.shouldTimeout = true;
}
DiscordGameEventType(String areaName, DiscordAreaType areaType, int... regionIds)
{
this.details = exploring(areaType, areaName);
this.priority = -2;
this.discordAreaType = areaType;
this.regionIds = regionIds;
this.shouldClear = true;
}
DiscordGameEventType(String state, int priority)
{
this.details = state;
this.priority = priority;
this.shouldClear = true;
} }
private static String training(final Skill skill) private static String training(final Skill skill)
@@ -143,17 +141,21 @@ public enum DiscordGameEventType
return "icon_" + what; return "icon_" + what;
} }
private static boolean combatSkillChanged(final DiscordGameEventType l) private static String exploring(DiscordAreaType areaType, String areaName)
{ {
for (Skill skill : Skill.values()) switch (areaType)
{ {
if (l.getState().contains(skill.getName())) case BOSSES:
{ return "Fighting: " + areaName;
return !COMBAT_SKILLS.contains(skill); case DUNGEONS:
} return "Exploring: " + areaName;
case CITIES:
return "Location: " + areaName;
case MINIGAMES:
return "Playing: " + areaName;
} }
return true; return "";
} }
public static DiscordGameEventType fromSkill(final Skill skill) public static DiscordGameEventType fromSkill(final Skill skill)
@@ -185,4 +187,9 @@ public enum DiscordGameEventType
default: return null; default: return null;
} }
} }
public static DiscordGameEventType fromRegion(final int regionId)
{
return FROM_REGION.get(regionId);
}
} }

View File

@@ -1,5 +1,6 @@
/* /*
* Copyright (c) 2018, Tomas Slusny <slusnucky@gmail.com> * Copyright (c) 2018, Tomas Slusny <slusnucky@gmail.com>
* Copyright (c) 2018, PandahRS <https://github.com/PandahRS>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -29,17 +30,22 @@ import com.google.inject.Inject;
import com.google.inject.Provides; import com.google.inject.Provides;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import java.util.EnumSet;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import net.runelite.api.Client; import net.runelite.api.Client;
import static net.runelite.api.Constants.CHUNK_SIZE;
import net.runelite.api.GameState; import net.runelite.api.GameState;
import net.runelite.api.Skill; import net.runelite.api.Skill;
import net.runelite.api.WorldType;
import net.runelite.api.coords.LocalPoint;
import net.runelite.api.coords.WorldPoint;
import net.runelite.api.events.ConfigChanged;
import net.runelite.api.events.ExperienceChanged; import net.runelite.api.events.ExperienceChanged;
import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.GameStateChanged;
import net.runelite.client.RuneLiteProperties; import net.runelite.client.RuneLiteProperties;
import net.runelite.client.config.ConfigManager; import net.runelite.client.config.ConfigManager;
import net.runelite.client.discord.DiscordService;
import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.task.Schedule; import net.runelite.client.task.Schedule;
@@ -60,19 +66,18 @@ public class DiscordPlugin extends Plugin
@Inject @Inject
private DiscordConfig config; private DiscordConfig config;
@Inject
private DiscordService discordService;
@Inject @Inject
private TitleToolbar titleToolbar; private TitleToolbar titleToolbar;
@Inject @Inject
private RuneLiteProperties properties; private RuneLiteProperties properties;
private final DiscordState discordState = new DiscordState(); @Inject
private DiscordState discordState;
private Map<Skill, Integer> skillExp = new HashMap<>(); private Map<Skill, Integer> skillExp = new HashMap<>();
private boolean loggedIn = false;
private NavigationButton discordButton; private NavigationButton discordButton;
private boolean loginFlag;
@Provides @Provides
private DiscordConfig provideConfig(ConfigManager configManager) private DiscordConfig provideConfig(ConfigManager configManager)
@@ -96,21 +101,48 @@ public class DiscordPlugin extends Plugin
.build(); .build();
titleToolbar.addNavigation(discordButton); titleToolbar.addNavigation(discordButton);
updateGameStatus(client.getGameState(), true); checkForGameStateUpdate();
} }
@Override @Override
protected void shutDown() throws Exception protected void shutDown() throws Exception
{ {
titleToolbar.removeNavigation(discordButton); titleToolbar.removeNavigation(discordButton);
discordService.clearPresence();
discordState.reset(); discordState.reset();
} }
@Subscribe @Subscribe
public void onGameStateChanged(GameStateChanged event) public void onGameStateChanged(GameStateChanged event)
{ {
updateGameStatus(event.getGameState(), false); switch (event.getGameState())
{
case LOGIN_SCREEN:
checkForGameStateUpdate();
return;
case LOGGING_IN:
loginFlag = true;
break;
case LOGGED_IN:
if (loginFlag)
{
loginFlag = false;
checkForGameStateUpdate();
}
break;
}
checkForAreaUpdate();
}
@Subscribe
public void configChanged(ConfigChanged event)
{
if (event.getGroup().equalsIgnoreCase("discord"))
{
checkForGameStateUpdate();
checkForAreaUpdate();
}
} }
@Subscribe @Subscribe
@@ -128,7 +160,7 @@ public class DiscordPlugin extends Plugin
if (discordGameEventType != null && config.showSkillingActivity()) if (discordGameEventType != null && config.showSkillingActivity())
{ {
discordState.triggerEvent(discordGameEventType, config.actionDelay()); discordState.triggerEvent(discordGameEventType);
} }
} }
@@ -138,33 +170,89 @@ public class DiscordPlugin extends Plugin
) )
public void checkForValidStatus() public void checkForValidStatus()
{ {
if (discordState.checkForTimeout(config.actionTimeout())) discordState.checkForTimeout();
{
updateGameStatus(client.getGameState(), true);
}
} }
@Schedule( private void checkForGameStateUpdate()
period = 1,
unit = ChronoUnit.SECONDS
)
public void flushDiscordStatus()
{ {
discordState.flushEvent(discordService); // Game state update does also full reset of discord state
discordState.reset();
discordState.triggerEvent(client.getGameState() == GameState.LOGGED_IN
? DiscordGameEventType.IN_GAME
: DiscordGameEventType.IN_MENU);
} }
private void updateGameStatus(GameState gameState, boolean force) private void checkForAreaUpdate()
{ {
if (gameState == GameState.LOGIN_SCREEN) if (client.getLocalPlayer() == null)
{ {
skillExp.clear(); return;
loggedIn = false;
discordState.triggerEvent(DiscordGameEventType.IN_MENU, config.actionDelay());
} }
else if (client.getGameState() == GameState.LOGGED_IN && (force || !loggedIn))
final int playerRegionID = getCurrentRegion();
if (playerRegionID == 0)
{ {
loggedIn = true; return;
discordState.triggerEvent(DiscordGameEventType.IN_GAME, config.actionDelay());
} }
final DiscordGameEventType discordGameEventType = DiscordGameEventType.fromRegion(playerRegionID);
if (discordGameEventType == null)
{
// Unknown region, reset to default in-game
discordState.triggerEvent(DiscordGameEventType.IN_GAME);
return;
}
if (!showArea(discordGameEventType))
{
return;
}
discordState.triggerEvent(discordGameEventType);
} }
private boolean showArea(final DiscordGameEventType event)
{
if (event == null)
{
return false;
}
final EnumSet<WorldType> worldType = client.getWorldType();
// Do not show location in PVP activities
if (worldType.contains(WorldType.SEASONAL_DEADMAN) ||
worldType.contains(WorldType.DEADMAN) ||
worldType.contains(WorldType.PVP) ||
worldType.contains(WorldType.PVP_HIGH_RISK))
{
return false;
}
return true;
}
private int getCurrentRegion()
{
if (!client.isInInstancedRegion())
{
return client.getLocalPlayer().getWorldLocation().getRegionID();
}
// get chunk data of current chunk
final LocalPoint localPoint = client.getLocalPlayer().getLocalLocation();
final int[][][] instanceTemplateChunks = client.getInstanceTemplateChunks();
final int z = client.getPlane();
final int chunkData = instanceTemplateChunks[z][localPoint.getRegionX() / CHUNK_SIZE][localPoint.getRegionY() / CHUNK_SIZE];
// extract world point from chunk data
final int chunkY = (chunkData >> 3 & 0x7FF) * CHUNK_SIZE;
final int chunkX = (chunkData >> 14 & 0x3FF) * CHUNK_SIZE;
final WorldPoint worldPoint = new WorldPoint(chunkX, chunkY, z);
return worldPoint.getRegionID();
}
} }

View File

@@ -24,109 +24,136 @@
*/ */
package net.runelite.client.plugins.discord; package net.runelite.client.plugins.discord;
import com.google.common.base.MoreObjects;
import com.google.common.collect.ComparisonChain;
import java.time.Duration; import java.time.Duration;
import java.time.Instant; import java.time.Instant;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Optional;
import javax.inject.Inject;
import lombok.Data;
import net.runelite.client.discord.DiscordPresence; import net.runelite.client.discord.DiscordPresence;
import net.runelite.client.discord.DiscordService; import net.runelite.client.discord.DiscordService;
public class DiscordState /**
* This class contains data about currently active discord state.
*/
class DiscordState
{ {
private final List<DiscordGameEventType> lastQueue = new ArrayList<>(); @Data
private DiscordGameEventType lastEvent; private class EventWithTime
private Instant startOfAction; {
private Instant lastAction; private final DiscordGameEventType type;
private DiscordPresence lastPresence; private final Instant start;
private boolean needsFlush; private Instant updated;
}
private final List<EventWithTime> events = new ArrayList<>();
private final DiscordService discordService;
private final DiscordConfig config;
private DiscordPresence lastPresence;
@Inject
private DiscordState(final DiscordService discordService, final DiscordConfig config)
{
this.discordService = discordService;
this.config = config;
}
/**
* Reset state.
*/
void reset() void reset()
{ {
lastQueue.clear(); discordService.clearPresence();
lastEvent = null; events.clear();
startOfAction = null;
lastAction = null;
lastPresence = null; lastPresence = null;
needsFlush = false;
} }
void flushEvent(DiscordService discordService) /**
* Trigger new discord state update.
*
* @param eventType discord event type
*/
void triggerEvent(final DiscordGameEventType eventType)
{ {
if (lastPresence != null && needsFlush) final Optional<EventWithTime> foundEvent = events.stream().filter(e -> e.type == eventType).findFirst();
{ EventWithTime event;
needsFlush = false;
discordService.updatePresence(lastPresence);
}
}
void triggerEvent(final DiscordGameEventType eventType, int delay) if (foundEvent.isPresent())
{
final boolean first = startOfAction == null;
final boolean changed = eventType != lastEvent && eventType.getIsChanged().apply(lastEvent);
boolean reset = false;
if (first)
{ {
reset = true; event = foundEvent.get();
} }
else if (changed) else
{ {
if (eventType.isConsiderDelay()) event = new EventWithTime(eventType, Instant.now());
events.add(event);
}
event.setUpdated(Instant.now());
if (event.getType().isShouldClear())
{
events.removeIf(e -> e.getType() != eventType && e.getType().isShouldClear());
}
events.sort((a, b) -> ComparisonChain.start()
.compare(b.getType().getPriority(), a.getType().getPriority())
.compare(b.getUpdated(), a.getUpdated())
.result());
event = events.get(0);
String imageKey = null;
String state = null;
String details = null;
for (EventWithTime eventWithTime : events)
{
if (imageKey == null)
{ {
final Duration actionDelay = Duration.ofSeconds(delay); imageKey = eventWithTime.getType().getImageKey();
final Duration sinceLastAction = Duration.between(lastAction, Instant.now());
if (sinceLastAction.compareTo(actionDelay) >= 0)
{
reset = true;
}
} }
else
if (details == null)
{ {
reset = true; details = eventWithTime.getType().getDetails();
}
if (state == null)
{
state = eventWithTime.getType().getState();
}
if (imageKey != null && details != null && state != null)
{
break;
} }
} }
if (reset) final DiscordPresence presence = DiscordPresence.builder()
.state(MoreObjects.firstNonNull(state, ""))
.details(MoreObjects.firstNonNull(details, ""))
.startTimestamp(event.getStart())
.smallImageKey(MoreObjects.firstNonNull(imageKey, "default"))
.build();
// This is to reduce amount of RPC calls
if (!presence.equals(lastPresence))
{ {
lastQueue.clear(); lastPresence = presence;
startOfAction = Instant.now(); discordService.updatePresence(presence);
}
if (!lastQueue.contains(eventType))
{
lastQueue.add(eventType);
lastQueue.sort(Comparator.comparingInt(DiscordGameEventType::getPriority));
}
lastAction = Instant.now();
final DiscordGameEventType newEvent = lastQueue.get(lastQueue.size() - 1);
if (lastEvent != newEvent)
{
lastEvent = newEvent;
lastPresence = DiscordPresence.builder()
.state(lastEvent.getState())
.details(lastEvent.getDetails())
.startTimestamp(startOfAction)
.smallImageKey(newEvent.getImageKey())
.build();
needsFlush = true;
} }
} }
boolean checkForTimeout(final int timeout) /**
* Check for current state timeout and act upon it.
*/
void checkForTimeout()
{ {
if (lastAction == null) final Duration actionTimeout = Duration.ofMinutes(config.actionTimeout());
{ events.removeIf(event -> event.getType().isShouldTimeout() &&
return false; event.getUpdated().isAfter(event.getStart().plus(actionTimeout)));
}
final Duration actionTimeout = Duration.ofMinutes(timeout);
return Instant.now().isAfter(lastAction.plus(actionTimeout));
} }
} }