1.8.8 Using variables in scoreboard plugins.

Discussion in 'Spigot Plugin Development' started by SPLATTER, Jan 26, 2020.

  1. Hello, I am wondering how I am supposed to use variables in my scoreboard plugin. as an example, I would put %balance% in my plugin and it would show the players balance on the scoreboard.

    here is my code

    Code (Java):

    package me.SPLATTER.scoreboard.scoreboard;

    import org.bukkit.Bukkit;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.scoreboard.DisplaySlot;
    import org.bukkit.scoreboard.Objective;
    import org.bukkit.scoreboard.Score;
    import org.bukkit.scoreboard.Scoreboard;
    import org.bukkit.scoreboard.ScoreboardManager;

    import me.SPLATTER.scoreboard.Main;
    import me.SPLATTER.scoreboard.utils.utils;

    public class scoreboardcode implements Listener{

        private Main plugin;
            public scoreboardcode(Main plugin) {
                this.plugin = plugin;
            Bukkit.getPluginManager().registerEvents(this, plugin);
            public void join(PlayerJoinEvent event) {
                Player player = event.getPlayer();

                ScoreboardManager m = Bukkit.getScoreboardManager();
                Scoreboard b = m.getNewScoreboard();

                Objective o = b.registerNewObjective("Money", "");
                o.setDisplayName(utils.chat("Tutorial Server"));

                Score Money = o.getScore(utils.chat("&aMoney&8: &6%bal%"));




    [ /code]
  2. Well, it's not going to work that way. It really depends on where you want to get the balance from. I assume you have an economy plugin installed on your server? In this case you would first have to check if your economy plugin has an API that can be called in your code to get the balance from a player.
  3. yeah, I have that! I user vault and placeholderapi And I have installed the api for vault, but it still doesn't work...
  4. I'm not sure if you've already found the PlaceholderAPI usage page, but it explains everything pretty detailed and seems to be exactly what you're looking for.