-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f6f6e66
commit 3b24206
Showing
17 changed files
with
1,716 additions
and
1,734 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,56 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace Visibility.Api | ||
namespace Visibility.Api; | ||
|
||
public interface IVisibilityApi | ||
{ | ||
public interface IVisibilityApi | ||
{ | ||
public int ApiVersion { get; } | ||
|
||
/// <summary> | ||
/// Fetch all entries from VoidList | ||
/// </summary> | ||
/// <returns>A collection of strings in the form of (name worldId reason)</returns> | ||
public IEnumerable<string> GetVoidListEntries(); | ||
|
||
/// <summary> | ||
/// Adds entry to VoidList | ||
/// </summary> | ||
/// <param name="name">Full player name</param> | ||
/// <param name="worldId">World ID</param> | ||
/// <param name="reason">Reason for adding</param> | ||
public void AddToVoidList(string name, uint worldId, string reason); | ||
|
||
/// <summary> | ||
/// Removes entry from VoidList | ||
/// </summary> | ||
/// <param name="name">Full player name</param> | ||
/// <param name="worldId">World ID</param> | ||
public void RemoveFromVoidList(string name, uint worldId); | ||
|
||
/// <summary> | ||
/// Fetch all entries from Whitelist | ||
/// </summary> | ||
/// <returns>A collection of strings in the form of (name worldId reason)</returns> | ||
public IEnumerable<string> GetWhitelistEntries(); | ||
|
||
/// <summary> | ||
/// Adds entry to Whitelist | ||
/// </summary> | ||
/// <param name="name">Full player name</param> | ||
/// <param name="worldId">World ID</param> | ||
/// <param name="reason">Reason for adding</param> | ||
public void AddToWhitelist(string name, uint worldId, string reason); | ||
|
||
/// <summary> | ||
/// Removes entry from Whitelist | ||
/// </summary> | ||
/// <param name="name">Full player name</param> | ||
/// <param name="worldId">World ID</param> | ||
public void RemoveFromWhitelist(string name, uint worldId); | ||
|
||
/// <summary> | ||
/// Enables or disables Visibility | ||
/// </summary> | ||
/// <param name="state">Enabled = true</param> | ||
public void Enable(bool state); | ||
} | ||
} | ||
public int ApiVersion { get; } | ||
|
||
/// <summary> | ||
/// Fetch all entries from VoidList | ||
/// </summary> | ||
/// <returns>A collection of strings in the form of (name worldId reason)</returns> | ||
public IEnumerable<string> GetVoidListEntries(); | ||
|
||
/// <summary> | ||
/// Adds entry to VoidList | ||
/// </summary> | ||
/// <param name="name">Full player name</param> | ||
/// <param name="worldId">World ID</param> | ||
/// <param name="reason">Reason for adding</param> | ||
public void AddToVoidList(string name, uint worldId, string reason); | ||
|
||
/// <summary> | ||
/// Removes entry from VoidList | ||
/// </summary> | ||
/// <param name="name">Full player name</param> | ||
/// <param name="worldId">World ID</param> | ||
public void RemoveFromVoidList(string name, uint worldId); | ||
|
||
/// <summary> | ||
/// Fetch all entries from Whitelist | ||
/// </summary> | ||
/// <returns>A collection of strings in the form of (name worldId reason)</returns> | ||
public IEnumerable<string> GetWhitelistEntries(); | ||
|
||
/// <summary> | ||
/// Adds entry to Whitelist | ||
/// </summary> | ||
/// <param name="name">Full player name</param> | ||
/// <param name="worldId">World ID</param> | ||
/// <param name="reason">Reason for adding</param> | ||
public void AddToWhitelist(string name, uint worldId, string reason); | ||
|
||
/// <summary> | ||
/// Removes entry from Whitelist | ||
/// </summary> | ||
/// <param name="name">Full player name</param> | ||
/// <param name="worldId">World ID</param> | ||
public void RemoveFromWhitelist(string name, uint worldId); | ||
|
||
/// <summary> | ||
/// Enables or disables Visibility | ||
/// </summary> | ||
/// <param name="state">Enabled = true</param> | ||
public void Enable(bool state); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,132 +1,126 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
using Lumina.Excel.GeneratedSheets; | ||
|
||
namespace Visibility.Api | ||
using Visibility.Void; | ||
|
||
namespace Visibility.Api; | ||
|
||
public class VisibilityApi: IDisposable, IVisibilityApi | ||
{ | ||
public class VisibilityApi : IDisposable, IVisibilityApi | ||
{ | ||
public int ApiVersion => 1; | ||
public int ApiVersion => 1; | ||
|
||
private bool initialised; | ||
private bool initialised; | ||
|
||
public VisibilityApi() | ||
{ | ||
this.initialised = true; | ||
} | ||
public VisibilityApi() => this.initialised = true; | ||
|
||
private void CheckInitialised() | ||
private void CheckInitialised() | ||
{ | ||
if (!this.initialised) | ||
{ | ||
if (!this.initialised) | ||
{ | ||
throw new Exception("PluginShare is not initialised."); | ||
} | ||
throw new Exception("PluginShare is not initialised."); | ||
} | ||
} | ||
|
||
public IEnumerable<string> GetVoidListEntries() | ||
{ | ||
this.CheckInitialised(); | ||
|
||
return VisibilityPlugin | ||
.Instance | ||
.Configuration | ||
.VoidList | ||
.Select(x => $"{x.Name} {x.HomeworldId} {x.Reason}") | ||
.ToList(); | ||
} | ||
|
||
public void AddToVoidList(string name, uint worldId, string reason) | ||
{ | ||
this.CheckInitialised(); | ||
|
||
World? world = Service.DataManager.GetExcelSheet<World>()?.SingleOrDefault(x => x.RowId == worldId); | ||
|
||
public IEnumerable<string> GetVoidListEntries() | ||
if (world == null) | ||
{ | ||
this.CheckInitialised(); | ||
|
||
return VisibilityPlugin | ||
.Instance | ||
.Configuration | ||
.VoidList | ||
.Select(x => $"{x.Name} {x.HomeworldId} {x.Reason}") | ||
.ToList(); | ||
throw new Exception($"Invalid worldId ({worldId})."); | ||
} | ||
|
||
public void AddToVoidList(string name, uint worldId, string reason) | ||
{ | ||
this.CheckInitialised(); | ||
VisibilityPlugin.Instance.VoidPlayer("", $"{name} {world.Name} {reason}"); | ||
} | ||
|
||
var world = Service.DataManager.GetExcelSheet<World>()?.SingleOrDefault(x => x.RowId == worldId); | ||
public void RemoveFromVoidList(string name, uint worldId) | ||
{ | ||
this.CheckInitialised(); | ||
|
||
if (world == null) | ||
{ | ||
throw new Exception($"Invalid worldId ({worldId})."); | ||
} | ||
VoidItem? item = VisibilityPlugin.Instance.Configuration.VoidList.SingleOrDefault( | ||
x => x.Name == name && x.HomeworldId == worldId); | ||
|
||
VisibilityPlugin.Instance.VoidPlayer("", $"{name} {world.Name} {reason}"); | ||
} | ||
|
||
public void RemoveFromVoidList(string name, uint worldId) | ||
if (item == null) | ||
{ | ||
this.CheckInitialised(); | ||
|
||
var item = VisibilityPlugin.Instance.Configuration.VoidList.SingleOrDefault( | ||
x => x.Name == name && x.HomeworldId == worldId); | ||
|
||
if (item == null) | ||
{ | ||
return; | ||
} | ||
|
||
VisibilityPlugin.Instance.Configuration.VoidList.Remove(item); | ||
VisibilityPlugin.Instance.Configuration.Save(); | ||
|
||
if (item.ObjectId > 0) | ||
{ | ||
VisibilityPlugin.Instance.RemoveChecked(item.ObjectId); | ||
VisibilityPlugin.Instance.ShowPlayer(item.ObjectId); | ||
} | ||
else | ||
{ | ||
VisibilityPlugin.Instance.RemoveChecked(item.Name); | ||
} | ||
return; | ||
} | ||
|
||
public IEnumerable<string> GetWhitelistEntries() | ||
VisibilityPlugin.Instance.Configuration.VoidList.Remove(item); | ||
VisibilityPlugin.Instance.Configuration.Save(); | ||
|
||
if (item.ObjectId > 0) | ||
{ | ||
this.CheckInitialised(); | ||
|
||
return VisibilityPlugin | ||
.Instance | ||
.Configuration | ||
.Whitelist | ||
.Select(x => $"{x.Name} {x.HomeworldId} {x.Reason}") | ||
.ToList(); | ||
VisibilityPlugin.Instance.RemoveChecked(item.ObjectId); | ||
VisibilityPlugin.Instance.ShowPlayer(item.ObjectId); | ||
} | ||
|
||
public void AddToWhitelist(string name, uint worldId, string reason) | ||
else | ||
{ | ||
this.CheckInitialised(); | ||
VisibilityPlugin.Instance.RemoveChecked(item.Name); | ||
} | ||
} | ||
|
||
var world = Service.DataManager.GetExcelSheet<World>()?.SingleOrDefault(x => x.RowId == worldId); | ||
public IEnumerable<string> GetWhitelistEntries() | ||
{ | ||
this.CheckInitialised(); | ||
|
||
return VisibilityPlugin | ||
.Instance | ||
.Configuration | ||
.Whitelist | ||
.Select(x => $"{x.Name} {x.HomeworldId} {x.Reason}") | ||
.ToList(); | ||
} | ||
|
||
if (world == null) | ||
{ | ||
throw new Exception($"Invalid worldId ({worldId})."); | ||
} | ||
public void AddToWhitelist(string name, uint worldId, string reason) | ||
{ | ||
this.CheckInitialised(); | ||
|
||
VisibilityPlugin.Instance.WhitelistPlayer("", $"{name} {world.Name} {reason}"); | ||
} | ||
World? world = Service.DataManager.GetExcelSheet<World>()?.SingleOrDefault(x => x.RowId == worldId); | ||
|
||
public void RemoveFromWhitelist(string name, uint worldId) | ||
if (world == null) | ||
{ | ||
this.CheckInitialised(); | ||
throw new Exception($"Invalid worldId ({worldId})."); | ||
} | ||
|
||
var item = VisibilityPlugin.Instance.Configuration.Whitelist.SingleOrDefault( | ||
x => x.Name == name && x.HomeworldId == worldId); | ||
VisibilityPlugin.Instance.WhitelistPlayer("", $"{name} {world.Name} {reason}"); | ||
} | ||
|
||
if (item == null) | ||
{ | ||
return; | ||
} | ||
public void RemoveFromWhitelist(string name, uint worldId) | ||
{ | ||
this.CheckInitialised(); | ||
|
||
VisibilityPlugin.Instance.Configuration.Whitelist.Remove(item); | ||
VisibilityPlugin.Instance.Configuration.Save(); | ||
} | ||
VoidItem? item = VisibilityPlugin.Instance.Configuration.Whitelist.SingleOrDefault( | ||
x => x.Name == name && x.HomeworldId == worldId); | ||
|
||
public void Enable(bool state) | ||
if (item == null) | ||
{ | ||
VisibilityPlugin.Instance.Configuration | ||
.SettingDictionary[nameof(VisibilityPlugin.Instance.Configuration.Enabled)].Invoke(state, false, false); | ||
return; | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
this.initialised = false; | ||
} | ||
VisibilityPlugin.Instance.Configuration.Whitelist.Remove(item); | ||
VisibilityPlugin.Instance.Configuration.Save(); | ||
} | ||
} | ||
|
||
public void Enable(bool state) => | ||
VisibilityPlugin.Instance.Configuration | ||
.SettingDictionary[nameof(VisibilityPlugin.Instance.Configuration.Enabled)].Invoke(state, false, false); | ||
|
||
public void Dispose() => this.initialised = false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.