Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server.Instance is null #61

Closed
Sqbika opened this issue Dec 8, 2022 · 1 comment · Fixed by #69
Closed

Server.Instance is null #61

Sqbika opened this issue Dec 8, 2022 · 1 comment · Fixed by #69
Milestone

Comments

@Sqbika
Copy link

Sqbika commented Dec 8, 2022

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

@Sqbika
Copy link
Author

Sqbika commented Dec 11, 2022

This can be fixed easily, albeit temporarily, by doing

        public override IPlayer Create(IGameComponent component)
        {
            if (((ReferenceHub) component).isLocalPlayer)
            {
                new Server(component);
            }

            return new MyPlayer(component, _plugin);
        }

@Killers0992 Killers0992 added this to the 12.0.0-beta10 milestone Dec 11, 2022
@zabszk zabszk linked a pull request Dec 13, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants