Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions examples/WithSharedTypes/WithSharedTypesPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ public class WithSharedTypesPlugin : BasePlugin
// Note that we use the same name for the capability as the one in the other plugin.
// IBalanceHandler is defined in MySharedTypes.Contracts, which is a shared library and placed in the `shared/` subfolder.
public static PlayerCapability<IBalanceHandler> BalanceCapability { get; } = new("myplugin:balance");

// Declares a player capability of a primitive type, in this case, a decimal.
public static PlayerCapability<Decimal> BalanceCapabilityDecimal { get; } = new("myplugin:balance_decimal");

// Plugin capabilities are similar to player capabilities, but they are not tied to a player, and are just generic APIs
// that are exposed by a plugin. In this case, we expose a balance service, which is used to clear all balances.
public static PluginCapability<IBalanceService> BalanceServiceCapability { get; } = new("myplugin:balance_service");

public override void Load(bool hotReload)
{
// Register the capability implementations here. Note that plugins don't need to register an implementation if it is already implemented in another plugin.
Capabilities.RegisterPlayerCapability(BalanceCapability, player => new BalanceHandler(player));
Capabilities.RegisterPluginCapability(BalanceServiceCapability, () => new BalanceService());
Capabilities.RegisterPlayerCapability(BalanceCapabilityDecimal, (player) => new BalanceHandler(player).Balance);
Capabilities.RegisterPlayerCapability(this, BalanceCapability, player => new BalanceHandler(player));
Capabilities.RegisterPluginCapability(this, BalanceServiceCapability, () => new BalanceService());
Capabilities.RegisterPlayerCapability(this, BalanceCapabilityDecimal, (player) => new BalanceHandler(player).Balance);

AddCommand("css_balance", "Gets your current balance", (player, info) =>
{
Expand Down
Loading
Loading