using System;
using RageCoop.Core.Scripting;
namespace RageCoop.Server.Scripting
{
///
/// Inherit from this class, constructor will be called automatically, but other scripts might have yet been loaded and will be null, you should use . to initiate your script.
///
public abstract class ServerScript
{
///
/// This method would be called from listener thread after all scripts have been loaded.
///
public abstract void OnStart();
///
/// This method would be called from listener thread when the server is shutting down, you MUST terminate all background jobs/threads in this method.
///
public abstract void OnStop();
///
/// Get the instance that can be used to control the server.
///
public API API { get; set; }
///
/// Get the this script belongs to, this property won't be initiated before .
///
public ServerResource CurrentResource { get; internal set; }
///
/// Get the that the script belongs to.
///
public ResourceFile CurrentFile { get; internal set; }
///
/// Eqivalent of in
///
public Core.Logger Logger { get { return CurrentResource.Logger; } }
}
///
/// Decorate your method with this attribute and use or to register commands.
///
[AttributeUsage(AttributeTargets.Method, Inherited = false)]
public class Command : Attribute
{
///
/// Sets name of the command
///
public string Name { get; set; }
///
/// Set the Usage (Example: "Please use "/help"". ArgsLength required!)
///
public string Usage { get; set; }
///
/// Set the length of arguments (Example: 2 for "/message USERNAME MESSAGE". Usage required!)
///
public short ArgsLength { get; set; }
///
///
///
/// Name of the command
public Command(string name)
{
Name = name;
}
}
///
/// The context containg command information.
///
public class CommandContext
{
///
/// Gets the client which executed the command
///
public Client Client { get; internal set; }
///
/// Gets the arguments (Example: "/message USERNAME MESSAGE", Args[0] for USERNAME)
///
public string[] Args { get; internal set; }
}
}