Skip to content

Commit

Permalink
Merge pull request #142 from nwesterhausen/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
nwesterhausen authored Nov 30, 2022
2 parents faaf0ff + 3ca5c7c commit 7696cf4
Show file tree
Hide file tree
Showing 47 changed files with 2,428 additions and 919 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
run: dotnet build --no-restore -c Release
- name: Attach release artifacts
uses: softprops/action-gh-release@v1
with:
Expand Down
17 changes: 15 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
{
"cSpell.words": [
"aequasi",
"Bepin",
"Bson",
"denikson",
"Digitalroot",
"discordconnector",
"ipify",
"Ipify",
"Leaderboard",
"leaderboards",
"PLAYERID",
"PUBLICIP",
"r2modman",
"Roadmap",
"softprops",
"Spidey",
"STEAMID",
"tcli",
"thedefside",
"Thunderstore",
"valheim",
"Valheim",
"Xithyr"
]
"Worldof",
"Xithyr",
"ZDOID",
"ZDOS"
],
"conventionalCommits.scopes": ["metadata", "gh-actions", "release"]
}
15 changes: 7 additions & 8 deletions DiscordConnector.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
<LangVersion>latest</LangVersion>
<OutputType>Library</OutputType>
<Optimize>true</Optimize>
</PropertyGroup>
<PropertyGroup>
<Deterministic>true</Deterministic>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>

Expand All @@ -20,23 +19,23 @@
<PackageReference Include="UnityEngine.Modules" Version="2019.4.24" IncludeAssets="compile" />
<PackageReference Include="Valheim.GameLibs" Version="*-*" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="all" />
</ItemGroup>

<Target Name="CreatePluginDir" AfterTargets="PrepareForBuild">
<Target Name="CreatePluginDir" AfterTargets="PrepareForBuild">
<MakeDir Directories="$(ProjectDir)bin/DiscordConnector" Condition="!Exists('$(ProjectDir)bin/DiscordConnector')" />
<MakeDir Directories="$(ProjectDir)bin/DiscordConnector/plugins" Condition="!Exists('$(ProjectDir)bin/DiscordConnector/plugins')" />
</Target>

<Target Name="CopyPluginFiles" AfterTargets="Build">
<ItemGroup>
<BuiltLibraryAndDeps Include="$(ProjectDir)bin/Debug/net48/DiscordConnector.dll" />
<BuiltLibraryAndDeps Include="$(TargetDir)DiscordConnector.dll" />
<!-- Include Newtonsoft.Json dependency -->
<BuiltLibraryAndDeps Include="$(ProjectDir)lib/Newtonsoft.Json/*.dll" />
<BuiltLibraryAndDeps Include="$(TargetDir)Newtonsoft.Json/*.dll" />
<!-- Include LiteDB dependency -->
<BuiltLibraryAndDeps Include="$(ProjectDir)bin/Debug/net48/LiteDB.dll" />
<BuiltLibraryAndDeps Include="$(TargetDir)LiteDB.dll" />
<!-- Metadata files for Thunderstore -->
<ThunderstoreMetadata Include="$(ProjectDir)Metadata/manifest.json" />
<ThunderstoreMetadata Include="$(ProjectDir)Metadata/icon.png" />
Expand All @@ -53,4 +52,4 @@
<Delete Files="$(ProjectDir)bin/DiscordConnector.zip" Condition="!Exists('$(ProjectDir)bin/bin/DiscordConnector.zip')" />
<ZipDirectory SourceDirectory="$(ProjectDir)bin/DiscordConnector" DestinationFile="$(ProjectDir)bin/DiscordConnector.zip" />
</Target>
</Project>
</Project>
25 changes: 25 additions & 0 deletions Metadata/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,31 @@ A full changelog for reference.

## History

### Version 2.1.0

A full leaderboard overhaul is in the version. The previous settings for the statistic leaderboards are depreciated in favor of configuration defined statistic leaderboard settings. Look in the `discordconnector-leaderboards.cfg` file and configure any number of the 4 leaderboards to present the kind of data you want. In addition to multiple leaderboards, there are now time-based filters for the leaderboards; restrict them to today or this week or leave them set to all-time. By default, all leaderboards are disabled. If you were using a leaderboard before, you will have to set up a leaderboard to accomplish what you were sending before and enable it. Sorry for the inconvenience but this was the safest tradeoff.

Also relating to statistic leaderboards, there is a new statistic available for the leaderboards, 'Time Online' which uses the saved 'join' and 'leave' records to estimate a player's time on the server and present that as a value. This obviously doesn't work if you had disabled one or the other pieces of tracking (either disabled recording 'join' or 'leave' stats in the toggles config file). This values are calculated when the leaderboard is created but that should be OK since it is in a non-blocking task call.

The new Active Player's Announcement can be configured to announce server activity at a pre-defined interval. Configurable stats for it include players currently online, unique players online today, unique players online this week and unique players all time. It will use the same method set in the main config file (`discordconnector.cfg`) for how to determine individual players to count unique players for these time spans.

