Continue script abstraction
This commit is contained in:
@@ -13,6 +13,8 @@ using ReallifeGamemode.Server.Core.RageMP;
|
||||
using ReallifeGamemode.Server.Core.Events;
|
||||
using System.Collections.Generic;
|
||||
using ReallifeGamemode.Server.Common;
|
||||
using System.Reflection;
|
||||
using System.Linq;
|
||||
using ReallifeGamemode.Server.Job;
|
||||
|
||||
/**
|
||||
@@ -35,10 +37,18 @@ namespace ReallifeGamemode.Server
|
||||
[ServerEvent(Event.ResourceStart)]
|
||||
public void OnResourceStart()
|
||||
{
|
||||
var methods = Assembly.GetExecutingAssembly()
|
||||
.GetTypes()
|
||||
.SelectMany(t => t.GetMethods())
|
||||
.Where(m => m.GetCustomAttributes(typeof(CommandAttribute), false).Length > 0)
|
||||
.ToArray();
|
||||
|
||||
var registeredCommands = methods.Select(c => c.GetCustomAttribute<CommandAttribute>().CommandString);
|
||||
|
||||
IAPI apiInstance = new RageAPI();
|
||||
eventHandler = new EventHandler(apiInstance);
|
||||
|
||||
new Core.Main(apiInstance, eventHandler);
|
||||
new Core.Main(apiInstance, eventHandler, registeredCommands.ToArray());
|
||||
|
||||
NAPI.Server.SetGlobalServerChat(false);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user