-
Notifications
You must be signed in to change notification settings - Fork 0
Documentation for developers
SpGerg edited this page Aug 29, 2023
·
12 revisions
You need import:
PlaceholdersAPI
You can find it in releases.
Placeholder class example:
public class CoolPlaceholder : IPlaceholder
{
public string Name => "Cool placeholder";
public string Identifier => "cool";
public string Author => "SpGerg";
public string Description => "Just cool placeholder, lol.";
public string OnPlaceholderRequest(Player player, string identifier)
{
if (identifier == "placeholder")
{
return "Coolest placeholder in the world.";
}
else if (identifier == "placeholder2")
{
return "Coolest placeholder again?";
}
return null;
}
}Placeholder example:
cool_placeholder
just-good_placeholder
identifier_placeholder
(DONT use _ in identifier)
After making placeholder class you need register this:
public override void OnEnabled()
{
PLAPI.Register(new CoolPlaceholder());
base.OnEnabled();
}After creating a placeholder, you can use it like this (It is other project):
public static void OnPlayerJump(JumpingEventArgs ev)
{
ev.Player.Broadcast(2, PLAPI.SetPlaceholders(ev.Player, "Placeholder: {cool_placeholder}"));
Timing.CallDelayed(3f, () =>
{
ev.Player.Broadcast(2, PLAPI.SetPlaceholders(ev.Player, "Placeholder: {just-good_placeholder2}"));
});
}All placeholders be automatically changing in configs (with IPlaceholderHook interface, and if it just string). But there is a problem that placeholders do not change at OnEnable. I can't find out the cause of this problem.

You can set placeholder color with IPlaceholderColor interface. But there is a problem that placeholders do not change at OnEnable. I can't find out the cause of this problem.
Example:
public class ColorPlaceholder : IPlaceholder, IPlaceholderColor
{
public string Name => "Color placeholder";
public string Identifier => "color";
public string Author => "SpGerg";
public string Description => "Color placeholder lol";
public ConsoleColor Color { get; set; } = ConsoleColor.Green;
public string OnPlaceholderRequest(Player player, string identifier)
{
if (identifier == "red")
{
Color = ConsoleColor.Red;
return "red placeholder";
}
Color = ConsoleColor.Green;
return "green placeholder";
}
}public static void OnPlayerHurting(HurtingEventArgs ev)
{
ev.Player.Broadcast(2, PLAPI.SetPlaceholders(ev.Player, "Im need {color_red} placeholder! and {color_weotghjwet}. And i can using other placeholders {cool_placeholder}!"));
}
