Skip to content

Plugin API (Methods)

laz edited this page Jun 27, 2025 · 58 revisions

This page includes all API methods supported by DaemonMC.

Check this page to learn how to use events: Events

CommandManager

Register(Command, Action)

Register new command with function.

CommandManager.Register(new Command("hub", "Teleport back to hub"), tpHub);

You will also need to create function for every command that will get called on command use. Example below shows function for "hub" command including trasfering to hub World if player isn't there.

private void tpHub(Player player)
{
    if (player.CurrentWorld.LevelName != "hub")
    {
        player.ChangeWorld(Server.GetWorld("hub"), new Vector3(2, -54, -11));
    }
    else
    {
        player.Teleport(new Vector3(2, -54, -11));
    }
}

Unregister(string)

Unregister built-in or other registered commands that you don't need.

CommandManager.Unregister("about")

Entity

All entity variants can be found here VanillaEntities except CustomEntity() but its usage is same. Possible ActorProperties values can be found here bedrock-samples by looking at "properties" values. For example from bedrock-samples

  "minecraft:entity": {
    "description": {
      "identifier": "minecraft:pig",
      "spawn_category": "creature",
      "is_spawnable": true,
      "is_summonable": true,
      "properties": {
        "minecraft:climate_variant": {
          "type": "enum",
          "values": [ "temperate", "warm", "cold" ],
          "default": "temperate",
          "client_sync": true
        }
      }
    },

We can create

ActorProperties.RegisterProperty("minecraft:pig", new ActorProperty(new string[] { "temperate", "warm", "cold" }, "minecraft:climate_variant"));

Entity spawn example.

public override void OnLoad()
{
    ResourcePackManager.RegisterAnimation("idleAnimation", "controller.animation.humanoid.custom_controller", "animation.humanoid.custom.Rocky");
    ActorProperties.RegisterProperty("minecraft:pig", new ActorProperty(new string[] { "temperate", "warm", "cold" }, "minecraft:climate_variant"));
}

var entity = new Spider();
entity.Position = Vector3(0, 0, 0);
entity.Skin = Skin.Create("Plugins/skin.png", "Plugins/geometry.json"); //Warning: This feature is exclusive for CustomEntity entities.
entity.NameTag = "Rocky";
entity.SpawnAnimation = "idleAnimation";
entity.Properties.UpdateEntry(0, 2); //this matched registered property at OnLoad(): 0 is index for climate_variant, 2 is property (in this case cold, according to registered property 0 - "temperate", 1 - "warm", 2 - "cold")
entity.Spawn(world);

Despawn()

Despawns entity.

entity.Despawn();

MoveTo(Vector3)

Move entity to specified location.

entity.MoveTo(new Vector3(10, -20, 15))

Properties.UpdateEntry(int, int/float);

Update entities properties registered by ActorProperties.RegisterProperty. Read more about how to use properties in Entity tab. Properties.UpdateEntry(0, 2);

PlayAnimation(string, long(optional))

Broadcast (long = (default -1)) or send to only one player (long - player.EntityID) entity animation registered by ResourcePackManager RegisterAnimation.

entity.PlayAnimation("CustomSpawnAnimation")

SetFlag(ActorFlags, Bool)

Enable (Bool - true) or disable (Bool - false) ActorFlags data for the entity.

entity.SetFlag(ActorFlags.ONFIRE, true);

SetNameTag(string)

Change entity display name that other players can see.

entity.SetNameTag($"Mod {player.username}")

Spawn(World)

Spawns entity in specified world.

entity.Spawn(world);

Form

Forms are way to make UI in the game. Below you can find how to build and send each type of forms. Every form is sent with player.SendForm(form, formAction) and need to have action void void formAction(Player player, string response) that will get called when player submitted form.

CustomForm()

CustomForm example with all possible components. More information about components usage and features you can find in Form Components selection

var form = new CustomForm();
form.Title = "Form title";
form.Content.Add(new Label("label test"));
form.Content.Add(new Dropdown("dropdown test", new List<string>() { "option1", "option2" }, "option1"));
form.Content.Add(new Input("input test", "username", "steve11"));
form.Content.Add(new Slider("slider test", 0, 10, 2));
form.Content.Add(new StepSlider("step slider test", new List<string>() { "value1", "value2", "value3", "value4" }, "value2"));
form.Content.Add(new Toggle("toggle test", true));
player.SendForm(form, formAction);

customform

To access this form values you will need to deserialize received data that in this case is string[]; And now you can access every data field. Data field count is starting from first added component labels including. Example is showing how to access data from this custom form example.

private void formAction(Player player, string response)
{
    var data = JsonConvert.DeserializeObject<string[]>(response); //we need to convert data to string array

    Log.debug(data[0]); //first content added so this output is "label test"
    Log.debug(data[1]); //here we got "option1" or "option2" depens on what was choosen
    Log.debug(data[2]); //"steve11" or anything that was typed in
    Log.debug(data[3]); //"1" to "10" - slider value
    Log.debug(data[4]); // "value1" to "value4" - value where slider was set on
    Log.debug(data[5]); //"true" or "false"
}

ModalForm()

Modal form is simplest form type. It supports two buttons.

var form = new ModalForm();
form.Title = "Form title";
form.Content = "Form text";
form.Button1 = "yes";
form.Button2 = "no";
player.SendForm(form, formAction);

modalform

In action you will get button title that player clicked on.

private void formAction(Player player, string response)
{
    Log.debug(response); //this can be "yes" or "no"
}

SimpleForm()

Simple form can contain multiple buttons.

var form = new SimpleForm();
form.Title = "Form title";
form.Content = "Form text";
form.Buttons = new List<Button>() { new Button("simple button"), new Button("button with pic", "textures/items/apple"), new Button("button with external pic", "https://imagesiteabcd.aa/image.png") };
player.SendForm(form, formAction);

simpleform

In action you will get data that button title that player clicked on.

private void formAction(Player player, string response)
{
    Log.debug(response); //this can be "simple button", "button with pic" or button with external pic"
}

Form Buttons

Button(string, string(optional));

Form buttons are components that can be use only by SimpleForm() form type.

This example shows how to have button with texture from your resource pack. If you need picture for button this is recomended approach because loading picture from external link will take more time.

To load picture from external resources just use picture link like https://imagesiteabcd.aa/image.png instead of "textures/items/apple". And to have button without picture optional value is not needed.

new Button("button with pic", "textures/items/apple")

Form Components

Form components are components that can be used only by CustomForm() form type.

Dropdown(string, List, string(optional))

Dropdown is component which player can use to choose values from dropdown added to CustomForm. In this example dropdown title will be "dropdown test", dropdown options are stored in string list: "option1" and "option2" and "option1" is optional value that will show up as default selected value in dropdown.

new Dropdown("dropdown test", new List<string>() { "option1", "option2" }, "option1")

Input(string, string, string(optional))

Input is component that player can use to enter text. In this example "input test" is title for this component, "username" is placeholder and will appear before player click on input that is when input is inactive and "steve11" is optional value that will be already typed in this input field.

new Input("input test", "username", "steve11")

Label(string)

Label is simplest component, it's just text component. Simple text will appear in form with this component that is this case is "label test".

new Label("label test")

Slider(string, int, int, int(optional))

Slider is component that can be used to choose between numeric values using slider. In this example "slider test" is title for this component, "0" is slider minimum value, 10 in this case is maximum value and 2 is optional value that will set slide in specified default value.

new Slider("slider test", 0, 10, 2)

StepSlider(string, List, string(optional))

StepSlider is something between Slider and Dropdown. Instead of numeric values like with Slider you can choose between string values using StepSlider. In this example "step slider test" is title for this component, "value1", "value2", "value3", "value4" are values that player will be able to slide between and "value2" is optional value that will set slider in specified position.

new StepSlider("step slider test", new List<string>() { "value1", "value2", "value3", "value4" }, "value2")

Toggle(string, bool(optional))

Toggle is simple component that appears as switch in form UI. Player can choose between enable or disable that will be true and false in bool. In this case "toggle test" is title for this component and true is optional value for this toggle to set it enabled or disabled.

new Toggle("toggle test", true)

Inventory

Inventory is used to store Player items. It is accessible using Player.Inventory

GetHand()

This function will return Item that player is holding in his hand or Air if player is not holding any item.

Log.debug(inventory.GetHand()) //[DEBUG] IronSword

OnChest(Item);

Put armor item on Player's chest.

inventory.OnChest(new Items.VanillaItems.DiamondChestplate());

OnFeet(Item);

Put armor item on Player's feet.

inventory.OnFeet(new Items.VanillaItems.NetheriteBoots());

OnHead(Item);

Put armor item on Player's head.

inventory.OnHead(new Items.VanillaItems.NetheriteHelmet());

OnLegs(Item);

Put armor item on Player's legs.

inventory.OnLegs(new Items.VanillaItems.DiamondLeggings());

Set(int, int, Item);

Put item in player's inventory. In this first int is container id and second is slot. Slot range is 0 - 35. 0 - 10 are also player's hotbar slots. 10 - 35 the rest inventory slots that are visable only when opening inventory. This example is showing how to put item in player's inventorys 2nd slot that is also hotbar 2nd slot. 0 is 1st slot.

Inventory.Set(0, 1, new Items.VanillaItems.DiamondLeggings());

Send(int, int, Item);

Similar to set but difference between Set and Send is that Send wont save item in player's inventory but just send it for visual effects.

Inventory.Send(0, 1, new Items.VanillaItems.DiamondLeggings());

Player

AddEffect(Effect, int(optional), bool(optional)))

