Skip to content

Commit

Permalink
[PR] API 11 update
Browse files Browse the repository at this point in the history
- Updated plugin for 7.1
  • Loading branch information
SheepGoMeh authored Nov 15, 2024
2 parents 650eb77 + 9566a49 commit 2fe7047
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 51 deletions.
10 changes: 5 additions & 5 deletions Visibility/Api/VisibilityApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Linq;

using Lumina.Excel.GeneratedSheets;
using Lumina.Excel.Sheets;

using Visibility.Void;

Expand Down Expand Up @@ -40,14 +40,14 @@ public void AddToVoidList(string name, uint worldId, string reason)
{
this.CheckInitialised();

World? world = Service.DataManager.GetExcelSheet<World>()?.SingleOrDefault(x => x.RowId == worldId);
World? world = Service.DataManager.GetExcelSheet<World>().SingleOrDefault(x => x.RowId == worldId);

if (world == null)
{
throw new Exception($"Invalid worldId ({worldId}).");
}

VisibilityPlugin.Instance.VoidPlayer("", $"{name} {world.Name} {reason}");
VisibilityPlugin.Instance.VoidPlayer("", $"{name} {world.Value.Name.ToString()} {reason}");
}

public void RemoveFromVoidList(string name, uint worldId)
Expand Down Expand Up @@ -92,14 +92,14 @@ public void AddToWhitelist(string name, uint worldId, string reason)
{
this.CheckInitialised();

World? world = Service.DataManager.GetExcelSheet<World>()?.SingleOrDefault(x => x.RowId == worldId);
World? world = Service.DataManager.GetExcelSheet<World>().SingleOrDefault(x => x.RowId == worldId);

if (world == null)
{
throw new Exception($"Invalid worldId ({worldId}).");
}

VisibilityPlugin.Instance.WhitelistPlayer("", $"{name} {world.Name} {reason}");
VisibilityPlugin.Instance.WhitelistPlayer("", $"{name} {world.Value.Name.ToString()} {reason}");
}

public void RemoveFromWhitelist(string name, uint worldId)
Expand Down
15 changes: 8 additions & 7 deletions Visibility/Configuration/VisibilityConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

using Dalamud.Configuration;

using Lumina.Excel.GeneratedSheets;
using Lumina.Excel.Sheets;
using Lumina.Text.ReadOnly;

using Visibility.Utils;
using Visibility.Void;
Expand Down Expand Up @@ -310,20 +311,20 @@ public void Init(ushort territoryType)
}
};

IEnumerable<(ushort, string)>? valueTuples = Service.DataManager.GameData.Excel.GetSheet<TerritoryType>()?
IEnumerable<(ushort, ReadOnlySeString)>? valueTuples = Service.DataManager.GetExcelSheet<TerritoryType>()?
.Where(
x => (x.TerritoryIntendedUse is 0 or 1 or 13 or 19 or 21 or 23 or 44 or 46 or 47 ||
this.TerritoryTypeWhitelist.Contains((ushort)x.RowId)) && !string.IsNullOrEmpty(x.Name) &&
x => (x.TerritoryIntendedUse.RowId is 0 or 1 or 13 or 19 or 21 or 23 or 44 or 46 or 47 ||
this.TerritoryTypeWhitelist.Contains((ushort)x.RowId)) && !x.Name.IsEmpty &&
x.RowId != 136)
.Select(x => ((ushort)x.RowId, x.PlaceName?.Value?.Name ?? "Unknown Place"));
.Select(x => ((ushort)x.RowId, x.PlaceName.ValueNullable?.Name ?? "Unknown Place"));

if (valueTuples != null)
{
foreach ((ushort rowId, string? placeName) in valueTuples)
foreach ((ushort rowId, ReadOnlySeString placeName) in valueTuples)
{
this.allowedTerritory.Add(rowId);
this.TerritoryTypeWhitelist.Add(rowId);
this.TerritoryPlaceNameDictionary[rowId] = placeName;
this.TerritoryPlaceNameDictionary[rowId] = placeName.ToString();
}
}

