How can i make a placeholder that works with featherboard?

Discussion in 'Spigot Plugin Development' started by daveyxbl, May 4, 2016.

  1. I'm wondering how i can hook my custom currency into featherboard..


    Code (Text):
    package net.fug.main;

    import org.bukkit.Bukkit;
    import org.bukkit.entity.Player;

    public class PackedIce {
        private Player player;
       
          public PackedIce(Player player)
          {
            this.player = player;
          }
       
          public PackedIce(String string)
          {
            this.player = Bukkit.getPlayer(string);
          }
       
          public Player player()
          {
            return this.player;
          }
       
          public int getIce()
          {
            return Main.get().getConfig().getInt("IceEconomy.users." + this.player.getName());
          }
       
          public void setCoins(int Ice)
          {
            Main.get().getConfig().set("IceEconomy.users." + this.player.getName(), Integer.valueOf(Ice));
            Main.get().saveConfig();
          }
       
          public void addIce(int Ice)
          {
            setCoins(getIce() + Ice);
          }
       
          public void removeIce(int Ice)
          {
            setCoins(getIce() - Ice);
          }
    }



     


    Code (Text):
    t = the player

    Stats(t).getTokens()
    I'm trying to get three currencies setup on the scoreboard. They are all using the same type of currency system.
     
    #1 daveyxbl, May 4, 2016
    Last edited: May 5, 2016
  2. On your onEnable, you're going to want to register the placeholder like so:
    Code (Text):
    PlaceholderAPI.registerOfflinePlaceholder("name", true,
                    new PlaceholderRequestEventHandler() {

                        @Override
                        public String onPlaceholderRequest(PlaceholderRequestEvent e) {
                            //return placeholder
                        }
                    });
    For example, if you wanted to return the player's name, you could do
    Code (Text):
    PlaceholderAPI.registerOfflinePlaceholder("rainbowname", true,
                    new PlaceholderRequestEventHandler() {

                        @Override
                        public String onPlaceholderRequest(PlaceholderRequestEvent e) {
                            return e.getOfflinePlayer().getName();
                    });
    Edit: Forgot to mention, you need MVdW Placeholders if you don't already have it: https://www.spigotmc.org/wiki/mvdw-placeholders/
     
    • Like Like x 1
  3. Code (Text):
    PlaceholderAPI.registerOfflinePlaceholder("rainbowname", true,
                    new PlaceholderRequestEventHandler() {
    doesn't work.. It may have been removed from the api when 1.9 came around..
     
  4. MVdW Placeholders was last updated in August, so it hasn't been changed since 1.9 (unless my time frame is really off, I hardly heard about it when 1.9 was released), so it might just not be compatible, in which case our only hope is an update.
     
  5. registerOfflinePlaceholder is giving me the error.. Its not anything else besides that.