promotional bannermobile promotional banner

ServerVariables | Custom Data and Variables for Players

[Server-Side] This mod allows you to create your own variables for the server and players, meaning you have total control on which values you set
Sin título.png

Sin título.png

Description

ServerVariables

Based on the plugin by Ajneb97 - ServerVariables of Minecraft

Hytale mod that allows storing and managing player variables in MySQL with configurable validation and limitations.

Author: DonKolia
Version: 1.0.0

Features

  • ✅ Persistent variable storage in MySQL
  • ✅ Validation system with data types (INTEGER, DOUBLE, TEXT)
  • ✅ Configurable limitations (min/max values, maximum characters)
  • ✅ Automatic out-of-range value management
  • ✅ Public API for other plugins
  • ✅ Configuration via YAML files
  • ✅ Complete commands with silent mode
  • ✅ Automatically derived initial values

Installation

  1. Place ServerVariables.jar in your Hytale server's mods/ folder
  2. Start the server to automatically generate the configuration
  3. Edit plugins/DonKolia_ServerVariables/config.json with your MySQL credentials
  4. Configure your variables in plugins/DonKolia_ServerVariables/variables/
  5. Restart the server or use /svar reload

 

Configuration

config.json

The config.json file is automatically generated in plugins/DonKolia_ServerVariables/:

{
  "databaseHost": "localhost",
  "databasePort": 3306,
  "databaseName": "hytale_vars",
  "databaseUser": "root",
  "databasePassword": "password"
}
 

Database

The plugin automatically creates the server_variables table:

CREATE TABLE server_variables (
    uuid VARCHAR(36) NOT NULL,
    player_name VARCHAR(16),
    var_key VARCHAR(64) NOT NULL,
    var_value TEXT,
    PRIMARY KEY (uuid, var_key)
);
 

Columns:

  • uuid - Player's UUID
  • player_name - Player's name (for easier queries)
  • var_key - Variable name
  • var_value - Stored value

Variable Configuration

Variables are defined in YAML files inside plugins/DonKolia_ServerVariables/variables/.

Example Files

On first startup, two example files are created:

variables_numerales.yml

variables:
  oro:
    value_type: INTEGER
    limitations:
      max_value: 999999
      min_value: 0
      manage_out_of_range: true

  nivel:
    value_type: INTEGER
    limitations:
      max_value: 100
      min_value: 1
      manage_out_of_range: true

  experiencia:
    value_type: INTEGER
    limitations:
      max_value: 1000000
      min_value: 0
      manage_out_of_range: true

  puntos-habilidad:
    value_type: INTEGER
    limitations:
      max_value: 500
      min_value: 0
      manage_out_of_range: true

  reputacion:
    value_type: DOUBLE
    limitations:
      max_value: 100.0
      min_value: -100.0
      manage_out_of_range: true
 

variables_tipo_texto.yml

variables:
  rango:
    value_type: TEXT
    limitations:
      max_characters: 20

  titulo:
    value_type: TEXT
    limitations:
      max_characters: 30

  clan:
    value_type: TEXT
    limitations:
      max_characters: 16

  prefijo:
    value_type: TEXT
    limitations:
      max_characters: 10

  sufijo:
    value_type: TEXT
    limitations:
      max_characters: 10
 

Variable Structure

variables:
  variable-name:
    value_type: INTEGER|DOUBLE|TEXT
    limitations:
      # For INTEGER and DOUBLE:
      max_value: 100
      min_value: 0
      manage_out_of_range: true

      # For TEXT:
      max_characters: 50
 

Value Types

value_type:

  • INTEGER - Whole numbers (e.g.: 1, 100, -5)
  • DOUBLE - Decimal numbers (e.g.: 1.5, 99.99, -10.25)
  • TEXT - Free text

Limitations

For numeric variables (INTEGER/DOUBLE):

  • max_value - Maximum allowed value
  • min_value - Minimum allowed value (also the initial value)
  • manage_out_of_range - If true, automatically adjusts out-of-range values to the nearest limit

For text variables (TEXT):

  • max_characters - Maximum number of characters allowed

Initial Values

Initial values are automatically derived:

  • INTEGER/DOUBLE: The value of min_value
  • TEXT: Empty string ""

Reload Variables

After creating or modifying YAML files:

/svar reload
 

Commands

All commands use the format /svar <subcommand> <arguments>

/svar set <variable> <value> <player> [silent:true]

Sets the value of a variable.

Validations:

  • The variable must be defined in the YAML files
  • The value must match the variable's type
  • Configured limitations are applied

Examples:

/svar set oro 1000 DonKolia
/svar set nivel 5 DonKolia
/svar set rango "Guerrero" DonKolia
/svar set reputacion 75.5 DonKolia silent:true
 

/svar get <variable> <player>

Gets the value of a variable.

Behavior:

  • If the variable doesn't exist in the DB, returns the initial value
  • Validates that the variable is defined in YAML

Examples:

/svar get oro DonKolia
/svar get nivel DonKolia
 

/svar add <variable> <value> <player> [silent:true]

Adds a value to a numeric variable (INTEGER or DOUBLE).

Validations:

  • Only works with INTEGER or DOUBLE variables
  • Applies limitations after adding

Examples:

/svar add oro 100 DonKolia
/svar add reputacion 5.5 DonKolia silent:true
 

/svar reduce <variable> <value> <player> [silent:true]

Reduces the value of a numeric variable (INTEGER or DOUBLE).

Validations:

  • Only works with INTEGER or DOUBLE variables
  • Applies limitations after subtracting

Examples:

/svar reduce oro 50 DonKolia
/svar reduce reputacion 10.0 DonKolia silent:true
 

/svar reset <variable> <player> [silent:true]

Resets a variable to its initial value.

Behavior:

  • INTEGER/DOUBLE: Resets to min_value
  • TEXT: Resets to empty string

Examples:

/svar reset oro DonKolia
/svar reset nivel DonKolia silent:true
 

/svar reload

Reloads the plugin configuration and YAML variables.

Example:

/svar reload
 

silent:true Parameter

Add silent:true at the end of the command to suppress confirmation messages.

Example:

/svar set oro 1000 DonKolia silent:true
 

Limitation Management

manage_out_of_range: true

When enabled, out-of-range values are automatically adjusted:

oro:
  value_type: INTEGER
  limitations:
    max_value: 1000
    min_value: 0
    manage_out_of_range: true
 

Examples:

  • /svar set oro 1500 DonKolia → Saved as 1000
  • /svar set oro -50 DonKolia → Saved as 0

manage_out_of_range: false

When disabled, the operation is rejected:

nivel:
  value_type: INTEGER
  limitations:
    max_value: 100
    min_value: 1
    manage_out_of_range: false
 

Examples:

  • /svar set nivel 150 DonKolia → Error: "Value 150 exceeds maximum of 100"
 

Common Error Messages

"Variable 'X' is not defined in configuration files"
The variable doesn't exist in any YAML file. Create it first.

"Invalid value type for variable 'X'. Expected: INTEGER"
The provided value doesn't match the variable's type.

"Value X exceeds maximum of Y"
The value exceeds the allowed maximum and manage_out_of_range is set to false.

"Text exceeds maximum length of X characters"
The text is too long for the TEXT variable.

License

Created by DonKolia for Hytale

The ServerVariables | Custom Data and Variables for Players Team

profile avatar
  • 1
    Projects
  • 183
    Downloads