Solved Factions Api Scoreboard

Discussion in 'Plugin Development' started by glory_fades, May 27, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    glory_fades

    so as u can tell i want a factions scoreboard

    Code:
    package me.ahrims.scoreboard;
    
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.entity.EnderPearl;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.ProjectileLaunchEvent;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.scoreboard.DisplaySlot;
    import org.bukkit.scoreboard.Objective;
    import org.bukkit.scoreboard.Score;
    import org.bukkit.scoreboard.Scoreboard;
    
    import com.massivecraft.factions.entity.MPlayer;
    
    public class Fscore extends JavaPlugin implements Listener {
    
        private Scoreboard board;
    
        public void onEnable() {
            getServer().getPluginManager().registerEvents(this, this);
        }
    
        public void makeScoreboard(Player player) {
            board = Bukkit.getScoreboardManager().getNewScoreboard();
    
            Objective objective = board.registerNewObjective("Test", "Test2");
            MPlayer mp = MPlayer.get(player);
            objective.setDisplayName(ChatColor.AQUA + "Test");
            objective.setDisplaySlot(DisplaySlot.SIDEBAR);
    
            Score score = objective.getScore(ChatColor.GOLD + "Online Players");
            score.setScore(Bukkit.getOnlinePlayers().size());
    
            Score score2 = objective.getScore(ChatColor.GOLD + "Current Faction");
            score2.setScore(mp.getFaction());
    
            Score score3 = objective.getScore(ChatColor.GOLD + "Faction Power");
    
            Score score4 = objective.getScore(ChatColor.GOLD + "Random");
            score4.setScore(Bukkit.getSpawnRadius());
        }
    
        @EventHandler
        public void onjoin(PlayerJoinEvent e) {
            Player p = e.getPlayer();
            p.setScoreboard(board);
           
        }
    }
    but at score2.setScore(mp.getFaction()); it gives me an error
    saying that it must be an int, anyone have an idea?
     
  2. Offline

    JuliusTOw3R

    @glory_fades show us your mp.getFaction() method and I think I can tell you.
     
  3. Offline

    SuperOriginal

    Scores can only be integers. If you're going to format a scoreboard to have Strings as the intended "score", you need to have it on another line; their scores being the numerical value that orders them correctly.

    Ex.
    My Scoreboard
    Faction: 2
    MyFaction 1
     
  4. Offline

    glory_fades

    well, yeah ik that i was just wondering if anyone has any suggestions on what to do different
     
  5. Offline

    SuperOriginal

    @glory_fades
    • Set the score of CurrentFaction: to an integer.
    • Set the score of their Faction's tag to the integer above that.
     
  6. Offline

    glory_fades

    @JuliusTOw3R mp.getFaction(); is from the factions api

    im just a little curious how i would set mp.getFaction(): to an integer?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 12, 2016
  7. Offline

    SuperOriginal

    Did you read what I said?
     
    glory_fades likes this.
  8. Offline

    glory_fades

    oh wow im so stupid thanks so much SuperOriginal :D
     
    Last edited: May 27, 2015
Thread Status:
Not open for further replies.

Share This Page