-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Remove "Services" * Add logging to service collection * Refactor plugin related classes to use DI * Some code cleanup * Inject service provider to Server.cs * Update sample plugin * A little refactor * Initial impl using Microsofts DI * Some cleanup * Fix logging stuff :))) * Fix error * Little refactors * Update dependencies * Make PluginBase inherit IAsync/Disposable * Refactors * Start reworking plugin manager * Remove plugin wrapper and anything to do with reflection * Fix errors * More refactors - Removes Plugin attribute and instead tries to find an embedded resource called plugin.json - Delete more event stuff - Refactor SamplePlugin * IPluginConfigurationManager -> IPluginRegistry * More plugin registry cleanup * Start organizing/fixing all things to do with commands Sorry for the massive commit 😭😭 * PluginContainer now manages service injection * Update SamplePlugin.csproj * Fix up commands * ObjectMethodExecutor * Cleanup * New event system pt. 1 * Fix build error 😭 * Some organization * Event stuff * Code cleanup * More cleanup * More cleanup * Update PluginBase.cs * Command refactor start * Re-do command execution * Refactor * PluginContainer can be null * Fix plugins not registering data properly * Commands now use ObjectMethodExecutor * Fix tests * SamplePlugin cleanup * Command framework refactor completed * Fix arguments not parsing correctly * Update SamplePlugin.cs * Code cleanup * Update SamplePlugin.cs * Cleanup events (they work now) * Move chat message event stuff * Use EventDispatcher for all events * Some more cleanup * Remove overridable name property * Update EventDispatcher.cs * Fix errors * Update EventDispatcher.cs * Try catch around HostedServices * Code cleanup * Create IExecutor.cs * Use IExecutor for commands * Use IExecutor for events * Fix commands * Whoopsie * Fix delegate commands not reading params properly * Fix event dispatcher 😅 * Cleanup argument parsers * Code cleanup * Only return when fetching relative pos * Assign player if valid guid * Update Client.cs * Code cleanup * Fix commands and commands tests * Use DI * throw if we didn't find a valid executor * Some more cleanup
- Loading branch information
Showing
100 changed files
with
2,764 additions
and
2,373 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 13 additions & 13 deletions
26
...ArgumentParsers/NumericArgumentParsers.cs → ...ArgumentParsers/NumericArgumentParsers.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
Obsidian.API/Commands/ArgumentParsers/PlayerArgumentParser.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
namespace Obsidian.API.Commands.ArgumentParsers; | ||
|
||
public class PlayerArgumentParser : BaseArgumentParser<IPlayer> | ||
{ | ||
public PlayerArgumentParser() : base(7, "minecraft:game_profile") | ||
{ | ||
} | ||
|
||
//TODO support selectors | ||
public override bool TryParseArgument(string input, CommandContext context, out IPlayer result) | ||
{ | ||
var server = context.Server; | ||
IPlayer? player = null; | ||
|
||
if (Guid.TryParse(input, out var guid)) | ||
// is valid GUID, try find with guid | ||
player = server.GetPlayer(guid); | ||
else | ||
// is not valid GUID, try find with name | ||
player = server.GetPlayer(input); | ||
|
||
result = player; | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using Obsidian.API.Plugins; | ||
using System.Diagnostics; | ||
|
||
namespace Obsidian.API.Commands; | ||
public abstract class CommandModuleBase | ||
{ | ||
private CommandContext? commandContext; | ||
|
||
[CommandContext] | ||
public CommandContext CommandContext | ||
{ | ||
get | ||
{ | ||
if (commandContext == null) | ||
throw new UnreachableException();//TODO empty command context maybe?? | ||
|
||
return this.commandContext; | ||
} | ||
set | ||
{ | ||
ArgumentNullException.ThrowIfNull(value); | ||
|
||
this.commandContext = value; | ||
} | ||
} | ||
|
||
public IPlayer? Player => this.CommandContext.Player; | ||
public IServer Server => this.CommandContext.Server; | ||
public ICommandSender Sender => this.CommandContext.Sender; | ||
|
||
public bool IsPlayer => this.CommandContext.IsPlayer; | ||
|
||
public PluginBase? Plugin => this.CommandContext.Plugin; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Obsidian.API.Events; | ||
|
||
namespace Obsidian.API.Plugins; | ||
public interface IPluginRegistry | ||
{ | ||
public IPluginRegistry RegisterCommandArgumentHandler<T>(T parser) where T : BaseArgumentParser; | ||
|
||
public IPluginRegistry MapCommands(); | ||
public IPluginRegistry MapCommand(string name, Delegate contextDelegate); | ||
public IPluginRegistry MapCommand(string name, ValueTaskContextDelegate<CommandContext> contextDelegate); | ||
|
||
public IPluginRegistry MapEvent<TEventArgs>(ValueTaskContextDelegate<TEventArgs> contextDelegate, Priority priority = Priority.Low) where TEventArgs : BaseMinecraftEventArgs; | ||
public IPluginRegistry MapEvent(Delegate contextDelegate, Priority priority = Priority.Low); | ||
public IPluginRegistry MapEvents(); | ||
} | ||
|
||
|
||
//TODO better name maybe?? | ||
public delegate ValueTask ValueTaskContextDelegate<TContext>(TContext context); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.