fix: don't run in pvp
This commit is contained in:
parent
c49eae0cf3
commit
11293a01ae
|
@ -24,6 +24,12 @@
|
|||
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\ImGuiScene.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Lumina, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null">
|
||||
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\Lumina.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Lumina.Excel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
|
||||
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\Lumina.Excel.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SharpDX.Mathematics, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1">
|
||||
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\SharpDX.Mathematics.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
using Dalamud.Game.Command;
|
||||
using Dalamud.Plugin;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Lumina.Excel.GeneratedSheets;
|
||||
|
||||
namespace PeepingTom {
|
||||
public class PeepingTomPlugin : IDalamudPlugin {
|
||||
|
@ -12,6 +14,8 @@ namespace PeepingTom {
|
|||
internal TargetWatcher Watcher { get; private set; } = null!;
|
||||
internal GameFunctions GameFunctions { get; private set; } = null!;
|
||||
|
||||
internal bool InPvp { get; private set; }
|
||||
|
||||
public void Initialize(DalamudPluginInterface pluginInterface) {
|
||||
this.Interface = pluginInterface ?? throw new ArgumentNullException(nameof(pluginInterface), "DalamudPluginInterface argument was null");
|
||||
this.Config = this.Interface.GetPluginConfig() as Configuration ?? new Configuration();
|
||||
|
@ -21,24 +25,34 @@ namespace PeepingTom {
|
|||
this.Ui = new PluginUi(this);
|
||||
|
||||
this.Interface.CommandManager.AddHandler("/ppeepingtom", new CommandInfo(this.OnCommand) {
|
||||
HelpMessage = "Use with no arguments to show the list. Use with \"c\" or \"config\" to show the config"
|
||||
HelpMessage = "Use with no arguments to show the list. Use with \"c\" or \"config\" to show the config",
|
||||
});
|
||||
this.Interface.CommandManager.AddHandler("/ptom", new CommandInfo(this.OnCommand) {
|
||||
HelpMessage = "Alias for /ppeepingtom"
|
||||
HelpMessage = "Alias for /ppeepingtom",
|
||||
});
|
||||
this.Interface.CommandManager.AddHandler("/ppeep", new CommandInfo(this.OnCommand) {
|
||||
HelpMessage = "Alias for /ppeepingtom"
|
||||
HelpMessage = "Alias for /ppeepingtom",
|
||||
});
|
||||
|
||||
this.Interface.Framework.OnUpdateEvent += this.Watcher.OnFrameworkUpdate;
|
||||
this.Interface.ClientState.OnLogin += this.OnLogin;
|
||||
this.Interface.ClientState.OnLogout += this.OnLogout;
|
||||
this.Interface.ClientState.TerritoryChanged += this.OnTerritoryChange;
|
||||
this.Interface.UiBuilder.OnBuildUi += this.DrawUi;
|
||||
this.Interface.UiBuilder.OnOpenConfigUi += this.ConfigUi;
|
||||
|
||||
this.Watcher.StartThread();
|
||||
}
|
||||
|
||||
private void OnTerritoryChange(object sender, ushort e) {
|
||||
try {
|
||||
var territory = this.Interface.Data.GetExcelSheet<TerritoryType>().GetRow(e);
|
||||
this.InPvp = territory.IsPvpZone;
|
||||
} catch (KeyNotFoundException) {
|
||||
PluginLog.Warning("Could not get territory for current zone");
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCommand(string command, string args) {
|
||||
if (args == "config" || args == "c") {
|
||||
this.Ui.SettingsOpen = true;
|
||||
|
@ -60,7 +74,7 @@ namespace PeepingTom {
|
|||
this.Watcher.ClearPrevious();
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool includeManaged) {
|
||||
public void Dispose() {
|
||||
this.Interface.Framework.OnUpdateEvent -= this.Watcher.OnFrameworkUpdate;
|
||||
this.Interface.ClientState.OnLogin -= this.OnLogin;
|
||||
this.Interface.ClientState.OnLogout -= this.OnLogout;
|
||||
|
@ -74,11 +88,6 @@ namespace PeepingTom {
|
|||
this.Ui.Dispose();
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
this.Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
private void DrawUi() {
|
||||
this.Ui.Draw();
|
||||
}
|
||||
|
|
|
@ -40,6 +40,10 @@ namespace PeepingTom {
|
|||
}
|
||||
|
||||
public void Draw() {
|
||||
if (this.Plugin.InPvp) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.SettingsOpen) {
|
||||
this.ShowSettings();
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ namespace PeepingTom {
|
|||
}
|
||||
|
||||
public void OnFrameworkUpdate(Framework framework) {
|
||||
if (!this._needsUpdate) {
|
||||
if (!this._needsUpdate || this.Plugin.InPvp) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue