Skip to content

Commit

Permalink
Geoip update
Browse files Browse the repository at this point in the history
Accuracy is no longer included, also fixes geoip message from showing up when not needed.
  • Loading branch information
123DMWM committed Jul 2, 2018
1 parent 5bb930f commit d895354
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
6 changes: 2 additions & 4 deletions fCraft/Commands/InfoCommands.cs
Expand Up @@ -1787,7 +1787,7 @@ static void EmotesHandler(Player player, CommandReader cmd)
info = FindPlayerInfo(player, cmd);
}
if (info == null) return;
if (info.GeoIP != info.LastIP.ToString() || info.Accuracy == 0) {
if (info.GeoIP != info.LastIP.ToString()) {
GetGeoip(info);
}

Expand All @@ -1799,7 +1799,6 @@ static void EmotesHandler(Player player, CommandReader cmd)
player.Message(" Longitude: &f{0}", info.Longitude ?? "N/A");
player.Message(" Time Zone: &f{0}", info.TimeZone ?? "N/A");
player.Message(" Hostname: &f{0}", info.Hostname ?? "N/A");
player.Message(" Accuracy: &f{0}", info.Accuracy);
player.Message("Geoip information by: &9http://geoip.pw/");
}

Expand Down Expand Up @@ -1854,7 +1853,7 @@ static void EmotesHandler(Player player, CommandReader cmd)
if (IPAddress.Parse(ip).IsLocal() && Server.ExternalIP != null) {
ip = Server.ExternalIP.ToString();
}
if (ip == info.GeoIP && info.Accuracy != 0) {
if (ip == info.GeoIP) {
return;
}
JsonObject result = null;
Expand All @@ -1870,7 +1869,6 @@ static void EmotesHandler(Player player, CommandReader cmd)
info.Latitude = result.Get("latitude") ?? "N/A";
info.Longitude = result.Get("longitude") ?? "N/A";
info.TimeZone = result.Get("timezone") ?? "N/A";
byte.TryParse(result.Get("accuracy"), out info.Accuracy);
info.Hostname = result.Get("host") ?? "N/A";
info.GeoIP = result.Get("ip") ?? "N/A";
return;
Expand Down
2 changes: 1 addition & 1 deletion fCraft/Network/IRC.cs
Expand Up @@ -1072,9 +1072,9 @@ static void PlayerReadyHandler([CanBeNull] object sender, [NotNull] IPlayerEvent
string ip = e.Player.Info.LastIP.ToString();
if (IPAddress.Parse(ip).IsLocal() && Server.ExternalIP != null)
ip = Server.ExternalIP.ToString();
e.Player.Info.TimesVisited == 1 ? " for the first time" : (ip != e.Player.Info.GeoIP || e.Player.Info.Accuracy == 0) ? "" : " from " + e.Player.Info.CountryName);

string message = string.Format("&2{0}&2(&A{1}&2) Connected{2}.", Bold, e.Player.ClassyName,
e.Player.Info.TimesVisited == 1 ? " for the first time" : (ip != e.Player.Info.GeoIP) ? "" : " from " + e.Player.Info.CountryName);
SendChannelMessage(message);
}
}
Expand Down
2 changes: 1 addition & 1 deletion fCraft/Player/PlayerInfo.cs
Expand Up @@ -107,7 +107,7 @@ public sealed partial class PlayerInfo : IClassy {
ip = Server.ExternalIP.ToString();
}

if (ip != GeoIP || Accuracy == 0) {
if (ip != GeoIP) {
Scheduler.NewBackgroundTask(GeoipLoginCallback).RunOnce(this, TimeSpan.Zero);
} else {
DisplayGeoIp(false);
Expand Down
2 changes: 1 addition & 1 deletion fCraft/System/Server.cs
Expand Up @@ -1263,7 +1263,7 @@ static IPAddress CheckExternalIP()
ip = ExternalIP.ToString();
return string.Format("&2(&A{0}&2) Connected{1}." + "{2}", player.ClassyName,
player.Info.TimesVisited == 1 ? " for the first time" :
(ip != player.Info.GeoIP || player.Info.Accuracy == 0 || string.IsNullOrEmpty(player.Info.CountryName)) ? "" :
(ip != player.Info.GeoIP || string.IsNullOrEmpty(player.Info.CountryName)) ? "" :
" from " + player.Info.CountryName, string.IsNullOrEmpty(player.ClientName) ? "" :
"&N&BUsing: " + player.ClientName);
}
Expand Down

0 comments on commit d895354

Please sign in to comment.