Skip to content

Commit

Permalink
feat: add social list and remove cache
Browse files Browse the repository at this point in the history
  • Loading branch information
kalilistic committed Nov 20, 2023
1 parent 9a3ca48 commit 8b0e328
Show file tree
Hide file tree
Showing 13 changed files with 526 additions and 149 deletions.
111 changes: 0 additions & 111 deletions Dalamud.DrunkenToad/Caching/CacheService.cs

This file was deleted.

13 changes: 0 additions & 13 deletions Dalamud.DrunkenToad/Caching/SortedCacheService.cs

This file was deleted.

13 changes: 0 additions & 13 deletions Dalamud.DrunkenToad/Caching/UnsortedCacheService.cs

This file was deleted.

7 changes: 7 additions & 0 deletions Dalamud.DrunkenToad/Core/DalamudContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ public class DalamudContext
/// </summary>
public static PlayerEventDispatcher PlayerEventDispatcher { get; private set; } = null!;

/// <summary>
/// Gets service for providing events when social list data is available.
/// </summary>
public static SocialListHandler SocialListHandler { get; private set; } = null!;

/// <summary>
/// Gets service that provides an extended location data API derived from territory change events.
/// </summary>
Expand Down Expand Up @@ -229,6 +234,7 @@ public static bool Initialize(DalamudPluginInterface pluginInterface)
TargetManager = new TargetManagerEx(DalamudTargetManager);
PlayerLocationManager = new PlayerLocationManager(ClientStateHandler, DataManager);
PlayerEventDispatcher = new PlayerEventDispatcher(GameFramework, ObjectCollection);
SocialListHandler = new SocialListHandler();
LocManager = new PluginLocalization(pluginInterface);
WindowManager = new WindowManager(pluginInterface);
ToadGui.Initialize(LocManager, DataManager);
Expand All @@ -251,6 +257,7 @@ public static void Dispose()
WindowManager.Dispose();
LocManager.Dispose();
PlayerEventDispatcher.Dispose();
SocialListHandler.Dispose();
PlayerLocationManager.Dispose();
}
catch (Exception ex)
Expand Down
17 changes: 17 additions & 0 deletions Dalamud.DrunkenToad/Core/Models/ToadDataCenter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace Dalamud.DrunkenToad.Core.Models;

/// <summary>
/// DataCenter data.
/// </summary>
public class ToadDataCenter
{
/// <summary>
/// Gets or sets data center id.
/// </summary>
public uint Id { get; set; }

/// <summary>
/// Gets data center name.
/// </summary>
public string Name { get; init; } = string.Empty;
}
9 changes: 3 additions & 6 deletions Dalamud.DrunkenToad/Core/Models/ToadLocalPlayer.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
namespace Dalamud.DrunkenToad.Core.Models;

using Utility;

/// <summary>
/// Subset of key properties from local player for eventing.
/// </summary>
Expand All @@ -25,14 +27,9 @@ public class ToadLocalPlayer
/// </summary>
public byte[]? Customize;

/// <summary>
/// Player Company Tag.
/// </summary>
public string CompanyTag = string.Empty;

/// <summary>
/// Validate if local player is valid.
/// </summary>
/// <returns>Indicator if local player is valid.</returns>
public bool IsValid() => this.ContentId != 0 && this.Name != string.Empty && this.HomeWorld != 0;
public bool IsValid() => this.ContentId != 0 && this.Name.IsValidCharacterName() && this.HomeWorld != 0;
}
46 changes: 46 additions & 0 deletions Dalamud.DrunkenToad/Core/Models/ToadSocialListMember.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
namespace Dalamud.DrunkenToad.Core.Models;

using Utility;

public class ToadSocialListMember
{
/// <summary>
/// The content ID of the local character.
/// </summary>
public ulong ContentId;

/// <summary>
/// Player Name.
/// </summary>
public string Name = string.Empty;

/// <summary>
/// Player HomeWorld ID.
/// </summary>
public ushort HomeWorld;

/// <summary>
/// Player is unable to retrieve (no name).
/// </summary>
public bool IsUnableToRetrieve;

/// <summary>
/// Validate if player is valid.
/// </summary>
/// <returns>Indicator if player is valid.</returns>
public bool IsValid()
{
if (this.ContentId == 0)
{
return false;
}

// If the player's name is null or empty, the player is valid only if they are marked as unable to retrieve.
if (string.IsNullOrEmpty(this.Name))
{
return this.IsUnableToRetrieve;
}

return DalamudContext.DataManager.IsValidWorld(this.HomeWorld) && this.Name.IsValidCharacterName();
}
}
5 changes: 5 additions & 0 deletions Dalamud.DrunkenToad/Core/Models/ToadWorld.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,9 @@ public class ToadWorld
/// Gets world name.
/// </summary>
public string Name { get; init; } = string.Empty;

/// <summary>
/// Gets world's data center.
/// </summary>
public uint DataCenterId { get; init; }
}
Loading

0 comments on commit 8b0e328

Please sign in to comment.