mirror of
https://github.com/Impostor/Impostor.git
synced 2026-10-19 15:51:42 +00:00
Add enums to set Color/Hat/Pet/Skin
This commit is contained in:
1 parent
dcc4da25de
commit
e308b7e3e6
9 files changed
+272
-13
No files matched your search
@@ -217,12 +217,53 @@ namespace Impostor.Plugins.Example.Handlers
|
||||
The last step to get your plugin working is to register the event listener, so the server knows about it. Go back to your plugin class and modify it as below.
|
||||
|
||||
```csharp
|
||||
public ExamplePlugin(ILogger<ExamplePlugin> logger, IEventManager eventManager)
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Impostor.Api.Events.Managers;
|
||||
using Impostor.Api.Plugins;
|
||||
using Impostor.Plugins.Example.Handlers;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Impostor.Plugins.Example
|
||||
{
|
||||
_logger = logger;
|
||||
// Add this line!
|
||||
eventManager.RegisterListener(new GameEventListener(logger));
|
||||
[ImpostorPlugin(
|
||||
package: "gg.impostor.example",
|
||||
name: "Example",
|
||||
author: "AeonLucid",
|
||||
version: "1.0.0")]
|
||||
public class ExamplePlugin : PluginBase
|
||||
{
|
||||
private readonly ILogger<ExamplePlugin> _logger;
|
||||
// Add the line below!
|
||||
private readonly IEventManager _eventManager;
|
||||
// Add the line below!
|
||||
private IDisposable _unregister;
|
||||
|
||||
public ExamplePlugin(ILogger<ExamplePlugin> logger, IEventManager eventManager)
|
||||
{
|
||||
_logger = logger;
|
||||
// Add the line below!
|
||||
_eventManager = eventManager;
|
||||
}
|
||||
|
||||
public override ValueTask EnableAsync()
|
||||
{
|
||||
_logger.LogInformation("Example is being enabled.");
|
||||
// Add the line below!
|
||||
_unregister = _eventManager.RegisterListener(new GameEventListener(_logger));
|
||||
return default;
|
||||
}
|
||||
|
||||
public override ValueTask DisableAsync()
|
||||
{
|
||||
_logger.LogInformation("Example is being disabled.");
|
||||
// Add the line below!
|
||||
_unregister.Dispose();
|
||||
return default;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## 7. Build and run your plugin
|
||||
|
||||
Reference in new issue
Block a user