Skip to content

Commit

Permalink
fix(server): add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielMcAssey committed Jan 12, 2025
1 parent bc34e6b commit 1e28117
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 6 deletions.
6 changes: 3 additions & 3 deletions GLOKON.Baiters.Core/BaitersServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ protected static bool CanSteamIdJoin(ulong steamId)

public IEnumerable<KeyValuePair<long, Actor>> Actors => _actors;
public IEnumerable<KeyValuePair<ulong, Player>> Players => _players;
public int PlayerCount => _players.Count + 1;
public int NpcActorCount => _actors.Where((kv) => kv.Value.Type != ActorType.Player).Count();

/// <summary>
Expand Down Expand Up @@ -500,9 +501,8 @@ private void SteamMatchmaking_OnLobbyMemberDisconnected(Lobby lobby, Friend from

private void UpdatePlayerCount()
{
int totalPlayerCount = (_players.Count + 1);
_lobby.SetData("count", totalPlayerCount.ToString());
Console.Title = string.Format("[{0}] {1} - {2}/{3}", options.JoinType, options.ServerName, totalPlayerCount, options.MaxPlayers);
_lobby.SetData("count", PlayerCount.ToString());
Console.Title = string.Format("[{0}] {1} - {2}/{3}", options.JoinType, options.ServerName, PlayerCount, options.MaxPlayers);
}
}
}
12 changes: 12 additions & 0 deletions GLOKON.Baiters.Core/Packets/Handlers/UserLeftWebLobbyHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using GLOKON.Baiters.Core.Models.Networking;

namespace GLOKON.Baiters.Core.Packets.Handlers
{
internal class UserLeftWebLobbyHandler(BaitersServer server) : IPacketHandler

Check warning on line 5 in GLOKON.Baiters.Core/Packets/Handlers/UserLeftWebLobbyHandler.cs

View workflow job for this annotation

GitHub Actions / build_and_release

Parameter 'server' is unread.

Check warning on line 5 in GLOKON.Baiters.Core/Packets/Handlers/UserLeftWebLobbyHandler.cs

View workflow job for this annotation

GitHub Actions / Build Server (ubuntu-latest, linux-x64) / build-server

Parameter 'server' is unread.

Check warning on line 5 in GLOKON.Baiters.Core/Packets/Handlers/UserLeftWebLobbyHandler.cs

View workflow job for this annotation

GitHub Actions / Build Server (windows-latest, win-x64) / build-server

Parameter 'server' is unread.
{
public void Handle(ulong sender, Packet packet)
{
// Nothing to do
}
}
}
1 change: 1 addition & 0 deletions GLOKON.Baiters.Core/Packets/PacketManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public void Setup()
handlers.Add("request_actors", new RequestActorsHandler(server));
handlers.Add("chalk_packet", new ChalkPacketHandler(server));
handlers.Add("message", new MessageHandler(server));
handlers.Add("user_left_weblobby", new UserLeftWebLobbyHandler(server));
}

private void Server_OnPacket(ulong sender, Packet packet)
Expand Down
2 changes: 1 addition & 1 deletion GLOKON.Baiters.Plugins.ChatCommand/ChatCommandPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public override void OnInit()
return;
}

GM.Server.SendMessage(string.Format("-- Players ({0}/{1}) --", GM.Server.Players.Count(), GM.Options.MaxPlayers), MessageColour.Information, sender);
GM.Server.SendMessage(string.Format("-- Players ({0}/{1}) --", GM.Server.PlayerCount, GM.Options.MaxPlayers), MessageColour.Information, sender);

