Skip to content

Commit

Permalink
Merge Skib
Browse files Browse the repository at this point in the history
Fix a few issues caused by stripping out old code
  • Loading branch information
DrMeepso authored Jan 1, 2025
2 parents 454aece + d988698 commit d1a7685
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 27 deletions.
6 changes: 2 additions & 4 deletions Cove.ChatCommands/ChatCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,9 @@ public override void onInit()
}
else
{
Dictionary<string, object> packet = new Dictionary<string, object>();
packet["type"] = "kick";
SendPacketToPlayer(packet, kickedplayer);
SendPlayerChatMessage(player, $"Kicked {kickedplayer.Username}");
SendGlobalChatMessage($"{kickedplayer.Username} was kicked from the lobby!");
KickPlayer(kickedplayer);
//SendGlobalChatMessage($"{kickedplayer.Username} was kicked from the lobby!");
}
});
SetCommandDescription("kick", "Kicks a player from the server");
Expand Down
3 changes: 2 additions & 1 deletion Cove/Server/Plugins/Server.Plugins.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public void loadAllPlugins(bool skipWarning = false)
if (plugin != null)
{
string pluginConfig = readConfigFromPlugin($"{assembly.GetName().Name}.plugin.cfg", assembly);
if (pluginConfig == string.Empty) continue; // no config file found, its probably not a plugin
Dictionary<string, string> config = ConfigReader.ReadFile(pluginConfig);

PluginInstance thisInstance = new(plugin, config["name"], config["id"], config["author"]);
Expand All @@ -90,7 +91,7 @@ string readConfigFromPlugin(string fileIdentifyer, Assembly asm)
}
else
{
throw new Exception("Plugin dosen't have a plugin.cfg file!");
return "";
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions Cove/Server/Server.Packet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ void OnNetworkPacket(byte[] packet, CSteamID sender)
Log($"[{thisPlayer.SteamId.m_SteamID}] {thisPlayer.Username} joined the server");
sendWebLobbyPacket(thisPlayer.SteamId);
updatePlayercount();

loadedPlugins.ForEach(p => p.plugin.onPlayerJoin(thisPlayer));
}

} else {
Expand Down
16 changes: 7 additions & 9 deletions Cove/Server/Server.Punish.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,9 @@ public void banPlayer(CSteamID id, bool saveToFile = false)
banPacket["type"] = "client_was_banned";
sendPacketToPlayer(banPacket, id);

// get the wfPlayer object
var player = AllPlayers.Find(p => p.SteamId.m_SteamID == id.m_SteamID);
SteamNetworkingMessages.CloseSessionWithUser(ref player.identity);

Dictionary<string, object> leftPacket = new();
leftPacket["type"] = "user_left_weblobby";
leftPacket["type"] = "peer_was_banned";
leftPacket["user_id"] = (long)id.m_SteamID;
leftPacket["reason"] = (int)2;
sendPacketToPlayers(leftPacket);

if (saveToFile)
Expand Down Expand Up @@ -75,11 +70,14 @@ private void writeToBansFile(CSteamID id)

public void kickPlayer(CSteamID id)
{
Dictionary<string, object> kickPacket = new();
kickPacket["type"] = "kick";
Dictionary<string, object> leftPacket = new();
leftPacket["type"] = "peer_was_kicked";
leftPacket["user_id"] = (long)id.m_SteamID;
sendPacketToPlayers(leftPacket);

Dictionary<string, object> kickPacket = new();
kickPacket["type"] = "client_was_kicked";
sendPacketToPlayer(kickPacket, id);
}

}
}
35 changes: 29 additions & 6 deletions Cove/Server/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ public partial class CoveServer
Dictionary<string, IHostedService> services = new();
public readonly object serverActorListLock = new();

public List<string> WantedTags = new();

