Jump to content

1.18 permissions? I think?


Recommended Posts

Where do I read up on this? I had been working on a mod in 1.17, and while parts of it sort of work in 1.18, other parts throw a message something like no name or privilege has been set.

Or, heck, if anyone just wants to answer what it means and how to fix it, that would be great!

Link to comment
Share on other sites

  • Thorfinn changed the title to 1.18 permissions? I think?

hmm.  that's not much to go on.  If this is related to registering new commands, here's some relatively new and related copypasta from Spud on the VS Discrod...not sure if any of this is 1.18 specific
----------------------
when you register the command with the server api, you can specify a permission needed to be able to call it Documentation (long link bc it goes to the specific function already): https://apidocs.vintagestory.at/api/Vintagestory.API.Server.ICoreServerAPI.html#Vintagestory_API_Server_ICoreServerAPI_RegisterCommand_System_String_System_String_System_String_Vintagestory_API_Common_ServerChatCommandDelegate_System_String_

You can see all the different permissions here:

https://apidocs.vintagestory.at/api/Vintagestory.API.Server.Privilege.html

so for example, the highest privilege someone can have is root. So if you want only someone with that privilege to be able to call the command, you'd register it like api.RegisterCommand(command, description, syntax, handler, Privilege.root);

Edited by Spear and Fang
  • Like 1
Link to comment
Share on other sites

Oops disregard that above post.  Apparently that info is somewhat outdated, as Tyron has reworked the command system to be Fluent.
He talked about this some time ago in Game Dev on the VS Discord, but I'm not sure if there's any related docs yet.

Sorry!

  • Like 1
Link to comment
Share on other sites

Thanks. Wondered if that wasn't the deal. Since then, I've seen the same (or at least a very similar) message from a few other mods that have not been specifically updated to 1.18. I'll just wait and see how others fix that problem. Imitation, flattery, etc.

Link to comment
Share on other sites

Oh, I think I found it. In issuing the api.registerCommand(), I've rarely bothered with specifying a privilege associated. I see in the Wiki that apparently since 1.15, I've supposed to been doing that. For example,

        public override void StartServerSide(ICoreServerAPI api)
        {
            base.StartServerSide(api);
            api.RegisterCommand("here", "spawns particles around the player", "",
                (IServerPlayer player, int groupId, CmdArgs args) =>
                    {

                    }, Privilege.chat);
        }

 I've just been leaving it off unless I wanted to make it only accessible to moderators or those with other defined privileges. Since many existing mods did that and worked, I just assumed leaving it off meant Everyone. Which maybe it did until 1.18.

I kept stripping it down until it got to two lines -- register a command, then send "Hello world" to the chat window, and it still gave the same message.

Quote

26.3.2023 18:43:57 [Notification] Handling Command /helloworld
26.3.2023 18:43:57 [Error] Player LamestScriptKiddie/sj5f36Swtd5630985nfr8 caused an exception through a command.
26.3.2023 18:43:57 [Error] Command: /helloworld
26.3.2023 18:43:57 [Error] Exception: System.InvalidOperationException: Incomplete command - no name or required privilege has been set
   at Vintagestory.Common.ChatCommandApi.Execute(String commandName, TextCommandCallingArgs args, Action`1 onCommandComplete) in C:\Users\Tyron\Documents\vintagestory\game\VintagestoryLib\Common\API\Command\ChatCommandApi.cs:line 91
   at Vintagestory.Common.ChatCommandApi.Execute(String commandName, IServerPlayer player, Int32 groupId, String args, Action`1 onCommandComplete) in C:\Users\Tyron\Documents\vintagestory\game\VintagestoryLib\Common\API\Command\ChatCommandApi.cs:line 111
26.3.2023 18:43:57 [Error]    at Vintagestory.Common.ChatCommandApi.Execute(String commandName, TextCommandCallingArgs args, Action`1 onCommandComplete) in C:\Users\Tyron\Documents\vintagestory\game\VintagestoryLib\Common\API\Command\ChatCommandApi.cs:line 91
   at Vintagestory.Common.ChatCommandApi.Execute(String commandName, IServerPlayer player, Int32 groupId, String args, Action`1 onCommandComplete) in C:\Users\Tyron\Documents\vintagestory\game\VintagestoryLib\Common\API\Command\ChatCommandApi.cs:line 111

I'll do a build later, as its dinner time, but I'm pretty confident that's probably it. That's the kind of error message I would expect if an explicit privilege level were now mandatory.

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.