foreach (var player in GM.Server.Players)
{
Expand Down
13 changes: 13 additions & 0 deletions PLUGINS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Plugin Development

Building plugins for Baiters is really easy!

There are 2 example plugins on this repository, the BanManager and ChatCommands, so feel free to use that as a basis.

## Steps

1. **Create** a new .NET Core library project
2. **Install** the `GLOKON.Baiters.Core` NuGet package using your package manager
3. **Extend** the `GLOKON.Baiters.Core.Plugins.BaitersPlugin` class to create your own Plugin entry point (It `must` have `GLOKON.Baiters.Core.GameManager` as its only parameter for the constructor)
4. **Build** your plugin, use the [GLOKON.Baiters.Core.GameManager](https://github.com/DanielMcAssey/baiters-server/blob/main/GLOKON.Baiters.Core/GameManager.cs) to interact with the server, listen to events, etc.
5. **Release** your plugin, make sure the plugin assembly file name ends with `.BaitersPlugin.dll`
44 changes: 42 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,50 @@ WebFishing Server with support for custom plugins

Runs on Windows, Linux and MacOS

Inspired by the amazing work by DrMeepso [https://github.com/DrMeepso/WebFishingCove](https://github.com/DrMeepso/WebFishingCove)
Inspired by the amazing work by DrMeepso [WebFishingCove](https://github.com/DrMeepso/WebFishingCove)

## About Baiters

Honestly? I just wanted to have a go at building a Steamworks server for a game that I enjoy.
I felt that the servers out there had a lot of room for improvement, in performance, maintainability and support.

## Setup
> [!IMPORTANT]
> Steam installed and a Steam account with WebFishing is required.
1. **Download** Baiters from the Releases page
2. **Copy** the `main_zone.tscn` from the game into the `scenes` folder (You need to extract it from the game ([Example Tool](https://github.com/bruvzg/gdsdecomp)))
3. **Configure** the `appsettings.json` or use the environment variables (See the config reference below)
4. **Run** the Steam client with the account with WebFishing
5. **Start** Baiters

## Plugins

Please see [PLUGINS.md](https://github.com/DanielMcAssey/baiters-server/blob/main/PLUGINS.md) on how to build your own plugins.

To install plugins, simply place the plugin file(s) into the `plugins` folder.


You will need to place the `main_zone.tscn` in the scenes folder, run the Steam Client on an account with access to WebFishing
## Enviroment Variables
> [!NOTE]
> Please note the `double` underscore
| Variable | Description |
| ----------------------- | ----------------------------------------------------------------------------------------------------- |
| `WebFishing__Admins__n` | Steam ID of the admins of the server (Replace `n` with an index in the array, Defaults to me (Please remove me!)) |
| `WebFishing__PluginsEnabled` | Enable/Disable plugins from being loaded (Values are `true` or `false`, Defaults to `false`) |
| `WebFishing__ServerName` | Name of the server to display on the server browser (Defaults to `My Baiters Server`) |
| `WebFishing__CommandPrefix` | Chat command prefix for server commands (Defaults to `!`) |
| `WebFishing__MaxPlayers` | Maximum players allowed on the server (Default is `50`) |
| `WebFishing__JoinType` | Visibility of the server to others (Valid values are `Public`, `InviteOnly`, `FriendsOnly`, Defaults to `Public`) |
| `WebFishing__JoinMessage` | Message to display to new users joining the server |
| `WebFishing__Tags__n` | Tags displayed on the server browser (Replace `n` with an index in the array) (Valid values are `talkative`, `quiet`, `grinding`, `chill`, `silly`, `hardcore`, `mature`, `modded`) |
| `WebFishing__Modifiers__FishChance` | Chance (from `0.0` to `1.0`) of a Fish spawning (Default is `0.50` (50%)) |
| `WebFishing__Modifiers__BirdChance` | Chance (from `0.0` to `1.0`) of a Void Portal spawning (Default is `0.33` (33%)) |
| `WebFishing__Modifiers__RainChance` | Chance (from `0.0` to `1.0`) of a Void Portal spawning (Default is `0.25` (25%)) |
| `WebFishing__Modifiers__MeteorChance` | Chance (from `0.0` to `1.0`) of a Void Portal spawning (Default is `0.01` (1%)) |
| `WebFishing__Modifiers__VoidPortalChance` | Chance (from `0.0` to `1.0`) of a Void Portal spawning (Default is `0.005` (0.5%)) |
| `WebFishing__Modifiers__MaxMetal` | Maximum metal spawned (Defaults to `7`) |
| `WebFishing__Modifiers__MaxFish` | Maximum Fish spawned in the server (Defaults to `30`) |
| `WebFishing__Modifiers__MaxBird` | Maximum Birds spawned in the server (Defaults to `8`) |
| `WebFishing__Modifiers__MaxNpcActors` | Maximum NPC (Non-Playable Characters, like fish, birds, metal, etc.) spawned (Defaults to `50`) |

0 comments on commit 1e28117

Please sign in to comment.