From 26b3ebec690786492b8da05181da2368c0178a98 Mon Sep 17 00:00:00 2001 From: Andrew Zhu Date: Mon, 30 May 2022 16:14:52 -0700 Subject: [PATCH] feat: add link to paissadb --- AutoSweep.csproj | 2 +- Paissa/Utils.cs | 1 + Plugin.cs | 43 ++++++++++++++++++++++++++++++++++++------- autoSweep.json | 4 ++-- 4 files changed, 40 insertions(+), 10 deletions(-) diff --git a/AutoSweep.csproj b/AutoSweep.csproj index af551a1..9daf5c6 100644 --- a/AutoSweep.csproj +++ b/AutoSweep.csproj @@ -14,7 +14,7 @@ $(appdata)\XIVLauncher\addon\Hooks\dev\ true autoSweep - 1.3.1.0 + 1.4.0.0 diff --git a/Paissa/Utils.cs b/Paissa/Utils.cs index c3c2614..da28cfc 100644 --- a/Paissa/Utils.cs +++ b/Paissa/Utils.cs @@ -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) { diff --git a/Plugin.cs b/Plugin.cs index 7b02da9..470dd36 100644 --- a/Plugin.cs +++ b/Plugin.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; using AutoSweep.Paissa; using AutoSweep.Structures; using Dalamud.Data; @@ -8,17 +9,19 @@ 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; @@ -26,12 +29,12 @@ public class Plugin : IDalamudPlugin { internal readonly DataManager Data; internal readonly Framework Framework; internal readonly GameNetwork Network; - internal readonly GameGui GameGui; internal readonly PaissaClient PaissaClient; internal readonly ExcelSheet HousingLandSets; internal readonly ExcelSheet Territories; internal readonly ExcelSheet Worlds; + private readonly DalamudLinkPayload chatLinkPayload; // state private readonly WardObserver wardObserver; @@ -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(); @@ -65,10 +67,15 @@ GameGui gameGui Worlds = data.GetExcelSheet(); HousingLandSets = data.GetExcelSheet(); + 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; @@ -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": @@ -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; } @@ -162,8 +190,9 @@ private void OnPlotUpdate(object sender, PlotUpdateEventArgs e) { /// 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]; diff --git a/autoSweep.json b/autoSweep.json index 1c5be98..2663d3f 100644 --- a/autoSweep.json +++ b/autoSweep.json @@ -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 }