Revert "Use Sublime Text's "Convert all open views to tabs" option"
This reverts commit b35a02d379.
This commit is contained in:
parent
b35a02d379
commit
12a39f4e9a
5 changed files with 302 additions and 302 deletions
|
|
@ -36,17 +36,17 @@ namespace TShockAPI.DB
|
||||||
database = db;
|
database = db;
|
||||||
|
|
||||||
var table = new SqlTable("GroupList",
|
var table = new SqlTable("GroupList",
|
||||||
new SqlColumn("GroupName", MySqlDbType.VarChar, 32) {Primary = true},
|
new SqlColumn("GroupName", MySqlDbType.VarChar, 32) {Primary = true},
|
||||||
new SqlColumn("Parent", MySqlDbType.VarChar, 32),
|
new SqlColumn("Parent", MySqlDbType.VarChar, 32),
|
||||||
new SqlColumn("Commands", MySqlDbType.Text),
|
new SqlColumn("Commands", MySqlDbType.Text),
|
||||||
new SqlColumn("ChatColor", MySqlDbType.Text),
|
new SqlColumn("ChatColor", MySqlDbType.Text),
|
||||||
new SqlColumn("Prefix", MySqlDbType.Text),
|
new SqlColumn("Prefix", MySqlDbType.Text),
|
||||||
new SqlColumn("Suffix", MySqlDbType.Text)
|
new SqlColumn("Suffix", MySqlDbType.Text)
|
||||||
);
|
);
|
||||||
var creator = new SqlTableCreator(db,
|
var creator = new SqlTableCreator(db,
|
||||||
db.GetSqlType() == SqlType.Sqlite
|
db.GetSqlType() == SqlType.Sqlite
|
||||||
? (IQueryBuilder) new SqliteQueryCreator()
|
? (IQueryBuilder) new SqliteQueryCreator()
|
||||||
: new MysqlQueryCreator());
|
: new MysqlQueryCreator());
|
||||||
if (creator.EnsureExists(table))
|
if (creator.EnsureExists(table))
|
||||||
{
|
{
|
||||||
// Add default groups if they don't exist
|
// Add default groups if they don't exist
|
||||||
|
|
|
||||||
|
|
@ -35,19 +35,19 @@ namespace TShockAPI.DB
|
||||||
database = db;
|
database = db;
|
||||||
|
|
||||||
var table = new SqlTable("Users",
|
var table = new SqlTable("Users",
|
||||||
new SqlColumn("ID", MySqlDbType.Int32) {Primary = true, AutoIncrement = true},
|
new SqlColumn("ID", MySqlDbType.Int32) {Primary = true, AutoIncrement = true},
|
||||||
new SqlColumn("Username", MySqlDbType.VarChar, 32) {Unique = true},
|
new SqlColumn("Username", MySqlDbType.VarChar, 32) {Unique = true},
|
||||||
new SqlColumn("Password", MySqlDbType.VarChar, 128),
|
new SqlColumn("Password", MySqlDbType.VarChar, 128),
|
||||||
new SqlColumn("UUID", MySqlDbType.VarChar, 128),
|
new SqlColumn("UUID", MySqlDbType.VarChar, 128),
|
||||||
new SqlColumn("Usergroup", MySqlDbType.Text),
|
new SqlColumn("Usergroup", MySqlDbType.Text),
|
||||||
new SqlColumn("Registered", MySqlDbType.Text),
|
new SqlColumn("Registered", MySqlDbType.Text),
|
||||||
new SqlColumn("LastAccessed", MySqlDbType.Text),
|
new SqlColumn("LastAccessed", MySqlDbType.Text),
|
||||||
new SqlColumn("KnownIPs", MySqlDbType.Text)
|
new SqlColumn("KnownIPs", MySqlDbType.Text)
|
||||||
);
|
);
|
||||||
var creator = new SqlTableCreator(db,
|
var creator = new SqlTableCreator(db,
|
||||||
db.GetSqlType() == SqlType.Sqlite
|
db.GetSqlType() == SqlType.Sqlite
|
||||||
? (IQueryBuilder) new SqliteQueryCreator()
|
? (IQueryBuilder) new SqliteQueryCreator()
|
||||||
: new MysqlQueryCreator());
|
: new MysqlQueryCreator());
|
||||||
creator.EnsureExists(table);
|
creator.EnsureExists(table);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -64,7 +64,7 @@ namespace TShockAPI.DB
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ret = database.Query("INSERT INTO Users (Username, Password, UUID, UserGroup, Registered) VALUES (@0, @1, @2, @3, @4);", user.Name,
|
ret = database.Query("INSERT INTO Users (Username, Password, UUID, UserGroup, Registered) VALUES (@0, @1, @2, @3, @4);", user.Name,
|
||||||
TShock.Utils.HashPassword(user.Password), user.UUID, user.Group, DateTime.UtcNow.ToString("s"));
|
TShock.Utils.HashPassword(user.Password), user.UUID, user.Group, DateTime.UtcNow.ToString("s"));
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
@ -113,7 +113,7 @@ namespace TShockAPI.DB
|
||||||
{
|
{
|
||||||
if (
|
if (
|
||||||
database.Query("UPDATE Users SET Password = @0 WHERE Username = @1;", TShock.Utils.HashPassword(password),
|
database.Query("UPDATE Users SET Password = @0 WHERE Username = @1;", TShock.Utils.HashPassword(password),
|
||||||
user.Name) == 0)
|
user.Name) == 0)
|
||||||
throw new UserNotExistException(user.Name);
|
throw new UserNotExistException(user.Name);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
@ -133,7 +133,7 @@ namespace TShockAPI.DB
|
||||||
{
|
{
|
||||||
if (
|
if (
|
||||||
database.Query("UPDATE Users SET UUID = @0 WHERE Username = @1;", uuid,
|
database.Query("UPDATE Users SET UUID = @0 WHERE Username = @1;", uuid,
|
||||||
user.Name) == 0)
|
user.Name) == 0)
|
||||||
throw new UserNotExistException(user.Name);
|
throw new UserNotExistException(user.Name);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
@ -170,18 +170,18 @@ namespace TShockAPI.DB
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateLogin(User user)
|
public void UpdateLogin(User user)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (database.Query("UPDATE Users SET LastAccessed = @0, KnownIps = @1 WHERE Username = @2;", DateTime.UtcNow.ToString("s"), user.KnownIps, user.Name) == 0)
|
if (database.Query("UPDATE Users SET LastAccessed = @0, KnownIps = @1 WHERE Username = @2;", DateTime.UtcNow.ToString("s"), user.KnownIps, user.Name) == 0)
|
||||||
throw new UserNotExistException(user.Name);
|
throw new UserNotExistException(user.Name);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
throw new UserManagerException("UpdateLogin SQL returned an error", ex);
|
throw new UserManagerException("UpdateLogin SQL returned an error", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetUserID(string username)
|
public int GetUserID(string username)
|
||||||
{
|
{
|
||||||
|
|
@ -295,11 +295,11 @@ namespace TShockAPI.DB
|
||||||
user.ID = result.Get<int>("ID");
|
user.ID = result.Get<int>("ID");
|
||||||
user.Group = result.Get<string>("Usergroup");
|
user.Group = result.Get<string>("Usergroup");
|
||||||
user.Password = result.Get<string>("Password");
|
user.Password = result.Get<string>("Password");
|
||||||
user.UUID = result.Get<string>("UUID");
|
user.UUID = result.Get<string>("UUID");
|
||||||
user.Name = result.Get<string>("Username");
|
user.Name = result.Get<string>("Username");
|
||||||
user.Registered = result.Get<string>("Registered");
|
user.Registered = result.Get<string>("Registered");
|
||||||
user.LastAccessed = result.Get<string>("LastAccessed");
|
user.LastAccessed = result.Get<string>("LastAccessed");
|
||||||
user.KnownIps = result.Get<string>("KnownIps");
|
user.KnownIps = result.Get<string>("KnownIps");
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -309,32 +309,32 @@ namespace TShockAPI.DB
|
||||||
public int ID { get; set; }
|
public int ID { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public string Password { get; set; }
|
public string Password { get; set; }
|
||||||
public string UUID { get; set; }
|
public string UUID { get; set; }
|
||||||
public string Group { get; set; }
|
public string Group { get; set; }
|
||||||
public string Registered { get; set; }
|
public string Registered { get; set; }
|
||||||
public string LastAccessed { get; set; }
|
public string LastAccessed { get; set; }
|
||||||
public string KnownIps { get; set; }
|
public string KnownIps { get; set; }
|
||||||
|
|
||||||
public User(string name, string pass, string uuid, string group, string registered, string last, string known)
|
public User(string name, string pass, string uuid, string group, string registered, string last, string known)
|
||||||
{
|
{
|
||||||
Name = name;
|
Name = name;
|
||||||
Password = pass;
|
Password = pass;
|
||||||
UUID = uuid;
|
UUID = uuid;
|
||||||
Group = group;
|
Group = group;
|
||||||
Registered = registered;
|
Registered = registered;
|
||||||
LastAccessed = last;
|
LastAccessed = last;
|
||||||
KnownIps = known;
|
KnownIps = known;
|
||||||
}
|
}
|
||||||
|
|
||||||
public User()
|
public User()
|
||||||
{
|
{
|
||||||
Name = "";
|
Name = "";
|
||||||
Password = "";
|
Password = "";
|
||||||
UUID = "";
|
UUID = "";
|
||||||
Group = "";
|
Group = "";
|
||||||
Registered = "";
|
Registered = "";
|
||||||
LastAccessed = "";
|
LastAccessed = "";
|
||||||
KnownIps = "";
|
KnownIps = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -72,126 +72,126 @@ namespace MaxMind
|
||||||
private const long COUNTRY_BEGIN = 16776960;
|
private const long COUNTRY_BEGIN = 16776960;
|
||||||
|
|
||||||
private static readonly string[] CountryCodes = {
|
private static readonly string[] CountryCodes = {
|
||||||
"--", "AP", "EU", "AD", "AE", "AF", "AG", "AI", "AL", "AM", "AN",
|
"--", "AP", "EU", "AD", "AE", "AF", "AG", "AI", "AL", "AM", "AN",
|
||||||
"AO", "AQ", "AR", "AS",
|
"AO", "AQ", "AR", "AS",
|
||||||
"AT", "AU", "AW", "AZ", "BA", "BB", "BD", "BE", "BF", "BG", "BH",
|
"AT", "AU", "AW", "AZ", "BA", "BB", "BD", "BE", "BF", "BG", "BH",
|
||||||
"BI", "BJ", "BM", "BN",
|
"BI", "BJ", "BM", "BN",
|
||||||
"BO", "BR", "BS", "BT", "BV", "BW", "BY", "BZ", "CA", "CC", "CD",
|
"BO", "BR", "BS", "BT", "BV", "BW", "BY", "BZ", "CA", "CC", "CD",
|
||||||
"CF", "CG", "CH", "CI",
|
"CF", "CG", "CH", "CI",
|
||||||
"CK", "CL", "CM", "CN", "CO", "CR", "CU", "CV", "CX", "CY", "CZ",
|
"CK", "CL", "CM", "CN", "CO", "CR", "CU", "CV", "CX", "CY", "CZ",
|
||||||
"DE", "DJ", "DK", "DM",
|
"DE", "DJ", "DK", "DM",
|
||||||
"DO", "DZ", "EC", "EE", "EG", "EH", "ER", "ES", "ET", "FI", "FJ",
|
"DO", "DZ", "EC", "EE", "EG", "EH", "ER", "ES", "ET", "FI", "FJ",
|
||||||
"FK", "FM", "FO", "FR",
|
"FK", "FM", "FO", "FR",
|
||||||
"FX", "GA", "GB", "GD", "GE", "GF", "GH", "GI", "GL", "GM", "GN",
|
"FX", "GA", "GB", "GD", "GE", "GF", "GH", "GI", "GL", "GM", "GN",
|
||||||
"GP", "GQ", "GR", "GS",
|
"GP", "GQ", "GR", "GS",
|
||||||
"GT", "GU", "GW", "GY", "HK", "HM", "HN", "HR", "HT", "HU", "ID",
|
"GT", "GU", "GW", "GY", "HK", "HM", "HN", "HR", "HT", "HU", "ID",
|
||||||
"IE", "IL", "IN", "IO",
|
"IE", "IL", "IN", "IO",
|
||||||
"IQ", "IR", "IS", "IT", "JM", "JO", "JP", "KE", "KG", "KH", "KI",
|
"IQ", "IR", "IS", "IT", "JM", "JO", "JP", "KE", "KG", "KH", "KI",
|
||||||
"KM", "KN", "KP", "KR",
|
"KM", "KN", "KP", "KR",
|
||||||
"KW", "KY", "KZ", "LA", "LB", "LC", "LI", "LK", "LR", "LS", "LT",
|
"KW", "KY", "KZ", "LA", "LB", "LC", "LI", "LK", "LR", "LS", "LT",
|
||||||
"LU", "LV", "LY", "MA",
|
"LU", "LV", "LY", "MA",
|
||||||
"MC", "MD", "MG", "MH", "MK", "ML", "MM", "MN", "MO", "MP", "MQ",
|
"MC", "MD", "MG", "MH", "MK", "ML", "MM", "MN", "MO", "MP", "MQ",
|
||||||
"MR", "MS", "MT", "MU",
|
"MR", "MS", "MT", "MU",
|
||||||
"MV", "MW", "MX", "MY", "MZ", "NA", "NC", "NE", "NF", "NG", "NI",
|
"MV", "MW", "MX", "MY", "MZ", "NA", "NC", "NE", "NF", "NG", "NI",
|
||||||
"NL", "NO", "NP", "NR",
|
"NL", "NO", "NP", "NR",
|
||||||
"NU", "NZ", "OM", "PA", "PE", "PF", "PG", "PH", "PK", "PL", "PM",
|
"NU", "NZ", "OM", "PA", "PE", "PF", "PG", "PH", "PK", "PL", "PM",
|
||||||
"PN", "PR", "PS", "PT",
|
"PN", "PR", "PS", "PT",
|
||||||
"PW", "PY", "QA", "RE", "RO", "RU", "RW", "SA", "SB", "SC", "SD",
|
"PW", "PY", "QA", "RE", "RO", "RU", "RW", "SA", "SB", "SC", "SD",
|
||||||
"SE", "SG", "SH", "SI",
|
"SE", "SG", "SH", "SI",
|
||||||
"SJ", "SK", "SL", "SM", "SN", "SO", "SR", "ST", "SV", "SY", "SZ",
|
"SJ", "SK", "SL", "SM", "SN", "SO", "SR", "ST", "SV", "SY", "SZ",
|
||||||
"TC", "TD", "TF", "TG",
|
"TC", "TD", "TF", "TG",
|
||||||
"TH", "TJ", "TK", "TM", "TN", "TO", "TL", "TR", "TT", "TV", "TW",
|
"TH", "TJ", "TK", "TM", "TN", "TO", "TL", "TR", "TT", "TV", "TW",
|
||||||
"TZ", "UA", "UG", "UM",
|
"TZ", "UA", "UG", "UM",
|
||||||
"US", "UY", "UZ", "VA", "VC", "VE", "VG", "VI", "VN", "VU", "WF",
|
"US", "UY", "UZ", "VA", "VC", "VE", "VG", "VI", "VN", "VU", "WF",
|
||||||
"WS", "YE", "YT", "RS",
|
"WS", "YE", "YT", "RS",
|
||||||
"ZA", "ZM", "ME", "ZW", "A1", "A2", "O1", "AX", "GG", "IM", "JE",
|
"ZA", "ZM", "ME", "ZW", "A1", "A2", "O1", "AX", "GG", "IM", "JE",
|
||||||
"BL", "MF"
|
"BL", "MF"
|
||||||
};
|
};
|
||||||
|
|
||||||
private static readonly string[] CountryNames = {
|
private static readonly string[] CountryNames = {
|
||||||
"N/A", "Asia/Pacific Region", "Europe", "Andorra",
|
"N/A", "Asia/Pacific Region", "Europe", "Andorra",
|
||||||
"United Arab Emirates", "Afghanistan",
|
"United Arab Emirates", "Afghanistan",
|
||||||
"Antigua and Barbuda", "Anguilla", "Albania", "Armenia",
|
"Antigua and Barbuda", "Anguilla", "Albania", "Armenia",
|
||||||
"Netherlands Antilles", "Angola",
|
"Netherlands Antilles", "Angola",
|
||||||
"Antarctica", "Argentina", "American Samoa", "Austria", "Australia",
|
"Antarctica", "Argentina", "American Samoa", "Austria", "Australia",
|
||||||
"Aruba", "Azerbaijan",
|
"Aruba", "Azerbaijan",
|
||||||
"Bosnia and Herzegovina", "Barbados", "Bangladesh", "Belgium",
|
"Bosnia and Herzegovina", "Barbados", "Bangladesh", "Belgium",
|
||||||
"Burkina Faso", "Bulgaria",
|
"Burkina Faso", "Bulgaria",
|
||||||
"Bahrain", "Burundi", "Benin", "Bermuda", "Brunei Darussalam",
|
"Bahrain", "Burundi", "Benin", "Bermuda", "Brunei Darussalam",
|
||||||
"Bolivia", "Brazil", "Bahamas",
|
"Bolivia", "Brazil", "Bahamas",
|
||||||
"Bhutan", "Bouvet Island", "Botswana", "Belarus", "Belize", "Canada",
|
"Bhutan", "Bouvet Island", "Botswana", "Belarus", "Belize", "Canada",
|
||||||
"Cocos (Keeling) Islands",
|
"Cocos (Keeling) Islands",
|
||||||
"Congo, The Democratic Republic of the", "Central African Republic",
|
"Congo, The Democratic Republic of the", "Central African Republic",
|
||||||
"Congo", "Switzerland",
|
"Congo", "Switzerland",
|
||||||
"Cote D'Ivoire", "Cook Islands", "Chile", "Cameroon", "China",
|
"Cote D'Ivoire", "Cook Islands", "Chile", "Cameroon", "China",
|
||||||
"Colombia", "Costa Rica", "Cuba",
|
"Colombia", "Costa Rica", "Cuba",
|
||||||
"Cape Verde", "Christmas Island", "Cyprus", "Czech Republic",
|
"Cape Verde", "Christmas Island", "Cyprus", "Czech Republic",
|
||||||
"Germany", "Djibouti", "Denmark",
|
"Germany", "Djibouti", "Denmark",
|
||||||
"Dominica", "Dominican Republic", "Algeria", "Ecuador", "Estonia",
|
"Dominica", "Dominican Republic", "Algeria", "Ecuador", "Estonia",
|
||||||
"Egypt", "Western Sahara",
|
"Egypt", "Western Sahara",
|
||||||
"Eritrea", "Spain", "Ethiopia", "Finland", "Fiji",
|
"Eritrea", "Spain", "Ethiopia", "Finland", "Fiji",
|
||||||
"Falkland Islands (Malvinas)",
|
"Falkland Islands (Malvinas)",
|
||||||
"Micronesia, Federated States of", "Faroe Islands", "France",
|
"Micronesia, Federated States of", "Faroe Islands", "France",
|
||||||
"France, Metropolitan", "Gabon",
|
"France, Metropolitan", "Gabon",
|
||||||
"United Kingdom", "Grenada", "Georgia", "French Guiana", "Ghana",
|
"United Kingdom", "Grenada", "Georgia", "French Guiana", "Ghana",
|
||||||
"Gibraltar", "Greenland",
|
"Gibraltar", "Greenland",
|
||||||
"Gambia", "Guinea", "Guadeloupe", "Equatorial Guinea", "Greece",
|
"Gambia", "Guinea", "Guadeloupe", "Equatorial Guinea", "Greece",
|
||||||
"South Georgia and the South Sandwich Islands", "Guatemala", "Guam",
|
"South Georgia and the South Sandwich Islands", "Guatemala", "Guam",
|
||||||
"Guinea-Bissau", "Guyana",
|
"Guinea-Bissau", "Guyana",
|
||||||
"Hong Kong", "Heard Island and McDonald Islands", "Honduras",
|
"Hong Kong", "Heard Island and McDonald Islands", "Honduras",
|
||||||
"Croatia", "Haiti", "Hungary",
|
"Croatia", "Haiti", "Hungary",
|
||||||
"Indonesia", "Ireland", "Israel", "India",
|
"Indonesia", "Ireland", "Israel", "India",
|
||||||
"British Indian Ocean Territory", "Iraq",
|
"British Indian Ocean Territory", "Iraq",
|
||||||
"Iran, Islamic Republic of", "Iceland", "Italy", "Jamaica", "Jordan",
|
"Iran, Islamic Republic of", "Iceland", "Italy", "Jamaica", "Jordan",
|
||||||
"Japan", "Kenya",
|
"Japan", "Kenya",
|
||||||
"Kyrgyzstan", "Cambodia", "Kiribati", "Comoros",
|
"Kyrgyzstan", "Cambodia", "Kiribati", "Comoros",
|
||||||
"Saint Kitts and Nevis",
|
"Saint Kitts and Nevis",
|
||||||
"Korea, Democratic People's Republic of", "Korea, Republic of",
|
"Korea, Democratic People's Republic of", "Korea, Republic of",
|
||||||
"Kuwait", "Cayman Islands",
|
"Kuwait", "Cayman Islands",
|
||||||
"Kazakstan", "Lao People's Democratic Republic", "Lebanon",
|
"Kazakstan", "Lao People's Democratic Republic", "Lebanon",
|
||||||
"Saint Lucia", "Liechtenstein",
|
"Saint Lucia", "Liechtenstein",
|
||||||
"Sri Lanka", "Liberia", "Lesotho", "Lithuania", "Luxembourg",
|
"Sri Lanka", "Liberia", "Lesotho", "Lithuania", "Luxembourg",
|
||||||
"Latvia", "Libyan Arab Jamahiriya",
|
"Latvia", "Libyan Arab Jamahiriya",
|
||||||
"Morocco", "Monaco", "Moldova, Republic of", "Madagascar",
|
"Morocco", "Monaco", "Moldova, Republic of", "Madagascar",
|
||||||
"Marshall Islands", "Macedonia",
|
"Marshall Islands", "Macedonia",
|
||||||
"Mali", "Myanmar", "Mongolia", "Macau", "Northern Mariana Islands",
|
"Mali", "Myanmar", "Mongolia", "Macau", "Northern Mariana Islands",
|
||||||
"Martinique", "Mauritania",
|
"Martinique", "Mauritania",
|
||||||
"Montserrat", "Malta", "Mauritius", "Maldives", "Malawi", "Mexico",
|
"Montserrat", "Malta", "Mauritius", "Maldives", "Malawi", "Mexico",
|
||||||
"Malaysia", "Mozambique",
|
"Malaysia", "Mozambique",
|
||||||
"Namibia", "New Caledonia", "Niger", "Norfolk Island", "Nigeria",
|
"Namibia", "New Caledonia", "Niger", "Norfolk Island", "Nigeria",
|
||||||
"Nicaragua", "Netherlands",
|
"Nicaragua", "Netherlands",
|
||||||
"Norway", "Nepal", "Nauru", "Niue", "New Zealand", "Oman", "Panama",
|
"Norway", "Nepal", "Nauru", "Niue", "New Zealand", "Oman", "Panama",
|
||||||
"Peru", "French Polynesia",
|
"Peru", "French Polynesia",
|
||||||
"Papua New Guinea", "Philippines", "Pakistan", "Poland",
|
"Papua New Guinea", "Philippines", "Pakistan", "Poland",
|
||||||
"Saint Pierre and Miquelon",
|
"Saint Pierre and Miquelon",
|
||||||
"Pitcairn Islands", "Puerto Rico", "Palestinian Territory",
|
"Pitcairn Islands", "Puerto Rico", "Palestinian Territory",
|
||||||
"Portugal", "Palau", "Paraguay",
|
"Portugal", "Palau", "Paraguay",
|
||||||
"Qatar", "Reunion", "Romania", "Russian Federation", "Rwanda",
|
"Qatar", "Reunion", "Romania", "Russian Federation", "Rwanda",
|
||||||
"Saudi Arabia",
|
"Saudi Arabia",
|
||||||
"Solomon Islands", "Seychelles", "Sudan", "Sweden", "Singapore",
|
"Solomon Islands", "Seychelles", "Sudan", "Sweden", "Singapore",
|
||||||
"Saint Helena", "Slovenia",
|
"Saint Helena", "Slovenia",
|
||||||
"Svalbard and Jan Mayen", "Slovakia", "Sierra Leone", "San Marino",
|
"Svalbard and Jan Mayen", "Slovakia", "Sierra Leone", "San Marino",
|
||||||
"Senegal", "Somalia",
|
"Senegal", "Somalia",
|
||||||
"Suriname", "Sao Tome and Principe", "El Salvador",
|
"Suriname", "Sao Tome and Principe", "El Salvador",
|
||||||
"Syrian Arab Republic", "Swaziland",
|
"Syrian Arab Republic", "Swaziland",
|
||||||
"Turks and Caicos Islands", "Chad", "French Southern Territories",
|
"Turks and Caicos Islands", "Chad", "French Southern Territories",
|
||||||
"Togo", "Thailand",
|
"Togo", "Thailand",
|
||||||
"Tajikistan", "Tokelau", "Turkmenistan", "Tunisia", "Tonga",
|
"Tajikistan", "Tokelau", "Turkmenistan", "Tunisia", "Tonga",
|
||||||
"Timor-Leste", "Turkey",
|
"Timor-Leste", "Turkey",
|
||||||
"Trinidad and Tobago", "Tuvalu", "Taiwan",
|
"Trinidad and Tobago", "Tuvalu", "Taiwan",
|
||||||
"Tanzania, United Republic of", "Ukraine", "Uganda",
|
"Tanzania, United Republic of", "Ukraine", "Uganda",
|
||||||
"United States Minor Outlying Islands", "United States", "Uruguay",
|
"United States Minor Outlying Islands", "United States", "Uruguay",
|
||||||
"Uzbekistan",
|
"Uzbekistan",
|
||||||
"Holy See (Vatican City State)", "Saint Vincent and the Grenadines",
|
"Holy See (Vatican City State)", "Saint Vincent and the Grenadines",
|
||||||
"Venezuela",
|
"Venezuela",
|
||||||
"Virgin Islands, British", "Virgin Islands, U.S.", "Vietnam",
|
"Virgin Islands, British", "Virgin Islands, U.S.", "Vietnam",
|
||||||
"Vanuatu", "Wallis and Futuna",
|
"Vanuatu", "Wallis and Futuna",
|
||||||
"Samoa", "Yemen", "Mayotte", "Serbia", "South Africa", "Zambia",
|
"Samoa", "Yemen", "Mayotte", "Serbia", "South Africa", "Zambia",
|
||||||
"Montenegro", "Zimbabwe",
|
"Montenegro", "Zimbabwe",
|
||||||
"Anonymous Proxy", "Satellite Provider", "Other", "Aland Islands",
|
"Anonymous Proxy", "Satellite Provider", "Other", "Aland Islands",
|
||||||
"Guernsey", "Isle of Man",
|
"Guernsey", "Isle of Man",
|
||||||
"Jersey", "Saint Barthelemy", "Saint Martin"
|
"Jersey", "Saint Barthelemy", "Saint Martin"
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
// Constructor
|
// Constructor
|
||||||
|
|
|
||||||
|
|
@ -18,26 +18,26 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
namespace TShockAPI.Hooks
|
namespace TShockAPI.Hooks
|
||||||
{
|
{
|
||||||
public class ReloadEventArgs
|
public class ReloadEventArgs
|
||||||
{
|
{
|
||||||
public TSPlayer Player { get; set; }
|
public TSPlayer Player { get; set; }
|
||||||
public ReloadEventArgs(TSPlayer ply)
|
public ReloadEventArgs(TSPlayer ply)
|
||||||
{
|
{
|
||||||
Player = ply;
|
Player = ply;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class GeneralHooks
|
public class GeneralHooks
|
||||||
{
|
{
|
||||||
public delegate void ReloadEventD(ReloadEventArgs e);
|
public delegate void ReloadEventD(ReloadEventArgs e);
|
||||||
public static event ReloadEventD ReloadEvent;
|
public static event ReloadEventD ReloadEvent;
|
||||||
|
|
||||||
public static void OnReloadEvent(TSPlayer ply)
|
public static void OnReloadEvent(TSPlayer ply)
|
||||||
{
|
{
|
||||||
if(ReloadEvent == null)
|
if(ReloadEvent == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ReloadEvent(new ReloadEventArgs(ply));
|
ReloadEvent(new ReloadEventArgs(ply));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,17 +35,17 @@ namespace TShockAPI
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Utils
|
public class Utils
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The lowest id for a prefix.
|
/// The lowest id for a prefix.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private const int FirstItemPrefix = 1;
|
private const int FirstItemPrefix = 1;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The highest id for a prefix.
|
/// The highest id for a prefix.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private const int LastItemPrefix = 83;
|
private const int LastItemPrefix = 83;
|
||||||
|
|
||||||
// Utils is a Singleton
|
// Utils is a Singleton
|
||||||
private static readonly Utils instance = new Utils();
|
private static readonly Utils instance = new Utils();
|
||||||
private Utils() {}
|
private Utils() {}
|
||||||
public static Utils Instance { get { return instance; } }
|
public static Utils Instance { get { return instance; } }
|
||||||
|
|
@ -67,7 +67,7 @@ namespace TShockAPI
|
||||||
/// Used for some places where a list of players might be used.
|
/// Used for some places where a list of players might be used.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>String of players seperated by commas.</returns>
|
/// <returns>String of players seperated by commas.</returns>
|
||||||
[Obsolete("Use GetPlayers and manually create strings. This should never have been kept as far as actual functions go.")]
|
[Obsolete("Use GetPlayers and manually create strings. This should never have been kept as far as actual functions go.")]
|
||||||
public string GetPlayers()
|
public string GetPlayers()
|
||||||
{
|
{
|
||||||
var sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
|
|
@ -85,56 +85,56 @@ namespace TShockAPI
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a list of current players on the server
|
/// Returns a list of current players on the server
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="includeIDs">bool includeIDs - whether or not the string of each player name should include ID data</param>
|
/// <param name="includeIDs">bool includeIDs - whether or not the string of each player name should include ID data</param>
|
||||||
/// <returns>List of strings with names</returns>
|
/// <returns>List of strings with names</returns>
|
||||||
public List<string> GetPlayers(bool includeIDs)
|
public List<string> GetPlayers(bool includeIDs)
|
||||||
{
|
{
|
||||||
var players = new List<string>();
|
var players = new List<string>();
|
||||||
|
|
||||||
foreach (TSPlayer ply in TShock.Players)
|
foreach (TSPlayer ply in TShock.Players)
|
||||||
{
|
{
|
||||||
if (ply != null && ply.Active)
|
if (ply != null && ply.Active)
|
||||||
{
|
{
|
||||||
if (includeIDs)
|
if (includeIDs)
|
||||||
{
|
{
|
||||||
players.Add(ply.Name + " (IX: " + ply.Index + ", ID: " + ply.UserID + ")");
|
players.Add(ply.Name + " (IX: " + ply.Index + ", ID: " + ply.UserID + ")");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
players.Add(ply.Name);
|
players.Add(ply.Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return players;
|
return players;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Used for some places where a list of players might be used.
|
/// Used for some places where a list of players might be used.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>String of players and their id seperated by commas.</returns>
|
/// <returns>String of players and their id seperated by commas.</returns>
|
||||||
[Obsolete("Use GetPlayers and manually create strings. This should never have been kept as far as actual functions go.")]
|
[Obsolete("Use GetPlayers and manually create strings. This should never have been kept as far as actual functions go.")]
|
||||||
public string GetPlayersWithIds()
|
public string GetPlayersWithIds()
|
||||||
{
|
{
|
||||||
var sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
foreach (TSPlayer player in TShock.Players)
|
foreach (TSPlayer player in TShock.Players)
|
||||||
{
|
{
|
||||||
if (player != null && player.Active)
|
if (player != null && player.Active)
|
||||||
{
|
{
|
||||||
if (sb.Length != 0)
|
if (sb.Length != 0)
|
||||||
{
|
{
|
||||||
sb.Append(", ");
|
sb.Append(", ");
|
||||||
}
|
}
|
||||||
sb.Append(player.Name);
|
sb.Append(player.Name);
|
||||||
string id = "(ID: " + Convert.ToString(TShock.Users.GetUserID(player.UserAccountName)) + ", IX:" + player.Index + ")";
|
string id = "(ID: " + Convert.ToString(TShock.Users.GetUserID(player.UserAccountName)) + ", IX:" + player.Index + ")";
|
||||||
sb.Append(id);
|
sb.Append(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Finds a player and gets IP as string
|
/// Finds a player and gets IP as string
|
||||||
|
|
@ -204,20 +204,20 @@ namespace TShockAPI
|
||||||
Broadcast(msg, color.R, color.G, color.B);
|
Broadcast(msg, color.R, color.G, color.B);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Broadcasts a message from a player, not TShock
|
/// Broadcasts a message from a player, not TShock
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="ply">TSPlayer ply - the player that will send the packet</param>
|
/// <param name="ply">TSPlayer ply - the player that will send the packet</param>
|
||||||
/// <param name="msg">string msg - the message</param>
|
/// <param name="msg">string msg - the message</param>
|
||||||
/// <param name="red">r</param>
|
/// <param name="red">r</param>
|
||||||
/// <param name="green">g</param>
|
/// <param name="green">g</param>
|
||||||
/// <param name="blue">b</param>
|
/// <param name="blue">b</param>
|
||||||
public void Broadcast(int ply, string msg, byte red, byte green, byte blue)
|
public void Broadcast(int ply, string msg, byte red, byte green, byte blue)
|
||||||
{
|
{
|
||||||
TSPlayer.All.SendMessageFromPlayer(msg, red, green, blue, ply);
|
TSPlayer.All.SendMessageFromPlayer(msg, red, green, blue, ply);
|
||||||
TSPlayer.Server.SendMessage(Main.player[ply].name + ": " + msg, red, green, blue);
|
TSPlayer.Server.SendMessage(Main.player[ply].name + ": " + msg, red, green, blue);
|
||||||
Log.Info(string.Format("Broadcast: {0}", Main.player[ply].name + ": " + msg));
|
Log.Info(string.Format("Broadcast: {0}", Main.player[ply].name + ": " + msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sends message to all players with 'logs' permission.
|
/// Sends message to all players with 'logs' permission.
|
||||||
|
|
@ -232,7 +232,7 @@ namespace TShockAPI
|
||||||
foreach (TSPlayer player in TShock.Players)
|
foreach (TSPlayer player in TShock.Players)
|
||||||
{
|
{
|
||||||
if (player != null && player != excludedPlayer && player.Active && player.Group.HasPermission(Permissions.logs) &&
|
if (player != null && player != excludedPlayer && player.Active && player.Group.HasPermission(Permissions.logs) &&
|
||||||
player.DisplayLogs && TShock.Config.DisableSpewLogs == false)
|
player.DisplayLogs && TShock.Config.DisableSpewLogs == false)
|
||||||
player.SendMessage(log, color);
|
player.SendMessage(log, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -293,7 +293,7 @@ namespace TShockAPI
|
||||||
/// <param name="tileX">X location</param>
|
/// <param name="tileX">X location</param>
|
||||||
/// <param name="tileY">Y location</param>
|
/// <param name="tileY">Y location</param>
|
||||||
public void GetRandomClearTileWithInRange(int startTileX, int startTileY, int tileXRange, int tileYRange,
|
public void GetRandomClearTileWithInRange(int startTileX, int startTileY, int tileXRange, int tileYRange,
|
||||||
out int tileX, out int tileY)
|
out int tileX, out int tileY)
|
||||||
{
|
{
|
||||||
int j = 0;
|
int j = 0;
|
||||||
do
|
do
|
||||||
|
|
@ -510,7 +510,7 @@ namespace TShockAPI
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a prefix by ID or name
|
/// Gets a prefix by ID or name
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="idOrName">ID or name</param>
|
/// <param name="idOrName">ID or name</param>
|
||||||
|
|
@ -635,18 +635,18 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
string playerName = player.Name;
|
string playerName = player.Name;
|
||||||
player.SilentKickInProgress = silent;
|
player.SilentKickInProgress = silent;
|
||||||
if (player.IsLoggedIn && saveSSI)
|
if (player.IsLoggedIn && saveSSI)
|
||||||
player.SaveServerCharacter();
|
player.SaveServerCharacter();
|
||||||
player.Disconnect(string.Format("Kicked: {0}", reason));
|
player.Disconnect(string.Format("Kicked: {0}", reason));
|
||||||
Log.ConsoleInfo(string.Format("Kicked {0} for : '{1}'", playerName, reason));
|
Log.ConsoleInfo(string.Format("Kicked {0} for : '{1}'", playerName, reason));
|
||||||
string verb = force ? "force " : "";
|
string verb = force ? "force " : "";
|
||||||
if (!silent)
|
if (!silent)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(adminUserName))
|
if (string.IsNullOrWhiteSpace(adminUserName))
|
||||||
Broadcast(string.Format("{0} was {1}kicked for '{2}'", playerName, verb, reason.ToLower()), Color.Green);
|
Broadcast(string.Format("{0} was {1}kicked for '{2}'", playerName, verb, reason.ToLower()), Color.Green);
|
||||||
else
|
else
|
||||||
Broadcast(string.Format("{0} {1}kicked {2} for '{3}'", adminUserName, verb, playerName, reason.ToLower()), Color.Green);
|
Broadcast(string.Format("{0} {1}kicked {2} for '{3}'", adminUserName, verb, playerName, reason.ToLower()), Color.Green);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -687,28 +687,28 @@ namespace TShockAPI
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool HasBanExpired(Ban ban, bool byName = false)
|
public bool HasBanExpired(Ban ban, bool byName = false)
|
||||||
{
|
{
|
||||||
DateTime exp;
|
DateTime exp;
|
||||||
bool expirationExists = DateTime.TryParse(ban.Expiration, out exp);
|
bool expirationExists = DateTime.TryParse(ban.Expiration, out exp);
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(ban.Expiration) && (expirationExists) &&
|
if (!string.IsNullOrWhiteSpace(ban.Expiration) && (expirationExists) &&
|
||||||
(DateTime.UtcNow >= exp))
|
(DateTime.UtcNow >= exp))
|
||||||
{
|
{
|
||||||
if (byName)
|
if (byName)
|
||||||
{
|
{
|
||||||
TShock.Bans.RemoveBan(ban.Name, true, true, false);
|
TShock.Bans.RemoveBan(ban.Name, true, true, false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TShock.Bans.RemoveBan(ban.IP, false, false, false);
|
TShock.Bans.RemoveBan(ban.IP, false, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Shows a file to the user.
|
/// Shows a file to the user.
|
||||||
|
|
@ -762,7 +762,7 @@ namespace TShockAPI
|
||||||
return TShock.Groups.groups[i];
|
return TShock.Groups.groups[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Group.DefaultGroup;
|
return Group.DefaultGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -796,23 +796,23 @@ namespace TShockAPI
|
||||||
ply.SendErrorMessage("Use \"my query\" for items with spaces");
|
ply.SendErrorMessage("Use \"my query\" for items with spaces");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Default hashing algorithm.
|
/// Default hashing algorithm.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string HashAlgo = "sha512";
|
public string HashAlgo = "sha512";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A dictionary of hashing algortihms and an implementation object.
|
/// A dictionary of hashing algortihms and an implementation object.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly Dictionary<string, Func<HashAlgorithm>> HashTypes = new Dictionary<string, Func<HashAlgorithm>>
|
public readonly Dictionary<string, Func<HashAlgorithm>> HashTypes = new Dictionary<string, Func<HashAlgorithm>>
|
||||||
{
|
{
|
||||||
{"sha512", () => new SHA512Managed()},
|
{"sha512", () => new SHA512Managed()},
|
||||||
{"sha256", () => new SHA256Managed()},
|
{"sha256", () => new SHA256Managed()},
|
||||||
{"md5", () => new MD5Cng()},
|
{"md5", () => new MD5Cng()},
|
||||||
{"sha512-xp", () => SHA512.Create()},
|
{"sha512-xp", () => SHA512.Create()},
|
||||||
{"sha256-xp", () => SHA256.Create()},
|
{"sha256-xp", () => SHA256.Create()},
|
||||||
{"md5-xp", () => MD5.Create()},
|
{"md5-xp", () => MD5.Create()},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a Sha256 string for a given string
|
/// Returns a Sha256 string for a given string
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue