2015-08-20 01:06:44 -04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2015-08-21 21:11:35 -04:00
|
|
|
|
using System.Linq;
|
2017-05-26 18:49:27 -04:00
|
|
|
|
using System.Threading.Tasks;
|
2015-08-20 01:06:44 -04:00
|
|
|
|
|
|
|
|
|
namespace SharedLibrary
|
|
|
|
|
{
|
|
|
|
|
public class Aliases
|
|
|
|
|
{
|
|
|
|
|
public Aliases(int Num, String N, String I)
|
|
|
|
|
{
|
|
|
|
|
Number = Num;
|
2015-08-21 21:11:35 -04:00
|
|
|
|
Names = N.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries).Select(s => s.Trim()).ToList();
|
|
|
|
|
IPS = new List<String>(I.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries));
|
2015-08-20 01:06:44 -04:00
|
|
|
|
}
|
|
|
|
|
|
2015-08-21 21:11:35 -04:00
|
|
|
|
public List<String> Names { get; private set; }
|
|
|
|
|
public List<String> IPS { get; private set; }
|
|
|
|
|
public int Number { get; private set; }
|
2015-08-20 01:06:44 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class Player
|
|
|
|
|
{
|
|
|
|
|
public enum Permission
|
|
|
|
|
{
|
|
|
|
|
Banned = -1,
|
|
|
|
|
User = 0,
|
|
|
|
|
Flagged = 1,
|
2016-01-16 17:58:24 -05:00
|
|
|
|
Trusted = 2,
|
|
|
|
|
Moderator = 3,
|
|
|
|
|
Administrator = 4,
|
|
|
|
|
SeniorAdmin = 5,
|
|
|
|
|
Owner = 6,
|
|
|
|
|
Creator = 7,
|
|
|
|
|
Console = 8,
|
2015-08-20 01:06:44 -04:00
|
|
|
|
}
|
|
|
|
|
|
2017-05-26 18:49:27 -04:00
|
|
|
|
public override bool Equals(object obj)
|
|
|
|
|
{
|
2017-05-31 01:31:56 -04:00
|
|
|
|
return ((Player)obj).NetworkID == NetworkID;
|
2017-05-26 18:49:27 -04:00
|
|
|
|
}
|
|
|
|
|
|
2017-05-28 21:07:33 -04:00
|
|
|
|
public override int GetHashCode()
|
|
|
|
|
{
|
|
|
|
|
return base.GetHashCode();
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-20 01:06:44 -04:00
|
|
|
|
public Player(string n, string id, int num, int l)
|
|
|
|
|
{
|
|
|
|
|
Name = n;
|
2017-05-31 01:31:56 -04:00
|
|
|
|
NetworkID = id;
|
|
|
|
|
ClientID = num;
|
2015-08-20 01:06:44 -04:00
|
|
|
|
Level = (Player.Permission)l;
|
|
|
|
|
lastOffense = String.Empty;
|
|
|
|
|
Connections = 0;
|
|
|
|
|
IP = "";
|
|
|
|
|
Warnings = 0;
|
|
|
|
|
Alias = new Aliases(0, "", "");
|
|
|
|
|
LastConnection = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Player(string n, string id, int num, String I)
|
|
|
|
|
{
|
|
|
|
|
Name = n;
|
2017-05-31 01:31:56 -04:00
|
|
|
|
NetworkID = id;
|
|
|
|
|
ClientID = num;
|
2015-08-20 01:06:44 -04:00
|
|
|
|
IP = I;
|
|
|
|
|
LastConnection = DateTime.Now;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-17 19:28:08 -04:00
|
|
|
|
public Player(String n, String id, Player.Permission P, String I, String UID, int dbid)
|
2015-08-20 01:06:44 -04:00
|
|
|
|
{
|
|
|
|
|
Name = n;
|
2017-05-31 01:31:56 -04:00
|
|
|
|
NetworkID = id;
|
2015-08-20 01:06:44 -04:00
|
|
|
|
Level = P;
|
|
|
|
|
IP = I;
|
2017-05-31 01:31:56 -04:00
|
|
|
|
ClientID = -1;
|
2017-05-26 18:49:27 -04:00
|
|
|
|
this.UID = UID;
|
2017-08-17 19:28:08 -04:00
|
|
|
|
DatabaseID = dbid;
|
2015-08-20 01:06:44 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Player(string n, string id, int num, Player.Permission l, int cind, String lo, int con, String IP2)
|
|
|
|
|
{
|
|
|
|
|
Name = n;
|
2017-05-31 01:31:56 -04:00
|
|
|
|
NetworkID = id;
|
|
|
|
|
ClientID = num;
|
2015-08-20 01:06:44 -04:00
|
|
|
|
Level = l;
|
2017-05-31 01:31:56 -04:00
|
|
|
|
DatabaseID = cind;
|
2015-08-20 01:06:44 -04:00
|
|
|
|
if (lo == null)
|
|
|
|
|
lastOffense = String.Empty;
|
|
|
|
|
else
|
|
|
|
|
lastOffense = lo;
|
|
|
|
|
Connections = con;
|
|
|
|
|
IP = IP2;
|
|
|
|
|
Warnings = 0;
|
|
|
|
|
Masked = false;
|
|
|
|
|
LastConnection = DateTime.Now;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-26 18:49:27 -04:00
|
|
|
|
public Player(string n, string id, int num, Player.Permission l, int cind, String lo, int con, String IP2, DateTime LC, string UID, bool masked)
|
2015-08-20 01:06:44 -04:00
|
|
|
|
{
|
|
|
|
|
Name = n;
|
2017-05-31 01:31:56 -04:00
|
|
|
|
NetworkID = id;
|
|
|
|
|
ClientID = num;
|
2015-08-20 01:06:44 -04:00
|
|
|
|
Level = l;
|
2017-05-31 01:31:56 -04:00
|
|
|
|
DatabaseID = cind;
|
2015-08-20 01:06:44 -04:00
|
|
|
|
if (lo == null)
|
|
|
|
|
lastOffense = String.Empty;
|
|
|
|
|
else
|
|
|
|
|
lastOffense = lo;
|
|
|
|
|
Connections = con;
|
|
|
|
|
IP = IP2;
|
|
|
|
|
Warnings = 0;
|
|
|
|
|
Masked = false;
|
|
|
|
|
LastConnection = LC;
|
2017-05-26 18:49:27 -04:00
|
|
|
|
this.UID = UID.Trim();
|
|
|
|
|
Masked = masked;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-31 01:31:56 -04:00
|
|
|
|
public override string ToString()
|
2017-05-26 18:49:27 -04:00
|
|
|
|
{
|
2017-05-31 01:31:56 -04:00
|
|
|
|
return $"{Name}::{NetworkID}";
|
2015-08-20 01:06:44 -04:00
|
|
|
|
}
|
|
|
|
|
|
2017-06-12 13:50:00 -04:00
|
|
|
|
public String GetLastConnection()
|
2015-08-20 01:06:44 -04:00
|
|
|
|
{
|
2017-06-12 17:47:31 -04:00
|
|
|
|
return Utilities.GetTimePassed(LastConnection);
|
2015-08-20 01:06:44 -04:00
|
|
|
|
}
|
|
|
|
|
|
2017-06-12 13:50:00 -04:00
|
|
|
|
public void UpdateName(String n)
|
2015-08-20 01:06:44 -04:00
|
|
|
|
{
|
|
|
|
|
if (n.Trim() != String.Empty)
|
|
|
|
|
Name = n;
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-12 13:50:00 -04:00
|
|
|
|
public void SetIP(String I)
|
2015-08-20 01:06:44 -04:00
|
|
|
|
{
|
|
|
|
|
IP = I;
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-12 13:50:00 -04:00
|
|
|
|
public void SetLevel(Permission Perm)
|
2015-08-20 01:06:44 -04:00
|
|
|
|
{
|
|
|
|
|
Level = Perm;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-26 18:49:27 -04:00
|
|
|
|
public async Task Tell(String Message)
|
2015-08-20 01:06:44 -04:00
|
|
|
|
{
|
2017-05-26 18:49:27 -04:00
|
|
|
|
await lastEvent.Owner.Tell(Message, this);
|
2015-08-20 01:06:44 -04:00
|
|
|
|
}
|
|
|
|
|
|
2017-05-26 18:49:27 -04:00
|
|
|
|
public async Task Kick(String Message, Player Sender)
|
2015-08-20 01:06:44 -04:00
|
|
|
|
{
|
2017-05-26 18:49:27 -04:00
|
|
|
|
await lastEvent.Owner.Kick(Message, this, Sender);
|
2015-08-20 01:06:44 -04:00
|
|
|
|
}
|
|
|
|
|
|
2017-05-26 18:49:27 -04:00
|
|
|
|
public async Task TempBan(String Message, Player Sender)
|
2016-01-16 17:58:24 -05:00
|
|
|
|
{
|
2017-05-26 18:49:27 -04:00
|
|
|
|
await lastEvent.Owner.TempBan(Message, this, Sender);
|
2016-01-16 17:58:24 -05:00
|
|
|
|
}
|
|
|
|
|
|
2017-05-26 18:49:27 -04:00
|
|
|
|
public async Task Warn(String Message, Player Sender)
|
2015-08-20 01:06:44 -04:00
|
|
|
|
{
|
2017-05-26 18:49:27 -04:00
|
|
|
|
await lastEvent.Owner.Warn(Message, this, Sender);
|
2015-08-20 01:06:44 -04:00
|
|
|
|
}
|
|
|
|
|
|
2017-05-26 18:49:27 -04:00
|
|
|
|
public async Task Ban(String Message, Player Sender)
|
2015-08-20 01:06:44 -04:00
|
|
|
|
{
|
2017-05-26 18:49:27 -04:00
|
|
|
|
await lastEvent.Owner.Ban(Message, this, Sender);
|
2015-08-20 01:06:44 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String Name { get; private set; }
|
2017-05-31 01:31:56 -04:00
|
|
|
|
public string NetworkID { get; private set; }
|
|
|
|
|
public int ClientID { get; private set; }
|
|
|
|
|
public Permission Level { get; private set; }
|
|
|
|
|
public int DatabaseID { get; private set; }
|
2015-08-20 01:06:44 -04:00
|
|
|
|
public int Connections { get; set; }
|
|
|
|
|
public String IP { get; private set; }
|
2017-05-26 18:49:27 -04:00
|
|
|
|
public String UID { get; private set; }
|
2015-08-20 01:06:44 -04:00
|
|
|
|
public DateTime LastConnection { get; private set; }
|
2017-05-28 21:07:33 -04:00
|
|
|
|
public int Ping;
|
|
|
|
|
|
2015-08-20 01:06:44 -04:00
|
|
|
|
public Event lastEvent;
|
|
|
|
|
public String lastOffense;
|
|
|
|
|
public int Warnings;
|
|
|
|
|
public Aliases Alias;
|
|
|
|
|
public bool Masked;
|
|
|
|
|
}
|
|
|
|
|
}
|