Skip to content

Commit

Permalink
a bunch of stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
soccermitchy committed Dec 18, 2016
1 parent bec6f49 commit ea17b27
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Client/GTACoOp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>full</DebugType>
<Optimize>true</Optimize>
<OutputPath>S:\Grand Theft Auto\GTA V Mods\CO-OP\scripts\</OutputPath>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
Expand Down
2 changes: 1 addition & 1 deletion Client/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ public Main()
{
UI.Notify("GTA V Coop mod by Guad, temporary continued by Bluscream and wolfmitchell.");
UI.Notify("Mod Version: " + ReadableScriptVersion());
UI.Notify("https://github.com/Bluscream/GTACoop/releases/latest");
UI.Notify("https://pydio.studiowolfree.com/public/gtacoop");
};

_mainMenu.AddItem(browserItem);
Expand Down
6 changes: 3 additions & 3 deletions Client/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("GTACoOp")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyCopyright("Copyright © 2016-2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("0.9.3.1")]
[assembly: AssemblyFileVersion("0.9.3.1")]
37 changes: 37 additions & 0 deletions gtaserver.core/PluginAPI/ICommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Threading.Tasks;
using GTAServer.ProtocolMessages;

namespace GTAServer.PluginAPI
{
public interface ICommand
{
/// <summary>
/// Name of the command
/// </summary>
string CommandName { get; }
/// <summary>
/// What shows in the help text for the command
/// </summary>
string HelpText { get; }

/// <summary>
/// List of permissions needed to run the command
/// </summary>
List<string> RequiredPermissions { get; }
/// <summary>
/// If every permission listed in RequiredPermissions is needed.
/// </summary>
bool AllPermissionsRequired { get; }

/// <summary>
/// Called when a command is being executed.
/// </summary>
/// <param name="caller">Person who called the command</param>
/// <param name="chatData">Chat data object from the message command</param>
void OnCommandExec(Client caller, ChatData chatData);
}
}
27 changes: 27 additions & 0 deletions gtaserver.core/PluginAPI/IPlugin.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
namespace GTAServer.PluginAPI
{
public interface IPlugin
{
/// <summary>
/// Name of the plugin
/// </summary>
string Name { get; }
/// <summary>
/// Description of the plugin
/// </summary>
string Description { get; }
/// <summary>
/// Name of the plugin author.
/// </summary>
string Author { get; }

/// <summary>
/// Plugin entry point, called when a plugin is being enabled.
/// Use this to register any necessary hooks and commands.
/// </summary>
/// <param name="gameServer">Game server object.</param>
/// <param name="isAfterServerLoad">If the plugin is being started after the server has started.</param>
/// <returns>If the plugin successfully loaded</returns>
bool OnEnable(GameServer gameServer, bool isAfterServerLoad);
}
}
39 changes: 39 additions & 0 deletions gtaserver.core/PluginAPI/PluginLoader.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;

namespace GTAServer.PluginAPI
{
public static class PluginLoader
{
public static string Location = System.AppContext.BaseDirectory;
private static ILogger _logger;
public static List<IPlugin> LoadPlugin(string targetAssemblyName)
{
_logger = Util.LoggerFactory.CreateLogger<GameServer>();
var assemblyName = targetAssemblyName;
var pluginList = new List<IPlugin>();


var pluginAssembly = Assembly.Load(new AssemblyName(assemblyName));
var types = pluginAssembly.GetExportedTypes();
var validTypes = types.Where(t => typeof(IPlugin).IsAssignableFrom(t)).ToArray();
if (!validTypes.Any())
{
_logger.LogError("No classes found that extend IPlugin in assembly " + assemblyName);
return new List<IPlugin>();
}
foreach (var plugin in validTypes)
{
var curPlugin = Activator.CreateInstance(plugin) as IPlugin;
if (curPlugin == null) _logger.LogWarning("Could not create instance of " + plugin.Name + " (returned null after Activator.CreateInstance)");
}

return pluginList;
}
}
}

0 comments on commit ea17b27

Please sign in to comment.