Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 25 additions & 13 deletions UIOptimization/FriendlistTeleporter.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System.Linq;
using DailyRoutines.Abstracts;
using DailyRoutines.Infos;
using DailyRoutines.Managers;
using Dalamud.Game.Gui.ContextMenu;
using FFXIVClientStructs.FFXIV.Client.Game.UI;
using System.Linq;

namespace DailyRoutines.Modules;

Expand Down Expand Up @@ -34,10 +34,17 @@ public override void Uninit()

private static void OnMenuOpen(IMenuOpenedArgs args)
{
if (TeleportItem.IsDisplay(args))
args.AddMenuItem(TeleportItem.Get());
if (ModuleManager.IsModuleEnabled("WorldTravelCommand") == true && CrossWorldItem.IsDisplay(args))
args.AddMenuItem(CrossWorldItem.Get());
try
{
if (TeleportItem.IsDisplay(args))
args.AddMenuItem(TeleportItem.Get());
} catch { }
try
{
if (ModuleManager.IsModuleEnabled("WorldTravelCommand") == true && CrossWorldItem.IsDisplay(args))
args.AddMenuItem(CrossWorldItem.Get());
} catch { }

}

private class TeleportMenuItem : MenuItemBase
Expand All @@ -50,7 +57,7 @@ private class TeleportMenuItem : MenuItemBase

public override bool IsDisplay(IMenuOpenedArgs args) => args.AddonName == "FriendList"
&& args.Target is MenuTargetDefault target
&& target.TargetCharacter?.Location.Value is not null
&& target.TargetCharacter is not null

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 代码质量

    • 必要性:该修改主要是移除了对OmenToolsOmenTools.Helpers的引用,并调整了try-catch块的逻辑结构。这些修改是有必要的,因为它们简化了代码结构并移除了不必要的依赖。
    • 逻辑错误:在OnMenuOpen方法中,try-catch块的调整可能会导致异常处理不够细致。原本的try-catch块是分开处理两个不同的逻辑,现在合并为一个try-catch块,可能会导致异常信息丢失或处理不当。
    • 兼容性:移除OmenToolsOmenTools.Helpers的引用可能会影响依赖于这些库的其他模块,需要确保这些模块不再需要这些依赖。
    • 代码结构优化try-catch块的结构可以进一步优化,建议将两个不同的逻辑分开处理,以便更好地捕获和处理异常。
    • 性能问题:没有明显的性能问题。
  2. 安全性

    • 敏感信息泄露:没有发现敏感信息泄露的风险。
    • 外部代码运行:没有发现运行来路不明的外部代码的风险。

改进建议

  • 建议将OnMenuOpen方法中的try-catch块分开处理,以便更好地捕获和处理异常。
  • 确保移除OmenToolsOmenTools.Helpers的引用不会影响其他模块的功能。

&& GetAetheryteId(
target.TargetCharacter.Location.Value.RowId,
out aetheryteID);
Expand Down Expand Up @@ -98,15 +105,20 @@ protected override void OnClicked(IMenuItemClickedArgs args)
public override bool IsDisplay(IMenuOpenedArgs args)
{
if (args.AddonName != "FriendList") return false;

if (args.Target is MenuTargetDefault { TargetCharacter.CurrentWorld.Value: { RowId: var _targetWorldID } } &&
_targetWorldID != DService.ClientState.LocalPlayer.CurrentWorld.Value.RowId)
try
{
targetWorldID = _targetWorldID;
return true;
if (args.Target is MenuTargetDefault { TargetCharacter.CurrentWorld.RowId: var _targetWorldID } &&
_targetWorldID !=DService.ClientState.LocalPlayer.CurrentWorld.RowId)
{
targetWorldID = _targetWorldID;
return true;
}
return false;
}
catch
{
return false;
}

return false;
}
}
}