Code Monkey home page Code Monkey logo

nwn.permissions's Introduction

NWN.Permissions

NWN.Permissions is a configurable and extensible permissions plugin for Anvil-based Neverwinter Nights servers that allows server admins to control abilities, commands and features for players and dungeon masters alike.

Out of the box, NWN.Permissions includes permission rules for controlling Dungeon Master powers in the DM client, and permissiosn for speaking in the shout channel, but this can be easily extended to support custom widgets and commands.

Installation

  1. Download the latest plugin from the Releases page: https://github.com/Jorteck/NWN.Permissions/releases
  2. Unzip the file, and place the NWN.Permissions folder into your Anvil plugin directory. The directory structure should look like the following:
|----Plugins/
     |----NWN.Permissions/
          |----NWN.Permissions.dll
  1. Launch the server. You should now be ready to start!

Configuration

See the Configuration Wiki Page for a guide on configuring permissions in-game, or via the config .yml files.

Adding permissions to your own plugin

To start, you will need to add the NWN.Permissions package as a reference in NuGet. This can be done by navigating to your plugin, and entering the follow command:

dotnet add package NWN.Permissions -v <desired version>

Where <desired version> is the version of NWN.Permissions you would like to to use.

Once installed, you will have access to the NWN.Permissions APIs. NWN.Permissions has a very simple interface for querying player permissions.

Simply reference Jorteck.Permissions.PermissionsService in your service constructor, and you can check your custom permissions using PermissionService.HasPermission():

using Anvil.API;
using Anvil.API.Events;
using Anvil.Services;
using Jorteck.Permissions;

[ServiceBinding(typeof(CoolCommandService))]
public sealed class CoolCommandService
{
  // The permission key to check.
  private const string MyPermissionKey = "server.usecoolcommand";

  private readonly PermissionsService permissionsService;

  public CoolCommandService(PermissionsService permissionsService)
  {
    this.permissionsService = permissionsService;
    NwModule.Instance.OnPlayerChat += OnPlayerChat;
  }

  private void OnPlayerChat(ModuleEvents.OnPlayerChat eventData)
  {
    // Check if the message sent was the cool command.
    if (eventData.Message == "/cool")
    {
      // Check to see if the sender of this message has permission to use the command.
      if (permissionsService.HasPermission(eventData.Sender, MyPermissionKey))
      {
        // Tell them they are cool!
        eventData.Sender.SendServerMessage("You are awesome!");
      }
    }
  }
}

nwn.permissions's People

Contributors

jakkn avatar jhett12321 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

jakkn

nwn.permissions's Issues

ListPermissions - List permissions for a user

Server admins should be able to list the permission rules for a user with /perms user listpermissions.

The returned list should have the explicit permissions for their user, as well as any permissions that are inherited from group memberships.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.