Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 1 addition & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ concurrency:
cancel-in-progress: true

env:
EXILED_REFERENCES_URL: https://misaka-zerotwo.github.io/SL-References/Dev.zip
EXILED_REFERENCES_URL: https://exslmod-team.github.io/SL-References/Dev.zip
EXILED_REFERENCES: ${{ github.workspace }}/refs
NWAPIPERMSYSTEM_URL: https://github.com/CedModV2/NWAPIPermissionSystem/releases/latest/download/NWAPIPermissionSystem.dll

jobs:
main:
Expand Down Expand Up @@ -41,11 +40,6 @@ jobs:
Invoke-WebRequest -Uri ${{ env.EXILED_REFERENCES_URL }} -OutFile ${{ github.workspace }}/References.zip
Expand-Archive -Path References.zip -DestinationPath ${{ env.EXILED_REFERENCES }} -Force

- name: Get nwapipermissionsystem
shell: pwsh
run: |
Invoke-WebRequest -Uri ${{ env.NWAPIPERMSYSTEM_URL }} -OutFile ${{ env.EXILED_REFERENCES }}/NWAPIPermissionSystem.dll

- name: Restore Packages
run: nuget restore ${{ github.workspace }}/XPSystem.sln

Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ You can always request more features by messaging me on discord: `moddedmcplayer
# Installation
Drag and drop plugin into the plugins folder. <br>
Use -nw-bundled instead of -nw if you are getting an error regarding missing 0Harmony.
### NWAPI version also requires
- https://github.com/CedModV2/NWAPIPermissionSystem/releases/latest
### ~~NWAPI version also requires~~
- ~~https://github.com/CedModV2/NWAPIPermissionSystem/releases/latest~~
- Uses LapAPI perms now, nw version still missing: generator, throw, and door events

## READ: If you have previously (before version 2.0) used the plugin and your data is gone,
Run `xps migrate` in the server console to migrate the old database.
Expand Down
6 changes: 5 additions & 1 deletion XPSystem.Console/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="NorthwoodLib" publicKeyToken="null" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.3.1.0" newVersion="1.3.1.0" />
<bindingRedirect oldVersion="0.0.0.0-1.4.0.0" newVersion="1.4.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="LabApi" publicKeyToken="null" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.0.0.0" newVersion="1.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
Expand Down
42 changes: 21 additions & 21 deletions XPSystem.Console/XPSystem.Console.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,44 +43,44 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ExMod.Exiled.9.1.1\lib\net48\Assembly-CSharp-Publicized.dll</HintPath>
<HintPath>..\packages\ExMod.Exiled.9.6.0\lib\net48\Assembly-CSharp-Publicized.dll</HintPath>
</Reference>
<Reference Include="CommandSystem.Core, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ExMod.Exiled.9.1.1\lib\net48\CommandSystem.Core.dll</HintPath>
<HintPath>..\packages\ExMod.Exiled.9.6.0\lib\net48\CommandSystem.Core.dll</HintPath>
</Reference>
<Reference Include="Exiled.API, Version=9.1.1.0, Culture=neutral, processorArchitecture=Amd64">
<HintPath>..\packages\ExMod.Exiled.9.1.1\lib\net48\Exiled.API.dll</HintPath>
<Reference Include="Exiled.API, Version=9.6.0.0, Culture=neutral, processorArchitecture=Amd64">
<HintPath>..\packages\ExMod.Exiled.9.6.0\lib\net48\Exiled.API.dll</HintPath>
</Reference>
<Reference Include="Exiled.CreditTags, Version=9.1.1.0, Culture=neutral, processorArchitecture=Amd64">
<HintPath>..\packages\ExMod.Exiled.9.1.1\lib\net48\Exiled.CreditTags.dll</HintPath>
<Reference Include="Exiled.CreditTags, Version=9.6.0.0, Culture=neutral, processorArchitecture=Amd64">
<HintPath>..\packages\ExMod.Exiled.9.6.0\lib\net48\Exiled.CreditTags.dll</HintPath>
</Reference>
<Reference Include="Exiled.CustomItems, Version=9.1.1.0, Culture=neutral, processorArchitecture=Amd64">
<HintPath>..\packages\ExMod.Exiled.9.1.1\lib\net48\Exiled.CustomItems.dll</HintPath>
<Reference Include="Exiled.CustomItems, Version=9.6.0.0, Culture=neutral, processorArchitecture=Amd64">
<HintPath>..\packages\ExMod.Exiled.9.6.0\lib\net48\Exiled.CustomItems.dll</HintPath>
</Reference>
<Reference Include="Exiled.CustomRoles, Version=9.1.1.0, Culture=neutral, processorArchitecture=Amd64">
<HintPath>..\packages\ExMod.Exiled.9.1.1\lib\net48\Exiled.CustomRoles.dll</HintPath>
<Reference Include="Exiled.CustomRoles, Version=9.6.0.0, Culture=neutral, processorArchitecture=Amd64">
<HintPath>..\packages\ExMod.Exiled.9.6.0\lib\net48\Exiled.CustomRoles.dll</HintPath>
</Reference>
<Reference Include="Exiled.Events, Version=9.1.1.0, Culture=neutral, processorArchitecture=Amd64">
<HintPath>..\packages\ExMod.Exiled.9.1.1\lib\net48\Exiled.Events.dll</HintPath>
<Reference Include="Exiled.Events, Version=9.6.0.0, Culture=neutral, processorArchitecture=Amd64">
<HintPath>..\packages\ExMod.Exiled.9.6.0\lib\net48\Exiled.Events.dll</HintPath>
</Reference>
<Reference Include="Exiled.Loader, Version=9.1.1.0, Culture=neutral, processorArchitecture=Amd64">
<HintPath>..\packages\ExMod.Exiled.9.1.1\lib\net48\Exiled.Loader.dll</HintPath>
<Reference Include="Exiled.Loader, Version=9.6.0.0, Culture=neutral, processorArchitecture=Amd64">
<HintPath>..\packages\ExMod.Exiled.9.6.0\lib\net48\Exiled.Loader.dll</HintPath>
</Reference>
<Reference Include="Exiled.Permissions, Version=9.1.1.0, Culture=neutral, processorArchitecture=Amd64">
<HintPath>..\packages\ExMod.Exiled.9.1.1\lib\net48\Exiled.Permissions.dll</HintPath>
<Reference Include="Exiled.Permissions, Version=9.6.0.0, Culture=neutral, processorArchitecture=Amd64">
<HintPath>..\packages\ExMod.Exiled.9.6.0\lib\net48\Exiled.Permissions.dll</HintPath>
</Reference>
<Reference Include="NorthwoodLib, Version=1.3.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ExMod.Exiled.9.1.1\lib\net48\NorthwoodLib.dll</HintPath>
<Reference Include="LabApi, Version=1.0.0.0, Culture=neutral, processorArchitecture=Amd64">
<HintPath>..\packages\ExMod.Exiled.9.6.0\lib\net48\LabApi.dll</HintPath>
</Reference>
<Reference Include="PluginAPI, Version=13.1.5.0, Culture=neutral, processorArchitecture=Amd64">
<HintPath>..\packages\ExMod.Exiled.9.1.1\lib\net48\PluginAPI.dll</HintPath>
<Reference Include="NorthwoodLib, Version=1.4.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ExMod.Exiled.9.6.0\lib\net48\NorthwoodLib.dll</HintPath>
</Reference>
<Reference Include="System"/>
<Reference Include="System.Core"/>
<Reference Include="System.Data"/>
<Reference Include="System.Xml"/>
<Reference Include="YamlDotNet, Version=11.0.0.0, Culture=neutral, PublicKeyToken=ec19458f3c15af5e, processorArchitecture=MSIL">
<HintPath>..\packages\ExMod.Exiled.9.1.1\lib\net48\YamlDotNet.dll</HintPath>
<HintPath>..\packages\ExMod.Exiled.9.6.0\lib\net48\YamlDotNet.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion XPSystem.Console/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="ExMod.Exiled" version="9.1.1" targetFramework="net48" />
<package id="ExMod.Exiled" version="9.6.0" targetFramework="net48" />
</packages>
8 changes: 5 additions & 3 deletions XPSystem/API/DisplayProviders/SyncVarXPDisplayProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ protected override void RefreshToEnabled(XPPlayer player)

foreach (var kvp in XPPlayer.Players)
{
if (kvp.Value.IsNPC)
continue;
if (player == kvp.Value)
continue;

if (!ShouldEdit(kvp.Value))
continue;

Expand All @@ -61,9 +62,10 @@ protected override void RefreshToDisabled(XPPlayer player)

foreach (var kvp in XPPlayer.Players)
{
if (kvp.Value.IsNPC)
continue;
if (player == kvp.Value)
continue;

if (!ShouldEdit(kvp.Value))
continue;

Expand Down Expand Up @@ -138,6 +140,6 @@ protected virtual TObject GetObject(XPPlayer player, PlayerInfoWrapper playerInf
/// <param name="player">The player to show the data of.</param>
/// <param name="target">The target player to show the data to.</param>
/// <returns>Whether or not the player's data should be shown to the target player.</returns>
protected virtual bool ShouldShowTo(XPPlayer player, XPPlayer target) => true;
protected virtual bool ShouldShowTo(XPPlayer player, XPPlayer target) => !target.IsNPC;
}
}
2 changes: 2 additions & 0 deletions XPSystem/API/DisplayProviders/XPDisplayProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ public virtual void RefreshTo(XPPlayer player)
{
if (!Config.Enabled && !HasSet)
return;
if (player.IsNPC)
return;

if (Config.Enabled)
{
Expand Down
28 changes: 15 additions & 13 deletions XPSystem/API/LoaderSpecific.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static class LoaderSpecific
#if EXILED
Exiled.API.Features.Paths.Configs;
#else
PluginAPI.Helpers.Paths.LocalPlugins.Plugins;
LabApi.Loader.Features.Paths.PathManager.Configs.FullName;
#endif

/// <summary>
Expand All @@ -41,17 +41,18 @@ public static ReferenceHub GetHub(string data)
return Exiled.API.Features.Player.Get(data)?.ReferenceHub;
#else
if (uint.TryParse(data, out uint networkId)
&& PluginAPI.Core.Player.TryGet(networkId, out var player))
&& LabApi.Features.Wrappers.Player.TryGet(networkId, out var player))
return player.ReferenceHub;

if (int.TryParse(data, out int playerId)
&& PluginAPI.Core.Player.TryGet(playerId, out player))
&& LabApi.Features.Wrappers.Player.TryGet(playerId, out player))
return player.ReferenceHub;

if (PluginAPI.Core.Player.TryGet(data, out player))
if (LabApi.Features.Wrappers.Player.TryGet(data, out player))
return player.ReferenceHub;

return PluginAPI.Core.Player.GetByName(data)?.ReferenceHub;
LabApi.Features.Wrappers.Player.TryGetPlayersByName(data, out var list);
return list.FirstOrDefault()?.ReferenceHub;
#endif
}

Expand Down Expand Up @@ -99,7 +100,7 @@ public static bool CheckPermission(ICommandSender sender, string permission)
#if EXILED
return Exiled.Permissions.Extensions.Permissions.CheckPermission(sender, permission);
#else
return NWAPIPermissionSystem.PermissionHandler.CheckPermission(sender, permission);
return LabApi.Features.Permissions.PermissionsExtensions.HasPermissions(sender, permission);
#endif

}
Expand All @@ -117,8 +118,8 @@ public static bool CheckPermission(ReferenceHub hub, string permission)
Exiled.API.Features.Player.Get(hub)
, permission);
#else
return NWAPIPermissionSystem.PermissionHandler
.CheckPermission(hub.authManager.UserId, permission);
return LabApi.Features.Permissions.PermissionsManager
.HasPermissions(LabApi.Features.Wrappers.Player.Get(hub), permission);
#endif
}

Expand All @@ -131,7 +132,8 @@ public static bool CheckNPC(ReferenceHub hub) =>
#if EXILED
Exiled.API.Features.Player.Get(hub)?.IsNPC == true;
#else
false;
// ReSharper disable once ConstantConditionalAccessQualifier
LabApi.Features.Wrappers.Player.Get(hub)?.IsNpc == true;
#endif

public static void LogDebug(string message)
Expand All @@ -140,7 +142,7 @@ public static void LogDebug(string message)
Exiled.API.Features.Log.Debug(message);
#else
if (XPAPI.Config.Debug)
PluginAPI.Core.Log.Debug(message);
LabApi.Features.Console.Logger.Debug(message);
#endif
}

Expand All @@ -149,7 +151,7 @@ public static void LogInfo(string message)
#if EXILED
Exiled.API.Features.Log.Info(message);
#else
PluginAPI.Core.Log.Info(message);
LabApi.Features.Console.Logger.Info(message);
#endif
}

Expand All @@ -158,7 +160,7 @@ public static void LogWarn(string message)
#if EXILED
Exiled.API.Features.Log.Warn(message);
#else
PluginAPI.Core.Log.Warning(message);
LabApi.Features.Console.Logger.Warn(message);
#endif
}

Expand All @@ -167,7 +169,7 @@ public static void LogError(string message)
#if EXILED
Exiled.API.Features.Log.Error(message);
#else
PluginAPI.Core.Log.Error(message);
LabApi.Features.Console.Logger.Error(message);
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion XPSystem/API/XPPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ private static void MakeCustomSyncWriter(NetworkIdentity behaviorOwner, Type tar
/// <inheritdoc cref="Exiled.API.Features.Player"/>
public static implicit operator XPPlayer(Exiled.API.Features.Player player) => Get(player.ReferenceHub);
#else
public static implicit operator XPPlayer(PluginAPI.Core.Player player) => Get(player.ReferenceHub);
public static implicit operator XPPlayer(LabApi.Features.Wrappers.Player player) => Get(player.ReferenceHub);
#endif
}
}
6 changes: 5 additions & 1 deletion XPSystem/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="NorthwoodLib" publicKeyToken="null" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.3.1.0" newVersion="1.3.1.0" />
<bindingRedirect oldVersion="0.0.0.0-1.4.0.0" newVersion="1.4.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="LabApi" publicKeyToken="null" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.0.0.0" newVersion="1.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal static class NicknamePatch
{
public static void Prefix(NicknameSync __instance, ref string value)
{
if (__instance._hub.IsHost)
if (!__instance._hub || __instance._hub.IsHost || __instance._hub.IsDummy)
return;

foreach (IXPDisplayProvider provider in XPAPI.DisplayProviders)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

public class NickPatchXPDisplayProvider : XPDisplayProvider<NickPatchXPDisplayProvider.NickConfig>
{
public Dictionary<string, string> DisplayNameOverrides { get; } = new Dictionary<string, string>();
public Dictionary<string, string> DisplayNameOverrides { get; } = new();

protected override void RefreshOfEnabled(XPPlayer player, PlayerInfoWrapper playerInfo) => Refresh(player);
protected override void RefreshOfDisabled(XPPlayer player) => Refresh(player);
Expand All @@ -25,6 +25,9 @@ internal static class DisplayNamePatch
{
public static void Prefix(NicknameSync __instance, ref string value)
{
if (!__instance._hub || __instance._hub.IsHost || __instance._hub.IsDummy)
return;

foreach (IXPDisplayProvider provider in XPAPI.DisplayProviders)
{
if (provider is NickPatchXPDisplayProvider nickProvider)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ internal static class NickCommandPatch
{
public static void Postfix(NicknameSync __instance)
{
if (__instance._hub.IsDummy)
return;

foreach (IXPDisplayProvider provider in XPAPI.DisplayProviders)
{
if (provider is NickXPDisplayProvider nickProvider && nickProvider.Config.PatchNickCommand)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ protected override bool ShouldEdit(XPPlayer player)

protected override bool ShouldShowTo(XPPlayer player, XPPlayer target)
{
if (!base.ShouldShowTo(player, target))
return false;
if (!Config.EditBadgeHiding)
return true;

Expand Down
17 changes: 12 additions & 5 deletions XPSystem/BuiltInProviders/LiteDB/LiteDBPlayerInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace XPSystem.BuiltInProviders.LiteDB
{
using System;
using global::LiteDB;
using XPSystem.API.Enums;
using XPSystem.API.StorageProviders.Models;
Expand All @@ -9,9 +10,12 @@ public class LiteDBNumberPlayerInfo : LiteDBPlayerInfo
[BsonId]
public ulong Id { get; set; }

public override T SetId<T>(object id)
public override T SetId<T>(IPlayerId id)
{
Id = (ulong)id;
if (id is not NumberPlayerId numberPlayerId)
throw new ArgumentException("id is not NumberPlayerId", nameof(id));

Id = numberPlayerId.IdNumber;
return (T)(object)this;
}

Expand All @@ -23,9 +27,12 @@ public class LiteDBStringPlayerInfo : LiteDBPlayerInfo
[BsonId]
public string Id { get; set; }

public override T SetId<T>(object id)
public override T SetId<T>(IPlayerId id)
{
Id = (string)id;
if (id is not StringPlayerId stringPlayerId)
throw new ArgumentException("id is not StringPlayerId", nameof(id));

Id = stringPlayerId.IdString;
return (T)(object)this;
}

Expand All @@ -39,7 +46,7 @@ public abstract class LiteDBPlayerInfo
public string Nickname { get; set; }
#endif

public abstract T SetId<T>(object id) where T : LiteDBPlayerInfo;
public abstract T SetId<T>(IPlayerId id) where T : LiteDBPlayerInfo;

protected abstract IPlayerId toPlayerId(AuthType authType);
public PlayerInfo ToPlayerInfo(AuthType authType)
Expand Down
4 changes: 2 additions & 2 deletions XPSystem/BuiltInProviders/LiteDB/LiteDBProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ protected override PlayerInfo GetPlayerInfoAndCreateOfNotExistNoCache(IPlayerId
T info = new T()
{
XP = 0
}.SetId<T>(playerId.Id);
}.SetId<T>(playerId);
collection.Insert(info);
return info.ToPlayerInfo(playerId.AuthType);
}
Expand Down Expand Up @@ -162,7 +162,7 @@ protected override void SetPlayerInfoNoCache(PlayerInfo playerInfo)
#if STORENICKS
Nickname = playerInfo.Nickname
#endif
}.SetId<T>(playerInfo.Player.Id));
}.SetId<T>(playerInfo.Player));
}
else
{
Expand Down
Loading
Loading