Skip to content

Commit

Permalink
plugins!
Browse files Browse the repository at this point in the history
  • Loading branch information
DrMeepso committed Nov 9, 2024
1 parent 2f87723 commit 94b05dc
Show file tree
Hide file tree
Showing 61 changed files with 7,466 additions and 575 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ jobs:
- name: Set up .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0.x' # Specify your .NET version
dotnet-version: '6.0.x' # Specify your .NET version

- name: Move to dir
run: cd WFServer

# Step 3: Restore dependencies
- name: Restore dependencies
Expand Down Expand Up @@ -53,7 +56,10 @@ jobs:
- name: Set up .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0.x' # Specify your .NET version
dotnet-version: '6.0.x' # Specify your .NET version

- name: Move to dir
run: cd WFServer

# Step 3: Restore dependencies
- name: Restore dependencies
Expand Down
Binary file modified .vs/ProjectEvaluation/wfsermver.metadata.v6.1
Binary file not shown.
Binary file modified .vs/ProjectEvaluation/wfsermver.projects.v6.1
Binary file not shown.
Binary file modified .vs/WFSermver/DesignTimeBuild/.dtbcache.v2
Binary file not shown.
Binary file modified .vs/WFSermver/v17/.futdcache.v2
Binary file not shown.
Binary file modified .vs/WFSermver/v17/.suo
Binary file not shown.
161 changes: 161 additions & 0 deletions ChatCommands/ChatCommands.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
using Steamworks;
using WFServer;

public class ChatCommands : CovePlugin
{

Server Server { get; set; } // lol

public ChatCommands(Server server) : base(server)
{
Server = server;
}

public override void onInit()
{
base.onInit();

log("Chat commands are here!");
}

public override void onPlayerJoin(WFPlayer player)
{
base.onPlayerJoin(player);
//sendPlayerChatMessage(player, "use !help for a list of commands!");
}

public override void onChatMessage(WFPlayer sender, string message)
{
base.onChatMessage(sender, message);

char[] msg = message.ToCharArray();
if (msg[0] == "!".ToCharArray()[0]) // its a command!
{
string command = message.Split(" ")[0].ToLower();
switch (command)
{
case "!help":
{
sendPlayerChatMessage(sender, "--- HELP ---");
sendPlayerChatMessage(sender, "Not much here tbh...");
}
break;

case "!users":
if (!isPlayerAdmin(sender)) return;
string messageBody = "";
foreach (var player in getAllPlayers())
{
messageBody += $"{player.FisherName} [{player.SteamId}]: {player.FisherID}\n";
}

//SendLetter(id, SteamClient.SteamId, "Players in the server", messageBody, "Always here - ", "Cove");
break;

case "!spawn":
{
if (!isPlayerAdmin(sender)) return;

var actorType = message.Split(" ")[1].ToLower();
bool spawned = false;
switch (actorType)
{
case "rain":
Server.spawnRainCloud();
spawned = true;
break;

case "fish":
Server.spawnFish();
spawned = true;
break;

case "meteor":
spawned = true;
Server.spawnFish("fish_spawn_alien");
break;

case "portal":
Server.spawnVoidPortal();
spawned = true;
break;

case "metal":
Server.spawnMetal();
spawned = true;
break;
}
if (spawned)
{
sendPlayerChatMessage(sender, $"Spawned {actorType}");
}
else
{
sendPlayerChatMessage(sender, $"\"{actorType}\" is not a spawnable actor!");
}
}
break;

case "!kick":
if (!isPlayerAdmin(sender)) return;
var kickUser = message.Split(" ")[1].ToUpper();
WFPlayer kickedplayer = getAllPlayers().ToList().Find(p => p.FisherID == kickUser);
if (kickedplayer == null)
{
sendPlayerChatMessage(sender, "That's not a player!");
}
else
{
Dictionary<string, object> packet = new Dictionary<string, object>();
packet["type"] = "kick";

sendPacketToPlayer(packet, kickedplayer);

sendPlayerChatMessage(sender, $"Kicked {kickedplayer.FisherName}");
sendGlobalChatMessage($"{kickedplayer.FisherName} was kicked from the lobby!");
}
break;

case "!setjoinable":
{
if (!isPlayerAdmin(sender)) return;
string arg = message.Split(" ")[1].ToLower();
if (arg == "true")
{
Server.gameLobby.SetJoinable(true);
sendPlayerChatMessage(sender, $"Opened lobby!");
if (!Server.codeOnly)
{
Server.gameLobby.SetData("type", "public");
sendPlayerChatMessage(sender, $"Unhid server from server list");
}
}
else if (arg == "false")
{
Server.gameLobby.SetJoinable(false);
sendPlayerChatMessage(sender, $"Closed lobby!");
if (!Server.codeOnly)
{
Server.gameLobby.SetData("type", "code_only");
sendPlayerChatMessage(sender, $"Hid server from server list");
}
}
else
{
sendPlayerChatMessage(sender, $"\"{arg}\" is not true or false!");
}
}
break;

case "!refreshadmins":
{
if (!isPlayerAdmin(sender)) return;
Server.readAdmins();
}
break;
}
}

}

}
22 changes: 22 additions & 0 deletions ChatCommands/ChatCommands.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebugType>none</DebugType>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DebugType>none</DebugType>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\WFServer\WFServer.csproj" />
<EmbeddedResource Include="plugin.cfg"></EmbeddedResource>
</ItemGroup>

</Project>
8 changes: 8 additions & 0 deletions ChatCommands/plugin.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# plugin name
name = Chat Commands

# plugin id
id = chatcommands

# authors!
author = DrMeepso
149 changes: 0 additions & 149 deletions Server.chatEvent.cs

This file was deleted.

Loading

0 comments on commit 94b05dc

Please sign in to comment.