Apply effect to player. First variable is Effect All possible effect values can be found here Effects.cs, second variable is optional effect duration in ticks variable. Default value is -1 that will apply for infinite time, last variable is bool that to show or hide effect particles. true to show particles, false to hide. Default value is true This example will apply Fire Resistance effect for 200 ticks or 10 seconds. Player can have multiple different effects at the same time.

player.AddEffect(Effects.FireResistance, 200)

ChangeWorld(World, Vector3)

Transfer player to another World.

player.ChangeWorld("SkyWars", new Vector3(0, 40, 0)) //"SkyWars" is world name for world found in worlds folder "SkyWars.mcworld"

ClearTitle()

Clear all on-screen titles and popups.

player.ClearTitle()

Kick(String)

Disconnect player from the server with message.

player.Kick("You have been kicked");

MoveTo(Vector3)

Move player to specified location. (For longer distances use Teleport(Vector3))

player.MoveTo(new Vector3(10, -20, 15))

PlayAnimation(string, bool(optional))

Broadcast (Bool - true) or send to only player itself (Bool - false) animation registered by ResourcePackManager RegisterAnimation.

player.PlayAnimation("CustomSpawnAnimation")

RemoveEffect(Effect)

Remove effect from player that have been added using AddEffect(Effect, int(optional), bool(optional))) and it's duration is not ended.

