Skip to content

Commit

Permalink
Merge pull request #138 from nwesterhausen/dev
Browse files Browse the repository at this point in the history
fix: 🐛 remove extra discord message, guard against double-adding keys
  • Loading branch information
nwesterhausen authored Nov 24, 2022
2 parents 73cfd27 + e5451bf commit 0f6afad
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 10 deletions.
1 change: 1 addition & 0 deletions DiscordConnector.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
<OutputType>Library</OutputType>
<Optimize>true</Optimize>
</PropertyGroup>
<PropertyGroup>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
Expand Down
7 changes: 7 additions & 0 deletions Metadata/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ A full changelog for reference.

## History

### Version 2.0.6

Fixes:

- Fixes plugin crash that could occur if the game was initiated more than once.
- Removed extraneous discord message on server load

### Version 2.0.5

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

## Changelog

### Version 2.0.6

Fixes:

- Fixes plugin crash that could occur if the game was initiated more than once.
- Removed extraneous discord message on server load

### Version 2.0.5

Features:
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": "2.0.5",
"version_number": "2.0.6",
"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
2 changes: 1 addition & 1 deletion 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.5"
versionNumber = "2.0.6"
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 Down
7 changes: 7 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ A full changelog

## History

### Version 2.0.6

Fixes:

- Fixes plugin crash that could occur if the game was initiated more than once.
- Removed extraneous discord message on server load

### Version 2.0.5

Features:
Expand Down
60 changes: 53 additions & 7 deletions src/Patches/ZNetPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,59 @@ internal class SetServer
{
private static void Postfix(ref bool server, ref bool openServer, ref bool publicServer, ref string serverName, ref string password, ref World world)
{
DiscordApi.SendMessage("Loaded server info");
Plugin.StaticServerSetup.Add(Plugin.ServerSetup.IsServer, server);
Plugin.StaticServerSetup.Add(Plugin.ServerSetup.IsOpenServer, openServer);
Plugin.StaticServerSetup.Add(Plugin.ServerSetup.IsPublicServer, publicServer);
Plugin.StaticServerInfo.Add(Plugin.ServerInfo.WorldName, world.m_name);
Plugin.StaticServerInfo.Add(Plugin.ServerInfo.WorldSeed, $"{world.m_seed}");
Plugin.StaticServerInfo.Add(Plugin.ServerInfo.WorldSeedName, world.m_seedName);
if (Plugin.StaticServerSetup.ContainsKey(Plugin.ServerSetup.IsServer))
{
Plugin.StaticServerSetup[Plugin.ServerSetup.IsServer] = server == true;
}
else
{
Plugin.StaticServerSetup.Add(Plugin.ServerSetup.IsServer, server == true);
}

if (Plugin.StaticServerSetup.ContainsKey(Plugin.ServerSetup.IsOpenServer))
{
Plugin.StaticServerSetup[Plugin.ServerSetup.IsOpenServer] = openServer == true;
}
else
{
Plugin.StaticServerSetup.Add(Plugin.ServerSetup.IsOpenServer, openServer == true);
}

if (Plugin.StaticServerSetup.ContainsKey(Plugin.ServerSetup.IsPublicServer))
{
Plugin.StaticServerSetup[Plugin.ServerSetup.IsPublicServer] = publicServer == true;
}
else
{
Plugin.StaticServerSetup.Add(Plugin.ServerSetup.IsPublicServer, publicServer == true);
}

if (Plugin.StaticServerInfo.ContainsKey(Plugin.ServerInfo.WorldName))
{
Plugin.StaticServerInfo[Plugin.ServerInfo.WorldName] = $"{world.m_name}";
}
else
{
Plugin.StaticServerInfo.Add(Plugin.ServerInfo.WorldName, $"{world.m_name}");
}

if (Plugin.StaticServerInfo.ContainsKey(Plugin.ServerInfo.WorldSeed))
{
Plugin.StaticServerInfo[Plugin.ServerInfo.WorldSeed] = $"{world.m_seed}";
}
else
{
Plugin.StaticServerInfo.Add(Plugin.ServerInfo.WorldSeed, $"{world.m_seed}");
}

if (Plugin.StaticServerInfo.ContainsKey(Plugin.ServerInfo.WorldSeedName))
{
Plugin.StaticServerInfo[Plugin.ServerInfo.WorldSeedName] = $"{world.m_seedName}";
}
else
{
Plugin.StaticServerInfo.Add(Plugin.ServerInfo.WorldSeedName, $"{world.m_seedName}");
}
}
}

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 = "2.0.5";
public const string PLUGIN_VERSION = "2.0.6";
public const string PLUGIN_REPO_SHORT = "github: nwesterhausen/valheim-discordconnector";
public const string PLUGIN_AUTHOR = "Nicholas Westerhausen";
}
Expand Down

0 comments on commit 0f6afad

Please sign in to comment.