Make compiling module a proper plugin

This commit is contained in:
UnknownShadow200 2023-12-10 22:16:24 +11:00
parent 9dead7961b
commit 7f7cf7cb52
8 changed files with 64 additions and 14 deletions

View File

@ -21,7 +21,7 @@ using MCGalaxy.Commands;
namespace MCGalaxy.Modules.Compiling
{
public sealed class CmdCmdCreate : CmdCompile
sealed class CmdCmdCreate : CmdCompile
{
public override string name { get { return "CmdCreate"; } }
public override string shortcut { get { return ""; } }

View File

@ -22,7 +22,7 @@ using MCGalaxy.Scripting;
namespace MCGalaxy.Modules.Compiling
{
public class CmdCompile : Command2
class CmdCompile : Command2
{
public override string name { get { return "Compile"; } }
public override string type { get { return CommandTypes.Other; } }

View File

@ -21,7 +21,7 @@ using MCGalaxy.Scripting;
namespace MCGalaxy.Modules.Compiling
{
public sealed class CmdCompLoad : CmdCompile
sealed class CmdCompLoad : CmdCompile
{
public override string name { get { return "CompLoad"; } }
public override string shortcut { get { return "cml"; } }

View File

@ -0,0 +1,44 @@
/*
Copyright 2015 MCGalaxy
Dual-licensed under the Educational Community License, Version 2.0 and
the GNU General Public License, Version 3 (the "Licenses"); you may
not use this file except in compliance with the Licenses. You may
obtain a copy of the Licenses at
https://opensource.org/license/ecl-2-0/
https://www.gnu.org/licenses/gpl-3.0.html
Unless required by applicable law or agreed to in writing,
software distributed under the Licenses are distributed on an "AS IS"
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
or implied. See the Licenses for the specific language governing
permissions and limitations under the Licenses.
*/
#if !MCG_STANDALONE
using System;
namespace MCGalaxy.Modules.Compiling
{
public sealed class CompilerPlugin : Plugin
{
public override string name { get { return "Compiler"; } }
Command cmdCreate = new CmdCmdCreate();
Command cmdCompile = new CmdCompile();
Command cmdCompLoad = new CmdCompLoad();
public override void Load(bool startup) {
Server.EnsureDirectoryExists(ICompiler.COMMANDS_SOURCE_DIR);
Command.Register(cmdCreate);
Command.Register(cmdCompile);
Command.Register(cmdCompLoad);
}
public override void Unload(bool shutdown) {
Command.Unregister(cmdCreate, cmdCompile, cmdCompLoad);
}
}
}
#endif

View File

@ -93,6 +93,8 @@ namespace MCGalaxy.Modules.Relay.Discord
public static DiscordBot Bot = new DiscordBot();
public override void Load(bool startup) {
Server.EnsureDirectoryExists("text/discord");
Bot.Config = Config;
Bot.ReloadConfig();
Bot.Connect();

View File

@ -139,6 +139,10 @@ namespace MCGalaxy
LoadCorePlugin(new IRCPlugin());
LoadCorePlugin(new IPThrottler());
#if !MCG_STANDALONE
LoadCorePlugin(new MCGalaxy.Modules.Compiling.CompilerPlugin());
#endif
LoadCorePlugin(new CountdownPlugin());
LoadCorePlugin(new CTFPlugin());
LoadCorePlugin(new LSPlugin());

View File

@ -142,14 +142,14 @@ namespace MCGalaxy
EnsureDirectoryExists("extra/bots");
EnsureDirectoryExists(Paths.ImportsDir);
EnsureDirectoryExists("blockdefs");
#if !MCG_STANDALONE
EnsureDirectoryExists(MCGalaxy.Modules.Compiling.ICompiler.COMMANDS_SOURCE_DIR); // TODO move to compiling module
#endif
EnsureDirectoryExists("text/discord"); // TODO move to discord plugin
}
static void EnsureDirectoryExists(string dir) {
public static void EnsureDirectoryExists(string dir) {
try {
if (!Directory.Exists(dir)) Directory.CreateDirectory(dir);
} catch (Exception ex) {
Logger.LogError("Creating directory " + dir, ex);
}
}
public static void LoadAllSettings() { LoadAllSettings(false); }

View File

@ -81,10 +81,10 @@ Compiling - .NET 6 / .NET 5 / .NET Core
-----------------
* Compiling for .NET 6: No changes necessary
* Compiling for .NET 5: Change `TargetFramework` in CLI/MCGalaxyCLI_Core.csproj to `net5.0`
* Compiling for .NET Core: Change `TargetFramework` in CLI/MCGalaxyCLI_Core.csproj to `netcoreapp3.1`
* Compiling for .NET 5: Change `TargetFramework` in CLI/MCGalaxyCLI_dotnet.csproj to `net5.0`
* Compiling for .NET Core: Change `TargetFramework` in CLI/MCGalaxyCLI_dotnet.csproj to `netcoreapp3.1`
Then navigate into `CLI` directory, and then run `dotnet build MCGalaxyCLI_Core.csproj`
Then navigate into `CLI` directory, and then run `dotnet build MCGalaxyCLI_dotnet.csproj`
**You will also need to copy `libsqlite3.so.0` from system libraries to `libsqlite3.so` in the server folder**