Additionally, the configuration files are nested in a subdirectory now. This is from a request on the plugin repository. When loading 2.1.0 (or future versions), the Discord Connector config files that are in the `BepInEx/config` directory will be automatically moved to the subdirectory and loaded from there. The subdirectory is `BepInEx/config/games.nwest.valheim.discordconnector`, and the config files themselves have shortened filenames. The records database is also moved to this subdirectory and renamed `records.db`.

Features:

- Adds new tracked stat for time on server (only works if you have enabled join and leave stats)
- Adds dynamically configured leaderboards (disabled by default)
- Adds an Active Players Announcement (disabled by default)

Changes:

- Configuration files are now nested in a subdirectory (first run will migrate them automatically)
- Database file moved into the subdirectory (first run will migrate it automatically)
- `config-debug.json` file is dumped to subdirectory after config load to be useful for debugging issues with the plugin (sensitive info is redacted, i.e. the webhook url)
- Multiple-choice config options use Enums on the backend now instead of Strings (may affect `discordconnector.cfg`: How to discern players in Record Retrieval)
- Building the plugin with the optimization flag present; in my tests, startup time of a Valheim server with just DiscordConnector installed was quicker
- Public IP is only queried if it is used (by including the %PUBLICIP% variable in a message)

### Version 2.0.8

Changes:
Expand Down
83 changes: 17 additions & 66 deletions Metadata/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Connect your Valheim server (dedicated or served from the game itself) to a Disc
- Set more than one message for each type and have one randomly chosen!
- Record number of logins/deaths/pings and flavor the Discord messages
- Works with non-dedicated server (games opened to lan from the client)
- Configure custom leader boards to be sent periodically, listing rankings for any of the tracked stats

### Supported Message Notifications

Expand All @@ -28,83 +29,33 @@ Connect your Valheim server (dedicated or served from the game itself) to a Disc

