Skip to content

Commit

Permalink
Merge pull request #97 from nwesterhausen/dev
Browse files Browse the repository at this point in the history
1.5.2 Record Retrieval Fixes
  • Loading branch information
nwesterhausen authored Oct 28, 2021
2 parents 4ef37ef + 967032d commit 12c6775
Show file tree
Hide file tree
Showing 13 changed files with 172 additions and 71 deletions.
10 changes: 10 additions & 0 deletions Metadata/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

A full changelog for reference.

### Version 1.5.2

Fixes:

- Highest and Lowest leaderboards were not checking the correct tables
- Configurable retrieval strategy for all records (either SteamID, PLayer Name, or both) -- always returns player names

Due to how records.json recorded stats and the LiteDB, you will not be able to use the old records with strategies
involving the SteamID because prior to 1.5.0 we were not recording the SteamID with the record.

### Version 1.5.1

Fixes:
Expand Down
19 changes: 6 additions & 13 deletions Metadata/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,15 @@ See the [current roadmap](https://github.com/nwesterhausen/valheim-discordconnec

## Changelog

**Release 1.0.0+ is a breaking release** since the structure of the configuration files completely changes. When you update you will need to modify the config
to save your webhook again and to update any message customization you have done!
### Version 1.5.2

**Release 1.2.0 affected the records.json file** so if you update and notice that your recorded stats aren't changing, it's a simple fix.

records.json pre 1.2.0:

```json
[{"Category":"death","Values":[{"PlayerName":"Xithyr","Value":13} ...
```
Fixes:

records.json 1.2.0+ (PlayerName changed to Key)
- Highest and Lowest leaderboards were not checking the correct tables
- Configurable retrieval strategy for all records (either SteamID, PLayer Name, or both) -- always returns player names

```json
[{"Category":"death","Values":[{"Key":"Xithyr","Value":13} ...
```
Due to how records.json recorded stats and the LiteDB, you will not be able to use the old records with strategies
involving the SteamID because prior to 1.5.0 we were not recording the SteamID with the record.

### Version 1.5.1

Expand Down
2 changes: 1 addition & 1 deletion Metadata/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "DiscordConnector",
"version_number": "1.5.1",
"version_number": "1.5.2",
"website_url": "https://discordconnector.valheim.nwest.games/",
"description": "Connects your Valheim server to a Discord webhook. Works for both dedicated and client-hosted servers.",
"dependencies": ["denikson-BepInExPack_Valheim-5.4.1600"]
Expand Down
10 changes: 10 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

A full changelog

### Version 1.5.2

Fixes:

- Highest and Lowest leaderboards were not checking the correct tables
- Configurable retrieval strategy for all records (either SteamID, PLayer Name, or both) -- always returns player names

Due to how records.json recorded stats and the LiteDB, you will not be able to use the old records with strategies
involving the SteamID because prior to 1.5.0 we were not recording the SteamID with the record.

### Version 1.5.1

Fixes:
Expand Down
22 changes: 21 additions & 1 deletion src/Config/MainConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@

namespace DiscordConnector.Config
{
public static class RetrievalDiscernmentMethods
{
public static readonly string BySteamID = "Treat each SteamID as a separate player";
public static readonly string ByNameAndSteamID = "Treat each SteamID:PlayerName combo as a separate player";
public static readonly string ByName = "Treat each PlayerName as a separate player";

}
internal class MainConfig
{
private ConfigFile config;
Expand All @@ -20,6 +27,7 @@ internal class MainConfig
private ConfigEntry<bool> sendPositionsToggle;
private ConfigEntry<bool> announcePlayerFirsts;
private ConfigEntry<int> numberRankingsListed;
private ConfigEntry<string> playerLookupPreference;

public MainConfig(ConfigFile configFile)
{
Expand Down Expand Up @@ -86,6 +94,16 @@ private void LoadConfig()
3,
"Set how many places (1st, 2nd, 3rd by default) to display when sending the ranked leaderboard.");

playerLookupPreference = config.Bind<string>(MAIN_SETTINGS,
"How to discern players in Record Retrieval",
RetrievalDiscernmentMethods.BySteamID,
new ConfigDescription("Choose a method for how players will be separated from the results of a record query.",
new AcceptableValueList<string>(new string[] {
RetrievalDiscernmentMethods.BySteamID,
RetrievalDiscernmentMethods.ByName,
RetrievalDiscernmentMethods.ByNameAndSteamID
})));


config.Save();
}
Expand All @@ -103,7 +121,8 @@ public string ConfigAsJson()
jsonString += $"\"colectStatsEnabled\":\"{CollectStatsEnabled}\",";
jsonString += $"\"sendPositionsEnabled\":\"{SendPositionsEnabled}\",";
jsonString += $"\"announcePlayerFirsts\":\"{AnnouncePlayerFirsts}\",";
jsonString += $"\"numberRankingsListed\":\"{IncludedNumberOfRankings}\"";
jsonString += $"\"numberRankingsListed\":\"{IncludedNumberOfRankings}\",";
jsonString += $"\"playerLookupPreference\":\"{RecordRetrievalDiscernmentMethod}\"";
jsonString += "}";
return jsonString;
}
Expand All @@ -117,6 +136,7 @@ public string ConfigAsJson()
public List<string> MutedPlayers => mutedPlayers;
public bool AnnouncePlayerFirsts => announcePlayerFirsts.Value;
public int IncludedNumberOfRankings => numberRankingsListed.Value;
public string RecordRetrievalDiscernmentMethod => playerLookupPreference.Value;

}
}
2 changes: 2 additions & 0 deletions src/Config/PluginConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public void ReloadConfig()
public bool DiscordEmbedsEnabled => mainConfig.DiscordEmbedsEnabled;
public bool SendPositionsEnabled => mainConfig.SendPositionsEnabled;
public bool AnnouncePlayerFirsts => mainConfig.AnnouncePlayerFirsts;
public string RecordRetrievalDiscernmentMethod => mainConfig.RecordRetrievalDiscernmentMethod;
public List<string> MutedPlayers => mainConfig.MutedPlayers;


