mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 12:05:51 -04:00
Modularise PlayerInfo more.
This commit is contained in:
parent
535d89d14b
commit
bb5670ad5d
@ -468,10 +468,10 @@ namespace MCGalaxy {
|
||||
return matches == 1 ? match : null;
|
||||
}
|
||||
|
||||
public static PlayerBot FindOrShowMatches(Player pl, string name) {
|
||||
public static PlayerBot FindMatches(Player pl, string name) {
|
||||
int matches = 0;
|
||||
return Extensions.FindOrShowMatches(pl, name, out matches, Bots.Items, b => true,
|
||||
b => b.name, "bots");
|
||||
return Extensions.FindMatches<PlayerBot>(pl, name, out matches, Bots.Items,
|
||||
b => true, b => b.name, "bots");
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@ -34,7 +34,7 @@ namespace MCGalaxy.Commands {
|
||||
PlayerBot.RemoveAllFromLevel(p.level); return;
|
||||
}
|
||||
|
||||
PlayerBot who = PlayerBot.FindOrShowMatches(p, message);
|
||||
PlayerBot who = PlayerBot.FindMatches(p, message);
|
||||
if (who == null) return;
|
||||
if (!p.level.name.CaselessEq(who.level.name)) {
|
||||
Player.Message(p, who.name + " is in a different level."); return;
|
||||
|
@ -33,7 +33,7 @@ namespace MCGalaxy.Commands {
|
||||
public override void Use(Player p, string message) {
|
||||
if (message == "") { Help(p); return; }
|
||||
string[] args = message.Split(' ');
|
||||
PlayerBot bot = PlayerBot.FindOrShowMatches(p, args[0]);
|
||||
PlayerBot bot = PlayerBot.FindMatches(p, args[0]);
|
||||
if (bot == null) return;
|
||||
|
||||
if (args.Length == 1) {
|
||||
|
@ -30,7 +30,7 @@ namespace MCGalaxy.Commands
|
||||
if (message == "") { Help(p); return; }
|
||||
if (p == null) { MessageInGameOnly(p); return; }
|
||||
|
||||
PlayerBot who = PlayerBot.FindOrShowMatches(p, message);
|
||||
PlayerBot who = PlayerBot.FindMatches(p, message);
|
||||
if (who == null) return;
|
||||
if (!p.level.name.CaselessEq(who.level.name)) {
|
||||
Player.Message(p, who.name + " is in a different level."); return;
|
||||
|
@ -52,12 +52,12 @@ namespace MCGalaxy.Commands.CPE {
|
||||
}
|
||||
|
||||
if (isBot && args.Length > 2) {
|
||||
pBot = PlayerBot.FindOrShowMatches(p, args[1]);
|
||||
pBot = PlayerBot.FindMatches(p, args[1]);
|
||||
if (pBot == null) return;
|
||||
model = args[2];
|
||||
} else if (args.Length > 1) {
|
||||
isBot = false;
|
||||
who = PlayerInfo.FindOrShowMatches(p, args[0]);
|
||||
who = PlayerInfo.FindMatches(p, args[0]);
|
||||
if (who == null) return;
|
||||
model = args.Length >= 2 ? args[1] : "humanoid";
|
||||
} else {
|
||||
|
@ -40,12 +40,12 @@ namespace MCGalaxy.Commands.CPE {
|
||||
string skin = null;
|
||||
|
||||
if (isBot && args.Length > 2) {
|
||||
pBot = PlayerBot.FindOrShowMatches(p, args[1]);
|
||||
pBot = PlayerBot.FindMatches(p, args[1]);
|
||||
if (pBot == null) return;
|
||||
skin = args[2];
|
||||
} else if (args.Length >= 2) {
|
||||
isBot = false;
|
||||
who = PlayerInfo.FindOrShowMatches(p, args[0]);
|
||||
who = PlayerInfo.FindMatches(p, args[0]);
|
||||
if (who == null) return;
|
||||
skin = args.Length >= 2 ? args[1] : who.truename;
|
||||
} else {
|
||||
|
@ -201,7 +201,7 @@ namespace MCGalaxy.Commands {
|
||||
}
|
||||
|
||||
string name = parts[1], room = parts[2];
|
||||
Player pl = PlayerInfo.FindOrShowMatches(p, name);
|
||||
Player pl = PlayerInfo.FindMatches(p, name);
|
||||
if (pl == null) return;
|
||||
if (!Server.Chatrooms.Contains(room)) {
|
||||
Player.Message(p, "There is no chatroom with the name '" + room + "'");
|
||||
@ -230,7 +230,7 @@ namespace MCGalaxy.Commands {
|
||||
}
|
||||
|
||||
string name = parts[1];
|
||||
Player pl = PlayerInfo.FindOrShowMatches(p, name);
|
||||
Player pl = PlayerInfo.FindMatches(p, name);
|
||||
if (pl == null) return;
|
||||
if (pl.group.Permission >= p.group.Permission) {
|
||||
MessageTooHighRank(p, "kick from a chatroom", false); return;
|
||||
|
@ -39,7 +39,7 @@ namespace MCGalaxy.Commands {
|
||||
args[0] = p.name;
|
||||
}
|
||||
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, args[0]);
|
||||
Player who = PlayerInfo.FindMatches(p, args[0]);
|
||||
if (who == null) return;
|
||||
if (p != null && who.group.Permission > p.group.Permission) {
|
||||
MessageTooHighRank(p, "change the color of", true); return;
|
||||
|
@ -30,7 +30,7 @@ namespace MCGalaxy.Commands
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
if (message == "") { Help(p); return; }
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, message);
|
||||
Player who = PlayerInfo.FindMatches(p, message);
|
||||
if (who == null) return;
|
||||
if (p != null && p.muted) { Player.Message(p, "Cannot use /high5 while muted."); return; }
|
||||
|
||||
|
@ -29,7 +29,7 @@ namespace MCGalaxy.Commands {
|
||||
public override void Use(Player p, string message) {
|
||||
if (message == "") { Help(p); return; }
|
||||
string[] args = message.Split(' ');
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, args[0]);
|
||||
Player who = PlayerInfo.FindMatches(p, args[0]);
|
||||
if (who == null) return;
|
||||
if (p != null && who.name == p.name) {
|
||||
Player.Message(p, "You cannot hug yourself, silly!"); return;
|
||||
|
@ -70,7 +70,7 @@ namespace MCGalaxy.Commands {
|
||||
Player.Message(p, "&aNo longer ignoring {0}", unignore);
|
||||
} else {
|
||||
int matches = 0;
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, action);
|
||||
Player who = PlayerInfo.FindMatches(p, action);
|
||||
if (who == null) {
|
||||
if (matches == 0)
|
||||
Player.SendMessage(p, "You must use the full name when unignoring offline players.");
|
||||
|
@ -42,7 +42,7 @@ namespace MCGalaxy.Commands {
|
||||
args[0] = p.name;
|
||||
}
|
||||
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, args[0]);
|
||||
Player who = PlayerInfo.FindMatches(p, args[0]);
|
||||
if (who == null) return;
|
||||
if (p != null && who.group.Permission > p.group.Permission) {
|
||||
MessageTooHighRank(p, "change the nick of", true); return;
|
||||
|
@ -39,7 +39,7 @@ namespace MCGalaxy.Commands {
|
||||
args[0] = p.name;
|
||||
}
|
||||
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, args[0]);
|
||||
Player who = PlayerInfo.FindMatches(p, args[0]);
|
||||
if (who == null) return;
|
||||
if (p != null && who.group.Permission > p.group.Permission) {
|
||||
MessageTooHighRank(p, "change the title color of", true); return;
|
||||
|
@ -41,7 +41,7 @@ namespace MCGalaxy.Commands {
|
||||
args[0] = p.name;
|
||||
}
|
||||
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, args[0]);
|
||||
Player who = PlayerInfo.FindMatches(p, args[0]);
|
||||
if (who == null) return;
|
||||
if (p != null && who.group.Permission > p.group.Permission) {
|
||||
MessageTooHighRank(p, "change the title of", true); return;
|
||||
|
@ -36,7 +36,7 @@ namespace MCGalaxy.Commands
|
||||
}
|
||||
else
|
||||
{
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, message);
|
||||
Player who = PlayerInfo.FindMatches(p, message);
|
||||
if (who == null) { p.whisperTo = ""; p.whisper = false; return; }
|
||||
|
||||
p.whisper = true;
|
||||
|
@ -87,7 +87,7 @@ namespace MCGalaxy.Commands
|
||||
} else if (cmd == "KICK") {
|
||||
if (arg == "") { p.SendMessage("You must specify a player to kick."); return; }
|
||||
|
||||
Player pl = PlayerInfo.FindOrShowMatches(p, arg);
|
||||
Player pl = PlayerInfo.FindMatches(p, arg);
|
||||
if (pl != null) {
|
||||
if (pl.level.name == p.level.name)
|
||||
PlayerActions.ChangeMap(pl, Server.mainLevel.name);
|
||||
|
@ -33,10 +33,10 @@ namespace MCGalaxy.Commands {
|
||||
if (CheckSuper(p, message, "player name")) return;
|
||||
|
||||
int matches = 1;
|
||||
Player who = message == "" ? p : PlayerInfo.FindOrShowMatches(p, message, out matches);
|
||||
Player who = message == "" ? p : PlayerInfo.FindMatches(p, message, out matches);
|
||||
if (matches > 1) return;
|
||||
if (matches == 0) {
|
||||
OfflinePlayer off = PlayerInfo.FindOfflineOrShowMatches(p, message);
|
||||
OfflinePlayer off = PlayerInfo.FindOfflineMatches(p, message);
|
||||
if (off == null) return;
|
||||
ecos = Economy.RetrieveEcoStats(off.name);
|
||||
Player.Message(p, "%3===Economy stats for: %f" + ecos.playerName + "%7(offline)%3===");
|
||||
|
@ -30,7 +30,7 @@ namespace MCGalaxy.Commands {
|
||||
if (message == "") { Help(p); return; }
|
||||
|
||||
string[] args = message.Split(' ');
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, args[0]);
|
||||
Player who = PlayerInfo.FindMatches(p, args[0]);
|
||||
if (who == null) return;
|
||||
|
||||
int amount = 0;
|
||||
|
@ -43,13 +43,13 @@ namespace MCGalaxy.Commands
|
||||
if (amount < 0) { Player.Message(p, "Cannot give negative %3" + Server.moneys); return; }
|
||||
|
||||
int matches = 1;
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, args[0], out matches);
|
||||
Player who = PlayerInfo.FindMatches(p, args[0], out matches);
|
||||
if (matches > 1) return;
|
||||
if (p != null && p == who) { Player.Message(p, "You cannot give yourself %3" + Server.moneys); return; }
|
||||
Economy.EcoStats ecos;
|
||||
|
||||
if (who == null) {
|
||||
OfflinePlayer off = PlayerInfo.FindOfflineOrShowMatches(p, args[0]);
|
||||
OfflinePlayer off = PlayerInfo.FindOfflineMatches(p, args[0]);
|
||||
if (off == null) return;
|
||||
ecos = Economy.RetrieveEcoStats(off.name);
|
||||
if (ReachedMax(p, ecos.money, amount)) return;
|
||||
|
@ -37,14 +37,14 @@ namespace MCGalaxy.Commands
|
||||
if (amount < 0) { Player.Message(p, "Cannot pay negative %3" + Server.moneys); return; }
|
||||
|
||||
int matches = 1;
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, args[0], out matches);
|
||||
Player who = PlayerInfo.FindMatches(p, args[0], out matches);
|
||||
if (matches > 1) return;
|
||||
if (p != null && p == who) { Player.Message(p, "You cannot pay yourself %3" + Server.moneys); return; }
|
||||
string target = null;
|
||||
Economy.EcoStats payer, receiver;
|
||||
|
||||
if (who == null) {
|
||||
OfflinePlayer off = PlayerInfo.FindOfflineOrShowMatches(p, args[0]);
|
||||
OfflinePlayer off = PlayerInfo.FindOfflineMatches(p, args[0]);
|
||||
if (off == null) return;
|
||||
payer = Economy.RetrieveEcoStats(p.name);
|
||||
receiver = Economy.RetrieveEcoStats(off.name);
|
||||
|
@ -45,13 +45,13 @@ namespace MCGalaxy.Commands
|
||||
if (amount < 0) { Player.Message(p, "%cYou can't take negative %3" + Server.moneys); return; }
|
||||
|
||||
int matches = 1;
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, args[0], out matches);
|
||||
Player who = PlayerInfo.FindMatches(p, args[0], out matches);
|
||||
if (matches > 1) return;
|
||||
if (p != null && p == who) { Player.Message(p, "%cYou can't take %3" + Server.moneys + "%c from yourself"); return; }
|
||||
|
||||
Economy.EcoStats ecos;
|
||||
if (who == null) {
|
||||
OfflinePlayer off = PlayerInfo.FindOfflineOrShowMatches(p, args[0]);
|
||||
OfflinePlayer off = PlayerInfo.FindOfflineMatches(p, args[0]);
|
||||
if (off == null) return;
|
||||
ecos = Economy.RetrieveEcoStats(off.name);
|
||||
Take(all, ref ecos, ref amount);
|
||||
|
@ -201,7 +201,7 @@ namespace MCGalaxy.Commands {
|
||||
return;
|
||||
}
|
||||
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, target);
|
||||
Player who = PlayerInfo.FindMatches(p, target);
|
||||
if (who == null) return;
|
||||
if (p.group.Permission < who.group.Permission) {
|
||||
MessageTooHighRank(p, "send countdown rules", true); return;
|
||||
|
@ -106,7 +106,7 @@ namespace MCGalaxy.Commands
|
||||
if (s[1] == "map")
|
||||
{
|
||||
if (s.Length < 3) { SetupHelp(p, "map"); return; }
|
||||
Level foundLevel = LevelInfo.FindOrShowMatches(p, s[2]);
|
||||
Level foundLevel = LevelInfo.FindMatches(p, s[2]);
|
||||
if (foundLevel == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ namespace MCGalaxy.Commands {
|
||||
public override void Use(Player p, string message) {
|
||||
if (message == "") { Help(p); return; }
|
||||
int matches;
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, message, out matches);
|
||||
Player who = PlayerInfo.FindMatches(p, message, out matches);
|
||||
if (matches > 1) return;
|
||||
|
||||
if (who == null) {
|
||||
|
@ -69,7 +69,7 @@ namespace MCGalaxy.Commands {
|
||||
Player.Message(p, "The current owner of the team is: " + team.Owner); return;
|
||||
}
|
||||
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, args[1]);
|
||||
Player who = PlayerInfo.FindMatches(p, args[1]);
|
||||
if (who == null) return;
|
||||
team.Owner = who.name;
|
||||
team.Action(who, "set the team owner to " + who.ColoredName);
|
||||
@ -157,7 +157,7 @@ namespace MCGalaxy.Commands {
|
||||
if (args.Length == 1) {
|
||||
Player.Message(p, "You need to provide the name of the person to invite."); return;
|
||||
}
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, args[1]);
|
||||
Player who = PlayerInfo.FindMatches(p, args[1]);
|
||||
if (who == null) return;
|
||||
|
||||
Player.Message(p, "Invited " + who.ColoredName + " %Sto join your team.");
|
||||
|
@ -115,7 +115,7 @@ namespace MCGalaxy.Commands {
|
||||
Player.Message(p, "TNT Wars Error: There isn't a game on your current level!"); return;
|
||||
}
|
||||
} else {
|
||||
Level lvl = LevelInfo.FindOrShowMatches(p, text[1]);
|
||||
Level lvl = LevelInfo.FindMatches(p, text[1]);
|
||||
if (lvl == null) return;
|
||||
|
||||
it = TntWarsGame.Find(lvl);
|
||||
@ -230,7 +230,7 @@ namespace MCGalaxy.Commands {
|
||||
return;
|
||||
|
||||
default:
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, text[1]);
|
||||
Player who = PlayerInfo.FindMatches(p, text[1]);
|
||||
if (who == null) return;
|
||||
|
||||
Player.Message(who, "TNT Wars Rules: (sent to you by " + p.ColoredName + " %S)");
|
||||
@ -486,7 +486,7 @@ namespace MCGalaxy.Commands {
|
||||
if (text[2] == "") {
|
||||
it.lvl = p.level;
|
||||
} else {
|
||||
it.lvl = LevelInfo.FindOrShowMatches(p, text[2]);
|
||||
it.lvl = LevelInfo.FindMatches(p, text[2]);
|
||||
if (it.lvl == null) return;
|
||||
}
|
||||
Player.Message(p, "TNT Wars: Level is now '" + it.lvl.name + "'");
|
||||
|
@ -32,7 +32,7 @@ namespace MCGalaxy.Commands {
|
||||
string[] args = message.Split(' ');
|
||||
if (args.Length < 2) { Help(p); return; }
|
||||
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, args[0]);
|
||||
Player who = PlayerInfo.FindMatches(p, args[0]);
|
||||
if (who == null) return;
|
||||
byte amount = 0;
|
||||
if (!byte.TryParse(args[1], out amount)) {
|
||||
|
@ -28,7 +28,7 @@ namespace MCGalaxy.Commands {
|
||||
public CmdDisInfect() { }
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
Player who = message == "" ? p : PlayerInfo.FindOrShowMatches(p, message);
|
||||
Player who = message == "" ? p : PlayerInfo.FindMatches(p, message);
|
||||
if (who == null) return;
|
||||
|
||||
if (!who.Game.Infected || !Server.zombie.RoundInProgress) {
|
||||
|
@ -28,7 +28,7 @@ namespace MCGalaxy.Commands {
|
||||
public CmdInfect() { }
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
Player who = message == "" ? p : PlayerInfo.FindOrShowMatches(p, message);
|
||||
Player who = message == "" ? p : PlayerInfo.FindMatches(p, message);
|
||||
if (who == null) return;
|
||||
|
||||
if (who.Game.Infected || !Server.zombie.RoundInProgress) {
|
||||
|
@ -34,7 +34,7 @@ namespace MCGalaxy.Commands
|
||||
string value = args[1];
|
||||
|
||||
if (args[0].CaselessEq("zombie")) {
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, value);
|
||||
Player who = PlayerInfo.FindMatches(p, value);
|
||||
if (who == null) return;
|
||||
|
||||
Player.Message(p, value + " was queued.");
|
||||
@ -42,7 +42,7 @@ namespace MCGalaxy.Commands
|
||||
if (Server.zombie.CurLevel != null)
|
||||
Server.zombie.CurLevel.ChatLevel(who.ColoredName + " %Swas queued as the next zombie.");
|
||||
} else if (args[0].CaselessEq("level")) {
|
||||
string map = LevelInfo.FindMapOrShowMatches(p, value);
|
||||
string map = LevelInfo.FindMapMatches(p, value);
|
||||
if (map == null) return;
|
||||
|
||||
Player.Message(p, map + " was queued.");
|
||||
|
@ -70,7 +70,7 @@ namespace MCGalaxy.Commands
|
||||
}
|
||||
else
|
||||
{
|
||||
Player player = PlayerInfo.FindOrShowMatches(p, split[0]);
|
||||
Player player = PlayerInfo.FindMatches(p, split[0]);
|
||||
if (player == null) return;
|
||||
|
||||
Player.Message(player, "Changelog:");
|
||||
|
@ -36,11 +36,11 @@ namespace MCGalaxy.Commands {
|
||||
|
||||
string name = null;
|
||||
int matches = 0;
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, message, out matches);
|
||||
Player who = PlayerInfo.FindMatches(p, message, out matches);
|
||||
if (matches > 1) return;
|
||||
if (who == null) {
|
||||
Player.Message(p, "Could not find player. Searching Player DB.");
|
||||
OfflinePlayer target = PlayerInfo.FindOfflineOrShowMatches(p, message);
|
||||
OfflinePlayer target = PlayerInfo.FindOfflineMatches(p, message);
|
||||
if (target == null) return;
|
||||
message = target.ip; name = target.name;
|
||||
} else {
|
||||
|
@ -39,7 +39,7 @@ namespace MCGalaxy.Commands {
|
||||
Player who = p;
|
||||
if (message != "") {
|
||||
if (!CheckExtraPerm(p)) { MessageNeedPerms(p, "can send the FAQ to a player."); return; }
|
||||
who = PlayerInfo.FindOrShowMatches(p, message);
|
||||
who = PlayerInfo.FindMatches(p, message);
|
||||
if (who == null) return;
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ namespace MCGalaxy.Commands {
|
||||
ShowLastCommand(p, pl);
|
||||
}
|
||||
} else {
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, message);
|
||||
Player who = PlayerInfo.FindMatches(p, message);
|
||||
if (who != null)
|
||||
ShowLastCommand(p, who);
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ namespace MCGalaxy.Commands {
|
||||
if (lvl != null) {
|
||||
data.FromOnlineLevel(lvl);
|
||||
} else {
|
||||
string map = LevelInfo.FindMapOrShowMatches(p, level);
|
||||
string map = LevelInfo.FindMapMatches(p, level);
|
||||
if (map == null) return;
|
||||
Server.s.Log(map);
|
||||
data.FromOfflineLevel(map);
|
||||
|
@ -52,7 +52,7 @@ namespace MCGalaxy.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, args[0]);
|
||||
Player who = PlayerInfo.FindMatches(p, args[0]);
|
||||
if (who == null) return;
|
||||
foreach (string line in lines)
|
||||
Player.Message(who, line);
|
||||
|
@ -37,7 +37,7 @@ namespace MCGalaxy.Commands
|
||||
|
||||
Player who = p;
|
||||
if (message != "") {
|
||||
who = PlayerInfo.FindOrShowMatches(p, message);
|
||||
who = PlayerInfo.FindMatches(p, message);
|
||||
if (who == null) return;
|
||||
if (p != null && p.group.Permission < who.group.Permission) {
|
||||
MessageTooHighRank(p, "send /oprules", false); return;
|
||||
|
@ -40,7 +40,7 @@ namespace MCGalaxy.Commands
|
||||
Player who = p;
|
||||
if (message != "") {
|
||||
if (!CheckExtraPerm(p)) { MessageNeedPerms(p, "can send the rules to a player."); return; }
|
||||
who = PlayerInfo.FindOrShowMatches(p, message);
|
||||
who = PlayerInfo.FindMatches(p, message);
|
||||
if (who == null) return;
|
||||
}
|
||||
|
||||
|
@ -31,14 +31,14 @@ namespace MCGalaxy.Commands
|
||||
if (message == "") { Help(p); return; }
|
||||
|
||||
int matches;
|
||||
Player pl = PlayerInfo.FindOrShowMatches(p, message, out matches);
|
||||
Player pl = PlayerInfo.FindMatches(p, message, out matches);
|
||||
if (matches > 1) return;
|
||||
if (matches == 1) {
|
||||
Player.Message(p, pl.name + " was first seen: " + pl.firstLogin);
|
||||
Player.Message(p, pl.color + pl.name + " %Sis currently online."); return;
|
||||
}
|
||||
|
||||
OfflinePlayer target = PlayerInfo.FindOfflineOrShowMatches(p, message);
|
||||
OfflinePlayer target = PlayerInfo.FindOfflineMatches(p, message);
|
||||
if (target == null) return;
|
||||
Player.Message(p, message + " was first seen: " + target.firstLogin);
|
||||
Player.Message(p, message + " was last seen: " + target.lastLogin);
|
||||
|
@ -29,7 +29,7 @@ namespace MCGalaxy.Commands {
|
||||
public override void Use(Player p, string message) {
|
||||
if (message == "") message = p.name;
|
||||
int matches;
|
||||
Player pl = PlayerInfo.FindOrShowMatches(p, message, out matches);
|
||||
Player pl = PlayerInfo.FindMatches(p, message, out matches);
|
||||
if (pl == null) return;
|
||||
if (pl.level.CurrentGame() != null && !(p == null || p.Game.Referee)) {
|
||||
Player.Message(p, "You can only use /where on people in games when you are in referee mode."); return;
|
||||
|
@ -37,7 +37,7 @@ namespace MCGalaxy.Commands {
|
||||
public override void Use(Player p, string message) {
|
||||
if (message == "") message = p.name;
|
||||
int matches;
|
||||
Player pl = PlayerInfo.FindOrShowMatches(p, message, out matches);
|
||||
Player pl = PlayerInfo.FindMatches(p, message, out matches);
|
||||
if (matches > 1) return;
|
||||
|
||||
WhoInfo info;
|
||||
@ -48,7 +48,7 @@ namespace MCGalaxy.Commands {
|
||||
Player.Message(p, "\"" + message + "\" is not a valid player name."); return;
|
||||
}
|
||||
Player.Message(p, "Searching database for the player..");
|
||||
OfflinePlayer target = PlayerInfo.FindOfflineOrShowMatches(p, message);
|
||||
OfflinePlayer target = PlayerInfo.FindOfflineMatches(p, message);
|
||||
if (target == null) return;
|
||||
info = FromOffline(target, message);
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ namespace MCGalaxy.Commands {
|
||||
if (CheckSuper(p, message, "level name")) return;
|
||||
Level lvl = p.level;
|
||||
if (message != "") {
|
||||
lvl = LevelInfo.FindOrShowMatches(p, message);
|
||||
lvl = LevelInfo.FindMatches(p, message);
|
||||
if (lvl == null) return;
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ namespace MCGalaxy.Commands.Moderation {
|
||||
Player who = PlayerInfo.Find(message);
|
||||
|
||||
if (who == null) {
|
||||
OfflinePlayer target = PlayerInfo.FindOfflineOrShowMatches(p, message);
|
||||
OfflinePlayer target = PlayerInfo.FindOfflineMatches(p, message);
|
||||
if (target == null) return;
|
||||
message = target.ip;
|
||||
} else {
|
||||
|
@ -37,7 +37,7 @@ namespace MCGalaxy.Commands
|
||||
|
||||
ushort x, y, z;
|
||||
if (args.Length == 1) {
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, args[0]);
|
||||
Player who = PlayerInfo.FindMatches(p, args[0]);
|
||||
if (who == null) return;
|
||||
if (who.level.physics < 3 || who.level.physics == 5) {
|
||||
Player.Message(p, "The physics on the player's level are not sufficient for exploding."); return;
|
||||
|
@ -28,7 +28,7 @@ namespace MCGalaxy.Commands
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
if (message == "") { Help(p); return; }
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, message);
|
||||
Player who = PlayerInfo.FindMatches(p, message);
|
||||
if (who == null) return;
|
||||
if (p == who) { Player.Message(p, "Cannot freeze yourself."); return; }
|
||||
if (p != null && who.group.Permission >= p.group.Permission) {
|
||||
|
@ -35,7 +35,7 @@ namespace MCGalaxy.Commands
|
||||
Player.Message(p, "Set Jail point.");
|
||||
return;
|
||||
}
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, message);
|
||||
Player who = PlayerInfo.FindMatches(p, message);
|
||||
if (who == null) return;
|
||||
|
||||
if (!who.jailed) {
|
||||
|
@ -35,7 +35,7 @@ namespace MCGalaxy.Commands {
|
||||
Server.s.Log("Stealth joker attempted");
|
||||
}
|
||||
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, message);
|
||||
Player who = PlayerInfo.FindMatches(p, message);
|
||||
if (who == null) return;
|
||||
if (p != null && who.group.Permission > p.group.Permission) {
|
||||
MessageTooHighRank(p, "joker", true); return;
|
||||
|
@ -32,7 +32,7 @@ namespace MCGalaxy.Commands {
|
||||
if (message == "") { Help(p); return; }
|
||||
string[] args = message.Split(trimChars, 2);
|
||||
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, args[0]);
|
||||
Player who = PlayerInfo.FindMatches(p, args[0]);
|
||||
if (who == null) return;
|
||||
if (args.Length > 1) message = args[1];
|
||||
else if (p == null) message = "You were kicked by the console.";
|
||||
|
@ -37,7 +37,7 @@ namespace MCGalaxy.Commands {
|
||||
Player who = PlayerInfo.Find(message);
|
||||
if (who == null) {
|
||||
Player.Message(p, "&eNo online player \"" + message + "\", searching database..");
|
||||
OfflinePlayer target = PlayerInfo.FindOfflineOrShowMatches(p, message);
|
||||
OfflinePlayer target = PlayerInfo.FindOfflineMatches(p, message);
|
||||
if (target == null) return;
|
||||
ip = target.ip;
|
||||
} else {
|
||||
|
@ -24,7 +24,7 @@ namespace MCGalaxy.Commands {
|
||||
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
Level level = LevelInfo.FindOrShowMatches(p, message);
|
||||
Level level = LevelInfo.FindMatches(p, message);
|
||||
if (level == null) return;
|
||||
|
||||
Player[] players = PlayerInfo.Online.Items;
|
||||
|
@ -29,7 +29,7 @@ namespace MCGalaxy.Commands.Moderation {
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
if (message == "" || message.Split(' ').Length > 2) { Help(p); return; }
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, message);
|
||||
Player who = PlayerInfo.FindMatches(p, message);
|
||||
if (who == null) {
|
||||
if (Server.muted.Contains(message)) {
|
||||
Server.muted.Remove(message);
|
||||
|
@ -35,7 +35,7 @@ namespace MCGalaxy.Commands {
|
||||
if (message == "") message = p.name;
|
||||
|
||||
int matches = 1;
|
||||
Player who = message == "" ? p : PlayerInfo.FindOrShowMatches(p, message, out matches);
|
||||
Player who = message == "" ? p : PlayerInfo.FindMatches(p, message, out matches);
|
||||
if (matches > 1) return;
|
||||
if (who != null) message = who.name;
|
||||
|
||||
|
@ -31,7 +31,7 @@ namespace MCGalaxy.Commands
|
||||
if (message == "") { Help(p); return; }
|
||||
|
||||
string[] args = message.Split(' ');
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, args[0]);
|
||||
Player who = PlayerInfo.FindMatches(p, args[0]);
|
||||
if (who == null) return;
|
||||
if (who.group.Permission >= p.group.Permission) {
|
||||
MessageTooHighRank(p, "hide", false); return;
|
||||
|
@ -32,8 +32,8 @@ namespace MCGalaxy.Commands {
|
||||
string[] args = message.Split(' ');
|
||||
if (args.Length > 2) { Help(p); return; }
|
||||
if (args.Length == 1) { Player.Message(p, "You did not specify the target player."); return; }
|
||||
Player source = PlayerInfo.FindOrShowMatches(p, args[0]);
|
||||
Player target = PlayerInfo.FindOrShowMatches(p, args[1]);
|
||||
Player source = PlayerInfo.FindMatches(p, args[0]);
|
||||
Player target = PlayerInfo.FindMatches(p, args[1]);
|
||||
|
||||
if (source == null || target == null) return;
|
||||
if (p.group.Permission < source.group.Permission) {
|
||||
|
@ -54,7 +54,7 @@ namespace MCGalaxy.Commands {
|
||||
Command.all.Find("hide").Use(p, "");
|
||||
Player.Message(p, "Stopped possessing " + who.color + who.name + "%S.");
|
||||
} else {
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, message);
|
||||
Player who = PlayerInfo.FindMatches(p, message);
|
||||
if (who == null) return;
|
||||
if (who.group.Permission >= p.group.Permission) {
|
||||
MessageTooHighRank(p, "possess", false); return;
|
||||
|
@ -29,7 +29,7 @@ namespace MCGalaxy.Commands
|
||||
public override void Use(Player p, string message) {
|
||||
if (message == "" || message.IndexOf(' ') != -1) { Help(p); return; }
|
||||
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, message);
|
||||
Player who = PlayerInfo.FindMatches(p, message);
|
||||
if (who == null) return;
|
||||
who.ignoreGrief = !who.ignoreGrief;
|
||||
Player.Message(p, who.ColoredName + "%S's trust status: " + who.ignoreGrief);
|
||||
|
@ -26,7 +26,7 @@ namespace MCGalaxy.Commands {
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
if (message == "" && p == null) { Help(p); return; }
|
||||
Player who = message == "" ? p : PlayerInfo.FindOrShowMatches(p, message);
|
||||
Player who = message == "" ? p : PlayerInfo.FindMatches(p, message);
|
||||
if (who == null) return;
|
||||
if (p != null && who.group.Permission > p.group.Permission) {
|
||||
MessageTooHighRank(p, "voice", true); return;
|
||||
|
@ -34,7 +34,7 @@ namespace MCGalaxy.Commands
|
||||
|
||||
if (Server.voteKickInProgress) { Player.Message(p, "Please wait for the current vote to finish!"); return; }
|
||||
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, message);
|
||||
Player who = PlayerInfo.FindMatches(p, message);
|
||||
if (who == null) return;
|
||||
|
||||
if (who.group.Permission >= p.group.Permission) {
|
||||
|
@ -27,15 +27,15 @@ namespace MCGalaxy.Commands.Moderation {
|
||||
public override void Use(Player p, string message) {
|
||||
if (message == "") { Help(p); return; }
|
||||
string[] args = message.Split(trimChars, 2);
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, args[0]);
|
||||
Player who = PlayerInfo.FindMatches(p, args[0]);
|
||||
string reason = args.Length == 1 ? "you know why." : args[1];
|
||||
|
||||
if (who == null) return;
|
||||
if (who == p) { Player.Message(p, "you can't warn yourself"); return; }
|
||||
if (p != null && p.group.Permission <= who.group.Permission) {
|
||||
MessageTooHighRank(p, "warn", false); return;
|
||||
}
|
||||
}
|
||||
|
||||
string reason = args.Length == 1 ? "you know why." : args[1];
|
||||
string warnedby = (p == null) ? "(console)" : p.ColoredName;
|
||||
Player.GlobalMessage(warnedby + " %ewarned " + who.ColoredName + " %ebecause:");
|
||||
Player.GlobalMessage("&c" + reason);
|
||||
@ -56,6 +56,13 @@ namespace MCGalaxy.Commands.Moderation {
|
||||
else Player.AddNote(who.name, p, "W", args[1]);
|
||||
}
|
||||
|
||||
static void WarnOffline(Player p, string[] args) {
|
||||
if (!Server.LogNotes) {
|
||||
Player.Message(p, "Notes logging must be enabled to warn offline players."); return;
|
||||
}
|
||||
Player.SendMessage(p, "Searching PlayerDB..");
|
||||
}
|
||||
|
||||
public override void Help(Player p) {
|
||||
Player.Message(p, "/warn <player> <reason> - Warns a player.");
|
||||
Player.Message(p, "Player will get kicked after 3 warnings.");
|
||||
|
@ -35,7 +35,7 @@ namespace MCGalaxy.Commands {
|
||||
}
|
||||
|
||||
string[] args = message.Split(' ');
|
||||
Player muter = PlayerInfo.FindOrShowMatches(p, args[0]);
|
||||
Player muter = PlayerInfo.FindMatches(p, args[0]);
|
||||
if (muter == null) return;
|
||||
|
||||
if (p != null && muter.group.Permission > p.group.Permission) {
|
||||
|
@ -36,7 +36,7 @@ namespace MCGalaxy.Commands.World {
|
||||
|
||||
Level lvl = p == null ? null : p.level;
|
||||
if (args.Length > 1) {
|
||||
lvl = LevelInfo.FindOrShowMatches(p, args[1]);
|
||||
lvl = LevelInfo.FindMatches(p, args[1]);
|
||||
if (lvl == null) return;
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ namespace MCGalaxy.Commands.World {
|
||||
if (!p.group.CanExecute("newlvl")) {
|
||||
Player.Message(p, "You cannot use /copylvl as you cannot use /newlvl."); return;
|
||||
}
|
||||
src = LevelInfo.FindMapOrShowMatches(p, src);
|
||||
src = LevelInfo.FindMapMatches(p, src);
|
||||
if (src == null) return;
|
||||
if (!Player.ValidName(dst)) { Player.Message(p, "\"" + dst + "\" is not a valid level name."); return; }
|
||||
if (LevelInfo.ExistsOffline(dst)) { Player.Message(p, "The level \"" + dst + "\" already exists."); return; }
|
||||
|
@ -41,7 +41,7 @@ namespace MCGalaxy.Commands.World {
|
||||
if (!Player.ValidName(message)) { Player.Message(p, "\"" + message + "\" is not a valid level name."); return; }
|
||||
if (lvl == Server.mainLevel) { Player.Message(p, "Cannot delete the main level."); return; }
|
||||
|
||||
string map = LevelInfo.FindMapOrShowMatches(p, message);
|
||||
string map = LevelInfo.FindMapMatches(p, message);
|
||||
if (map == null) return;
|
||||
LevelPermission perbuild = GetPerBuildPermission(map);
|
||||
if (p != null && perbuild > p.group.Permission) {
|
||||
|
@ -69,7 +69,7 @@ namespace MCGalaxy.Commands.World {
|
||||
lvl = LevelInfo.Find(message);
|
||||
if (lvl != null) return GoToLevel(p, lvl, message);
|
||||
|
||||
string map = LevelInfo.FindMapOrShowMatches(p, message);
|
||||
string map = LevelInfo.FindMapMatches(p, message);
|
||||
if (map == null) return false;
|
||||
return GotoOfflineLevel(p, map);
|
||||
} else {
|
||||
|
@ -54,7 +54,7 @@ namespace MCGalaxy.Commands {
|
||||
Chat.GlobalMessageOps("Unlocked by: " + ((p == null) ? "Console" : p.name));
|
||||
}
|
||||
} else {
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, args[1]);
|
||||
Player who = PlayerInfo.FindMatches(p, args[1]);
|
||||
if (who == null) return;
|
||||
|
||||
if (!who.jailed) {
|
||||
|
@ -40,7 +40,7 @@ namespace MCGalaxy.Commands.World {
|
||||
Player.Message(p, "\"{0}\" is not a valid level name.", message); return;
|
||||
}
|
||||
|
||||
string map = LevelInfo.FindMapOrShowMatches(p, message);
|
||||
string map = LevelInfo.FindMapMatches(p, message);
|
||||
if (map == null) return;
|
||||
|
||||
Server.level = map;
|
||||
|
@ -35,14 +35,14 @@ namespace MCGalaxy.Commands
|
||||
if (parts.Length == 1) {
|
||||
if (!int.TryParse(parts[0], out seconds)) {
|
||||
seconds = 30;
|
||||
lvl = LevelInfo.FindOrShowMatches(p, parts[0]);
|
||||
lvl = LevelInfo.FindMatches(p, parts[0]);
|
||||
if (lvl == null) return;
|
||||
}
|
||||
} else {
|
||||
if (!int.TryParse(parts[0], out seconds)) {
|
||||
Player.Message(p, "You must specify pause time in seconds"); return;
|
||||
}
|
||||
lvl = LevelInfo.FindOrShowMatches(p, parts[1]);
|
||||
lvl = LevelInfo.FindMatches(p, parts[1]);
|
||||
if (lvl == null) return;
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ namespace MCGalaxy.Commands {
|
||||
}
|
||||
|
||||
if (args.Length == 2) {
|
||||
level = LevelInfo.FindOrShowMatches(p, args[0]);
|
||||
level = LevelInfo.FindMatches(p, args[0]);
|
||||
if (level == null) return;
|
||||
}
|
||||
SetPhysics(level, state);
|
||||
|
@ -31,7 +31,7 @@ namespace MCGalaxy.Commands.World {
|
||||
public override void Use(Player p, string message) {
|
||||
if (message == "" || message.IndexOf(' ') == -1) { Help(p); return; }
|
||||
string[] args = message.Split(' ');
|
||||
Level lvl = LevelInfo.FindOrShowMatches(p, args[0]);
|
||||
Level lvl = LevelInfo.FindMatches(p, args[0]);
|
||||
if (lvl == null) return;
|
||||
string newName = args[1];
|
||||
if (!Player.ValidName(newName)) {
|
||||
|
@ -34,7 +34,7 @@ namespace MCGalaxy.Commands {
|
||||
Level lvl;
|
||||
string[] args = message.Split(' ');
|
||||
if (args.Length >= 2) {
|
||||
lvl = LevelInfo.FindOrShowMatches(p, args[1]);
|
||||
lvl = LevelInfo.FindMatches(p, args[1]);
|
||||
if (lvl == null) return;
|
||||
} else {
|
||||
if (p != null && p.level != null) {
|
||||
|
@ -52,7 +52,7 @@ namespace MCGalaxy.Commands {
|
||||
ReloadMap(p, who, true);
|
||||
}
|
||||
} else {
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, parts[0]);
|
||||
Player who = PlayerInfo.FindMatches(p, parts[0]);
|
||||
if (who == null) {
|
||||
return;
|
||||
} else if (who.group.Permission > p.group.Permission && p != who) {
|
||||
|
@ -28,7 +28,7 @@ namespace MCGalaxy.Commands
|
||||
public override void Use(Player p, string message) {
|
||||
string[] args = message.Split(' ');
|
||||
if (message == "" || args.Length < 2) { Help(p); return; }
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, args[0]);
|
||||
Player who = PlayerInfo.FindMatches(p, args[0]);
|
||||
Group grp = Group.FindOrShowMatches(p, args[1]);
|
||||
if (who == null || grp == null) return;
|
||||
|
||||
|
@ -29,7 +29,7 @@ namespace MCGalaxy.Commands {
|
||||
public override void Use(Player p, string message) {
|
||||
if (!message.Contains(" ")) { Help(p); return; }
|
||||
string[] args = message.Split(trimChars, 2);
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, args[0]);
|
||||
Player who = PlayerInfo.FindMatches(p, args[0]);
|
||||
if (who == null || message == "") {Help(p); return; }
|
||||
if (who.muted) { Player.Message(p, "Cannot impersonate a muted player"); return; }
|
||||
|
||||
|
@ -26,7 +26,7 @@ namespace MCGalaxy.Commands {
|
||||
public CmdInvincible() { }
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
Player who = message == "" ? p : PlayerInfo.FindOrShowMatches(p, message);
|
||||
Player who = message == "" ? p : PlayerInfo.FindMatches(p, message);
|
||||
if (who == null) return;
|
||||
|
||||
if (p != null && who.group.Permission > p.group.Permission) {
|
||||
|
@ -34,7 +34,7 @@ namespace MCGalaxy.Commands
|
||||
string killer = p == null ? "(console)" : p.ColoredName;
|
||||
string[] args = message.Split(trimChars, 2);
|
||||
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, args[0]);
|
||||
Player who = PlayerInfo.FindMatches(p, args[0]);
|
||||
if (args.Length >= 2) {
|
||||
if(args[1].ToLower() == "explode") {
|
||||
deathMessage = " was exploded by " + killer;
|
||||
|
@ -44,8 +44,8 @@ namespace MCGalaxy.Commands
|
||||
}
|
||||
|
||||
if (args.Length == 2) { // /move name map
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, args[0]);
|
||||
Level where = LevelInfo.FindOrShowMatches(p, args[1]);
|
||||
Player who = PlayerInfo.FindMatches(p, args[0]);
|
||||
Level where = LevelInfo.FindMatches(p, args[1]);
|
||||
if (who == null || where == null) return;
|
||||
if (p != null && who.group.Permission > p.group.Permission) {
|
||||
MessageTooHighRank(p, "move", true); return;
|
||||
@ -63,7 +63,7 @@ namespace MCGalaxy.Commands
|
||||
Player who;
|
||||
int offset = 0;
|
||||
if (args.Length == 4) {
|
||||
who = PlayerInfo.FindOrShowMatches(p, args[0]);
|
||||
who = PlayerInfo.FindMatches(p, args[0]);
|
||||
if (who == null) return;
|
||||
if (p != null && who.group.Permission > p.group.Permission) {
|
||||
MessageTooHighRank(p, "move", true); return;
|
||||
|
@ -34,7 +34,7 @@ namespace MCGalaxy.Commands {
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
if (message == "") { Help(p); return; }
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, message);
|
||||
Player who = PlayerInfo.FindMatches(p, message);
|
||||
if (who == null) return;
|
||||
|
||||
if (p != null && (Server.server_owner == "Notch" || Server.server_owner == "")) {
|
||||
|
@ -30,7 +30,7 @@ namespace MCGalaxy.Commands {
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
string[] parts = message.Split(trimChars, 3);
|
||||
Player target = PlayerInfo.FindOrShowMatches(p, parts[0]);
|
||||
Player target = PlayerInfo.FindMatches(p, parts[0]);
|
||||
if (target == null) return;
|
||||
if (p != null && p.group.Permission < target.group.Permission) {
|
||||
MessageTooHighRank(p, "send commands for", true); return;
|
||||
|
@ -48,7 +48,7 @@ namespace MCGalaxy.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, message);
|
||||
Player who = PlayerInfo.FindMatches(p, message);
|
||||
if (who == null) return;
|
||||
if (p.group.Permission < who.group.Permission) {
|
||||
MessageTooHighRank(p, "summon", true); return;
|
||||
|
@ -31,7 +31,7 @@ namespace MCGalaxy.Commands {
|
||||
string[] args = message.Split(' ');
|
||||
if (args.Length > 1) { Help(p); return; }
|
||||
|
||||
Player target = PlayerInfo.FindOrShowMatches(p, message);
|
||||
Player target = PlayerInfo.FindMatches(p, message);
|
||||
if (target == null) return;
|
||||
if (target.level.IsMuseum) {
|
||||
Player.Message(p, "Player \"" + message + "\" is in a museum!"); return;
|
||||
|
@ -19,7 +19,7 @@ namespace MCGalaxy.Commands {
|
||||
int number = message.Split(' ').Length;
|
||||
if (number > 1) { Help(p); return; }
|
||||
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, message);
|
||||
Player who = PlayerInfo.FindMatches(p, message);
|
||||
if (who == p) { Player.Message(p, "&cError:%S You cannot send yourself a request!"); return; }
|
||||
if (who == null) return;
|
||||
if (who.listignored.Contains(p.name))
|
||||
|
@ -46,7 +46,7 @@ namespace MCGalaxy.Commands {
|
||||
Player who = p;
|
||||
string[] args = message.Split(' ');
|
||||
if (args.Length > 1) {
|
||||
who = PlayerInfo.FindOrShowMatches(p, args[1]);
|
||||
who = PlayerInfo.FindMatches(p, args[1]);
|
||||
if (who == null) return;
|
||||
}
|
||||
args[0] = Path.GetFileName(args[0]);
|
||||
|
@ -43,7 +43,7 @@ namespace MCGalaxy.Commands {
|
||||
return;
|
||||
}
|
||||
|
||||
Player pl = PlayerInfo.FindOrShowMatches(p, message);
|
||||
Player pl = PlayerInfo.FindMatches(p, message);
|
||||
if (pl == null) return;
|
||||
|
||||
Command spawn = Command.all.Find("spawn");
|
||||
|
@ -64,7 +64,7 @@ namespace MCGalaxy.Eco {
|
||||
if (Server.zombie.QueuedLevel != null) {
|
||||
Player.Message(p, "Someone else has already queued a level."); return;
|
||||
}
|
||||
string map = LevelInfo.FindMapOrShowMatches(p, message);
|
||||
string map = LevelInfo.FindMapMatches(p, message);
|
||||
if (map == null) return;
|
||||
|
||||
Command.all.Find("queue").Use(p, "level " + map);
|
||||
|
@ -41,28 +41,28 @@ namespace MCGalaxy {
|
||||
return matches == 1 ? match : null;
|
||||
}
|
||||
|
||||
public static Level FindOrShowMatches(Player pl, string name) {
|
||||
int matches = 0; return FindOrShowMatches(pl, name, out matches);
|
||||
public static Level FindMatches(Player pl, string name) {
|
||||
int matches = 0; return FindMatches(pl, name, out matches);
|
||||
}
|
||||
|
||||
public static Level FindOrShowMatches(Player pl, string name, out int matches) {
|
||||
return Extensions.FindOrShowMatches(pl, name, out matches, LevelInfo.Loaded.Items,
|
||||
l => true, l => l.name, "loaded levels");
|
||||
public static Level FindMatches(Player pl, string name, out int matches) {
|
||||
return Extensions.FindMatches<Level>(pl, name, out matches, LevelInfo.Loaded.Items,
|
||||
l => true, l => l.name, "loaded levels");
|
||||
}
|
||||
|
||||
public static string FindMapOrShowMatches(Player pl, string name) {
|
||||
int matches = 0; return FindMapOrShowMatches(pl, name, out matches);
|
||||
public static string FindMapMatches(Player pl, string name) {
|
||||
int matches = 0; return FindMapMatches(pl, name, out matches);
|
||||
}
|
||||
|
||||
public static string FindMapOrShowMatches(Player pl, string name, out int matches) {
|
||||
public static string FindMapMatches(Player pl, string name, out int matches) {
|
||||
matches = 0;
|
||||
if (!Player.ValidName(name)) {
|
||||
Player.Message(pl, "\"{0}\" is not a valid level name.", name); return null;
|
||||
}
|
||||
|
||||
var files = Directory.EnumerateFiles("levels", "*.lvl");
|
||||
string map = Extensions.FindOrShowMatches(pl, name, out matches, files,
|
||||
l => true, l => Path.GetFileNameWithoutExtension(l), "levels");
|
||||
string map = Extensions.FindMatches<string>(pl, name, out matches, files,
|
||||
l => true, l => Path.GetFileNameWithoutExtension(l), "levels");
|
||||
if (map != null)
|
||||
map = Path.GetFileNameWithoutExtension(map);
|
||||
return map;
|
||||
|
@ -225,7 +225,7 @@ namespace MCGalaxy {
|
||||
}
|
||||
|
||||
static void HandleWhisper(Player p, string target, string message) {
|
||||
Player who = PlayerInfo.FindOrShowMatches(p, target);
|
||||
Player who = PlayerInfo.FindMatches(p, target);
|
||||
if (who == null) return;
|
||||
if (who == p) { Player.Message(p, "Trying to talk to yourself, huh?"); return; }
|
||||
|
||||
|
@ -166,15 +166,16 @@ namespace MCGalaxy
|
||||
}
|
||||
|
||||
/// <summary> Find the group(s) which contain the given name. </summary>
|
||||
public static Group FindOrShowMatches(Player p, string name, out int matches) {
|
||||
public static Group FindMatches(Player p, string name, out int matches) {
|
||||
name = name.ToLower();
|
||||
MapName(ref name);
|
||||
return Extensions.FindOrShowMatches(p, name, out matches, GroupList, g => true, g => g.name, "ranks");
|
||||
return Extensions.FindMatches<Group>(p, name, out matches,
|
||||
GroupList, g => true, g => g.name, "ranks");
|
||||
}
|
||||
|
||||
/// <summary> Find the group(s) which contain the given name. </summary>
|
||||
public static Group FindOrShowMatches(Player p, string name) {
|
||||
int matches = 0; return FindOrShowMatches(p, name, out matches);
|
||||
int matches = 0; return FindMatches(p, name, out matches);
|
||||
}
|
||||
|
||||
static void MapName(ref string name) {
|
||||
|
@ -11,7 +11,7 @@ software distributed under the Licenses are distributed on an "AS IS"
|
||||
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
or implied. See the Licenses for the specific language governing
|
||||
permissions and limitations under the Licenses.
|
||||
*/
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
@ -48,19 +48,19 @@ namespace MCGalaxy {
|
||||
return matches == 1 ? match : null;
|
||||
}
|
||||
|
||||
public static Player FindOrShowMatches(Player pl, string name, bool onlyCanSee = true) {
|
||||
int matches = 0; return FindOrShowMatches(pl, name, out matches, onlyCanSee);
|
||||
public static Player FindMatches(Player pl, string name, bool onlyCanSee = true) {
|
||||
int matches = 0; return FindMatches(pl, name, out matches, onlyCanSee);
|
||||
}
|
||||
|
||||
public static Player FindOrShowMatches(Player pl, string name, out int matches, bool onlyCanSee = true) {
|
||||
public static Player FindMatches(Player pl, string name, out int matches, bool onlyCanSee = true) {
|
||||
matches = 0;
|
||||
if (!Player.ValidName(name)) {
|
||||
Player.Message(pl, "\"{0}\" is not a valid player name.", name); return null;
|
||||
}
|
||||
|
||||
return Extensions.FindOrShowMatches(pl, name, out matches, Online.Items,
|
||||
p => Entities.CanSee(pl, p) || !onlyCanSee,
|
||||
p => p.name, "online players");
|
||||
return Extensions.FindMatches<Player>(pl, name, out matches, Online.Items,
|
||||
p => Entities.CanSee(pl, p) || !onlyCanSee,
|
||||
p => p.name, "online players");
|
||||
}
|
||||
|
||||
public static Player FindExact(string name) {
|
||||
@ -106,7 +106,7 @@ namespace MCGalaxy {
|
||||
|
||||
const string query = "INSERT INTO Players (Name, IP, FirstLogin, LastLogin, totalLogin, Title, totalDeaths, Money, totalBlocks, totalKicked, TimeSpent) " +
|
||||
"VALUES ('{0}', '{1}', '{2:yyyy-MM-dd HH:mm:ss}', '{3:yyyy-MM-dd HH:mm:ss}', {4}, '{5}', {6}, {7}, {8}, {9}, '{10}')";
|
||||
Database.executeQuery(String.Format(query, p.name, p.ip, p.firstLogin, DateTime.Now, p.totalLogins,
|
||||
Database.executeQuery(String.Format(query, p.name, p.ip, p.firstLogin, DateTime.Now, p.totalLogins,
|
||||
p.title, p.overallDeath, p.money, p.loginBlocks, p.totalKicked, p.time.ToDBTime()));
|
||||
string ecoQuery = "INSERT INTO Economy (player, money, total, purchase, payment, salary, fine) VALUES ('" + p.name + "', " + p.money + ", 0, '%cNone', '%cNone', '%cNone', '%cNone')";
|
||||
Database.executeQuery(ecoQuery);
|
||||
@ -165,7 +165,7 @@ namespace MCGalaxy {
|
||||
}
|
||||
}
|
||||
|
||||
public static List<string> FindAccounts(string ip) {
|
||||
public static List<string> FindAccounts(string ip) {
|
||||
ParameterisedQuery query = ParameterisedQuery.Create();
|
||||
query.AddParam("@IP", ip);
|
||||
DataTable clones = Database.fillData(query, "SELECT Name FROM Players WHERE IP=@IP");
|
||||
@ -179,42 +179,42 @@ namespace MCGalaxy {
|
||||
clones.Dispose();
|
||||
return alts;
|
||||
}
|
||||
|
||||
public static string FindOfflineNameMatches(Player p, string name) {
|
||||
using (DataTable results = QueryMulti(name, "Name")) {
|
||||
int matches = 0;
|
||||
DataRow row = Extensions.FindMatches<DataRow>(p, name, out matches, results.Rows,
|
||||
r => true, r => r["Name"].ToString(), "players", 20);
|
||||
return row == null ? null : row["Name"].ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public static OfflinePlayer FindOfflineMatches(Player p, string name) {
|
||||
using (DataTable results = QueryMulti(name, "*")) {
|
||||
int matches = 0;
|
||||
DataRow row = Extensions.FindMatches<DataRow>(p, name, out matches, results.Rows,
|
||||
r => true, r => r["Name"].ToString(), "players", 20);
|
||||
return row == null ? null : FillInfo(row, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static DataTable Query(string name, string selector) {
|
||||
ParameterisedQuery query = ParameterisedQuery.Create();
|
||||
query.AddParam("@Name", name);
|
||||
string syntax = Server.useMySQL ?
|
||||
string syntax = Server.useMySQL ?
|
||||
"SELECT " + selector + " FROM Players WHERE Name=@Name COLLATE utf8_general_ci" :
|
||||
"SELECT " + selector + " FROM Players WHERE Name=@Name COLLATE NOCASE";
|
||||
return Database.fillData(query, syntax);
|
||||
}
|
||||
|
||||
public static OfflinePlayer FindOfflineOrShowMatches(Player p, string name) {
|
||||
static DataTable QueryMulti(string name, string selector) {
|
||||
ParameterisedQuery query = ParameterisedQuery.Create();
|
||||
query.AddParam("@Name", "%" + name + "%");
|
||||
string syntax = Server.useMySQL ?
|
||||
"SELECT * FROM Players WHERE Name LIKE @Name LIMIT 20" :
|
||||
"SELECT * FROM Players WHERE Name LIKE @Name LIMIT 20 COLLATE NOCASE";
|
||||
|
||||
using (DataTable results = Database.fillData(query, syntax)) {
|
||||
if (results.Rows.Count == 0) {
|
||||
Player.Message(p, "No players found matching \"{0}\".", name); return null;
|
||||
}
|
||||
if (results.Rows.Count == 1)
|
||||
return FillInfo(results.Rows[0], true);
|
||||
List<string> matches = new List<string>();
|
||||
|
||||
foreach (DataRow row in results.Rows) {
|
||||
string entry = row["Name"].ToString().Trim();
|
||||
if (entry.CaselessEq(name)) return FillInfo(row, true);
|
||||
matches.Add(entry);
|
||||
}
|
||||
string count = matches.Count == 20 ? "20+" : matches.Count.ToString();
|
||||
Player.Message(p, "{0} players found matching \"{1}\": {2}",
|
||||
count, name, String.Join(", ", matches));
|
||||
return null;
|
||||
}
|
||||
string syntax = Server.useMySQL ?
|
||||
"SELECT " + selector + " FROM Players WHERE Name LIKE @Name LIMIT 21" :
|
||||
"SELECT " + selector + " FROM Players WHERE Name LIKE @Name LIMIT 21 COLLATE NOCASE";
|
||||
return Database.fillData(query, syntax);
|
||||
}
|
||||
|
||||
static OfflinePlayer FillInfo(DataRow row, bool fullStats) {
|
||||
|
@ -1,23 +1,24 @@
|
||||
/*
|
||||
Copyright 2011 MCForge
|
||||
|
||||
Author: fenderrock87
|
||||
|
||||
Dual-licensed under the Educational Community License, Version 2.0 and
|
||||
the GNU General Public License, Version 3 (the "Licenses"); you may
|
||||
not use this file except in compliance with the Licenses. You may
|
||||
obtain a copy of the Licenses at
|
||||
|
||||
http://www.opensource.org/licenses/ecl2.php
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the Licenses are distributed on an "AS IS"
|
||||
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
or implied. See the Licenses for the specific language governing
|
||||
permissions and limitations under the Licenses.
|
||||
*/
|
||||
Copyright 2011 MCForge
|
||||
|
||||
Author: fenderrock87
|
||||
|
||||
Dual-licensed under the Educational Community License, Version 2.0 and
|
||||
the GNU General Public License, Version 3 (the "Licenses"); you may
|
||||
not use this file except in compliance with the Licenses. You may
|
||||
obtain a copy of the Licenses at
|
||||
|
||||
http://www.opensource.org/licenses/ecl2.php
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the Licenses are distributed on an "AS IS"
|
||||
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
or implied. See the Licenses for the specific language governing
|
||||
permissions and limitations under the Licenses.
|
||||
*/
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
@ -25,15 +26,15 @@ using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MCGalaxy {
|
||||
|
||||
|
||||
public static class Extensions {
|
||||
|
||||
|
||||
public static string Truncate(this string source, int maxLength) {
|
||||
if (source.Length > maxLength)
|
||||
source = source.Substring(0, maxLength);
|
||||
return source;
|
||||
}
|
||||
|
||||
|
||||
public static byte[] GZip(this byte[] bytes) {
|
||||
using (MemoryStream ms = new MemoryStream()) {
|
||||
using (GZipStream gs = new GZipStream(ms, CompressionMode.Compress, true))
|
||||
@ -83,17 +84,17 @@ namespace MCGalaxy {
|
||||
}
|
||||
|
||||
public static string Concatenate<T>(this List<T> list, string separator) {
|
||||
return String.Join(separator, list);
|
||||
return String.Join(separator, list);
|
||||
}
|
||||
|
||||
public static string ToDBTime(this TimeSpan value) {
|
||||
return value.Days + " " + value.Hours + " " + value.Minutes + " " + value.Seconds;
|
||||
return value.Days + " " + value.Hours + " " + value.Minutes + " " + value.Seconds;
|
||||
}
|
||||
|
||||
public static TimeSpan ParseDBTime(this string value) {
|
||||
string[] parts = value.Split(' ');
|
||||
return new TimeSpan(int.Parse(parts[0]), int.Parse(parts[1]),
|
||||
int.Parse(parts[2]), int.Parse(parts[3]));
|
||||
string[] parts = value.Split(' ');
|
||||
return new TimeSpan(int.Parse(parts[0]), int.Parse(parts[1]),
|
||||
int.Parse(parts[2]), int.Parse(parts[3]));
|
||||
}
|
||||
|
||||
const StringComparison comp = StringComparison.OrdinalIgnoreCase;
|
||||
@ -103,7 +104,7 @@ namespace MCGalaxy {
|
||||
|
||||
public static bool CaselessContains(this List<string> items, string value) {
|
||||
foreach (string item in items) {
|
||||
if (item.Equals(value, comp)) return true;
|
||||
if (item.Equals(value, comp)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -121,7 +122,7 @@ namespace MCGalaxy {
|
||||
// Make sure we do an aligned write/read for the bulk copy
|
||||
while( bytes > 0 && ( startIndex & 0x7 ) != 0 ) {
|
||||
*srcByte = value; srcByte++; bytes--;
|
||||
startIndex++;
|
||||
startIndex++;
|
||||
}
|
||||
uint valueInt = (uint)( ( value << 24 ) | ( value << 16 ) | ( value << 8 ) | value );
|
||||
|
||||
@ -145,27 +146,27 @@ namespace MCGalaxy {
|
||||
}
|
||||
}
|
||||
|
||||
public static T FindOrShowMatches<T>(Player pl, string name, out int matches, IEnumerable<T> items,
|
||||
Predicate<T> filter, Func<T, string> nameGetter, string type) {
|
||||
T match = default(T); matches = 0;
|
||||
public static T FindMatches<T>(Player pl, string name, out int matches, IEnumerable items,
|
||||
Predicate<T> filter, Func<T, string> nameGetter, string type, int limit = 5) {
|
||||
T match = default(T); matches = 0;
|
||||
name = name.ToLower();
|
||||
StringBuilder matchNames = new StringBuilder();
|
||||
|
||||
foreach (T item in items) {
|
||||
if (!filter(item)) continue;
|
||||
string itemName = nameGetter(item);
|
||||
if (itemName.Equals(name, comp)) { matches = 1; return item; }
|
||||
if (!filter(item)) continue;
|
||||
string itemName = nameGetter(item);
|
||||
if (itemName.Equals(name, comp)) { matches = 1; return item; }
|
||||
if (itemName.IndexOf(name, comp) < 0) continue;
|
||||
|
||||
match = item; matches++;
|
||||
if (matches <= 5)
|
||||
if (matches <= limit)
|
||||
matchNames.Append(itemName).Append(", ");
|
||||
else if (matches == 6)
|
||||
else if (matches == limit + 1)
|
||||
matchNames.Append("(and more)").Append(", ");
|
||||
}
|
||||
|
||||
if (matches == 0) {
|
||||
Player.Message(pl, "No " + type + " match \"" + name + "\"."); return default(T);
|
||||
Player.Message(pl, "No " + type + " match \"" + name + "\"."); return default(T);
|
||||
} else if (matches == 1) {
|
||||
return match;
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user