Posts by Miwarre

    As initially described by @notabadminer in this thread, using Inventory.insertNewItem() with a type ID of 43 (objectkit) results in an item being added which has no icon and empty name ("---").


    Either items of type 43 require more parameters (and the Inventory.insertNewItem() requires a different signature or an overloaded variant) or another way has to be found.


    Thanks!

    Sorry it made perfect sense in my mind :D , I will start over. I would like to see someone make an alert to let the Server Owner know when a new person logs on to the server. Sending the Alert to Steam would be the best way. Of course it should have a timer of sorts, so it does not register the people who log on then off.

    I see, thanks for the explanation.


    I have no idea of what sending a notification to Steam implies (nor which kinds of notifications can be sent), but Java allows to access the 'outer world' in some ways. So, in principle, might be possible.


    However, once we 'get out' from the current RW server process, a HUGE lot of things can go wrong (the host where the server is running might not allow sending e-mails or other kinds of messages, the recipient might be not ready to accept it, and so on). Therefore, implementing such a feature in a reasonably reliable way looks much more complex than it may seem at first sight.


    I for one, I am not going to attempt it. Anyone brave enough to accept the challenge?

    Adding a book item via a plug-in is definitely possible; it is not structurally more complex than the existing sample Guest book plug-in. It would not be very difficult to have it expandable to add more recipes (or pets, or monsters, or tunes, or whatever) over time.


    Implementing anything even remooooooootely resembling an NPC is waaaaaay beyond the current plug-in API possibilities though and I do not expect this to change any soon...

    A plug-in allowing any player to get planks, triangular planks, beams, logs and 4 type of windows textured with any of 198 built-in RW construction textures (in other words, the textures of the blocks, which in full creative mode can be obtained wit the console command "item woodplank/beam/log <qty> <textureId>"), even outside of full creative mode.


    It is not intended as a way of cheating, but as a way to extend building possibilities. Then, items have a cost in resources: by default, the same cost a block with the same texture would have: stones, sandstones, dirt, iron ingots, copper ingots (but wood lumbers are used instead of logs).


    Version 0.5.4


    *) Apparently NetBeans does not automatically rebuild all the necessary source files and some of the last fixes did not went through into the .jar. This version is a full rebuild with all the known bugs really fixed! All servers using previous versions are strongly invited to upgrade!


    Version 0.5.3


    *) Fixed a bug with iron and copper ingot ID's: now iron and copper materials are correctly consumed on item making.


    Version 0.5.2


    *) Fixed a bug with new window ID's: now all windows can be properly created.


    Version 0.5.1


    *) Fixed a bug when switching to the last screen of textures while the selected image is greater than the last screen max image.


    Version 0.5.0


    *) Updated to latest plug-in API (0.9.3): now it should work correctly with the latest RW server and client.


    Version 0.4.1


    *) Fixed a bug with the type selection radio buttons.


    *) When in creative mode, resources are free only if the permission file for the player has "freecrafting" set to true.


    - Features



    *) Any of the 198 built-in construction textures can be used (there are 4 screens as the one shown above, through the Up and Down arrows on the right).


    *) Selection of Plank, Beam, Log, Triangle and the 4 type of window frames.


    *) 1 to 64 quantity.


    *) "Min" and "Max" button to jump to minimum (1) and maximum (64) quantity.


    *) ID of textures.


    *) The cost in resources of the current selection is shown.


    *) The player must have enough resources in the inventory (any slot) to "buy" all the selected items; if there are not enough resources, the player is notified in the chat and nothing happens.


    *) On buy, the resources are withdrawn from the inventory and the new items left in it.


    *) By default, one item costs one resource, but greedy server owners can set a higher cost in the plug-in settings.properties.


    *) A setting allows to have item for free (no resources needed) for admins and / or while in creative mode, as in the vanilla game.


    *) All GUI texts can be localised to any other language. English and Italian are provided; Files for German and French (France and Canada) are provided as examples but untranslated. Details in the locale/readme.txt file.
    ____________________


    Important - Important - Important - Important:


    in order to work the plug-in requires the GUI back-end plug-in 0.5.0 available here. Install it at the same time of (or before) installing this plug-in or the server will crash at start-up!
    ____________________


    - Commands


    There is only one command: /pnb (for Planks 'N Beams, but configurable in the plug-in settings.properties) which shows the above screen.


    Installation


    *) Extract the files in the ZIP placing the whole pnb folder into the plugins folder of RW (if the plugins folder does not exist, just create one). The resulting hierarchy shall be:


    Code
    ── RisingWorld
    ├── plugins
    │ ├── pnb
    │ │ ├── assets
    │ │ ├── locale
    │ │ ├── pnb.jar
    │ │ └── settings. properties


    Open points and known issues


    *) As built-in images cannot be accessed, the plug-in has its own, reduced, version of the textures for the GUI and must send them to the client for display; this may affect bandwidth. Only actual practice may tell if and how much. (This only refers to the images used in the GUI, not to the textures actually used to texturise the items, which RW manages internally).


    *) The GUI images come from RW own textures, scaled to 50% and cropped to 64x64 pixels (to fit a reasonable amount of textures in a screen). I hope this does not result in a copyright infringement. I tried to put the images inside the .jar, as a measure of (rather limited) protection, but I could not find a way (see here for details).


    *) Other bugs may well exist! I did my best but foreseeing all the possible use cases and contexts is hard. Post here bug reports, with specific steps to replicate the issues and I'll try to correct them.


    I really need steps or instructions to replicate the problem on my PC or I cannot fix it!


    Source Code


    The source code for this plug-in is available on github .


    Enjoy!

    Files

    • pnb_0_5_4.zip

      (912.78 kB, downloaded 1,903 times, last: )

    I would just like to mention that you always have to be careful about the reloadplugins command. Unloading and reloading classes during runtime is definitely not intended in Java, so there is always a chance that this leads to strange behaviour. Basically this command is mainly there for having an easy way to test plugins without the need to restart the game/server.

    Yes, thanks for reminding everybody of this important point.


    This is the reason why I personally didn't bother to fix an issue with one of my plug-ins which shows up only with reloadplugins.


    On the other hands, also the community and the world servers are somewhat 'in alpha', not only the main programme. Then, it may happen that test/debug features like this one are more frequently used than in a future 'regular use'...

    Did anybody find a way to load an image from the plug-in .jar?


    Background:
    A) The ImageInformation constructors accept either a File or a String.


    B) Class.gerResourceAsStream(String path) returns an InputStream and I found no (reasonably fool-proof) way to obtain a File from an InputStream


    C) Class.getResource(String path) return an URL, which can be converted to a URI and from this a File. So this seemed the way to go.


    However the following code fails:


    Code
    URL url = PlanksAndBeams.plugin.getClass().getResource("/assets/0.png");
    URI uri = url.toURI();
    File file = new File(uri);
    ImageInformation ii = new ImageInformation(file);

    It crashes in line 3 with the error: java.lang.IllegalArgumentException: URI is not hierarchical in new File(uri);


    Just for information:
    *) url.path = file:/home/mmg/.local/share/Steam/steamapps/common/RisingWorldDedicatedServer/plugins/pnb/pnb.jar!/assets/0.png
    *) uri.string = jar:file:/home/mmg/.local/share/Steam/steamapps/common/RisingWorldDedicatedServer/plugins/pnb/pnb.jar!/assets/0.png
    *) url.protocol = "jar"
    *) uri.scheme = "jar"
    *) and, yes, the .jar file contains the "/assets/0.png" file.


    (I would expect the path to start with "file:///", i.e. 3 slashes, bu maybe it does not matter)


    Anyone has any suggestion? Thanks!

    Hello All,


    An Alert for when someone come on to the Server and of course it should have a timer of sorts, so it does not register the people who log on then off.

    Is this a request or an offer?


    An alert where? to whom? how?

    1) I don't know about @Galveston01 plug-in, but I assume that at start up (i.e. when the server is restarted) everything should be there, without any need for an additional reloadplugins.


    2) If you are using the last version of GPS, the error it notifies when doing reloadplugins is benign (and as far as I know unavoidable, it also does not occur always, but apparently randomly, depending on the relative timing of the various RW threads, which is unpredictable).


    It never, never, NEVER crashed my server.


    Are you sure you have the last version (1.0.0: check in server log, where GPS tells its version at start up)?

    The API has player.getInventory().insertNewItem(itemID, itemVariation, amount); This does not work for adding objects. It adds item ID:43, Variation:0, Name: objectkit but the item is blank


    testItem.toString() shows:"Item: Item - id: 43 texture: 1 stack: 1 value: -1.0 status: 0 attribute: obj_9, name: objectkit"


    I am assuming all that is required to add the workbench to inventory is having a way to assign the attribute "obj_9"?

    I tried .insertNewItem((short)43, 0, 1); and in fact an item is added but without any icon in the inventory display and with a name of "---". Dropping it results in a crate being dropped.


    I also added a regular workbench to the inventory (via the usual game operation, which is of course shown correctly in the inventory) and through debug inspection I see differences in obfuscated fields (not accessible through the plug-in API).


    I assume the add item API is not complete yet and an additional parameter would be required to specify the item sub-type for types like "objectkit" with several sub-types.

    1) I used the world database out of ease of implementation. I will look into changing to a separate database.

    As we are speaking of just two tables with at most a couple of hundreds of rows each, there are little reasons for not using SQLite, which is simple, fast and easy. Using a plug-in specific SQLite DB is just a matter of replacing


    WorldDatabase database = getWorldDatabase();


    with


    Datatase database = getSQLiteConnection(getPath() + "/myDBname.db");


    or, if you want to have a separate DB for each world (mostly for use with single player installations, where multiple worlds normally coexist):


    Datatase database = getSQLiteConnection(getPath() + "/myDBname-" + getWorld().getName()+".db");


    I would use database as a class field, so that you can open it at plug-in start-up (onEnable()) and close it at plug-in close-down (onDisable()) and have it ready to use any time you need it (database.executeQuery(...);, database.executeUpdate(...);, etc).


    About the other points, I see you have quickly found a solution. Great!

    @Deirdre: This is a possible change to the GPS plug-in to display coordinates in RW proprietary format:



    The format can be selected with a boolean property in the plug-in configuration file and is server-wide (chosen by server owner and applying to all players).


    Would this suit better your need?