Send(Packet)

Send custom data packet.

SetActorData setActorData = new SetActorData
{
   EntityId = 22,
   Metadata = new Dictionary<ActorData, Metadata>() { { ActorData.VISIBLE_MOB_EFFECTS, new Metadata(1) } }
};
player.Send(setActorData);

SendAbilities(byte, byte)

Change player permission levels.

player.SendAbilities(3, 0) //playerPermissions, commandPermissions

SendChatMessage(string, string)

Send chat message from specific source.

player.SendChatMessage("hi hi text message", "Bot1")

chatmessage

SendActionBarTitle(String, int(optional), int(optional), int(optional))

Send action bar messsage.

player.SendActionBarTitle("hi hi text message");

actionbar

SendJukeboxPopup(String)

Send jukebox like message popup.

player.SendJukeboxPopup("hi hi text message");

jukeboxpopup

SendLevelEvent(Vector3, LevelEvents, int(optional))

Send LevelEvent to specified player.

player.SendLevelEvent(new Vector3(10, -50, 20), LevelEvents.ParticlesEvaporate);

SendMetadata(Bool)

Send to player itself (Bool - false) or broadcast (Bool - true) to every player this player updated metadata values.

player.SendMetadata(true);

SendMessage(String)

Send chat message to specified player.

player.SendMessage("hi hi text message");

