Skip to content

Commit 31e2f0a

Browse files
Fixed customroles. Exiled 9.0.0-beta.1 release (#2769)
* Fixed Pawn.cs being null if try to use it by Player::Get().Cast<Pawn>(). Adding a method for load a constructor without any param or constructor. Removing abstract from RoleBehaviour.cs for allow the creating of an instance. Added custom role example under Exiled.Example for testing purpose. * Fixed custom roles. * Added test role (testing purposes) * Fixed customroles. Release 9.0.0-beta.1
1 parent ec7b96e commit 31e2f0a

7 files changed

Lines changed: 20 additions & 24 deletions

File tree

EXILED.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
<PropertyGroup>
1717
<!-- This is the global version and is used for all projects that don't have a version -->
18-
<Version Condition="$(Version) == ''">9.0.0-alpha.19</Version>
18+
<Version Condition="$(Version) == ''">9.0.0-beta.1</Version>
1919
<!-- Enables public beta warning via the PUBLIC_BETA constant -->
2020
<PublicBeta>false</PublicBeta>
2121

Exiled.API/Features/Core/EActor.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,6 @@ protected virtual void PostInitialize()
481481
/// </summary>
482482
protected virtual void OnBeginPlay()
483483
{
484-
SubscribeEvents();
485484
}
486485

487486
/// <summary>

Exiled.API/Features/Core/EObject.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -918,4 +918,4 @@ protected virtual void OnDestroyed()
918918
{
919919
}
920920
}
921-
}
921+
}

Exiled.API/Features/Core/GameEntity.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ public T AddComponent<T>(string name = "")
163163
public EActor AddComponent(Type type, string name = "")
164164
{
165165
EActor component = EObject.CreateDefaultSubobject(type, GameObject).Cast<EActor>();
166-
component.Base = GameObject;
167166

168167
if (!component)
169168
return null;

Exiled.API/Features/Core/Generic/EBehaviour.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ namespace Exiled.API.Features.Core.Generic
2525
public abstract class EBehaviour<T> : EActor
2626
where T : GameEntity
2727
{
28+
/// <summary>
29+
/// Initializes a new instance of the <see cref="EBehaviour{T}"/> class.
30+
/// </summary>
31+
protected EBehaviour()
32+
{
33+
}
34+
2835
/// <summary>
2936
/// Gets or sets the owner of the <see cref="EBehaviour{T}"/>.
3037
/// </summary>
@@ -78,6 +85,12 @@ protected override void PostInitialize()
7885
}
7986
}
8087

88+
/// <inheritdoc />
89+
protected override void OnBeginPlay()
90+
{
91+
base.OnBeginPlay();
92+
}
93+
8194
/// <inheritdoc/>
8295
protected override void Tick()
8396
{

Exiled.CustomModules/API/Features/CustomModule.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,7 @@ public static void LoadAll()
318318
/// <param name="shouldBeEnabled">Determines whether the loaded modules should be enabled after loading.</param>
319319
public static void Load(Assembly assembly = null, bool shouldBeEnabled = false)
320320
{
321-
Log.InfoWithContext($"Using defined assembly? {assembly is null}");
322321
assembly ??= Assembly.GetCallingAssembly();
323-
Log.InfoWithContext($"{assembly.GetName().Name}");
324322

325323
UUModuleType FindClosestModuleType(Type t, IEnumerable<FieldInfo> source)
326324
{
@@ -331,7 +329,6 @@ UUModuleType FindClosestModuleType(Type t, IEnumerable<FieldInfo> source)
331329

332330
Type runtime_ModuleType = assembly.GetTypes().FirstOrDefault(t => !t.IsAbstract && typeof(UUModuleType).IsAssignableFrom(t)) ?? typeof(UUModuleType);
333331
IEnumerable<FieldInfo> moduleTypeValuesInfo = runtime_ModuleType.GetFields(BindingFlags.Static | BindingFlags.Public).Where(f => f.GetValue(null) is UUModuleType);
334-
Log.InfoWithContext($"DB1");
335332

336333
foreach (Type type in assembly.GetTypes())
337334
{

Exiled.CustomModules/API/Features/CustomRoles/RoleBehaviour.cs

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -355,9 +355,9 @@ protected override void PostInitialize()
355355
protected override void OnBeginPlay()
356356
{
357357
base.OnBeginPlay();
358-
359358
if (!Owner)
360359
{
360+
Log.WarnWithContext("Owner is null");
361361
Destroy();
362362
return;
363363
}
@@ -369,6 +369,8 @@ protected override void OnBeginPlay()
369369
Owner.ChangeAppearance(FakeAppearance, false);
370370

371371
PermanentEffects?.ForEach(x => Owner.SyncEffect(x));
372+
373+
SubscribeEvents();
372374
}
373375

374376
/// <inheritdoc/>
@@ -450,9 +452,6 @@ protected override void SubscribeEvents()
450452
{
451453
base.SubscribeEvents();
452454

453-
EscapingEventDispatcher.Bind(this, OnEscaping);
454-
EscapedEventDispatcher.Bind(this, OnEscaped);
455-
456455
Exiled.Events.Handlers.Player.ChangingItem += ChangingItemBehaviour;
457456
Exiled.Events.Handlers.Player.Destroying += DestroyOnLeave;
458457
Exiled.Events.Handlers.Player.ChangingRole += DestroyOnChangingRole;
@@ -474,6 +473,8 @@ protected override void SubscribeEvents()
474473
Exiled.Events.Handlers.Player.Handcuffing += HandcuffingBehavior;
475474
Exiled.Events.Handlers.Map.PlacingBlood += PlacingBloodBehavior;
476475
Exiled.Events.Handlers.Player.ChangingNickname += OnInternalChangingNickname;
476+
EscapingEventDispatcher.Bind(this, OnEscaping);
477+
EscapedEventDispatcher.Bind(this, OnEscaped);
477478
}
478479

479480
/// <inheritdoc/>
@@ -759,21 +760,8 @@ protected virtual void PlacingBloodBehavior(PlacingBloodEventArgs ev)
759760
/// <inheritdoc cref="Exiled.Events.Handlers.Player.OnEnteringPocketDimension(EnteringPocketDimensionEventArgs)"/>
760761
protected virtual void DroppingItemBehavior(DroppingItemEventArgs ev)
761762
{
762-
if (ev.Item is null)
763-
{
764-
Log.Error("Item is null");
765-
}
766-
767-
Log.InfoWithContext($"{ev.Player} is trying to drop {ev.Item.Type}");
768-
769-
Log.WarnWithContext(Settings.CanDropItems);
770763
if (!Check(ev.Player) || Settings.CanDropItems)
771-
{
772-
Log.InfoWithContext($"{ev.Player} is not {CustomRole.Name} or can drop items as {CustomRole.Name}");
773764
return;
774-
}
775-
776-
Log.InfoWithContext($"{ev.Player} cannot drop items");
777765

778766
ev.IsAllowed = false;
779767
}

0 commit comments

Comments
 (0)