mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 10:01:27 -07:00
Alter how game teleports are detected
This commit is contained in:
parent
9d7f9f7ba3
commit
5205287f36
@ -117,7 +117,7 @@ namespace Bloxstrap.Integrations
|
|||||||
|
|
||||||
App.Logger.WriteLine($"[DiscordRichPresence::SetCurrentGame] Setting presence for Place ID {_activityWatcher.ActivityPlaceId}");
|
App.Logger.WriteLine($"[DiscordRichPresence::SetCurrentGame] Setting presence for Place ID {_activityWatcher.ActivityPlaceId}");
|
||||||
|
|
||||||
var universeIdResponse = await Utility.Http.GetJson<UniverseIdResponse>($"https://apis.roblox.com/universes/v1/places/{_activityWatcher.ActivityPlaceId}/universe");
|
var universeIdResponse = await Http.GetJson<UniverseIdResponse>($"https://apis.roblox.com/universes/v1/places/{_activityWatcher.ActivityPlaceId}/universe");
|
||||||
if (universeIdResponse is null)
|
if (universeIdResponse is null)
|
||||||
{
|
{
|
||||||
App.Logger.WriteLine($"[DiscordRichPresence::SetCurrentGame] Could not get Universe ID!");
|
App.Logger.WriteLine($"[DiscordRichPresence::SetCurrentGame] Could not get Universe ID!");
|
||||||
@ -131,10 +131,9 @@ namespace Bloxstrap.Integrations
|
|||||||
if (_timeStartedUniverse is null || !_activityWatcher.ActivityIsTeleport || universeId != _currentUniverseId)
|
if (_timeStartedUniverse is null || !_activityWatcher.ActivityIsTeleport || universeId != _currentUniverseId)
|
||||||
_timeStartedUniverse = DateTime.UtcNow;
|
_timeStartedUniverse = DateTime.UtcNow;
|
||||||
|
|
||||||
_activityWatcher.ActivityIsTeleport = false;
|
|
||||||
_currentUniverseId = universeId;
|
_currentUniverseId = universeId;
|
||||||
|
|
||||||
var gameDetailResponse = await Utility.Http.GetJson<ApiArrayResponse<GameDetailResponse>>($"https://games.roblox.com/v1/games?universeIds={universeId}");
|
var gameDetailResponse = await Http.GetJson<ApiArrayResponse<GameDetailResponse>>($"https://games.roblox.com/v1/games?universeIds={universeId}");
|
||||||
if (gameDetailResponse is null || !gameDetailResponse.Data.Any())
|
if (gameDetailResponse is null || !gameDetailResponse.Data.Any())
|
||||||
{
|
{
|
||||||
App.Logger.WriteLine($"[DiscordRichPresence::SetCurrentGame] Could not get Universe info!");
|
App.Logger.WriteLine($"[DiscordRichPresence::SetCurrentGame] Could not get Universe info!");
|
||||||
@ -144,7 +143,7 @@ namespace Bloxstrap.Integrations
|
|||||||
GameDetailResponse universeDetails = gameDetailResponse.Data.ToArray()[0];
|
GameDetailResponse universeDetails = gameDetailResponse.Data.ToArray()[0];
|
||||||
App.Logger.WriteLine($"[DiscordRichPresence::SetCurrentGame] Got Universe details");
|
App.Logger.WriteLine($"[DiscordRichPresence::SetCurrentGame] Got Universe details");
|
||||||
|
|
||||||
var universeThumbnailResponse = await Utility.Http.GetJson<ApiArrayResponse<ThumbnailResponse>>($"https://thumbnails.roblox.com/v1/games/icons?universeIds={universeId}&returnPolicy=PlaceHolder&size=512x512&format=Png&isCircular=false");
|
var universeThumbnailResponse = await Http.GetJson<ApiArrayResponse<ThumbnailResponse>>($"https://thumbnails.roblox.com/v1/games/icons?universeIds={universeId}&returnPolicy=PlaceHolder&size=512x512&format=Png&isCircular=false");
|
||||||
if (universeThumbnailResponse is null || !universeThumbnailResponse.Data.Any())
|
if (universeThumbnailResponse is null || !universeThumbnailResponse.Data.Any())
|
||||||
{
|
{
|
||||||
App.Logger.WriteLine($"[DiscordRichPresence::SetCurrentGame] Could not get Universe thumbnail info!");
|
App.Logger.WriteLine($"[DiscordRichPresence::SetCurrentGame] Could not get Universe thumbnail info!");
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
private const string GameJoinedEntryPattern = @"serverId: ([0-9\.]+)\|[0-9]+";
|
private const string GameJoinedEntryPattern = @"serverId: ([0-9\.]+)\|[0-9]+";
|
||||||
|
|
||||||
private int _logEntriesRead = 0;
|
private int _logEntriesRead = 0;
|
||||||
|
private bool _teleportMarker = false;
|
||||||
|
|
||||||
public event EventHandler<string>? OnLogEntry;
|
public event EventHandler<string>? OnLogEntry;
|
||||||
public event EventHandler? OnGameJoin;
|
public event EventHandler? OnGameJoin;
|
||||||
@ -27,8 +28,6 @@
|
|||||||
public string LogFilename = null!;
|
public string LogFilename = null!;
|
||||||
|
|
||||||
// these are values to use assuming the player isn't currently in a game
|
// these are values to use assuming the player isn't currently in a game
|
||||||
// keep in mind ActivityIsTeleport is only reset by DiscordRichPresence when it's done accessing it
|
|
||||||
// because of the weird chronology of where the teleporting entry is outputted, there's no way to reset it in here
|
|
||||||
public bool ActivityInGame = false;
|
public bool ActivityInGame = false;
|
||||||
public long ActivityPlaceId = 0;
|
public long ActivityPlaceId = 0;
|
||||||
public string ActivityJobId = "";
|
public string ActivityJobId = "";
|
||||||
@ -130,6 +129,16 @@
|
|||||||
ActivityJobId = match.Groups[1].Value;
|
ActivityJobId = match.Groups[1].Value;
|
||||||
ActivityMachineAddress = match.Groups[3].Value;
|
ActivityMachineAddress = match.Groups[3].Value;
|
||||||
|
|
||||||
|
if (_teleportMarker)
|
||||||
|
{
|
||||||
|
ActivityIsTeleport = true;
|
||||||
|
_teleportMarker = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ActivityIsTeleport = false;
|
||||||
|
}
|
||||||
|
|
||||||
App.Logger.WriteLine($"[RobloxActivity::ExamineLogEntry] Joining Game ({ActivityPlaceId}/{ActivityJobId}/{ActivityMachineAddress})");
|
App.Logger.WriteLine($"[RobloxActivity::ExamineLogEntry] Joining Game ({ActivityPlaceId}/{ActivityJobId}/{ActivityMachineAddress})");
|
||||||
}
|
}
|
||||||
else if (!ActivityInGame && ActivityPlaceId != 0)
|
else if (!ActivityInGame && ActivityPlaceId != 0)
|
||||||
@ -184,7 +193,7 @@
|
|||||||
else if (entry.Contains(GameTeleportingEntry))
|
else if (entry.Contains(GameTeleportingEntry))
|
||||||
{
|
{
|
||||||
App.Logger.WriteLine($"[RobloxActivity::ExamineLogEntry] Initiating teleport to server ({ActivityPlaceId}/{ActivityJobId}/{ActivityMachineAddress})");
|
App.Logger.WriteLine($"[RobloxActivity::ExamineLogEntry] Initiating teleport to server ({ActivityPlaceId}/{ActivityJobId}/{ActivityMachineAddress})");
|
||||||
ActivityIsTeleport = true;
|
_teleportMarker = true;
|
||||||
}
|
}
|
||||||
else if (entry.Contains(GameMessageEntry))
|
else if (entry.Contains(GameMessageEntry))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user