mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-23 04:32:50 -04:00
Doing ban/rank of an offline player, but forgetting the + at the end, should autocomplete that +.
This commit is contained in:
parent
eed351c654
commit
4fe6fd5178
@ -84,7 +84,7 @@ namespace MCGalaxy.Commands {
|
||||
string prefix = data.Title == "" ? "" : color + "[" + data.TitleColor + data.Title + color + "] ";
|
||||
|
||||
WhoInfo info = new WhoInfo();
|
||||
info.FullName = prefix + color + data.Name.TrimEnd('+');
|
||||
info.FullName = prefix + color + data.Name.RemoveLastPlus();
|
||||
info.Name = data.Name;
|
||||
info.Group = group;
|
||||
info.Money = data.Money; info.Deaths = data.Deaths;
|
||||
|
@ -75,9 +75,9 @@ namespace MCGalaxy.Commands {
|
||||
}
|
||||
}
|
||||
|
||||
if (Server.Devs.CaselessContains(who.Name.TrimEnd('+')))
|
||||
if (Server.Devs.CaselessContains(who.Name.RemoveLastPlus()))
|
||||
Player.Message(p, " Player is an &9{0} Developer", Server.SoftwareName);
|
||||
if (Server.Mods.CaselessContains(who.Name.TrimEnd('+')))
|
||||
if (Server.Mods.CaselessContains(who.Name.RemoveLastPlus()))
|
||||
Player.Message(p, " Player is an &9{0} Moderator", Server.SoftwareName);
|
||||
if (Server.server_owner.CaselessEq(who.Name))
|
||||
Player.Message(p, " Player is the &cServer owner");
|
||||
|
@ -127,7 +127,7 @@ namespace MCGalaxy.Commands.Moderation {
|
||||
if (confirmed != null) reason = confirmed;
|
||||
|
||||
if (match != null) {
|
||||
if (match.CaselessEq(name)) return match;
|
||||
if (match.RemoveLastPlus().CaselessEq(name.RemoveLastPlus())) return match;
|
||||
// Not an exact match, may be wanting to ban a non-existent account
|
||||
Player.Message(p, "1 player matches \"{0}\": {1}", name, match);
|
||||
}
|
||||
|
@ -201,8 +201,8 @@ namespace MCGalaxy.Network {
|
||||
byte[] buffer = new byte[138 + (extPos ? 6 : 0)];
|
||||
buffer[0] = Opcode.CpeExtAddEntity2;
|
||||
buffer[1] = id;
|
||||
NetUtils.Write(displayName.TrimEnd('+'), buffer, 2, hasCP437);
|
||||
NetUtils.Write(skinName.TrimEnd('+'), buffer, 66, hasCP437);
|
||||
NetUtils.Write(displayName.RemoveLastPlus(), buffer, 2, hasCP437);
|
||||
NetUtils.Write(skinName.RemoveLastPlus(), buffer, 66, hasCP437);
|
||||
|
||||
int offset = NetUtils.WritePos(pos, buffer, 130, extPos);
|
||||
buffer[130 + offset] = rot.RotY;
|
||||
|
@ -54,7 +54,7 @@ namespace MCGalaxy.Network {
|
||||
byte[] buffer = new byte[74 + (extPos ? 6 : 0)];
|
||||
buffer[0] = Opcode.AddEntity;
|
||||
buffer[1] = id;
|
||||
NetUtils.Write(name.TrimEnd('+'), buffer, 2, hasCP437);
|
||||
NetUtils.Write(name.RemoveLastPlus(), buffer, 2, hasCP437);
|
||||
|
||||
int offset = NetUtils.WritePos(pos, buffer, 66, extPos);
|
||||
buffer[66 + offset] = rot.RotY;
|
||||
|
@ -31,7 +31,7 @@ namespace MCGalaxy.Tasks {
|
||||
string type = line.Split(':')[0].ToLower();
|
||||
List<string> list = (type == "devs") ? Server.Devs : (type == "mods") ? Server.Mods : null;
|
||||
foreach (string name in line.Split(':')[1].Split())
|
||||
list.Add(name.TrimEnd('+'));
|
||||
list.Add(name.RemoveLastPlus());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -21,16 +21,25 @@ namespace MCGalaxy {
|
||||
|
||||
public static class StringExts {
|
||||
|
||||
/// <summary> Sets the first character of the input string touppercase. </summary>
|
||||
public static string Capitalize(this string str) {
|
||||
if (String.IsNullOrEmpty(str))
|
||||
return String.Empty;
|
||||
if (String.IsNullOrEmpty(str)) return str;
|
||||
|
||||
char[] a = str.ToCharArray();
|
||||
a[0] = char.ToUpper(a[0]);
|
||||
return new string(a);
|
||||
}
|
||||
|
||||
/// <summary> Removes an ending + from an account name. </summary>
|
||||
public static string RemoveLastPlus(this string str) {
|
||||
if (String.IsNullOrEmpty(str)) return str;
|
||||
|
||||
if (str[str.Length - 1] != '+') return str;
|
||||
return str.Substring(0, str.Length - 1);
|
||||
}
|
||||
|
||||
|
||||
/// <summary> Converts a string consisting of code page 437 indices into unicode. </summary>
|
||||
public static string Cp437ToUnicode(this string str) {
|
||||
if (str == null || str.Length == 0 || !HasSpecial(str)) return str;
|
||||
|
||||
@ -39,7 +48,9 @@ namespace MCGalaxy {
|
||||
c[i] = Cp437ToUnicode(str[i]);
|
||||
return new String(c);
|
||||
}
|
||||
|
||||
|
||||
/// <summary> Converts a unicode string into a string consisting of code page 437 indices. </summary>
|
||||
/// <remarks> Unicode characters not in code page 437 are converted to '?'. </remarks>
|
||||
public static string UnicodeToCp437(this string str) {
|
||||
if (str == null || str.Length == 0 || !HasSpecial(str)) return str;
|
||||
|
||||
@ -49,6 +60,7 @@ namespace MCGalaxy {
|
||||
return new String(c);
|
||||
}
|
||||
|
||||
/// <summary> Modifies the characters of a string consisting of code page 437 indices into unicode. </summary>
|
||||
public unsafe static void Cp437ToUnicodeInPlace(this string str) {
|
||||
fixed (char* ptr = str) {
|
||||
for (int i = 0; i < str.Length; i++) {
|
||||
@ -56,7 +68,9 @@ namespace MCGalaxy {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary> Modifies the characters of a unicode string into code page 437 indices. </summary>
|
||||
/// <remarks> Unicode characters not in code page 437 are replaced with '?'. </remarks>
|
||||
public static unsafe void UnicodeToCp437InPlace(this string str) {
|
||||
fixed (char* ptr = str) {
|
||||
for (int i = 0; i < str.Length; i++) {
|
||||
@ -66,6 +80,7 @@ namespace MCGalaxy {
|
||||
}
|
||||
|
||||
|
||||
/// <summary> Converts a code page 437 indice into unicode. </summary>
|
||||
public static char Cp437ToUnicode(this char c) {
|
||||
if (c < 0x20) {
|
||||
return FullCP437Handler.ControlCharReplacements[c];
|
||||
@ -76,7 +91,8 @@ namespace MCGalaxy {
|
||||
}
|
||||
return '?';
|
||||
}
|
||||
|
||||
|
||||
/// <summary> Converts a unicode character into a code page 437 indice. </summary>
|
||||
public static char UnicodeToCp437(this char c) {
|
||||
int cpIndex = 0;
|
||||
if (c >= ' ' && c <= '~') {
|
||||
|
Loading…
x
Reference in New Issue
Block a user