All implementations of Command are now automatically found and loaded by the commandmanager
This commit is contained in:
parent
a188c05ed2
commit
c1fa2fe285
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using TrueCraft.API.Server;
|
using TrueCraft.API.Server;
|
||||||
using TrueCraft.API.Networking;
|
using TrueCraft.API.Networking;
|
||||||
@ -19,15 +20,16 @@ namespace TrueCraft.Commands
|
|||||||
|
|
||||||
private void LoadCommands()
|
private void LoadCommands()
|
||||||
{
|
{
|
||||||
Commands.Add(new PingCommand());
|
var truecraftAssembly = Assembly.GetExecutingAssembly();
|
||||||
Commands.Add(new GiveCommand());
|
|
||||||
Commands.Add(new GiveMeCommand());
|
var types = truecraftAssembly.GetTypes()
|
||||||
Commands.Add(new HelpCommand());
|
.Where(t => typeof (ICommand).IsAssignableFrom(t))
|
||||||
Commands.Add(new ResendInvCommand());
|
.Where(t => !t.IsAbstract);
|
||||||
Commands.Add(new PositionCommand());
|
|
||||||
Commands.Add(new TimeCommand());
|
foreach (var command in types.Select(type => (ICommand)Activator.CreateInstance(type)))
|
||||||
Commands.Add(new LogCommand());
|
{
|
||||||
Commands.Add(new TellCommand());
|
Commands.Add(command);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Reference in New Issue
Block a user