Before You Report
Version
1.1.6
Description
The ParticleDisruptorItem class overrides the ChamberMax, ChamberedAmmo, and Cocked properties but only provides a get accessor for them. Because the base class (FirearmItem) has both get and set for these properties, attempting to set any of them on a ParticleDisruptorItem falls back to the base class setter.
The base class setters attempt to cast the ActionModule to AutomaticActionModule, which fails for the Disruptor (since it uses DisruptorActionModule), resulting in an internal LabAPI error logged to the server console.
To Reproduce
- Obtain a
ParticleDisruptorItem instance.
- Attempt to set its
ChamberMax, ChamberedAmmo, or Cocked property (e.g., disruptor.ChamberMax = 5; or disruptor.Cocked = true;).
- Check the server console. You will see the following error:
[ERROR] [LabApi] Unable to set <PropertyName> as this firearm's IActionModule is not valid.
Expected Behavior
Setting these properties on a Particle Disruptor should either be ignored silently (since it's a special weapon with fixed mechanics) or throw a clear NotSupportedException without falling back to the incompatible base class logic.
Additional Information
Proposed Fix
In LabApi\Features\Wrappers\Items\Firearm\SpecialFirearms\ParticleDisruptorItem.cs:
Add setters that throw a NotSupportedException to override the base class behavior and clearly indicate invalid operations.
Proposed fix:
public override int ChamberedAmmo
{
get
{
if (ActionModule is DisruptorActionModule actionModule)
{
return actionModule.IsLoaded ? 1 : 0;
}
return 0;
}
set => throw new NotSupportedException("ChamberedAmmo cannot be modified for the Particle Disruptor.");
}
public override int ChamberMax
{
get => 1;
set => throw new NotSupportedException("ChamberMax cannot be modified for the Particle Disruptor.");
}
public override bool Cocked
{
get
{
if (ActionModule is DisruptorActionModule actionModule)
{
return actionModule.IsLoaded;
}
return false;
}
set => throw new NotSupportedException("Cocked state cannot be modified for the Particle Disruptor.");
}
Before You Report
Version
1.1.6
Description
The
ParticleDisruptorItemclass overrides theChamberMax,ChamberedAmmo, andCockedproperties but only provides agetaccessor for them. Because the base class (FirearmItem) has bothgetandsetfor these properties, attempting to set any of them on aParticleDisruptorItemfalls back to the base class setter.The base class setters attempt to cast the
ActionModuletoAutomaticActionModule, which fails for the Disruptor (since it usesDisruptorActionModule), resulting in an internal LabAPI error logged to the server console.To Reproduce
ParticleDisruptorIteminstance.ChamberMax,ChamberedAmmo, orCockedproperty (e.g.,disruptor.ChamberMax = 5;ordisruptor.Cocked = true;).[ERROR] [LabApi] Unable to set <PropertyName> as this firearm's IActionModule is not valid.Expected Behavior
Setting these properties on a Particle Disruptor should either be ignored silently (since it's a special weapon with fixed mechanics) or throw a clear
NotSupportedExceptionwithout falling back to the incompatible base class logic.Additional Information
Proposed Fix
In
LabApi\Features\Wrappers\Items\Firearm\SpecialFirearms\ParticleDisruptorItem.cs:Add setters that throw a
NotSupportedExceptionto override the base class behavior and clearly indicate invalid operations.Proposed fix: