Skip to content

Commit

Permalink
Allow players to be kicked via FisherID
Browse files Browse the repository at this point in the history
  • Loading branch information
DrMeepso committed Nov 22, 2024
1 parent dac6b64 commit 6995852
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
17 changes: 13 additions & 4 deletions Cove.ChatCommands/ChatCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,13 @@ public override void onChatMessage(WFPlayer sender, string message)
case "!kick":
{
if (!IsPlayerAdmin(sender)) return;
string playerName = message.Substring(command.Length + 1);
WFPlayer kickedplayer = GetAllPlayers().ToList().Find(p => p.Username.Equals(playerName, StringComparison.OrdinalIgnoreCase));
string playerIdent = message.Substring(command.Length + 1);
// try find a user with the username first
WFPlayer kickedplayer = GetAllPlayers().ToList().Find(p => p.Username.Equals(playerIdent, StringComparison.OrdinalIgnoreCase));
// if there is no player with the username try find someone with that fisher ID
if (kickedplayer == null)
kickedplayer = GetAllPlayers().ToList().Find(p => p.FisherID.Equals(playerIdent, StringComparison.OrdinalIgnoreCase));

if (kickedplayer == null)
{
SendPlayerChatMessage(sender, "That's not a player!");
Expand All @@ -155,8 +160,12 @@ public override void onChatMessage(WFPlayer sender, string message)
if (!IsPlayerAdmin(sender)) return;
// hacky fix,
// Extract player name from the command message
string playerName = message.Substring(command.Length + 1);
WFPlayer playerToBan = GetAllPlayers().ToList().Find(p => p.Username.Equals(playerName, StringComparison.OrdinalIgnoreCase));
string playerIdent = message.Substring(command.Length + 1);
// try find a user with the username first
WFPlayer playerToBan = GetAllPlayers().ToList().Find(p => p.Username.Equals(playerIdent, StringComparison.OrdinalIgnoreCase));
// if there is no player with the username try find someone with that fisher ID
if (playerToBan == null)
playerToBan = GetAllPlayers().ToList().Find(p => p.FisherID.Equals(playerIdent, StringComparison.OrdinalIgnoreCase));

if (playerToBan == null)
{
Expand Down
1 change: 0 additions & 1 deletion Cove/GodotFormat/GDWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public static byte[] WriteGodotPacket(Dictionary<string, object> packet)
writeDictionary(packet, bw);

return stream.ToArray();

}

private static void writeAny(object packet, BinaryWriter bw)
Expand Down
3 changes: 1 addition & 2 deletions Cove/Server/Server.Packet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ void OnNetworkPacket(byte[] packet, CSteamID sender)
pongPacket["type"] = "send_ping";
pongPacket["time"] = DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString();
pongPacket["from"] = SteamUser.GetSteamID().m_SteamID.ToString();
// send the ping packet!
//SteamNetworking.SendP2PPacket(packet.SteamId, writePacket(pongPacket), nChannel: 1);

sendPacketToPlayer(pongPacket, sender);
}
break;
Expand Down
2 changes: 1 addition & 1 deletion Cove/Server/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ void OnPlayerChat(string message, CSteamID id)
{

WFPlayer sender = AllPlayers.Find(p => p.SteamId == id);
Console.WriteLine($"{sender.Username}: {message}");
Console.WriteLine($"[{sender.FisherID}] {sender.Username}: {message}");

foreach (PluginInstance plugin in loadedPlugins)
{
Expand Down
9 changes: 6 additions & 3 deletions Cove/server.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ ageRestricted = false
# controls if the server appears as a public or code-only lobby
codeOnly = true

# join message
# 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)
# Join Message:
# if enabled will skip sending the configured join message
hideJoinMessage = false

# 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)

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

0 comments on commit 6995852

Please sign in to comment.