Skip to content

Commit

Permalink
feat: add link to paissadb
Browse files Browse the repository at this point in the history
  • Loading branch information
zhudotexe committed May 30, 2022
1 parent 323ff53 commit 26b3ebe
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 10 deletions.
2 changes: 1 addition & 1 deletion AutoSweep.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<DalamudLibPath>$(appdata)\XIVLauncher\addon\Hooks\dev\</DalamudLibPath>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<AssemblyName>autoSweep</AssemblyName>
<AssemblyVersion>1.3.1.0</AssemblyVersion>
<AssemblyVersion>1.4.0.0</AssemblyVersion>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
Expand Down
1 change: 1 addition & 0 deletions Paissa/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace AutoSweep.Paissa {
public class Utils {
// configuration constants
public const string CommandName = "/psweep";
public const string HouseCommandName = "/phouse";
public const int NumWardsPerDistrict = 24;

public static uint TerritoryTypeIdToLandSetId(uint territoryTypeId) {
Expand Down
43 changes: 36 additions & 7 deletions Plugin.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using AutoSweep.Paissa;
using AutoSweep.Structures;
using Dalamud.Data;
Expand All @@ -8,30 +9,32 @@
using Dalamud.Game.Gui;
using Dalamud.Game.Network;
using Dalamud.Game.Text;
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Game.Text.SeStringHandling.Payloads;
using Dalamud.Logging;
using Dalamud.Plugin;
using Lumina.Excel;
using Lumina.Excel.GeneratedSheets;
using Lumina.Text;

namespace AutoSweep {
public class Plugin : IDalamudPlugin {
public string Name => "PaissaHouse";

// frameworks/data
internal readonly DalamudPluginInterface PluginInterface;
internal readonly ChatGui Chat;
internal readonly ClientState ClientState;
internal readonly CommandManager Commands;
internal readonly Configuration Configuration;
internal readonly DataManager Data;
internal readonly Framework Framework;
internal readonly GameNetwork Network;
internal readonly GameGui GameGui;
internal readonly PaissaClient PaissaClient;

internal readonly ExcelSheet<HousingLandSet> HousingLandSets;
internal readonly ExcelSheet<TerritoryType> Territories;
internal readonly ExcelSheet<World> Worlds;
private readonly DalamudLinkPayload chatLinkPayload;

// state
private readonly WardObserver wardObserver;
Expand All @@ -46,16 +49,15 @@ public Plugin(
DataManager data,
CommandManager commands,
ClientState clientState,
Framework framework,
GameGui gameGui
Framework framework
) {
PluginInterface = pi;
Chat = chat;
Network = network;
Data = data;
Commands = commands;
ClientState = clientState;
Framework = framework;
GameGui = gameGui;

// setup
Configuration = pi.GetPluginConfig() as Configuration ?? new Configuration();
Expand All @@ -65,10 +67,15 @@ GameGui gameGui
Worlds = data.GetExcelSheet<World>();
HousingLandSets = data.GetExcelSheet<HousingLandSet>();

commands.AddHandler(Utils.HouseCommandName, new CommandInfo(OnHouseCommand) {
HelpMessage = "View all houses available for sale."
});
commands.AddHandler(Utils.CommandName, new CommandInfo(OnCommand) {
HelpMessage = $"Configure PaissaHouse settings.\n\"{Utils.CommandName} reset\" to reset a sweep if sweeping the same district multiple times in a row."
});

chatLinkPayload = pi.AddChatLinkHandler(0, OnChatLinkClick);

// event hooks
network.NetworkMessage += OnNetworkEvent;
pi.UiBuilder.Draw += DrawUI;
Expand All @@ -92,11 +99,25 @@ public void Dispose() {
Framework.Update -= OnUpdateEvent;
ClientState.Login -= OnLogin;
Commands.RemoveHandler(Utils.CommandName);
Commands.RemoveHandler(Utils.HouseCommandName);
PluginInterface.RemoveChatLinkHandler();
PaissaClient?.Dispose();
lotteryObserver.Dispose();
}

// ==== dalamud events ====
private void OnHouseCommand(string command, string args) {
Chat.Print(new SeString(
new TextPayload("Thanks for using PaissaHouse! You can view all of the houses available for sale at "),
new UIForegroundPayload(710),
chatLinkPayload,
new TextPayload("https://paissadb.zhu.codes/"),
RawPayload.LinkTerminator,
new UIForegroundPayload(0),
new TextPayload(" (opens in browser)."))
);
}

private void OnCommand(string command, string args) {
switch (args) {
case "reset":
Expand All @@ -109,6 +130,13 @@ private void OnCommand(string command, string args) {
}
}

private void OnChatLinkClick(uint cmdId, SeString seString) {
Process.Start(new ProcessStartInfo {
FileName = "https://paissadb.zhu.codes/",
UseShellExecute = true
});
}

private void OnLogin(object _, EventArgs __) {
clientNeedsHello = true;
}
Expand Down Expand Up @@ -162,8 +190,9 @@ 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;
SeString districtName = place?.NameNoArticle.RawString.Length > 0 ? place.NameNoArticle : place?.Name; // languages like German do not use NameNoArticle (#2)
SeString worldName = Worlds.GetRow(worldId)?.Name;
// 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;

HousingLandSet landSet = HousingLandSets.GetRow(Utils.TerritoryTypeIdToLandSetId(territoryTypeId));
byte? houseSize = landSet?.PlotSize[plotNumber];
Expand Down
4 changes: 2 additions & 2 deletions autoSweep.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"Author": "zhudotexe",
"Name": "PaissaHouse",
"InternalName": "autoSweep",
"Description": "Looking for that perfect house? PaissaHouse lets you receive notifications when a new plot of land is up for sale on your home world.\n\nWant to contribute? Check out the repository (globe icon below) for instructions.",
"Description": "Looking for that perfect house? PaissaHouse lets you receive notifications when a new plot of land is up for sale on your home world.\nView the list of all houses available on a world at https://paissadb.zhu.codes/!\n\nWant to contribute? Check out the repository (globe icon below) for instructions.",
"RepoUrl": "https://github.com/zhudotexe/FFXIV_PaissaHouse",
"ApplicableVersion": "any",
"Tags": [
"housing"
],
"IconUrl": "https://raw.githubusercontent.com/zhudotexe/FFXIV_PaissaHouse/main/images/icon.png",
"Punchline": "Chat alerts for player housing.",
"Punchline": "Crowdsourced housing alerts and lottery tracking for all.",
"DalamudApiLevel": 6
}

0 comments on commit 26b3ebe

Please sign in to comment.