Skip to content

Commands

Hazel Rojas edited this page Oct 5, 2023 · 10 revisions

Note

We will include the SteveSharp.Core using for all the commands.

You must have a project created.

The commands will be written inside of functions.

/say

Classes references:
SteveSharp.Core.Chat

You can execute /say by calling the Chat.Say() method

For example:

Chat.Say("Hello World!")

Result:

say Hello World!

/tellraw

Classes references:
SteveSharp.Core.Chat
SteveSharp.JsonShapes.TextComponent

This is a more complicated instruction, you can check the TextComponent class to write the message structure.

You need to call the Chat.Out() method, giving a specific argument: You need to initialize an array of TextComponents

Chat.Out(
    new TextComponent[] {
        
    }
)

And then, add a TextComponent inside of the array, to create a TextComponent:

Chat.Out(
    new TextComponent[] {
        new TextComponent {
            
        }
    }
)

And then, specify the text, and another property if you want (the code is yours)

Chat.Out(
    new TextComponent[] {
        new TextComponent {
            text = "This is my /tellraw",
            color = "green",
            italic = true,
            underlined = true
        }
    }
)

Another benefit: Because the method uses an array of TextComponents, you can write multiple texts like in the commands!

Chat.Out(
    new TextComponent[] {
        new TextComponent {
            text = "This is my",
            color = "aqua",
            italic = true
        },
        new TextComponent {
            text = "/tellraw",
            color = "green",
            italic = true,
            underlined = true
        }
    }
)

/scoreboard

Classes references:
SteveSharp.Core.Score

Outside the function, add this code to declare your scoreboard, this will initialize your scoreboard object in the code. Please specify the id parameter at least. If is dummy type, skip the type parameter, else, specify that parameter, and if your scoreboard includes a name, also specify the name parameter

Score MyScore = new Score("myScore");

objectives

add

Outside the function, to add the function, you will need to initialize your scoreboard object and inside the function, add the AddObjective() method of your scoreboard. Example:

Score MyScore = new Score("myScore");
MyFunction.WriteAllCommands(
    new string[]{
        MyScore.AddObjective()
    }
);

Result:

scoreboard objectives add myScore dummy

You can add multiple objectives in a single instruction calling the Score.AddObjectives() method

MyFunction.WriteAllCommands(
    new string[]{
        Score.AddObjectives(
            new Score[]{
                new Score("my"),
                new Score("three", "deathCount"),
                new Score("scoreboards", "used:warped_fungus_on_a_stick")
            }
        )
    }
);

Result:

scoreboard objectives add my dummy
scoreboard objectives add three deathCount
scoreboard objectives add scoreboards used:warped_fungus_on_a_stick

but will be a trouble later when you will work using that scoreboards and will be illegible, I recommend declaring all the scoreboards before, and then execute the single instruction:

Score My = new Score("my");
Score Three = new Score("three", "deathCount");
Score Scoreboards = new Score("scoreboards", "used:warped_fungus_on_a_stick");
MyFunction.WriteAllCommands(
    new string[]{
        Score.AddObjectives(
            new Score[]{
                My,
                Three,
                Scoreboards
            }
        )
    }
);

Result:

scoreboard objectives add my dummy
scoreboard objectives add three deathCount
scoreboard objectives add scoreboards used:warped_fungus_on_a_stick

Clone this wiki locally