Skip to content

Commit dbbf5f1

Browse files
Merge pull request #106 from UchuServer/command-registration
fix command registration
2 parents 0dcfccb + 5dd929d commit dbbf5f1

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

Uchu.Core/UchuServer.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -345,18 +345,15 @@ public virtual void RegisterAssembly(Assembly assembly)
345345
instance.SetServer(this);
346346

347347
// Get all packet handlers and add them to the handler map
348-
foreach (var method in group.GetMethods().Where(m => !m.IsStatic && !m.IsAbstract))
348+
foreach (var method in group.GetMethods().Where(m => !m.IsAbstract))
349349
{
350-
var attr = method.GetCustomAttribute<PacketHandlerAttribute>();
351-
if (attr != null)
350+
if (method.GetCustomAttribute<PacketHandlerAttribute>() is {} packetHandlerAttribute)
352351
{
353-
RegisterPacketHandler(method, attr, instance);
352+
RegisterPacketHandler(method, packetHandlerAttribute, instance);
354353
}
355-
else
354+
else if (method.GetCustomAttribute<CommandHandlerAttribute>() is {} commandHandlerAttribute)
356355
{
357-
var cmdAttr = method.GetCustomAttribute<CommandHandlerAttribute>();
358-
if (cmdAttr == null) continue;
359-
RegisterCommandHandler(method, cmdAttr, instance);
356+
RegisterCommandHandler(method, commandHandlerAttribute, instance);
360357
}
361358
}
362359
}

0 commit comments

Comments
 (0)