Skip to content

Commit

Permalink
[Exiled::API] EnumClasses fix (Exiled-Team#2445)
Browse files Browse the repository at this point in the history
* enum fix

* fix
  • Loading branch information
VALERA771 authored Feb 11, 2024
1 parent 575c084 commit 698c323
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Exiled.API/Features/Core/Generic/EnumClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Exiled.API.Features.Core.Generic
using System.Reflection;

using Exiled.API.Features.Core.Generic.Pools;

using Exiled.API.Interfaces;
using LiteNetLib.Utils;

/// <summary>
Expand All @@ -22,7 +22,7 @@ namespace Exiled.API.Features.Core.Generic
/// </summary>
/// <typeparam name="TSource">The type of the source object to handle the instance of.</typeparam>
/// <typeparam name="TObject">The type of the child object to handle the instance of.</typeparam>
public abstract class EnumClass<TSource, TObject> : IComparable, IEquatable<TObject>, IComparable<TObject>, IComparer<TObject>
public abstract class EnumClass<TSource, TObject> : IComparable, IEquatable<TObject>, IComparable<TObject>, IComparer<TObject>, IEnumClass
where TSource : Enum
where TObject : EnumClass<TSource, TObject>
{
Expand Down
4 changes: 2 additions & 2 deletions Exiled.API/Features/Core/Generic/UniqueUnmanagedEnumClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Exiled.API.Features.Core.Generic
using System.Reflection;

using Exiled.API.Features.Core.Generic.Pools;

using Exiled.API.Interfaces;
using LiteNetLib.Utils;

/// <summary>
Expand All @@ -22,7 +22,7 @@ namespace Exiled.API.Features.Core.Generic
/// </summary>
/// <typeparam name="TSource">The type of the <see langword="unmanaged"/> source object to handle the instance of.</typeparam>
/// <typeparam name="TObject">The type of the child object to handle the instance of.</typeparam>
public abstract class UniqueUnmanagedEnumClass<TSource, TObject> : IComparable, IEquatable<TObject>, IComparable<TObject>, IComparer<TObject>, IConvertible
public abstract class UniqueUnmanagedEnumClass<TSource, TObject> : IComparable, IEquatable<TObject>, IComparable<TObject>, IComparer<TObject>, IConvertible, IEnumClass
where TSource : unmanaged, IComparable, IFormattable, IConvertible, IComparable<TSource>, IEquatable<TSource>
where TObject : UniqueUnmanagedEnumClass<TSource, TObject>
{
Expand Down
4 changes: 2 additions & 2 deletions Exiled.API/Features/Core/Generic/UnmanagedEnumClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Exiled.API.Features.Core.Generic
using System.Reflection;

using Exiled.API.Features.Core.Generic.Pools;

using Exiled.API.Interfaces;
using LiteNetLib.Utils;

/// <summary>
Expand All @@ -22,7 +22,7 @@ namespace Exiled.API.Features.Core.Generic
/// </summary>
/// <typeparam name="TSource">The type of the <see langword="unmanaged"/> source object to handle the instance of.</typeparam>
/// <typeparam name="TObject">The type of the child object to handle the instance of.</typeparam>
public abstract class UnmanagedEnumClass<TSource, TObject> : IComparable, IEquatable<TObject>, IComparable<TObject>, IComparer<TObject>, IConvertible
public abstract class UnmanagedEnumClass<TSource, TObject> : IComparable, IEquatable<TObject>, IComparable<TObject>, IComparer<TObject>, IConvertible, IEnumClass
where TSource : unmanaged, IComparable, IFormattable, IConvertible, IComparable<TSource>, IEquatable<TSource>
where TObject : UnmanagedEnumClass<TSource, TObject>
{
Expand Down
16 changes: 16 additions & 0 deletions Exiled.API/Interfaces/IEnumClass.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// -----------------------------------------------------------------------
// <copyright file="IEnumClass.cs" company="Exiled Team">
// Copyright (c) Exiled Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
// </copyright>
// -----------------------------------------------------------------------

namespace Exiled.API.Interfaces
{
/// <summary>
/// An interface for all enum classes.
/// </summary>
public interface IEnumClass
{
}
}
16 changes: 16 additions & 0 deletions Exiled.Events/Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ namespace Exiled.Events
{
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;

using API.Enums;
using API.Features;
using CentralAuth;
using Exiled.API.Interfaces;
using Exiled.Events.Features;
using HarmonyLib;
using InventorySystem.Items.Pickups;
Expand Down Expand Up @@ -83,6 +86,19 @@ public override void OnEnabled()
ServerConsole.ReloadServerName();

EventManager.RegisterEvents<Handlers.Player>(this);

foreach (Type type in typeof(IEnumClass).Assembly.GetTypes().Where(x => x.GetInterface(nameof(IEnumClass)) == typeof(IEnumClass)))
{
FieldInfo[] fieldInfos = type.GetFields();

if (fieldInfos.All(x => !x.IsInitOnly))
continue;

foreach (FieldInfo field in fieldInfos.Where(x => x.IsStatic))
{
field.GetValue(null);
}
}
}

/// <inheritdoc/>
Expand Down

0 comments on commit 698c323

Please sign in to comment.