-
-
Notifications
You must be signed in to change notification settings - Fork 3
Messages file
JSON Components ↑
JSON components allow you to send advanced, customizable, messages using Minecraft's JSON formatting system.
This section will tell you all about Annoying API's JSON system and how to use it in the messages file!
There are 5 different types of JSON components that can be used to send messages (each one can have hover text). Each one will perform a different action when hovered over or clicked:
-
text
(HOVER) Shows text, this is the default type -
suggest
(CLICK) Puts text in the player's chat box -
copy
(CLICK) Copies text to the player's clipboard [1.15+ only!] -
chat
(CLICK) Forces the player to send a message (/
can be prefixed to make the player run a command) -
web
(CLICK) Prompts the player to open a URL in their browser
The characters you put in plugin.splitters.json
are used to split the message into the component arguments.
By default, the splitter is @@
, which is what will be used in the examples below.
This is the format of a single message, all single messages are suggest
components:
key1: "display1@@hover1@@suggest1"
# Sent to player: "display1"
# Shown on hover: "hover1"
# Put in player's chat bar when clicked: "suggest1"
-
display1
cannot be empty. If it is, the key name will be sent (ex:plugin.prefix
). -
hover1
can be empty. If it is, a normal (non-JSON) message will be sent. -
suggest1
can be empty. If it is, atext
message will be sent.
These are the formats of an advanced message, all advanced message components depend on what their sub-key start with:
key2:
text: "display2@@hover2"
# Sent to player: "display2"
# Shown on hover: "hover2"
suggest: "display3@@hover3@@suggest2"
# Sent to player: "display3"
# Shown on hover: "hover3"
# Put in player's chat bar when clicked: "suggest2"
copy: "display4@@hover4@@clipboard1"
# Sent to player: "display4"
# Shown on hover: "hover4"
# Copied to player's clipboard when clicked: "clipboard1"
chat: "display5@@hover5@@chat1"
# Sent to player: "display5"
# Shown on hover: "hover5"
# Chat message sent by player when clicked: "chat1"
web: "display6@@hover6@@web1"
# Sent to player: "display6"
# Shown on hover: "hover6"
# Website prompted to open when clicked: "web1"
All the messages in the above example will be strung together into a single message, display2display3display4display5display6
This way you can create something like this: [Accept][Decline]
. When clicking on one of the options, it can run different functions/commands.
To have multiple of the same components in a message, you simply have to put any text after the component's name:
key3:
command-accept: "[Accept]@@Accept the request@@/accept"
command-decline: "[Decline]@@Decline the request@@/deny"
The name of a text
sub-key doesn't matter since it's the default component (just don't have it start with another component's name).
Placeholder Parameters ↑
Some placeholders will allow you to input a parameter. These parameters are used to change the output of the placeholder
To input a parameter, you simply put it after the placeholder name (inside the %%
), separated by the plugin.splitters.placeholder
(default: ==
)
Example: %placeholder==parameter%
Below are the different types of parameters that can be used...
The examples will use ==
as the splitter, but you can change it by modifying plugin.splitters.placeholder
-
time
A time (in milliseconds) will be inputted by the plugin. The parameter will determine the format of the time. View the DurationFormatUtils documentation here.Examples (
5400000
):-
%cooldown==m':'s%
->1:30
-
%cooldown==H':'m':'s%
->1:30:0
-
%cooldown==d'd' H'h' m'm' s's'%
->1h 30m 0s
-
-
number
A number will be inputted by the plugin. The parameter will determine the format of the number. View the DecimalFormat documentation here.Examples (
8637.2
):-
%money==#,###%
->8,637
-
%money==#,###.##%
->8,637.2
-
%money==#,###.00%
->8,637.20
-
-
boolean
A boolean (true
/false
) will be inputted by the plugin. The parameter will determine the output of the boolean. You must use//
to split the true and false outputs. If you don't, the placeholder will be replaced withtrue
orfalse
.Examples (
true
):-
%state==enabled//disabled%
->enabled
-
%state==yes//no%
->yes
-
%state==invalid%
->true
-
Placeholders that support parameters will be displayed as %name==type%
in the message's placeholder list.
Examples: %cooldown==time%
, %money==number%
, %state==boolean%
key4: "KDR: %kdr==#.##%" # %kdr==number%
If the comments are not present in your messages file, please check the plugin's wiki/documentation on GitHub!
Global Placeholders ↑
Global Placeholders are placeholders that can be used in any message in the file. This is extremely useful for things like prefixes, color schemes, and more!
Using a global placeholder is just like any other placeholder, simply surround the placeholder name with %
(ex: %prefix%
).
WARNING: Global placeholders can conflict with local placeholders! Please be wary when creating your own global placeholder(s)!
global-placeholders: # It's recommended to keep all the default global placeholders (prefix, p, s, pe, se)
prefix: "&3&lANNOYING &8&l| &b" # Prefix for the plugin, typically used in the beginning of most messages
p: "&b" # Base color for non-error messages
s: "&3" # Highlight color for non-error messages
pe: "&c" # Base color for error messages
se: "&4" # Highlight color for error messages
Errors ↑
Errors are very important for EVERY plugin! Annoying API has a few required (sorta) error messages to ensure everything works correctly.
If one of these errors are removed, the plugin won't break, however, any error messages will just be sent as the error message key (example: error.invalid-arguments
).
# Error messages when a player does something wrong
error:
# Player doesn't have permission to use a command
no-permission: "%prefix%%pe%You must have %se%%permission%%pe% to use this!@@%pe%%command%@@%command%" # %permission%
# Console tries to use a command that can only be used by players
player-only: "%prefix%%pe%You must be a player to run this command!@@%pe%%command%@@%command%"
# Command is used with an invalid/incorrect argument
invalid-argument: "%prefix%%se%%argument%%pe% is an invalid argument!@@%pe%%command%@@%command%" # %argument%
# Command is used with multiple invalid/incorrect arguments
invalid-arguments: "%prefix%%pe%Invalid arguments!@@%pe%%command%@@%command%"
# Command is used when it's disabled
disabled-command: "%prefix%%se%%command%%pe% is disabled!@@%pe%%command%@@%command%"