Some kind of access to the Console. . .

From now on, we will use this info box to inform you about noteable updates on our Trello-Roadmap!

Trello update: We've recently implemented grass and now finalized the occlusion renderer to prevent grass from passing through objects. In addition to that, snowfall now also affects meadows
  • It would be great to have some kind of access the games console via the API.


    I'm imagining something like this sudocode:


    Code
    Console c = this.server.getConsole();
    int id = 1;
    c.execute("spawnnpc dummy id " + id);


    Why? Well I would like to let people spawn NPCs dummies into their builds, but I want to *limit* this (depending on game time). I don't want to allow a new player, who may just be on the server to cause chaos to go around spawning 100's (if not 1000's) of NPCs (which someone could do with a script if blanket access was allowed).


    I would also like to be able to easily write a plugin to spawn NPC animals. I've had a look at the API and I can't see any calls in there that would allow me to do this. The only way round I can see is to directly add new NPCs via the main database. Something I don't like doing hence my own database and own tables for Medieval Realms!


    Something like this would be great!



    Code
    for ( int i = 0 ; i < TOTAL ; i++ ) {
    c.execute("spawnnpc cow id " + some_id_number);
    }


    P.s. I know this is sudocode; I'm not sure how you can spawn anything with an ID number as I've not looked into it yet, but we'll defo need ID numbers on the spawns if we are to keep track of them :saint:

  • you could set up permission groups with an automatic ranking system (e.g. my ServerTools plugin has one included, or I could send you the code to implement one in your own plugin if you don't want to use a separate one) so that they get to a permission group after having spent some time on the server.


    Then the permission group they get to will have in it deny: -* (means all), then allow: -spawnnpc (to give them access to this command only)


    Unfortunately this way you cannot limit the number of NPCs per player.


    Tbh I would like to have console access or at least all the console commands available through the API too.


    I would also like to see a way to obtain for instance the current setr, setl, setp, rotation, etc. settings of a player or maybe have an event e.g. creativeSettingChangeEvent called when a player changes one of those setting with an event.getChangeType() kind of flag to see which of the settings was changed because having a setrChangeEvent, setlChangeEvent, setpChangeEvent, rotationChangeEvent sounds a bit silly to me XD

  • Hmm the problem there is that giving access to *every* spawnnpc command, allowing players to spawn not just the "dummies" :(


    I had wanted to control the amount on an individual (automated) basis.


    Tbh I would like to have console access or at least all the console commands available through the API too.

    I totally agree there!


    I would also like to map certain commands to keys, like setr/setl/setp that you mentioned. Would be so time saving when building with planks and beams using a key press rather than typing in setr 1 setr15 all the time (which I seem to be doing more and more often).


    I *think* it may be possible to do what I'm asking with direct database writes to the main world database ( <X x1000 ) . . . but that will require a LOT of work and LOT of testing on a none-live server before I would even consider adding it to a live world.


    Hopefully @red51 will heed our calls and add API calls for all the console commands in the near future ;):saint::D

  • I *think* it may be possible to do what I'm asking with direct database writes to the main world database ( x1000 ) . . . but that will require a LOT of work and LOT of testing on a none-live server before I would even consider adding it to a live world.

    I don't think it is possible, I have tried for instance to turn a furnace on by a direct database edit but it didn't work because the server is using a cached version of the database when online and saves to the actual database every few seconds, thus doesn't read my change on the fly

  • Sorry for my late response! I will add a way to execute console commands with the next update :)


    However, if you want to spawn npc's, you can use the spawnNpc() method in the World class: https://javadoc.rising-world.n…rld.api.utils.Quaternion-


    For example:

    Code
    //get a reference to the world class
    World world = getWorld();
    //spawn a bear (id 7)
    world.spawnNpc((short) 7, new Vector3f(...), Quaternion.IDENTITY);


    Or alternatively you can make use of definitions (if you don't know a certain npc id, for example):

    Code
    //get the npc definition for a bear
    Definitions.NpcDefinition npcDef = Definitions.getNpcDefinition("bear");
    //spawn the npc
    getWorld().spawnNpc((short)npcDef.getID(), new Vector3f(...), Quaternion.IDENTITY);


    Spawn an npc in front of a player (unfortunately there is no util function for that available, but it will be added soon):


    Sorry for not using syntax highlighting, the current version of the forum software suffers from a bug which discards comments while highlighting is active X/

Participate now!

Don’t have an account yet? Create a new account now and be part of our community!