Skip to content

Commit

Permalink
using /api [name] should be same as /api p [name]
Browse files Browse the repository at this point in the history
  • Loading branch information
UnknownShadow200 committed Jun 9, 2017
1 parent 162cb5c commit bb75755
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions fCraft/Commands/InfoCommands.cs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1925,34 +1925,39 @@ private static void APIPInfoHandler(Player player, CommandReader cmd) {
CdApi.PrintUsage(player); CdApi.PrintUsage(player);
return; return;
} }

string value = cmd.Next(); string value = cmd.Next();
if (value == null) { if (value == null) { value = type; type = "player"; }
value = "player/" + player.Name;
}
int id; int id;

switch (type.ToLower()) { switch (type.ToLower()) {
case "id": case "id":
case "i": case "i":
if (!int.TryParse(value, out id)) { if (!int.TryParse(value, out id)) {
player.Message("ID not valid integer!"); player.Message("ID not valid integer!");
return; return;
} else {
value = "id/" + id;
} }

value = "id/" + id;
break; break;

case "player": case "player":
case "p": case "p":
if (!Player.IsValidPlayerName(value)) {
player.Message("Name not a valid player name!");
return;
}

value = "player/" + value; value = "player/" + value;
break; break;
default:
value = "player/" + player.Name;
break;
} }

string data = Server.downloadDatastring("http://www.classicube.net/api/" + value); string data = Server.downloadDatastring("http://www.classicube.net/api/" + value);
if (string.IsNullOrEmpty(data) || !data.Contains("username")) { if (string.IsNullOrEmpty(data) || !data.Contains("username")) {
player.Message("Player not found!"); player.Message("Player not found!");
return; return;
} }

JsonObject result = JsonObject.Parse(data); JsonObject result = JsonObject.Parse(data);
string error; string error;
result.TryGetValue("error", out error); result.TryGetValue("error", out error);
Expand Down

0 comments on commit bb75755

Please sign in to comment.