HogWarp
  • Home
    • Frequently Asked Questions
    • Supported Versions
  • Client
    • Quick start
      • Playstation Controller not working
      • Epic Games Version Saves Fix
  • Server
    • Quick Start
    • Server Requirements
    • Troubleshooting
  • Scripting
    • Getting Started
    • Client side
      • Basics
      • Setting up mods
        • Local Cooking / Building
    • Server side
      • Plugin
        • Creating a Plugin
        • Structure / Lifecycle
        • Plugin ↔ Plugin
      • Debugging
      • Event handling
      • API Documentation
        • Server
          • IPlugin
          • PlayerSystem
          • RpcManager
          • Timer
          • World
        • Game
          • Types
        • Systems
          • Logger
          • ClientRpcAttribute
          • ReplicatedAttribute
          • ServerRpcAttribute
Powered by GitBook
On this page
  1. Scripting
  2. Server side
  3. Plugin

Plugin ↔ Plugin

The following page describes how a plugin may interact with another plugin, e.g. calling functions.

PreviousStructure / LifecycleNextDebugging

Last updated 3 months ago

Given that there are two plugins PluginA and PluginB , it is possible to call methods / access each other using the PluginManager.

A reference to the build *.dll of the other plugin is required in the solution, similiar to the HogWarpSdk.dll reference done in .

Make sure to only access another plugin earliest in the PostLoad lifecycle, as it is not guaranteed to be loaded if called earlier.

Example

PluginA.cs
namespace PluginA;

public class Plugin : HogWarpSdk.IPlugin
{
    public string Author { get; } = "YourName";
    public string Name { get; } = "PluginA";
    public Version Version { get; } = new(1, 0, 0, 0);
    
    public Plugin() { }

    public void PostLoad() { }

    public void Shutdown() { }
    
    public void DoSomething() 
    {
        // This method is called from a different plugin
    }
}

PluginB.cs
namespace PluginB;

public class Plugin : HogWarpSdk.IPlugin
{
    public string Author { get; } = "YourName";
    public string Name { get; } = "PluginB";
    public Version Version { get; } = new(1, 0, 0, 0);
    
    public Plugin() { }

    public void PostLoad() 
    { 
        _logger.Info("Post load");

        var pluginA = HogWarpSdk.Server.PluginManager.Get<PluginA.Plugin>();
        if (pluginA != null)
        {
            _logger.Info($"PluginA found, version {pluginA.Version}");
            pluginA.DoSomething();
        }
        else
        {
            _logger.Info("PluginA not found");
        }
    }

    public void Shutdown() { }
}

Configure the project