Skip to content
Permalink
Browse files

Geoip update

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 d8953545b9cca2d9656a6d01975886d464513ce3
Showing with 5 additions and 7 deletions.
  1. +2 −4 fCraft/Commands/InfoCommands.cs
  2. +1 −1 fCraft/Network/IRC.cs
  3. +1 −1 fCraft/Player/PlayerInfo.cs
  4. +1 −1 fCraft/System/Server.cs
@@ -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);
}

@@ -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/");
}

@@ -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;
@@ -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;
@@ -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);
}
}
@@ -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);
@@ -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);
}

0 comments on commit d895354

Please sign in to comment.
You can’t perform that action at this time.