1
0
Fork 0
This repository has been archived on 2019-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
Galactic_Colors_Control/Galactic Colors Control Server/Commands/Client/KickCommand.cs

48 lines
1.8 KiB
C#
Raw Normal View History

2016-10-30 14:15:27 +00:00
using Galactic_Colors_Control_Common;
using System;
2016-10-09 12:27:08 +00:00
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
namespace Galactic_Colors_Control_Server.Commands
{
2016-11-03 20:01:16 +00:00
public class ClientKickCommand : ICommand
2016-10-09 12:27:08 +00:00
{
public string Name { get { return "kick"; } }
public string DescText { get { return "Kicks selected client."; } }
2016-11-03 20:01:16 +00:00
public string HelpText { get { return "Use /client kick [username] <reason> to kick client from server."; } }
public Manager.CommandGroup Group { get { return Manager.CommandGroup.client; } }
2016-10-09 12:27:08 +00:00
public bool IsServer { get { return true; } }
public bool IsClient { get { return false; } }
2016-10-11 10:09:51 +00:00
public bool IsClientSide { get { return false; } }
2016-10-09 12:27:08 +00:00
public bool IsNoConnect { get { return true; } }
public int minArgs { get { return 1; } }
public int maxArgs { get { return 2; } }
public void Execute(string[] args, Socket soc, bool server = false)
{
Socket target = null;
foreach(Socket client in Program.clients.Keys)
{
2016-11-03 20:01:16 +00:00
if(Utilities.GetName(client) == args[2]) { target = client; }
2016-10-09 12:27:08 +00:00
}
if (target != null)
{
2016-11-03 20:01:16 +00:00
Logger.Write(args[2] + " was kick by server.", Logger.logType.info);
2016-10-09 12:27:08 +00:00
if (args.Length > 2)
{
2016-11-03 20:01:16 +00:00
Utilities.Send(target, "/kick " + args[3], Common.dataType.message);
Logger.Write("because" + args[2], Logger.logType.debug);
2016-10-09 12:27:08 +00:00
}
else {
2016-10-30 14:15:27 +00:00
Utilities.Send(target, "/kick", Common.dataType.message);
2016-10-09 12:27:08 +00:00
}
}
else
{
2016-11-03 20:01:16 +00:00
Utilities.Return("Can't find " + args[2], soc, server);
2016-10-09 12:27:08 +00:00
}
}
}
}