Skip to content

Commit

Permalink
feat: update for 7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
zhudotexe committed Nov 18, 2024
1 parent f06a010 commit b2c9686
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 33 deletions.
4 changes: 2 additions & 2 deletions AutoSweep.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
<AssemblyName>autoSweep</AssemblyName>
<AssemblyVersion>1.4.5.0</AssemblyVersion>
<AssemblyVersion>1.4.6.0</AssemblyVersion>
</PropertyGroup>

<PropertyGroup>
Expand Down Expand Up @@ -68,7 +68,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="DalamudPackager" Version="2.1.13" />
<PackageReference Include="DalamudPackager" Version="11.0.0" />
<PackageReference Include="DebounceThrottle" Version="2.0.0" />
<PackageReference Include="WebSocketSharp.Standard" Version="1.0.3" />
</ItemGroup>
Expand Down
5 changes: 2 additions & 3 deletions Paissa/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,12 @@ public void Dispose() {
public void Hello() {
IPlayerCharacter player = Plugin.ClientState.LocalPlayer;
if (player == null) return;
var homeworld = player.HomeWorld.GameData;
if (homeworld == null) return;
var homeworld = player.HomeWorld.Value;
var charInfo = new Dictionary<string, object> {
{ "cid", Plugin.ClientState.LocalContentId },
{ "name", player.Name.ToString() },
{ "world", homeworld.Name.ToString() },
{ "worldId", player.HomeWorld.Id }
{ "worldId", homeworld.RowId }
};
string content = JsonConvert.SerializeObject(charInfo);
Plugin.PluginLog.Debug(content);
Expand Down
10 changes: 5 additions & 5 deletions Paissa/LotteryObserver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using AutoSweep.Structures;
using Dalamud.Hooking;
using Dalamud.Utility.Signatures;
using Lumina.Excel.GeneratedSheets;
using Lumina.Excel.Sheets;
using Lumina.Text;

namespace AutoSweep.Paissa {
Expand Down Expand Up @@ -60,14 +60,14 @@ long a8
$"housingType={housingType}, territoryTypeId={territoryTypeId}, wardId={wardId}, plotId={plotId}, apartmentNumber={apartmentNumber}, placardSaleInfoPtr={placardSaleInfoPtr}, a8={a8}");

// get information about the world from the clientstate
World world = Plugin.ClientState.LocalPlayer?.CurrentWorld.GameData;
World? world = Plugin.ClientState.LocalPlayer?.CurrentWorld.ValueNullable;
if (world is null) return;

SeString place = plugin.Territories.GetRow(territoryTypeId)?.PlaceName.Value?.Name;
SeString worldName = world.Name;
var place = plugin.Territories.GetRow(territoryTypeId).PlaceName.Value.Name;
var worldName = world.Value.Name;
Plugin.PluginLog.Info($"Plot {place} {wardId + 1}-{plotId + 1} ({worldName}) has {saleInfo.EntryCount} lottery entries.");

plugin.PaissaClient.PostLotteryInfo(world.RowId, territoryTypeId, wardId, plotId, saleInfo);
plugin.PaissaClient.PostLotteryInfo(world.Value.RowId, territoryTypeId, wardId, plotId, saleInfo);
}
}

Expand Down
9 changes: 5 additions & 4 deletions Paissa/Utils.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Lumina.Excel.GeneratedSheets;

using Lumina.Excel.Sheets;