Expand Down Expand Up @@ -162,6 +163,7 @@ public void ReloadConfig()
public bool DebugEveryEventCheck => togglesConfig.DebugEveryEventCheck;
public bool DebugEveryEventChange => togglesConfig.DebugEveryEventChange;
public bool DebugHttpRequestResponse => togglesConfig.DebugHttpRequestResponse;
public bool DebugDatabaseMethods => togglesConfig.DebugDatabaseMethods;

// Leaderboard Messages
public string LeaderboardTopPlayerHeading => messagesConfig.LeaderboardTopPlayerHeading;
Expand Down
7 changes: 7 additions & 0 deletions src/Config/TogglesConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ internal class TogglesConfig
private ConfigEntry<bool> debugEveryEventPlayerPosCheck;
private ConfigEntry<bool> debugEventChanges;
private ConfigEntry<bool> debugHttpRequestResponses;
private ConfigEntry<bool> debugDatabaseMethods;

public TogglesConfig(ConfigFile configFile)
{
Expand Down Expand Up @@ -315,6 +316,10 @@ private void LoadConfig()
false,
"If enabled, this will write a log message at the DEBUG level with the content of HTTP request responses." + Environment.NewLine +
"Nearly all of these requests are when data is sent to the Discord Webhook.");
debugDatabaseMethods = config.Bind<bool>(DEBUG_TOGGLES,
"Debug Message for Database Methods",
false,
"If enabled, this will write a log message at the DEBUG level with logs generated while executing database methods.");

// LEADERBOARD_BOTTOM_N_TOGGLES
sendDeathInverseRankingLeaderboard = config.Bind<bool>(LEADERBOARD_BOTTOM_N_TOGGLES,
Expand Down Expand Up @@ -409,6 +414,7 @@ public string ConfigAsJson()
jsonString += $"\"debugEveryPlayerPosCheck\":\"{DebugEveryPlayerPosCheck}\",";
jsonString += $"\"debugEveryEventCheck\":\"{DebugEveryEventCheck}\",";
jsonString += $"\"debugEventChanges\":\"{DebugEveryEventChange}\",";
jsonString += $"\"debugDatabaseMethods\":\"{DebugDatabaseMethods}\",";
jsonString += $"\"debugHttpRequestResponses\":\"{DebugHttpRequestResponse}\"";
jsonString += "},";

Expand Down Expand Up @@ -472,6 +478,7 @@ public string ConfigAsJson()
public bool DebugEveryEventCheck => debugEveryEventCheck.Value;
public bool DebugEveryEventChange => debugEventChanges.Value;
public bool DebugHttpRequestResponse => debugHttpRequestResponses.Value;
public bool DebugDatabaseMethods => debugDatabaseMethods.Value;
public bool InverseRankedDeathLeaderboardEnabled => sendDeathInverseRankingLeaderboard.Value;
public bool InverseRankedPingLeaderboardEnabled => sendPingInverseRankingLeaderboard.Value;
public bool InverseRankedSessionLeaderboardEnabled => sendSessionInverseRankingLeaderboard.Value;
Expand Down
1 change: 0 additions & 1 deletion src/Leaderboard/Leaderboard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ internal abstract class Base
/// </summary>
public void SendLeaderboardOnTimer(object sender, ElapsedEventArgs elapsedEventArgs)
{
Plugin.StaticLogger.LogDebug($"Running the leaderboard send");
this.SendLeaderboard();
}

Expand Down
3 changes: 2 additions & 1 deletion src/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ private void Awake()
leaderboardTimer.Elapsed += StaticLeaderboards.TopPlayers.SendLeaderboardOnTimer;
leaderboardTimer.Elapsed += StaticLeaderboards.BottomPlayers.SendLeaderboardOnTimer;
// Interval is learned from config file in minutes
leaderboardTimer.Interval = 60 * 1000 * StaticConfig.StatsAnnouncementPeriod;
// leaderboardTimer.Interval = 60 * 1000 * StaticConfig.StatsAnnouncementPeriod;
leaderboardTimer.Interval = 30 * 1000 * StaticConfig.StatsAnnouncementPeriod;
Plugin.StaticLogger.LogDebug($"Enabling leaderboard timers with interval {leaderboardTimer.Interval}ms");
leaderboardTimer.Start();
}
Expand Down
2 changes: 1 addition & 1 deletion src/PluginInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ internal static class PluginInfo
{
public const string PLUGIN_ID = "games.nwest.valheim.discordconnector";
public const string PLUGIN_NAME = "Valheim Discord Connector";
public const string PLUGIN_VERSION = "1.5.1";
public const string PLUGIN_VERSION = "1.5.2";
public const string PLUGIN_REPO_SHORT = "github: nwesterhausen/valheim-discordconnector";
public const string PLUGIN_AUTHOR = "Nicholas Westerhausen";
}
Expand Down
5 changes: 5 additions & 0 deletions src/Records/Classes/SimpleStat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ public SimpleStat(ObjectId _id, string name, System.DateTime date, ulong steamId
SteamId = steamId;
Pos = pos;
}

public override string ToString()
{
return $"{Date.ToShortDateString()} {Date.ToShortTimeString()}: {Name} ({SteamId}) at {Pos}";
}
}

}
Loading

0 comments on commit 12c6775

Please sign in to comment.