Giter Site home page Giter Site logo

northwood-studios / nwpluginapi Goto Github PK

View Code? Open in Web Editor NEW
77.0 9.0 46.0 2.18 MB

Official server-side plugin system for SCP: Secret Laboratory game.

License: GNU Lesser General Public License v3.0

C# 92.29% PowerShell 0.59% CSS 4.49% JavaScript 2.63%
scpsl scpsl-framework scpsl-modloader scpsl-plugin scpsl-server scp-sl secret-lab secret-laboratory scp-secret-laboratory scp-sl-server

nwpluginapi's Introduction

Nw Plugin API GitHub release NuGet Discord Invitation License

Official server-side plugin system for SCP: Secret Laboratory game.

Documentation can be found here.

nwpluginapi's People

Contributors

bonjemus avatar ced777ric avatar exilon24 avatar jesus-qc avatar joker-119 avatar killers0992 avatar michal78900 avatar microsievert avatar minerpl avatar misaka-zerotwo avatar moddedmcplayer avatar pintthedragon avatar realmwth avatar sebascapo avatar sirmeepington avatar srlicht avatar takail avatar xlittleleft avatar zabszk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nwpluginapi's Issues

Wrong arguments in PlayerInteractLocker

[2022-12-15 00:48:45.131 +00:00] [Error] [PluginAPI] Event OnInteractWithLocker (PlayerInteractLocker) in plugin MyPlugin.Plugin contains wrong parameters
                                  - Player, Locker, Byte, Boolean
                                  - Required:
                                  - IPlayer.

I used the github template and only changed MyPlayer to Player.

[Suggestion] Documentation

Basically it would be nice to document not only the api but Assembly-CSharp and release their documentation xml files somewhere.

Plugin/Event Priority

There should be a priority to how events are executed. Some plugins might want to go first, and others last. For example, a gamemode plugin might want to run first to prevent incompatibilities with other plugins, and a logging plugin might want to go last to make sure it logs what actually happens.

Oban event (or event for all bans)

There isn't any event to see offline bans. I think the best case would be to have a banned event that passes in a nullable player + issuer, plus the ban details.

Event 99 is not registered in manager

I have registered the event(PlayerInteractDoor) as it is in the github examples and in the console it shows this error:

[Error] [PluginAPI] Event 99 is not registered in manager! ( create issue on github )

More events

106 events:

  • PlayerPocketDimensionEnter
  • PlayerPocketDimensionLeave
  • PlayerPocketDimensionDie

Others:

  • PlayerSetNickname(Player player, string oldName)
  • PlayerThrowGrenade - Preferably allowing the plugin to change things like direction and throwing power
  • PlayerInfect - Things like amount of damage and time they will be infected would be useful.
  • ServerNameSet
  • OnSummonVehicle - Whenever the helicopter or car is summoned
  • OnPlayerTriggerTesla
  • On079UseElevator

Add Player.Items

If it could be a list with just the items I would be grateful :)

Explicitly define enum values

For the sake of plugin compatibility between releases, enum values should be explicitly defined. This is because any changes other than adding a new enum members to the end of an enum will cause a plugin to use the incorrect enum member unless it is recompiled, which can be very bad. To solve this, enum values should be explicitly defined, especially for enums in the API but also for commonly used enums outside of it (e.g., RoleType, ItemType).

Doc

Where can we find the doc?

Suggestion: new events

Updated requested events list:

SCP079Interaction
SCP914ChangeKnob
SCP914Activate
PlayerInteractDoor
RoundSpawnRoles (so we can alter player roles on round start automatically)
ReinforcementArrive
ReinforcementPrepare

Allow viewing cancelled events

I think cancelled events should be viewable by plugins. They should also be able to un-cancel events.

Making events fully cancellable by plugins can lead to some issues. I think a good example is the difference between cancelling and handling.

Say, for example, we have a command system that works by having an CommandExecuted event. It's been established that this is only for handling commands. In this case, the expectation is that the plugins send some response. Furthermore, they shouldn't send duplicate responses. One way of doing this might be with a Handled property somewhere. As soon as one of the plugins handles the command (and so Handled is true), there's no reason to continue, because it's already been handled.

But this isn't how plugin events work.

Consider the case of a similar event, CommandRan. I'm giving them different names, but they're effectively the same. The difference is that CommandRan isn't meant for executing commands. Rather, it's meant for letting the plugins do something, anything, when a command is ran. It might also have a Cancelled property. If we handle this cancellation the same as handle above, then one plugin may use the event to create a command. When they see the command, they send a response and cancel the event. That's all well and good, but what happens if another plugin comes in and wants to log every command that's ran. Because the previous plugin cancelled, this plugin just won't see the event, and will log incorrectly.

