started working on more commands

This commit is contained in:
caesarakalaeii 2023-08-12 19:40:46 +02:00
parent 131e0cd802
commit 6bfd45a8b0
3 changed files with 124 additions and 39 deletions

View File

@ -4,9 +4,6 @@ using BattleBitAPI;
using BattleBitAPI.Common;
using BattleBitAPI.Server;
using CommunityServerAPI;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
internal class Program
{
@ -14,15 +11,8 @@ internal class Program
{
var listener = new ServerListener<MyPlayer, MyGameServer>();
listener.Start(55669);
CreateHostBuilder(args).Build().Run();
Thread.Sleep(-1);
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
internal class MyPlayer : Player<MyPlayer>
@ -305,18 +295,18 @@ internal class MyGameServer : GameServer<MyPlayer>
public class SpeedCommand : APICommand
{
public new static string CommandPrefix = "!speed";
public new string CommandPrefix = "!speed";
public new static string Help =
$"{CommandPrefix} 'steamid' 'amount': Sets speed multiplier of specific player the specified amount";
public new string Help =
"'steamid' 'amount': Sets speed multiplier of specific player the specified amount";
public new static Command ChatCommand(MyPlayer player, ChatChannel channel, string msg)
public new Command ChatCommand(MyPlayer player, ChatChannel channel, string msg)
{
var splits = msg.Split(" ");
var c = new Command
{
StreamerId = Convert.ToUInt64(splits[1]),
Action = ActionType.Speed,
Action = ActionType.Help,
Amount = int.Parse(splits[2]),
ExecutorName = "Chat Test"
};
@ -324,27 +314,53 @@ internal class MyGameServer : GameServer<MyPlayer>
}
}
/*
case "!teleport":
{
public class ChangeAttachmentCommand : APICommand
{
public new string CommandPrefix = "!changeAttachment";
break;
}
case "!speed":
{
c.Action = ActionType.Speed;
c.Amount = 5;
c.ExecutorName = "Tester";
break;
}
case "!changeAttachement":
public new string Help =
"'steamid' 'pri=Attachment' 'sec=Attachment': the attachements of specific player the specified amount";
public new Command ChatCommand(MyPlayer player, ChatChannel channel, string msg)
{
var splits = msg.Split(" ");
var c = new Command
{
c.Action = ActionType.ChangeAttachement;
c.Amount = 1;
c.Data = splits.Skip(0).Take(splits.Length);
c.ExecutorName = "Tester";
break;
}
StreamerId = Convert.ToUInt64(splits[1]),
Action = ActionType.ChangeAttachement,
Amount = int.Parse(splits[2]),
AttachmentChange = Utility.ParseAttachments(splits),
ExecutorName = "Chat Test"
};
return c;
}
}
public class ChangeWeaponCommand : APICommand
{
public new string CommandPrefix = "!changeWeapon";
public new string Help =
"'steamid' 'pri=Weapon' 'sec=Weapon': the weapons of specific player the specified amount";
public new Command ChatCommand(MyPlayer player, ChatChannel channel, string msg)
{
var splits = msg.Split(" ");
var c = new Command
{
StreamerId = Convert.ToUInt64(splits[1]),
Action = ActionType.ChangeAttachement,
Amount = int.Parse(splits[2]),
AttachmentChange = Utility.ParseAttachments(splits),
ExecutorName = "Chat Test"
};
return c;
}
}
/*
case "!changeWeapon":
{
c.Action = ActionType.ChangeWeapon;

View File

@ -1,13 +1,10 @@
using System.Collections.Concurrent;
using System.Numerics;
using BattleBitAPI.Common;
namespace CommunityServerAPI
{
public class Data
{
private bool isData;
}
public class Command
{
@ -19,6 +16,12 @@ namespace CommunityServerAPI
public IEnumerable<string> Data { get; set; }
public string ExecutorName { get; set; }
public List<Attachment> AttachmentChange{ get; set; }
public List<Weapon> WeaponChange{ get; set; }
public List<Gadget> GadgetChange{ get; set; }
}
public class CommandQueue

66
Utility.cs Normal file
View File

@ -0,0 +1,66 @@
using BattleBitAPI.Common;
namespace CommunityServerAPI;
public class Utility
{
public static List<Attachment> ParseAttachments(string[] splits)
{
var attachments = new List<Attachment>();
var s = splits.Skip(3);
foreach (var st in s)
{
if(Attachments.TryFind(st, out var attach))
{
attachments.Add(attach);
}
else
{
attachments.Add(default);
}
}
return attachments;
}
public static List<Weapon> ParseWeapons(string[] splits)
{
var weapons = new List<Weapon>();
var s = splits.Skip(3);
foreach (var st in s)
{
if(Weapons.TryFind(st, out var weapon))
{
weapons.Add(weapon);
}
else
{
weapons.Add(default);
}
}
return weapons;
}
public static List<Gadget> ParseGadgets(string[] splits)
{
var gadgets = new List<Gadget>();
var s = splits.Skip(3);
foreach (var st in s)
{
if(Gadgets.TryFind(st, out var gadget))
{
gadgets.Add(gadget);
}
else
{
gadgets.Add(default);
}
}
return gadgets;
}
}