Rename /scripting to /plugin and add /plugins

This commit is contained in:
UnknownShadow200 2018-01-27 09:25:26 +11:00
parent cf8c251d43
commit 27ec13ec0b
4 changed files with 37 additions and 46 deletions

View File

@ -28,7 +28,7 @@ namespace MCGalaxy.Commands.Fun {
if (alive.Length == 0) { Player.Message(p, "No one is alive."); return; }
Player.Message(p, "Players who are &2alive %Sare:");
Player.Message(p, alive.Join(pl => pl.ColoredName + "%S"));
Player.Message(p, alive.Join(pl => pl.ColoredName));
}
public override void Help(Player p) {

View File

@ -20,28 +20,34 @@ using System.IO;
using MCGalaxy.Scripting;
namespace MCGalaxy.Commands.Scripting {
public sealed class CmdScripting : Command {
public override string name { get { return "Scripting"; } }
public sealed class CmdPlugin : Command {
public override string name { get { return "Plugin"; } }
public override string type { get { return CommandTypes.Other; } }
public override LevelPermission defaultRank { get { return LevelPermission.Nobody; } }
public override CommandAlias[] Aliases {
get { return new[] { new CommandAlias("PLoad", "pload"), new CommandAlias("PUnload", "punload"),
new CommandAlias("PCreate", "pcreate"), new CommandAlias("PCompile", "pcompile") }; }
get { return new[] { new CommandAlias("PLoad", "load"), new CommandAlias("PUnload", "unload"),
new CommandAlias("PCreate", "create"), new CommandAlias("PCompile", "compile"),
new CommandAlias("Plugins", "list") }; }
}
public override bool MessageBlockRestricted { get { return true; } }
public override void Use(Player p, string message) {
if (message.CaselessEq("list")) {
Player.Message(p, "Loaded plugins: " + Plugin.all.Join(pl => pl.name));
return;
}
string[] parts = message.SplitSpaces(2);
if (parts.Length == 1) { Help(p); return; }
if (!Formatter.ValidName(p, parts[1], "plugin")) return;
if (parts[0].CaselessEq("pload")) {
if (parts[0].CaselessEq("load")) {
LoadPlugin(p, parts[1]);
} else if (parts[0].CaselessEq("punload")) {
} else if (parts[0].CaselessEq("unload")) {
UnloadPlugin(p, parts[1]);
} else if (parts[0].CaselessEq("pcreate")) {
} else if (parts[0].CaselessEq("create")) {
CreatePlugin(p, parts[1]);
} else if (parts[0].CaselessEq("pcompile")) {
} else if (parts[0].CaselessEq("compile")) {
CompilePlugin(p, parts[1]);
} else {
Help(p);
@ -126,14 +132,16 @@ namespace MCGalaxy
}}";
public override void Help(Player p) {
Player.Message(p, "%T/Scripting pcreate [name]");
Player.Message(p, "%T/Plugin create [name]");
Player.Message(p, "%HCreate a example .cs plugin file");
Player.Message(p, "%T/Scripting pcompile [name]");
Player.Message(p, "%T/Plugin compile [name]");
Player.Message(p, "%HCompiles a .cs plugin file");
Player.Message(p, "%T/Scripting pload [filename]");
Player.Message(p, "%T/Plugin load [filename]");
Player.Message(p, "%HLoad a plugin from your plugins folder");
Player.Message(p, "%T/Scripting punload [name]");
Player.Message(p, "%T/Plugin unload [name]");
Player.Message(p, "%HUnloads a currently loaded plugin");
Player.Message(p, "%T/Plugin list");
Player.Message(p, "%HLists all loaded plugins");
}
}
}

View File

@ -353,7 +353,7 @@
<Compile Include="Commands\Scripting\CmdCmdUnload.cs" />
<Compile Include="Commands\Scripting\CmdCompile.cs" />
<Compile Include="Commands\Scripting\CmdCompload.cs" />
<Compile Include="Commands\Scripting\CmdScripting.cs" />
<Compile Include="Commands\Scripting\CmdPlugin.cs" />
<Compile Include="Commands\World\CmdBlockProperties.cs" />
<Compile Include="Commands\World\CmdCopyLVL.cs" />
<Compile Include="Commands\World\CmdDeleteLvl.cs" />

View File

@ -31,60 +31,43 @@ namespace MCGalaxy {
/// <summary> This class provides for more advanced modification to MCGalaxy </summary>
public abstract partial class Plugin {
/// <summary> Use this to load all your events and everything you need. </summary>
/// <param name="startup">True if this was used from the server startup and not loaded from the command.</param>
/// <summary> Hooks into events and initalises states/resources etc </summary>
/// <param name="startup"> True if plugin is being auto loaded due to server starting up, false if manually. </param>
public abstract void Load(bool startup);
/// <summary> Use this method to dispose of everything you used. </summary>
/// <param name="shutdown">True if this was used by the server shutting down and not a command.</param>
/// <summary> Unhooks from events and disposes of state/resources etc </summary>
/// <param name="shutdown"> True if plugin is being auto unloaded due to server shutting down, false if manually. </param>
public abstract void Unload(bool shutdown);
/// <summary> This method is runned when a player does /help <pluginame>
/// Use it to show player's what this command is about. </summary>
/// <param name="p">Player who runned this command.</param>
/// <summary> Called when a player does /help on the plugin. Typically, shows to the player what this plugin is about. </summary>
/// <param name="p"> Player who is doing /help. </param>
public abstract void Help(Player p);
/// <summary> Name of the plugin. </summary>
public abstract string name { get; }
/// <summary> Your website. </summary>
public abstract string website { get; }
/// <summary> Oldest version of MCGalaxy the plugin is compatible with. </summary>
public abstract string MCGalaxy_Version { get; }
/// <summary> Version of your plugin. </summary>
public abstract int build { get; }
/// <summary> Message to display once plugin is loaded. </summary>
public abstract string welcome { get; }
/// <summary> The creator/author of this plugin. (Your name) </summary>
public abstract string creator { get; }
/// <summary> Whether or not to load this plugin at startup. </summary>
/// <summary> Whether or not to auto load this plugin on server startup. </summary>
public abstract bool LoadAtStartup { get; }
}
public abstract class Plugin_Simple : Plugin {
/// <summary> This method is runned when a player does /help <pluginame>
/// Use it to show player's what this command is about. </summary>
/// <param name="p">Player who runned this command.</param>
public override void Help(Player p) {
Player.Message(p, "No help is available for this plugin.");
}
/// <summary> Your website. </summary>
public override string website { get { return "http://www.example.org"; } }
/// <summary> Version of your plugin. </summary>
public override int build { get { return 0; } }
/// <summary> Message to display once plugin is loaded. </summary>
public override string welcome { get { return "Plugin " + name + " loaded."; } }
/// <summary> Whether or not to load this plugin at startup. </summary>
public override bool LoadAtStartup { get { return true; } }
}
}