Added Additional Command Perm to Title

This commit is contained in:
Venom983 2015-10-16 02:10:51 -04:00
parent 3175cc9f5e
commit e386828167

View File

@ -40,28 +40,29 @@ namespace MCGalaxy.Commands
Player.SendMessage(p, "Cannot change the title of someone of greater rank");
return;
}
string query;
string newTitle = "";
if (message.Split(' ').Length > 1) newTitle = message.Substring(pos + 1);
else
if (who != p && (int)p.group.Permission >= CommandOtherPerms.GetPerm(this))
{
who.title = "";
who.SetPrefix();
Player.GlobalChat(who, who.color + who.name + Server.DefaultColor + " had their title removed.", false);
query = "UPDATE Players SET Title = '' WHERE Name = @Name";
Database.AddParams("@Name", who.name);
Database.executeQuery(query);
return;
}
string query;
string newTitle = "";
if (message.Split(' ').Length > 1) newTitle = message.Substring(pos + 1);
else
{
who.title = "";
who.SetPrefix();
Player.GlobalChat(who, who.color + who.name + Server.DefaultColor + " had their title removed.", false);
query = "UPDATE Players SET Title = '' WHERE Name = @Name";
Database.AddParams("@Name", who.name);
Database.executeQuery(query);
return;
}
if (newTitle != "")
{ //remove the brackets from the given title
newTitle = newTitle.ToString().Trim().Replace("[", "");
newTitle = newTitle.Replace("]", "");
}
if (newTitle != "")
{ //remove the brackets from the given title
newTitle = newTitle.ToString().Trim().Replace("[", "");
newTitle = newTitle.Replace("]", "");
}
if (newTitle.Length > 17) { Player.SendMessage(p, "Title must be under 17 letters."); return; }
if (newTitle.Length > 17) { Player.SendMessage(p, "Title must be under 17 letters."); return; }
/*string title = newTitle.ToLower();
@ -71,39 +72,44 @@ namespace MCGalaxy.Commands
}*/
if (newTitle != "")
Player.GlobalChat(who, who.color + who.name + Server.DefaultColor + " was given the title of &b[" + newTitle + "%b]", false);
else Player.GlobalChat(who, who.color + who.prefix + who.name + Server.DefaultColor + " had their title removed.", false);
if (newTitle != "")
Player.GlobalChat(who, who.color + who.name + Server.DefaultColor + " was given the title of &b[" + newTitle + "%b]", false);
else Player.GlobalChat(who, who.color + who.prefix + who.name + Server.DefaultColor + " had their title removed.", false);
if (!Regex.IsMatch(newTitle.ToLower(), @".*%([0-9]|[a-f]|[k-r])%([0-9]|[a-f]|[k-r])%([0-9]|[a-f]|[k-r])"))
{
if (Regex.IsMatch(newTitle.ToLower(), @".*%([0-9]|[a-f]|[k-r])(.+?).*"))
{
Regex rg = new Regex(@"%([0-9]|[a-f]|[k-r])(.+?)");
MatchCollection mc = rg.Matches(newTitle.ToLower());
if (mc.Count > 0)
{
Match ma = mc[0];
GroupCollection gc = ma.Groups;
newTitle.Replace("%" + gc[1].ToString().Substring(1), "&" + gc[1].ToString().Substring(1));
}
}
}
if (!Regex.IsMatch(newTitle.ToLower(), @".*%([0-9]|[a-f]|[k-r])%([0-9]|[a-f]|[k-r])%([0-9]|[a-f]|[k-r])"))
{
if (Regex.IsMatch(newTitle.ToLower(), @".*%([0-9]|[a-f]|[k-r])(.+?).*"))
{
Regex rg = new Regex(@"%([0-9]|[a-f]|[k-r])(.+?)");
MatchCollection mc = rg.Matches(newTitle.ToLower());
if (mc.Count > 0)
{
Match ma = mc[0];
GroupCollection gc = ma.Groups;
newTitle.Replace("%" + gc[1].ToString().Substring(1), "&" + gc[1].ToString().Substring(1));
}
}
}
if (newTitle == "")
{
query = "UPDATE Players SET Title = '' WHERE Name = @Name";
Database.AddParams("@Name", who.name);
if (newTitle == "")
{
query = "UPDATE Players SET Title = '' WHERE Name = @Name";
Database.AddParams("@Name", who.name);
}
else
{
query = "UPDATE Players SET Title = @Title WHERE Name = @Name";
Database.AddParams("@Title", newTitle);
Database.AddParams("@Name", who.name);
}
Database.executeQuery(query);
who.title = newTitle;
who.SetPrefix();
}
else
{
query = "UPDATE Players SET Title = @Title WHERE Name = @Name";
Database.AddParams("@Title", newTitle);
Database.AddParams("@Name", who.name);
Player.SendMessage(p, "Cannot change the title of someone else");
}
Database.executeQuery(query);
who.title = newTitle;
who.SetPrefix();
}
public override void Help(Player p)
{
@ -111,4 +117,4 @@ namespace MCGalaxy.Commands
Player.SendMessage(p, "If no [title] is given, the player's title is removed.");
}
}
}
}