Skip to content

Commit bb75755

Browse files
using /api [name] should be same as /api p [name]
1 parent 162cb5c commit bb75755

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

fCraft/Commands/InfoCommands.cs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1925,34 +1925,39 @@ private static void APIPInfoHandler(Player player, CommandReader cmd) {
19251925
CdApi.PrintUsage(player);
19261926
return;
19271927
}
1928+
19281929
string value = cmd.Next();
1929-
if (value == null) {
1930-
value = "player/" + player.Name;
1931-
}
1930+
if (value == null) { value = type; type = "player"; }
19321931
int id;
1932+
19331933
switch (type.ToLower()) {
19341934
case "id":
19351935
case "i":
19361936
if (!int.TryParse(value, out id)) {
19371937
player.Message("ID not valid integer!");
19381938
return;
1939-
} else {
1940-
value = "id/" + id;
19411939
}
1940+
1941+
value = "id/" + id;
19421942
break;
1943+
19431944
case "player":
19441945
case "p":
1946+
if (!Player.IsValidPlayerName(value)) {
1947+
player.Message("Name not a valid player name!");
1948+
return;
1949+
}
1950+
19451951
value = "player/" + value;
19461952
break;
1947-
default:
1948-
value = "player/" + player.Name;
1949-
break;
19501953
}
1954+
19511955
string data = Server.downloadDatastring("http://www.classicube.net/api/" + value);
19521956
if (string.IsNullOrEmpty(data) || !data.Contains("username")) {
19531957
player.Message("Player not found!");
19541958
return;
19551959
}
1960+
19561961
JsonObject result = JsonObject.Parse(data);
19571962
string error;
19581963
result.TryGetValue("error", out error);

0 commit comments

Comments
 (0)