Skip to content
WolfDen133 edited this page Apr 2, 2023 · 3 revisions

Welcome to the ServerSettingsAPI wiki!

Here you will learn about the api and its different methods

Required methods

You must register the api in your own plugin on enable otherwise the plugin wont work.

API::register($this); // $this being your plugin instance

You must define a title for your form, not doing this will result in a cilent side error.

API::getServerSettings()->setTitle(string $title); 

Optional methods

Icon is the icon that is displayed on the phisical button, it can either be a texture path, or a url

// Icon type can be accessed from constants in the ServerSettings class
// E.G. ServerSettings::TYPE_PATH or ServerSettings::TYPE_URL
// Icon data is the actual string of the url or texture path
API::getServerSettings()->setIcon(int $iconType, string $data);

image

Lables are just plain text for the user to read

API::getServerSettings()->addLabel(string $text);

image

Inputs are plaintext fields for the player to input

API::getServerSettings()->addInput(string $title, string $placeholder, string $default);

image

Toggles are on/off switches for the player to toggle

API::getServerSettings()->addToggle(string $text, bool $default);

image

Sliders are a way for the user to input integer data between to values Step being the devision between the inputed values

API::getServerSettings()->addSlider($text, int $min, int $max, int $step, int $default);

image

Stepped sliders are a way for users to choose between multiple set values in a slider

API::getServerSettings()->addStepSlider(string $text, array $options, int $defaultIndex);

image

Dropdowns are a way for players to choose between multiple set values using a list

API::getServerSettings()->addDropdown(string $text, array $options, array $defaultIndex);

image

Getting the data

Data is presented in an array that is ordered in the order that you set every field

API::getServerSettings()->addToggle(string $text, bool $default);

API::getServerSettings()->setCallable(function (Player $player, array $data = null) : void {
    if ($data == null) return;
    $value1 = $data[0]; // Would return a true false value from the toggle
});

Clone this wiki locally