See the [current roadmap](https://github.com/nwesterhausen/valheim-discordconnector/projects/1) as a Github project.

- Fancier Discord messages
- Discord bot integration
- Multiple webhook support
- More statistics able to be sent
- More statistics trackable/able to be sent
- New day messages

## Changelog

### Version 2.0.8
### Version 2.1.0

Changes:

- `%WORLD_NAME%` will now only replace with world name once server has started up to avoid an issue with Key Manager

### Version 2.0.7

Changes:

- Further guards against null-reference exceptions

### Version 2.0.6
A full leaderboard overhaul is in the version. The previous settings for the statistic leaderboards are depreciated in favor of configuration defined statistic leaderboard settings. Look in the `discordconnector-leaderboards.cfg` file and configure any number of the 4 leaderboards to present the kind of data you want. In addition to multiple leaderboards, there are now time-based filters for the leaderboards; restrict them to today or this week or leave them set to all-time. By default, all leaderboards are disabled. If you were using a leaderboard before, you will have to set up a leaderboard to accomplish what you were sending before and enable it. Sorry for the inconvenience but this was the safest tradeoff.

Fixes:
Also relating to statistic leaderboards, there is a new statistic available for the leaderboards, 'Time Online' which uses the saved 'join' and 'leave' records to estimate a player's time on the server and present that as a value. This obviously doesn't work if you had disabled one or the other pieces of tracking (either disabled recording 'join' or 'leave' stats in the toggles config file). This values are calculated when the leaderboard is created but that should be OK since it is in a non-blocking task call.

- Fixes plugin crash that could occur if the game was initiated more than once.
- Removed extraneous discord message on server load
The new Active Player's Announcement can be configured to announce server activity at a pre-defined interval. Configurable stats for it include players currently online, unique players online today, unique players online this week and unique players all time. It will use the same method set in the main config file (`discordconnector.cfg`) for how to determine individual players to count unique players for these time spans.

### Version 2.0.5
Additionally, the configuration files are nested in a subdirectory now. This is from a request on the plugin repository. When loading 2.1.0 (or future versions), the Discord Connector config files that are in the `BepInEx/config` directory will be automatically moved to the subdirectory and loaded from there. The subdirectory is `BepInEx/config/games.nwest.valheim.discordconnector`, and the config files themselves have shortened filenames. The records database is also moved to this subdirectory and renamed `records.db`.

Features:

- Adds a config option to format how position data is formatted
- Adds a config option to format how the automatically-appended position data is formatted
- Adds a new variable which can be used in any messages: `%WORLD_NAME%` turns into the name of the world.
- Adds new tracked stat for time on server (only works if you have enabled join and leave stats) *The duration provided will probably be inaccurate*
- Adds dynamically configured leaderboards (disabled by default)
- Adds an Active Players Announcement (disabled by default)

Changes:

- `%POS%` now renders without the enclosing parentheses.

### Version 2.0.4

Features:

- Adds a config option to enable sending non-player shouts to Discord. This is in the main config file and disabled by default.

### Version 2.0.3

Other Changes:

- Set BepInEx dependency to exactly 5.4.19 instead of 5.* (this stops a warning from showing up)

### Version 2.0.2

If a shout is performed by a player that isn't a real player (like a mod), it would break the shout call from working. This is because Discord Connector was trying to lookup the player's details and encountering null. The plugin now checks for that and returns early if null is found.

Fixes:

- Detect if a shout is by a non-player and gracefully exit.

### Version 2.0.1

With this update, we bring back Steam_ID variable inclusion and leaderboard message sending (respecting your config settings). I recommend you replace your `discordconnector.valheim.nwest.games-records.db` database, since the records will not line up and will be essentially soft-reset because the column name changed with the different type of data. Steam IDs are prefaced with 'Steam_' now, so you could migrate your stat database with a bit of effort. I believe this could all be done with queries inside the LiteDB Query Tool.

Fixes:

- Periodic leaderboard messages sending will now respect your config value instead of never sending
- The STEAMID variable works again. An alias is the PLAYERID variable, which does the same thing -- they both provide the full player id, so `Steam_<SteamID>` or `XBox_<XBoxID>`

Breaking changes:

- Player IDs are tracked in the stat database using a new column name, which resets any stat tracking because the player ID is used to resolve to a single player by combining with the character name.

### Version 2.0.0

Previous version broke with the new updates to Valheim using the PlayFab server stuff. Previously, the steam ID was grabbed directly from the socket but that doesn't work anymore. To get something workable (the other messages work), I have removed the code which tried to get the SteamID and disabled leaderboard sending.

Breaking changes:

- Removed steamid variable (internally) and tracking stats by steamid. This broke with the PlayFab changes to Valheim. It will be a bit involved to figure out how to deliver the same thing again, so if you have an idea or seen it done in another mod, please reach out with a Github Issue or ping on Discord.
- Leaderboard records will reset and a new database with suffix '-records2.db' will be saved anew. This is because what is being tracked is changed (used to be steamid, now it is using the character id).
- Periodic leaderboard messages will not send, ignoring the setting in the config (for now). This is until a more reliable method of determining players apart.
- Configuration files are now nested in a subdirectory (first run will migrate them automatically)
- Database file moved into the subdirectory (first run will migrate it automatically)
- `config-debug.json` file is dumped to subdirectory after config load to be useful for debugging issues with the plugin (sensitive info is redacted, i.e. the webhook url)
- Multiple-choice config options use Enums on the backend now instead of Strings (may affect `discordconnector.cfg`: How to discern players in Record Retrieval)
- Building the plugin with the optimization flag present; in my tests, startup time of a Valheim server with just DiscordConnector installed was quicker
- Public IP is only queried if it is used (by including the %PUBLICIP% variable in a message)
Binary file added Metadata/icon2-hdpi.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Metadata/icon2-xhdpi-box.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Metadata/icon2-xhdpi.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Metadata/icon2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
67 changes: 67 additions & 0 deletions Metadata/icon2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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": "2.0.8",
"version_number": "2.1.0",
"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.1901"]
Expand Down
4 changes: 2 additions & 2 deletions Metadata/thunderstore.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ schemaVersion = "0.0.1"
[package]
namespace = "nwesterhausen"
name = "DiscordConnector"
versionNumber = "2.0.8"
versionNumber = "2.1.0"
description = "Connects your Valheim server to a Discord webhook. Works for both dedicated and client-hosted servers."
websiteUrl = "https://discordconnector.valheim.nwest.games/"
containsNsfwContent = false
Expand All @@ -24,4 +24,4 @@ target = ""
[publish]
repository = "https://thunderstore.io"
communities = ["valheim"]
categories = []
categories = []
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![Build](https://github.com/nwesterhausen/valheim-discordconnector/actions/workflows/dotnet.yml/badge.svg)](https://github.com/nwesterhausen/valheim-discordconnector/actions/workflows/dotnet.yml)
[![Publish](https://github.com/nwesterhausen/valheim-discordconnector/actions/workflows/publish.yml/badge.svg)](https://github.com/nwesterhausen/valheim-discordconnector/actions/workflows/publish.yml)
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/nwesterhausen/valheim-discordconnector?label=Github%20Release&style=flat&labelColor=%2332393F)](https://github.com/nwesterhausen/valheim-discordconnector/releases/latest)
[![Thunderstore.io](https://img.shields.io/badge/Thunderstore.io-2.0.8-%23375a7f?style=flat&labelColor=%2332393F)](https://valheim.thunderstore.io/package/nwesterhausen/DiscordConnector/)
[![Thunderstore.io](https://img.shields.io/badge/Thunderstore.io-2.1.0-%23375a7f?style=flat&labelColor=%2332393F)](https://valheim.thunderstore.io/package/nwesterhausen/DiscordConnector/)
[![NexusMods](https://img.shields.io/badge/NexusMods-2.0.6-%23D98F40?style=flat&labelColor=%2332393F)](https://www.nexusmods.com/valheim/mods/1551/)

Connect your Valheim server to Discord. ([See website for installation or configuration instructions](https://discordconnector.valheim.nwest.games/)). This plugin is largely based on [valheim-discord-notifier](https://github.com/aequasi/valheim-discord-notifier), but this plugin supports randomized messages, muting players, and Discord message embeds.
Expand Down
Loading

0 comments on commit 7696cf4

Please sign in to comment.