Expand Down
4 changes: 2 additions & 2 deletions Visibility/Visibility.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<LangVersion>default</LangVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Nullable>enable</Nullable>
<AssemblyVersion>1.1.8.1</AssemblyVersion>
<AssemblyVersion>1.1.8.2</AssemblyVersion>
<FileVersion>$(AssemblyVersion)</FileVersion>
<IsPackable>false</IsPackable>
<Authors>SheepGoMeh</Authors>
Expand Down Expand Up @@ -61,7 +61,7 @@
</Reference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="DalamudPackager" Version="2.1.13" />
<PackageReference Include="DalamudPackager" Version="11.0.0" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\Resources.Designer.cs">
Expand Down
63 changes: 30 additions & 33 deletions Visibility/VisibilityPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@
using Dalamud.Plugin;
using Dalamud.Plugin.Services;

using Lumina.Excel.GeneratedSheets;

using Visibility.Api;
using Visibility.Configuration;
using Visibility.Ipc;
using Visibility.Utils;
using Visibility.Void;
using FFXIVClientStructs.FFXIV.Client.Game.Character;
using FFXIVClientStructs.FFXIV.Client.Game.Object;

using Lumina.Excel.Sheets;

namespace Visibility;

Expand Down Expand Up @@ -345,12 +344,11 @@ public void VoidPlayer(string command, string arguments)
return;
}

World? world = Service.DataManager.GetExcelSheet<World>()?.SingleOrDefault(
x =>
x.DataCenter.Value?.Region != 0 &&
x.Name.ToString().Equals(args[2], StringComparison.InvariantCultureIgnoreCase));
World? world = Service.DataManager.GetExcelSheet<World>().SingleOrDefault(x =>
x.DataCenter.ValueNullable?.Region != 0 &&
x.Name.ToString().Equals(args[2], StringComparison.InvariantCultureIgnoreCase));

if (world == default(World))
if (world is null)
{
Service.ChatGui.Print(
this.PluginLocalization.InvalidWorldNameError(this.PluginLocalization.VoidListName, args[2]));
Expand All @@ -361,7 +359,7 @@ public void VoidPlayer(string command, string arguments)

VoidItem voidItem;
IGameObject? playerCharacter = Service.ObjectTable.SingleOrDefault(
x => x is IPlayerCharacter character && character.HomeWorld.Id == world.RowId &&
x => x is IPlayerCharacter character && character.HomeWorld.Value.RowId == world.Value.RowId &&
character.Name.TextValue.Equals(playerName, StringComparison.InvariantCultureIgnoreCase)) as IPlayerCharacter;

if (playerCharacter != null)
Expand All @@ -373,8 +371,8 @@ public void VoidPlayer(string command, string arguments)
{
Id = character->AccountId,
Name = character->NameString,
HomeworldId = world.RowId,
HomeworldName = world.Name,
HomeworldId = world.Value.RowId,
HomeworldName = world.Value.Name.ToString(),
Reason = args.Length == 3 ? string.Empty : args[3],
Manual = command == "VoidUIManual"
};
Expand All @@ -385,17 +383,17 @@ public void VoidPlayer(string command, string arguments)
voidItem = new VoidItem
{
Name = playerName,
HomeworldId = world.RowId,
HomeworldName = world.Name,
HomeworldId = world.Value.RowId,
HomeworldName = world.Value.Name.ToString(),
Reason = args.Length == 3 ? string.Empty : args[3],
Manual = command == "VoidUIManual"
};
}

SeString playerString = new(
new PlayerPayload(playerName, world.RowId),
new PlayerPayload(playerName, world.Value.RowId),
new IconPayload(BitmapFontIcon.CrossWorld),
new TextPayload(world.Name));
new TextPayload(world.Value.Name.ToString()));

if (!this.Configuration.VoidList.Any(
x =>
Expand Down Expand Up @@ -438,16 +436,16 @@ public void VoidTargetPlayer(string command, string arguments)
Id = character->AccountId,
Name = character->NameString,
HomeworldId = character->HomeWorld,
HomeworldName = playerCharacter.HomeWorld.GameData!.Name,
HomeworldName = playerCharacter.HomeWorld.Value.Name.ToString(),
Reason = arguments,
Manual = false
};
}

SeString playerString = new(
new PlayerPayload(playerCharacter.Name.TextValue, playerCharacter.HomeWorld.GameData!.RowId),
new PlayerPayload(playerCharacter.Name.TextValue, playerCharacter.HomeWorld.Value.RowId),
new IconPayload(BitmapFontIcon.CrossWorld),
new TextPayload(playerCharacter.HomeWorld.GameData!.Name));
new TextPayload(playerCharacter.HomeWorld.Value.Name.ToString()));

