Skip to content

Configuring Stonks for Fabric

nahkd123 edited this page Aug 8, 2023 · 1 revision

This is the guide for configuring Stonks for Fabric.

All file locations

  • Configuration file (global): /config/stonks/config
  • Market offers data (if you are using internal service): /world/stonks.bin (or /saves/<World Name>/stonks.bin if you installed Stonks in your client, which is not needed).

The global configuration file

This configuration file affects all worlds, thus it's called "global configuration file".

Syntax

This configuration file uses a special format with this following syntax:

// This is a comment

// This is a standard key-value pair configuration
key value

// A configuration file can accepts more than 1 key-value pair with same key:
key yet another value

// Multi lines value thing
key my value \
    on a different line \
    remove the " \" suffix to \
    end multi line mode

// Indentation
parentKey value for parent key
    child value
    child another child value
        childInChild

// No value configuration
keyWithNoValue

Default configuration

Note: If you want to reset to default configuration, simply delete /config/stonks/config.

This is the default configuration that came with Stonks for Fabric. Please note that this is the stripped down config; the full config can be obtained by deleting /config/stonks/config or extract default-config from stonks-fabric.jar.

// Stonks2 for Fabric: Configuration file
// ...

// Service
// You can only have 1 active service for each server
useService stonks.fabric.service.IntegratedStonksService
    // Because this is integrated service, you have to specify all products
    // If you are using remote service, you don't have to specify products here
    category foods
        name Foods
        product apple
            name Apple
            construction item minecraft:apple
        product carrot
            name Carrot
            construction item minecraft:carrot
        // ... More products here ...
    category specials
        name Special Items
        product special_paper
            name Special Paper
            construction item minecraft:paper{ \
                display: { \
                    Name: '{"text": "Special Paper", "color": "red", "italic": false}', \
                    Lore: [ \
                        '{"text": "Edit this in /config/stonks/config!", "color": "aqua", "italic": false}' \
                    ] \
                } \
            }

// Adapters
useAdapter stonks.fabric.adapter.provided.ItemsAdapter

// ...

Services

  • Key: useService [Service name]

stonks.fabric.service.IntegratedStonksService

useService stonks.fabric.service.IntegratedStonksService

This is the service that comes with Stonks for Fabric and included in default configuration.

category category_id
    name Category Name
    // Category icons are not supported (yet).
    product product_id
        // Name of the product that will be
        // displayed in menus
        name My Product
        construction [see adapters section]

category another_category_id
    name Category Name
    // ...

Adapters

  • Key: useAdapter [Adapter name]

stonks.fabric.adapter.provided.ItemsAdapter

useAdapter stonks.fabric.adapter.provided.ItemsAdapter

This adapter converts construction data from products to items and vice versa. Construction data must follow the following syntax:

item <Item ID>[NBT Data]

For example:

product product_id
    name Cool Product
    construction item mymod:mod_item_id{NbtKey: "Value"}

stonks.fabric.adapter.provided.ScoreboardUnitAdapter

useAdapter stonks.fabric.adapter.provided.ScoreboardUnitAdapter

This adapter converts construction data from products to scoreboard objective score and vice versa. Construction data must follow the following syntax:

scoreboard-objective objectiveName

If the objective does not exists, it will creates a new objective with dummy criterion.

stonks.fabric.adapter.provided.ScoreboardEconomyAdapter

useAdapter stonks.fabric.adapter.provided.ScoreboardEconomyAdapter
    objective balance
    decimals 2

This adapter uses player's score in scoreboard objective for economy system.

Player's balance can be calculated using this formula: balance = score / (10 ^ decimals).

stonks.fabric.adapter.provided.CommonEconomyAdapter

useAdapter stonks.fabric.adapter.provided.CommonEconomyAdapter
    id modid:account_id
    decimals 2

This adapter allows Stonks to interact with other mods that are using Patbox's Common Economy API. The player's balance formula is the same as ScoreboardEconomyAdapter, except score now become rawBalance (which is 64-bit integer).