Skip to content

Commit

Permalink
New Bear Site Support (#24)
Browse files Browse the repository at this point in the history
* fix: update bear api to new site path

* don't include microseconds in bear time field

---------

Co-authored-by: ditzy <[email protected]>
  • Loading branch information
Shinryin and dit-zy authored Aug 9, 2024
1 parent 426281f commit c0ce836
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ScoutHelper/Config/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class Configuration : IPluginConfiguration {

public int Version { get; set; } = 0;

public string BearApiBaseUrl { get; set; } = "https://tracker-api.beartoolkit.com/public/";
public string BearApiBaseUrl { get; set; } = "https://tracker.beartoolkit.com/api/";
public string BearApiTrainPath { get; set; } = "hunttrain";
public TimeSpan BearApiTimeout { get; set; } = TimeSpan.FromSeconds(5);
public string BearSiteTrainUrl { get; set; } = "https://tracker.beartoolkit.com/train";
Expand Down
11 changes: 9 additions & 2 deletions ScoutHelper/Managers/BearManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ namespace ScoutHelper.Managers;
public class BearManager : IDisposable {
private readonly IPluginLog _log;
private readonly Configuration _conf;

private static readonly JsonSerializerSettings JsonSerializerSettings = new JsonSerializerSettings() {
DateFormatString = "yyyy'-'MM'-'dd'T'HH':'mm':'ssK",
DateTimeZoneHandling = DateTimeZoneHandling.Utc
};

private static HttpClient HttpClient { get; } = new();

private IDictionary<uint, (Patch patch, string name)> MobIdToBearName { get; init; }
Expand Down Expand Up @@ -54,9 +60,10 @@ IEnumerable<TrainMob> trainMobs
.Max();

var requestPayload = JsonConvert.SerializeObject(
new BearApiTrainRequest(worldName, _conf.BearTrainName, highestPatch.BearName(), spawnPoints)
new BearApiTrainRequest(worldName, _conf.BearTrainName, highestPatch.BearName(), spawnPoints),
JsonSerializerSettings
);
_log.Debug("Request payload: {0}", requestPayload);
_log.Debug("Request payload: {0:l}", requestPayload);
var requestContent = new StringContent(requestPayload, Encoding.UTF8, Constants.MediaTypeJson);

try {
Expand Down

0 comments on commit c0ce836

Please sign in to comment.