if (!this.Configuration.VoidList.Any(
x =>
Expand Down Expand Up @@ -488,12 +486,11 @@ public void WhitelistPlayer(string command, string arguments)
return;
}

World? world = Service.DataManager.GetExcelSheet<World>()?.SingleOrDefault(
x =>
x.DataCenter.Value?.Region != 0 &&
x.Name.ToString().Equals(args[2], StringComparison.InvariantCultureIgnoreCase));
World? world = Service.DataManager.GetExcelSheet<World>().SingleOrDefault(x =>
x.DataCenter.ValueNullable?.Region != 0 &&
x.Name.ToString().Equals(args[2], StringComparison.InvariantCultureIgnoreCase));

if (world == default(World))
if (world is null)
{
Service.ChatGui.Print(
this.PluginLocalization.InvalidWorldNameError(this.PluginLocalization.WhitelistName, args[2]));
Expand All @@ -504,7 +501,7 @@ public void WhitelistPlayer(string command, string arguments)

IPlayerCharacter? playerCharacter = Service.ObjectTable.SingleOrDefault(
x =>
x is IPlayerCharacter character && character.HomeWorld.Id == world.RowId &&
x is IPlayerCharacter character && character.HomeWorld.Value.RowId == world.Value.RowId &&
character.Name.TextValue.Equals(playerName, StringComparison.Ordinal)) as IPlayerCharacter;

VoidItem item;
Expand All @@ -518,8 +515,8 @@ public void WhitelistPlayer(string command, string arguments)
{
Id = character->ContentId,
Name = character->NameString,
HomeworldId = world.RowId,
HomeworldName = world.Name,
HomeworldId = world.Value.RowId,
HomeworldName = world.Value.Name.ToString(),
Reason = args.Length == 3 ? string.Empty : args[3],
Manual = command == "WhitelistUIManual"
};
Expand All @@ -530,17 +527,17 @@ public void WhitelistPlayer(string command, string arguments)
item = new VoidItem
{
Name = playerName,
HomeworldId = world.RowId,
HomeworldName = world.Name,
HomeworldId = world.Value.RowId,
HomeworldName = world.Value.Name.ToString(),
Reason = args.Length == 3 ? string.Empty : args[3],
Manual = command == "WhitelistUIManual"
};
}

SeString playerString = new(
new PlayerPayload(playerName, world.RowId),
new PlayerPayload(playerName, world.Value.RowId),
new IconPayload(BitmapFontIcon.CrossWorld),
new TextPayload(world.Name));
new TextPayload(world.Value.Name.ToString()));

if (!this.Configuration.Whitelist.Any(
x =>
Expand Down Expand Up @@ -584,16 +581,16 @@ public void WhitelistTargetPlayer(string command, string arguments)
Id = character->ContentId,
Name = character->NameString,
HomeworldId = character->HomeWorld,
HomeworldName = playerCharacter.HomeWorld.GameData!.Name,
HomeworldName = playerCharacter.HomeWorld.Value.Name.ToString(),
Reason = arguments,
Manual = false
};
}

SeString playerString = new(
new PlayerPayload(playerCharacter.Name.TextValue, playerCharacter.HomeWorld.GameData!.RowId),
new PlayerPayload(playerCharacter.Name.TextValue, playerCharacter.HomeWorld.Value.RowId),
new IconPayload(BitmapFontIcon.CrossWorld),
new TextPayload(playerCharacter.HomeWorld.GameData!.Name));
new TextPayload(playerCharacter.HomeWorld.Value.Name.ToString()));

if (!this.Configuration.Whitelist.Any(
x =>
Expand Down
2 changes: 1 addition & 1 deletion Visibility/Windows/VoidItemList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public override void Draw()

Encoding.Default.GetBytes(actor.GetFirstname()).CopyTo(this.buffer[0], 0);
Encoding.Default.GetBytes(actor.GetLastname()).CopyTo(this.buffer[1], 0);
Encoding.Default.GetBytes(actor.HomeWorld.GameData!.Name).CopyTo(this.buffer[2], 0);
Encoding.Default.GetBytes(actor.HomeWorld.Value.Name.ToString()).CopyTo(this.buffer[2], 0);

manual = false;
}
Expand Down
6 changes: 3 additions & 3 deletions Visibility/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=="
}
}
}
Expand Down

0 comments on commit 2fe7047

Please sign in to comment.