namespace AutoSweep.Paissa {
public class Utils {
Expand Down Expand Up @@ -44,9 +45,9 @@ public static bool ConfigEnabledForPlot(Plugin plugin, ushort worldId, ushort di
// does the config want notifs for this world?
World eventWorld = plugin.Worlds.GetRow(worldId);
if (!(plugin.Configuration.AllNotifs
|| plugin.Configuration.HomeworldNotifs && worldId == Plugin.ClientState.LocalPlayer?.HomeWorld.Id
|| plugin.Configuration.DatacenterNotifs && eventWorld?.DataCenter.Row ==
Plugin.ClientState.LocalPlayer?.HomeWorld.GameData?.DataCenter.Row))
|| plugin.Configuration.HomeworldNotifs && worldId == Plugin.ClientState.LocalPlayer?.HomeWorld.RowId
|| plugin.Configuration.DatacenterNotifs && eventWorld.DataCenter.RowId ==
Plugin.ClientState.LocalPlayer?.HomeWorld.Value.DataCenter.RowId))
return false;
// get the district config
DistrictNotifConfig districtNotifs;
Expand Down
6 changes: 3 additions & 3 deletions Paissa/WardObserver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ IntPtr dataPtr
// reset last sweep info to the current sweep
SweepState.StartDistrictSweep(wardInfo);

SeString districtName = plugin.Territories.GetRow((uint)wardInfo.LandIdent.TerritoryTypeId)?.PlaceName.Value?.Name;
SeString worldName = plugin.Worlds.GetRow((uint)wardInfo.LandIdent.WorldId)?.Name;
var districtName = plugin.Territories.GetRow((uint)wardInfo.LandIdent.TerritoryTypeId).PlaceName.Value.Name;
var worldName = plugin.Worlds.GetRow((uint)wardInfo.LandIdent.WorldId).Name;
if (plugin.Configuration.ChatSweepAlert) {
Plugin.Chat.Print($"Began sweep for {districtName} ({worldName})");
}
Expand Down Expand Up @@ -77,7 +77,7 @@ IntPtr dataPtr
private void OnFinishedDistrictSweep(HousingWardInfo housingWardInfo) {
if (!plugin.Configuration.ChatSweepAlert) return;

SeString districtName = plugin.Territories.GetRow((uint)SweepState.DistrictId)?.PlaceName.Value?.Name;
var districtName = plugin.Territories.GetRow((uint)SweepState.DistrictId).PlaceName.Value.Name;

Plugin.Chat.Print($"Swept all {Utils.NumWardsPerDistrict} wards. Thank you for your contribution!");
Plugin.Chat.Print($"Here's a summary of open plots in {districtName}:");
Expand Down
25 changes: 12 additions & 13 deletions Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using Dalamud.Plugin;
using Dalamud.Plugin.Services;
using Lumina.Excel;
using Lumina.Excel.GeneratedSheets;
using Lumina.Excel.Sheets;

namespace AutoSweep {
public sealed class Plugin : IDalamudPlugin {
Expand Down Expand Up @@ -141,7 +141,7 @@ private void OnPlotOpened(object sender, PlotOpenedEventArgs e) {
World eventWorld = Worlds.GetRow(e.PlotDetail.world_id);
OnFoundOpenHouse(e.PlotDetail.world_id, e.PlotDetail.district_id, e.PlotDetail.ward_number,
e.PlotDetail.plot_number, e.PlotDetail.price,
$"New plot available for purchase on {eventWorld?.Name}: ");
$"New plot available for purchase on {eventWorld.Name}: ");
}

private void OnPlotUpdate(object sender, PlotUpdateEventArgs e) {
Expand All @@ -156,7 +156,7 @@ private void OnPlotUpdate(object sender, PlotUpdateEventArgs e) {
World eventWorld = Worlds.GetRow(e.PlotUpdate.world_id);
OnFoundOpenHouse(e.PlotUpdate.world_id, e.PlotUpdate.district_id, e.PlotUpdate.ward_number,
e.PlotUpdate.plot_number, e.PlotUpdate.price,
$"New plot available for purchase on {eventWorld?.Name}: ");
$"New plot available for purchase on {eventWorld.Name}: ");
}


Expand All @@ -165,19 +165,18 @@ private void OnPlotUpdate(object sender, PlotUpdateEventArgs e) {
/// </summary>
internal void OnFoundOpenHouse(uint worldId, uint territoryTypeId, int wardNumber, int plotNumber, uint? price,
string messagePrefix = "") {
PlaceName place = Territories.GetRow(territoryTypeId)?.PlaceName.Value;
PlaceName place = Territories.GetRow(territoryTypeId).PlaceName.Value;
// languages like German do not use NameNoArticle (#2)
Lumina.Text.SeString districtName =
place?.NameNoArticle.RawString.Length > 0 ? place.NameNoArticle : place?.Name;
Lumina.Text.SeString worldName = Worlds.GetRow(worldId)?.Name;
var districtName =
!place.NameNoArticle.IsEmpty ? place.NameNoArticle : place.Name;
var worldName = Worlds.GetRow(worldId).Name;

HousingLandSet landSet = HousingLandSets.GetRow(Utils.TerritoryTypeIdToLandSetId(territoryTypeId));
byte? houseSize = landSet?.PlotSize[plotNumber];
byte? houseSize = landSet.LandSet[plotNumber].PlotSize;
uint realPrice =
price.GetValueOrDefault(landSet?.InitialPrice[plotNumber] ??
0); // if price is null, it's probably the default price (landupdate)
price.GetValueOrDefault(landSet.LandSet[plotNumber].InitialPrice); // if price is null, it's probably the default price (landupdate)

string districtNameNoSpaces = districtName?.ToString().Replace(" ", "");
string districtNameNoSpaces = districtName.ToString().Replace(" ", "");
int wardNum = wardNumber + 1;
int plotNum = plotNumber + 1;
float housePriceMillions = realPrice / 1000000f;
Expand All @@ -195,8 +194,8 @@ internal void OnFoundOpenHouse(uint worldId, uint territoryTypeId, int wardNumbe
break;
case OutputFormat.Custom:
var template = $"{messagePrefix}{Configuration.OutputFormatString}";
output = Utils.FormatCustomOutputString(template, districtName?.ToString(), districtNameNoSpaces,
worldName, wardNum.ToString(),
output = Utils.FormatCustomOutputString(template, districtName.ToString(), districtNameNoSpaces,
worldName.ToString(), wardNum.ToString(),
plotNum.ToString(), realPrice.ToString(), housePriceMillions.ToString("F3"), houseSizeName);
break;
default:
Expand Down
6 changes: 3 additions & 3 deletions packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"net8.0-windows7.0": {
"DalamudPackager": {
"type": "Direct",
"requested": "[2.1.13, )",
"resolved": "2.1.13",
"contentHash": "rMN1omGe8536f4xLMvx9NwfvpAc9YFFfeXJ1t4P4PE6Gu8WCIoFliR1sh07hM+bfODmesk/dvMbji7vNI+B/pQ=="
"requested": "[11.0.0, )",
"resolved": "11.0.0",
"contentHash": "bjT7XUlhIJSmsE/O76b7weUX+evvGQctbQB8aKXt94o+oPWxHpCepxAGMs7Thow3AzCyqWs7cOpp9/2wcgRRQA=="
},
"DebounceThrottle": {
"type": "Direct",
Expand Down

0 comments on commit b2c9686

Please sign in to comment.