mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 12:05:51 -04:00
Fix /whonick returning 'player not online' when multiple people matched the given nickname.
This commit is contained in:
parent
f452602912
commit
2697c934cd
@ -99,7 +99,7 @@ namespace MCGalaxy.Commands.Bots{
|
||||
Player.Message(p, "Created new bot AI: &b" + ai);
|
||||
using (StreamWriter w = new StreamWriter("bots/" + ai))
|
||||
w.WriteLine("#Version 2");
|
||||
} else if (instructions[0] != "#Version 2") {
|
||||
} else if (!instructions[0].CaselessEq("#Version 2")) {
|
||||
Player.Message(p, "File found is out-of-date. Overwriting");
|
||||
File.Delete("bots/" + ai);
|
||||
using (StreamWriter w = new StreamWriter("bots/" + ai))
|
||||
|
@ -28,11 +28,18 @@ namespace MCGalaxy.Commands.Info {
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
if (message.Length == 0) { Help(p); return; }
|
||||
Player nick = PlayerInfo.FindNick(p, message);
|
||||
if (nick == null) {
|
||||
Player.Message(p, "The player is not online."); return;
|
||||
}
|
||||
Player nick = FindNick(p, message);
|
||||
|
||||
if (nick == null) return;
|
||||
Player.Message(p, "This player's real username is " + nick.name);
|
||||
}
|
||||
|
||||
static Player FindNick(Player p, string nick) {
|
||||
nick = Colors.Strip(nick);
|
||||
Player[] players = PlayerInfo.Online.Items;
|
||||
int matches = 0;
|
||||
return Matcher.Find<Player>(p, nick, out matches, players, pl => Entities.CanSee(p, pl),
|
||||
pl => Colors.Strip(pl.DisplayName), "online player nicks");
|
||||
}
|
||||
|
||||
public override void Help(Player p) {
|
||||
|
@ -46,7 +46,7 @@ namespace MCGalaxy.Core {
|
||||
case ModActionType.Warned:
|
||||
AddNote(action, "W"); break;
|
||||
case ModActionType.Ban:
|
||||
string banType = action.Duration.Ticks == 0 ? "B" : "T";
|
||||
string banType = action.Duration.Ticks != 0 ? "T" : "B";
|
||||
AddNote(action, banType); break;
|
||||
}
|
||||
}
|
||||
|
@ -378,9 +378,6 @@ namespace MCGalaxy {
|
||||
[Obsolete("Use PlayerInfo.FindExact(name)")]
|
||||
public static Player FindExact(string name) { return PlayerInfo.FindExact(name); }
|
||||
|
||||
[Obsolete("Use PlayerInfo.FindNick(name)")]
|
||||
public static Player FindNick(string name) { return PlayerInfo.FindNick(null, name); }
|
||||
|
||||
unsafe static byte NextFreeId() {
|
||||
byte* used = stackalloc byte[256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
|
@ -25,8 +25,6 @@ namespace MCGalaxy {
|
||||
/// <summary> Array of all currently online players. </summary>
|
||||
/// <remarks> Note this field is highly volatile, you should cache references to the items array. </remarks>
|
||||
public static VolatileArray<Player> Online = new VolatileArray<Player>(true);
|
||||
[Obsolete("Use PlayerInfo.Online.Items")]
|
||||
public static List<Player> players;
|
||||
|
||||
public static Group GetGroup(string name) { return Group.GroupIn(name); }
|
||||
|
||||
@ -89,23 +87,6 @@ namespace MCGalaxy {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Player FindNick(Player p, string nick) {
|
||||
nick = Colors.Strip(nick);
|
||||
Player[] players = PlayerInfo.Online.Items;
|
||||
Player match = null; int matches = 0;
|
||||
|
||||
foreach (Player pl in players) {
|
||||
if (!Entities.CanSee(p, pl)) continue;
|
||||
string name = Colors.Strip(pl.DisplayName);
|
||||
|
||||
if (name.CaselessEq(nick)) return pl;
|
||||
if (name.CaselessContains(nick)) {
|
||||
match = pl; matches++;
|
||||
}
|
||||
}
|
||||
return matches == 1 ? match : null;
|
||||
}
|
||||
|
||||
|
||||
/// <summary> Retrieves from the database the player data for the player
|
||||
|
@ -36,7 +36,7 @@ namespace MCGalaxy {
|
||||
|
||||
public static IRCBot IRC;
|
||||
public static Thread locationChecker;
|
||||
public static DateTime StartTime, StartTimeLocal;
|
||||
public static DateTime StartTime;
|
||||
|
||||
public static PlayerExtList AutoloadMaps;
|
||||
public static PlayerMetaList RankInfo = new PlayerMetaList("text/rankinfo.txt");
|
||||
|
@ -76,12 +76,10 @@ namespace MCGalaxy {
|
||||
|
||||
#pragma warning disable 0618
|
||||
Player.players = PlayerInfo.Online.list;
|
||||
PlayerInfo.players = PlayerInfo.Online.list;
|
||||
Server.levels = LevelInfo.Loaded.list;
|
||||
#pragma warning restore 0618
|
||||
|
||||
StartTime = DateTime.UtcNow;
|
||||
StartTimeLocal = StartTime.ToLocalTime();
|
||||
shuttingDown = false;
|
||||
Logger.Log(LogType.SystemActivity, "Starting Server");
|
||||
ServicePointManager.Expect100Continue = false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user