MBedwars provides four different scoreboard configs files for 4 different game/player states
lobby.yml Displayed when a player is in the waiting lobbyingame.yml Displayed when a player is playing in an arenaspectator.yml Displayed when a player is spectating in an arenaend-lobby.yml Displayed when a player is in in an arena's end-lobbyAll the config files listed above can be found in /MBedwars/scoreboard-layouts
Each scoreboard can be individually be enabled or disabled using the enabled config:
# Set if this scoreboard should be displayed or not
enabled: true
Each configuation has a default board. The default board is what is normally displayed, however overriding-boards can override the default board.
Example Configuaration:
# The default scoreboard layout for this scoreboard type
default:
# Default board configuation here
Overriding boards allow you to use an Arena Pickers to override default boards under certian arena condtions. For example, this is useful if you want to display a different scoreboard in a solos, or doubles arena.
# Here you can add scoreboards that may override the default board in certain arenas
overriding-boards:
'[teams=100]': # The arena picker for this layout
# Overriding board configuation here
Available Configs (For every board)
title The title line in the scoreboardtop-lines The top lines of the scoreboard (above the each-team lines)each-team The lines allocated for each enabled team in an arenabottom-lines The bottom lines of the scoreboard (below the each-team lines)The placeholders available in these configs are listed at the top of your scoreboard config files.
Different Minecraft versions have different scoreboard restrictions. The following table shows what restrictions apply to what versions.
Restrictions:
| Version | Character Limit | Character Limit Ignores Color Codes | Hex Support |
|---|---|---|---|
| 1.8.8 -> 1.12.2 | ≈40 | No | No |
| 1.13 -> 1.15.2 | ≈120 | No | No |
| 1.16 -> 1.20.1 | ≈120 | Yes | Yes |
| 1.21+ | Unlimited | Irrelevant | Yes |
If you are running a modern Minecraft version, and have older clients connect with ViaVersion or ProtocalSupport, MBedwars will automagically render the scoreboard differently for that specific client. For example, if you are running a 1.20 server, and are using hex color codes, MBedwars will automatcially remove the hex colors from the text to enable more charaters to be displayed. This also enables you write color codes like this
&a𞉀. On newver versions, players will see the hex color code (𞉀), but older clients will just see the&c.
Make sure you have PlaceholderAPI installed (learn more).
Basically, you must create a new placeholder that displays the frames of the animations. There are multiple solutions for this, but we are going to use PlaceholderAPI's JavaScript expansion.
Start off by opening the config.yml of MBedwars and changing the config scoreboard-refreshrate. With this, you basically define how frequently the animation shall be updated, with the unit being ticks. By default it's set to 20 (animation placeholder is updated once per second). Although we are going to use 5 (20 / 4 = 5 times per second). Adapt the value to your liking: Greater values may result in faster and more fluet animations, although also increase your CPU usage.
One way to create a placeholder is using PlaceholderAPI's JavaScript expansion. Install it as explained on their wiki.
You should see the following line in your console:
[Server thread/INFO]: [PlaceholderAPI] Successfully registered external expansion: javascript [x.x.x]
Open /plugins/PlaceholderAPI/javascript_placeholders.yml and add the following lines:
mbw-example-animation: # the name of the placeholder
file: mbw-example-animation.js # the name of the file containing the script
Create a file called mbw-example-animation.js at /plugins/PlaceholderAPI/javascripts. We have provided examples that you may use for your first animation, and then build upon that yourself:
var refreshRate = 5; // in ticks. should be the same as configured in MBedwars's config.yml
var text = "MBedwars.com"; // the text to be animation with this example animation
var color = "&e"; // the color used with this animation
var debug = false; // set this to true to disable cache and are changing the code
// logic start
var frames;
function createFrames() {
var frames = [ ];
function addFrame(frame) {
frames.push(frame);
}
// create the frames, insert your own logic here!
{
// wait frames
for (var i=0; i<6; i++)
addFrame(text);
// move color through all chars
for (var i=0; i<text.length; i++) {
var pre = text.substring(0, i);
var c = text.charAt(i);
var after = text.substr(i+1);
addFrame(pre + color + c + "&f" + after);
}
// flash
for (var i=0; i<2; i++) {
addFrame(text);
addFrame(color + text);
}
}
return frames;
}
// avoid processing: utilize data as cache
// do NOT call Placeholder.saveData()
var player = BukkitPlayer;
var absFrame = Math.floor(player.getTicksLived() / refreshRate);
// get from cache
if (!debug && Data.exists("cache")) {
var frames = Data.get("cache"); // js-expansion turns it into a MemorySection
var count = frames.getKeys(false).size();
frames.getString(absFrame % count);
} else {
frames = createFrames();
// build cache
Data.set("cache", frames);
frames[absFrame % frames.length];
}
var refreshRate = 5; // in ticks. should be the same as configured in MBedwars's config.yml
var text = "&6This plugin is &lamazing&6! &bMarcely's Bedwars &fprovides so many great features"; // the text to be animation with this example animation
var maxLength = 21;
var waitCount = 6;
var debug = false; // set this to true to disable cache and are changing the code
// logic start
var frames;
function createFrames() {
var frames = [ ];
var textNoColor = text.replace(/&[0-9a-fk-r]/g, "");
function addFrame(frame) {
frames.push(frame);
}
// make sure to not leave color chars alone
function substr(pos) {
var out = "", active = "", vis = 0, end = pos + maxLength, started = false;
for (var i = 0; i < text.length; i++) {
var code = text[i] == "&" && /[0-9a-fk-r]/i.test(text[i + 1] || "") && text.substr(i, 2);
if (code) {
var c = code[1].toLowerCase();
if (c == "r") active = "";
else if (/[0-9a-f]/.test(c)) active = code; // color resets formatting
else active += code; // formatting stacks: &l&o&n etc.
if (started && vis < end) out += code;
i++;
} else {
if (vis >= pos && vis < end) {
if (!started) out += active, started = true;
out += text[i];
}
vis++;
}
}
return out;
}
// create the frames, insert your own logic here!
{
// wait frames (start)
for (var i=0; i<waitCount; i++)
addFrame(substr(0));
// sliding frames (to end)
var movingCount = Math.max(0, textNoColor.length - maxLength);
for (var i=0; i<movingCount; i++)
addFrame(substr(i));
// wait frames (end)
for (var i=0; i<waitCount; i++)
addFrame(substr(movingCount));
}
return frames;
}
// avoid processing: utilize data as cache
// do NOT call Placeholder.saveData()
var player = BukkitPlayer;
var absFrame = Math.floor(player.getTicksLived() / refreshRate);
// get from cache
if (!debug && Data.exists("cache")) {
var frames = Data.get("cache"); // js-expansion turns it into a MemorySection
var count = frames.getKeys(false).size();
frames.getString(absFrame % count);
} else {
frames = createFrames();
// build cache
Data.set("cache", frames);
frames[absFrame % frames.length];
}