I think the solution to this is to allow plugins to view if an event is cancelled, and maybe also uncancel it. In this case, our first plugin can respond to the user and set it to cancelled. Then, our second plugin will see the event (and that it was cancelled), but will still be able to log it. If any other plugins comes in and tries to respond to the user after the first plugin already did, it can check if the event was cancelled, and if so, not do anything.

Side note: Plugins should use the actual command system. This is just an example. Also, plugin/event priority would help fix this, but maybe the logging plugin wants to always run last (maybe to see if the event was marked as cancelled).

Player::Get(UserId) does not work as intended

Player::Get(UserId) always returns null, even if the userid specific is in the game.

It appears that players never get aded to the PlayerUserIds dictionary which is supposed to happen in EventManager::ExecuteEvent which does not appear to happen.

Add PlayerBanning and PlayerKicking Events and a way to prevent them

Currently, there are events to handle players that have already been banned or kicked. But for the purposes of certain plugins, particularly ones that use an online web panel and API, there needs to be a way to run logic before a ban or kick and a way to prevent it. Currently, the only solution is to unban someone immediately after they get banned, which is inconvenient.

Project Structure

The project structure is very wrong, it is based on wrappers for the main classes.

The structure it should have is just implement the api into the main classes, this won't only provide a higher maintainability but readability and stability.

Pls add to SCP079Generator

// <smod>
public bool Open
{
	get => HasFlag(_flags, GeneratorFlags.Open);
	set => ServerSetFlag(GeneratorFlags.Open, value);
}

public bool Unlocked
{
	get => HasFlag(_flags, GeneratorFlags.Unlocked);
	set => ServerSetFlag(GeneratorFlags.Unlocked, value);
}

public float TimeLeft => (float)_leverStopwatch.Elapsed.TotalSeconds - _leverDelay;

public float ActivationTime => _leverDelay;
// </smod>

Server.Instance is null

During Runtime, the Server.Instance return null, which causes any Player.SendBroadcast call to fail with NullRef.

System.NullReferenceException: Object reference not set to an instance of an object
                                   at PluginAPI.Core.Player.SendBroadcast (System.String message, System.UInt16 duration, Broadcast+BroadcastFlags type, System.Boolean shouldClearPrevious)

I'm using version 12.0.0-beta9

The API uses Server.Instance.GetComponent<Broadcast> in the SendBroadcast function but bc command uses Broadcast.Instance. This can be used as a WorkAround

Add setrank function to the player class

Basically this but with the group part fixed. You could simply make the permissions handler public in the game and use this exact code.

image

public static void SetRank(this Player player, string color = null, string text = null, string group = null)
{
	ServerRoles roleComponent = player.ReferenceHub.serverRoles;

	if (roleComponent != null)
	{
		// TODO: Fix vanilla ranks
		if (group != null)
			roleComponent.SetGroup(ServerStatic.PermissionsHandler.GetGroup(group), false);
		if (color != null)
			roleComponent.SetColor(color);
		if (text != null)
			roleComponent.SetText(text);
	}
}

Add IsLocked in Warhead

I don't want them to be able to disable the auto warhead. For now I will use

private static AlphaWarheadController Controller;
Controller.IsLocked = true;

Add 106 events

  • PlayerEnterFemurBreaker
  • PlayerContain106 (Specifically when someone presses the button)
  • Player106Teleport
  • Player106CreatePortal
  • PlayerPocketDimensionEnter
  • PlayerPocketDimensionLeave
  • PlayerPocketDimensionDie (?)

Not sure about the last one, we had it in smod but I can't really see how it is useful in comparison to the normal death event.

Missing way to deny events

Adding IsAllowed or Cancel() to events that can be prevented, ex. ServerEventType.PlayerDeath or ServerEventType.PlayerDamage

Invalid cast exception after first eventhandler of event with multiple handlers fires

afbeelding

Which leads back to
afbeelding
in EventManager::ExcuteEvent

the method in question calls
afbeelding
which seems to replace elements with the Player object for that handler. (error occurs on the highlighted text)

It seems like the args array is being reused, but Player objects cannot be casted back to (igamecomponent) so it throws an exception

If ToArray is called on the args array everything works as expected, this is likely due to that ToArray creates a copy of the array, which means changes done by RegenerateParameters do not affect the other handlers as each has their own copy of the array.

afbeelding

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.