message

SendPopup(String)

Send tooltip like message popup.

player.SendPopup("hi hi text message");

popup

SendTip(String)

Send tooltip message.

player.SendTip("hi hi text message");

tip

SendTitle(String, String(optional), int(optional), int(optional), int(optional))

Send title and subtitle messages.

player.SendTitle("hi hi text message", "more text");

title

SetFlag(ActorFlags, Bool)

Enable (Bool - true) or disable (Bool - false) ActorFlags data for the player.

player.SetFlag(ActorFlags.ONFIRE, true);

SetNameTag(string)

Change player display name that other players can see.

player.SetNameTag($"Mod {player.username}")

SetPermissions(PermissionSet)

Set custom player permissions using PermissionSet values.

player.SetPermissions(new PermissionSet() { Build = true, Mine = false, AttackMobs = true });

Teleport(Vector3)

Teleport player to specified location.

player.Teleport(new Vector3(10, -20, 15));

Transfer(String, ushort)

Transfter player to other server.

player.Transfer("mc.cobwebsmp.com", 19132);

ResourcePackManager

RegisterAnimation(string, string, string, string(optional))

Register animation found in your servers resource pack.

ResourcePackManager.RegisterAnimation("CustomSpawnAnimation", "controller.animation.humanoid.custom_controller", "animation.humanoid.custom.spawnAnimation");

Skin

Create(string, string)

This function create Skin object from provided .png texture and .json geometry data.

Skin entitySkin = Skin.Create("Plugins/vipchest.png", "Plugins/vipchest.json");

Server

GetPlayer(EntityID)

Get Player object using EntityID;

Player player = Server.GetPlayer(123);

GetWorld(String);

Get World object using World name

World world = Server.GetWorld("My World");

GetOnlinePlayers()

Get array of Player objects currently on the server.

Player[] onlinePlayers = Server.GetOnlinePlayers();

World

Data sent using there methods is broadcasted to all players in specified World.

ClearTitle()

Clear all on-screen titles and popups.

world.ClearTitle()

Send(Packet)

Send custom data packet to all players in this World.

SetActorData setActorData = new SetActorData
{
   EntityId = 22,
   Metadata = new Dictionary<ActorData, Metadata>() { { ActorData.VISIBLE_MOB_EFFECTS, new Metadata(1) } }
};
world.Send(setActorData);

SendActionBarTitle(String, int(optional), int(optional), int(optional))

Send action bar messsage.

world.SendActionBarTitle("hi hi text message");

SendBlock(Block, int, int, int)

Send block update to all players in this World using block coordinate system.

world.SendBlock(new DiamondBlock(), 10, 5, 2);

SendBlock(Block, Vector3)

Send block update to all players in this World using player position coordinate system.

world.SendBlock(new DiamondBlock(), player.Position);

SendChatMessage(string, string)

Send chat message from specific source.

world.SendChatMessage("hi hi text message", "Bot1")

chatmessage

SendJukeboxPopup(String)

Send jukebox like message popup.

world.SendJukeboxPopup("hi hi text message");

jukeboxpopup

SendLevelEvent(Vector3, LevelEvents, int(optional))

Send LevelEvent to all players in this World.

world.SendLevelEvent(new Vector3(x, y, z), LevelEvents.ParticlesEvaporate);

SendMessage(String)

Send chat message.

world.SendMessage("hi hi text message");

message

SendPopup(String)

Send tooltip like message popup.

world.SendPopup("hi hi text message");

popup

SendTitle(String, String(optional), int(optional), int(optional), int(optional))

Send title and subtitle messages.

world.SendTitle("hi hi text message", "more text");

title

SendTip(String)

Send tooltip message.

world.SendTip("hi hi text message");

tip

Clone this wiki locally