File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
EXILED/Exiled.API/Features/Toys Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -142,7 +142,22 @@ public bool IsStatic
142
142
/// </summary>
143
143
/// <param name="adminToyBase">The <see cref="AdminToys.AdminToyBase"/> instance.</param>
144
144
/// <returns>The corresponding <see cref="AdminToy"/> instance.</returns>
145
- public static AdminToy Get ( AdminToyBase adminToyBase ) => Map . Toys . FirstOrDefault ( x => x . AdminToyBase == adminToyBase ) ;
145
+ public static AdminToy Get ( AdminToyBase adminToyBase )
146
+ {
147
+ if ( adminToyBase == null )
148
+ return null ;
149
+
150
+ if ( BaseToAdminToy . TryGetValue ( adminToyBase , out AdminToy adminToy ) )
151
+ return adminToy ;
152
+
153
+ return adminToyBase switch
154
+ {
155
+ LightSourceToy lightSourceToy => new Light ( lightSourceToy ) ,
156
+ PrimitiveObjectToy primitiveObjectToy => new Primitive ( primitiveObjectToy ) ,
157
+ ShootingTarget shootingTarget => new ShootingTargetToy ( shootingTarget ) ,
158
+ _ => throw new System . NotImplementedException ( )
159
+ } ;
160
+ }
146
161
147
162
/// <summary>
148
163
/// Spawns the toy into the game. Use <see cref="UnSpawn"/> to remove it.
You can’t perform that action at this time.
0 commit comments