public void Init()
{
cbThread = new(runSteamworksUpdate);
Expand Down Expand Up @@ -187,6 +189,20 @@ public void Init()
showBotRejoins = getBoolFromString(config[key]);
break;

case "tags":
var tags = config[key].Split(',');
// remove trailing whitespace from the tags
for (int i = 0; i < tags.Length; i++)
{
tags[i] = tags[i].Trim().ToLower();
}
WantedTags = tags.ToList();
break;

case "skibidi":
Log("Dop dop dop, yes yes");
break;

default:
Log($"\"{key}\" is not a supported config option!");
continue;
Expand Down Expand Up @@ -288,7 +304,10 @@ public void Init()
string[] LOBBY_TAGS = ["talkative", "quiet", "grinding", "chill", "silly", "hardcore", "mature", "modded"];
for (int i = 0; i < LOBBY_TAGS.Length; i++)
{
SteamMatchmaking.SetLobbyData(SteamLobby, $"tag_{LOBBY_TAGS[i]}", "0");
bool wantedTag = WantedTags.Contains(LOBBY_TAGS[i]);
SteamMatchmaking.SetLobbyData(SteamLobby, $"tag_{LOBBY_TAGS[i]}", wantedTag ? "1" : "0");
if (wantedTag)
Log($"Added tag: {LOBBY_TAGS[i]}");
}

ulong epoch = (ulong)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
Expand Down Expand Up @@ -346,6 +365,10 @@ public void Init()

SteamNetworkingMessages.CloseSessionWithUser(ref player.identity);
updatePlayercount();

// tell all plugins that the player left
loadedPlugins.ForEach(plugin => plugin.plugin.onPlayerLeave(player));

}
}
}
Expand All @@ -363,7 +386,6 @@ public void Init()
return;
}

//Log($"Accepting session request from {param.m_identityRemote.GetSteamID64().ToString()}");
// get the players WFPlayer object
WFPlayer player = AllPlayers.Find(p => p.SteamId == param.m_identityRemote.GetSteamID());
if (player == null)
Expand Down Expand Up @@ -400,7 +422,8 @@ out chatEntryType
{
string lobbyMessage = Encoding.UTF8.GetString(data, 0, messageLength);

if (String.Compare("$weblobby_join_request", lobbyMessage) == 0)
// man i dont fucking know anymore
if (String.Compare("$weblobby_join_request", lobbyMessage) == 0 || lobbyMessage.Trim() == "$weblobby_join_request")
{
if (AllPlayers.Contains(AllPlayers.Find(p => p.SteamId == userId)))
{
Expand Down Expand Up @@ -486,15 +509,14 @@ void RunNetwork()
if (messages.Count == 0)
break;

//Log($"Received {messages.Count} messages on channel {i}");
didWork = true;
for (int j = 0; j < messages.Count; j++)
{
// print every attribute of the message
//Log($"Message {j}:{messages[j].identity}");
OnNetworkPacket(messages[j].payload, new CSteamID(messages[j].identity));
}
}
}

catch (Exception e)
{
if (!showErrorMessages)
Expand Down Expand Up @@ -542,6 +564,7 @@ void OnPlayerChat(string message, CSteamID id)
{
string command = message.Split(' ')[0].Substring(1);
string[] args = message.Split(' ').Skip(1).ToArray();

if (DoseCommandExist(command))
{
InvokeCommand(sender, command, args);
Expand Down
6 changes: 6 additions & 0 deletions Cove/server.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ codeOnly = true
# Sets custom join message shown to players when they join the lobby
joinMessage = This is a Cove dedicated server! Please report any issues to the github (xr0.xyz/cove)

# Server tags!
# Webfishing has these tags: talkative, quiet, grinding, chill, silly, hardcore, mature, modded
# add them to the thingy below seperated by a comma
# no, you cant make new ones up
tags = modded, chill, silly

# rain spawn multiplyer, incressing this number will increase the ammount he rain chance incresses each tick
rainSpawnMultiplyer = 1

Expand Down
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
> [!NOTE]
> ## Cove 1.0! 🥳
> As of WebFishing v1.09 cove implements all fetures from the main game making it a parallel experience compared to the actual game!
> It works :D
# Webfishing Cove
Cove is a dedicated server for WebFishing written in C#!

> [!IMPORTANT]
> Cove is very new, there will be unexpected bugs!
>
> If you encounter any large issues or bugs please let me know!
Cove is a implementation of the WebFishing network protocall in a CLI meaning it dosent require Godot or anything other than Steamworks!

# How it works
Expand Down Expand Up @@ -57,13 +51,17 @@ If you have any questions or issues with Cove, **create and issue on Github** or
- Run the server EXE and enjoy!
- Please be respectful and dont name the servers anything stupid!

5. Look below
- Links if you wanna find plugins or make them are below!
# Other info

Some default / popular plugins can be found in the [CovePlugins](https://github.com/DrMeepso/CovePlugins) repo

The repo for a template plugin can be found here: [CovePluginTemplate](https://github.com/DrMeepso/TemplateCovePlugin)

More plugins can be found in the discord server for cove listed above!

[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/E1E0E65CR)

All donations are greatly appreciated!!!!!!!! <3 :3

0 comments on commit d1a7685

Please sign in to comment.