ScoreBoard

Spokers

Пользователь
1) Сервер игнорирует существование скора
2)Spigot 1.8
3)
Java:
public ISCOREAPI sapi;
public void onEnable() {
sapi=new ISCOREAPI();
}

public static void onScore(Player p) {
File pl_f = new File("plugins/GZerus/players", ""+ p.getName() +".yml");
FileConfiguration pl = YamlConfiguration.loadConfiguration(pl_f);
ISCOREAPI api = new ISCOREAPI();
api.createObjective(Strings.p, "GZerus"); //Ваш заголовок
api.createTeam("GZerusP");

api.setScore(Bukkit.getOfflinePlayer("§e§lСтатистика"), 15);
api.setScore(Bukkit.getOfflinePlayer("§e§l " + p.getName()), 14);
api.setScore(Bukkit.getOfflinePlayer("§fСломано блоков: " + pl.getInt("users."+p.getName()+".blocks")), 13);
api.setScore(Bukkit.getOfflinePlayer("§fУбито монстров: " + pl.getInt("users."+p.getName()+".Kill_mob")), 12);
api.setScore(Bukkit.getOfflinePlayer("§fУбито игроков: " + pl.getInt("users."+p.getName()+".Kill_player")), 11);
api.addPlayerToTeam("GZerusP", p);
api.refreshPlayerScoreboard(p);
}
Java:
public class ISCOREAPI
{
/* ISCOREAPI by Firebreath15 v1.5
*
* Written for private use. Do not duplicate or republish.
*/
  Scoreboard board;
  Objective obj;

  public ISCOREAPI()
  {
    this.board = Bukkit.getScoreboardManager().getNewScoreboard();
  }

  public void setScoreboard(Player p) {
    this.board = p.getScoreboard();
    this.obj = this.board.getObjective(DisplaySlot.SIDEBAR);
  }

  public void createObjective(String name, String desc) {
    if (this.board.getObjective(name) == null) {
      this.obj = this.board.registerNewObjective(name, desc);
      this.obj.setDisplayName(name);
      this.obj.setDisplaySlot(DisplaySlot.SIDEBAR); // Вы можете сделать не только "таблицы", можно и сделать подсчет над головой, главное в DisplaySlot выберите другой вариант. Их существует несколько. Посмотрите на вики
    }
  }

  public void removeObjective(String obj) {
          if(board.getObjective(obj)!=null){
                  this.board.getObjective(obj).unregister();
          }
  }

  public void createTeam(String name) {
    if (this.board.getTeam(name) == null) {
      Team team = this.board.registerNewTeam(name);
      team.setDisplayName(name);
    }
  }

  public void removeTeam(String team) {
    this.board.getTeam(team).unregister();
  }

  public void addPlayerToTeam(String team, Player p) {
    this.board.getTeam(team).addPlayer(p);
  }

  public int getScores(OfflinePlayer p) {
    Score score = this.obj.getScore(p);
    return score.getScore();
  }

  public void setScore(OfflinePlayer p, int sc) {
    Score score = this.obj.getScore(p);
    score.setScore(sc);
  }

  public void removePlayerFromTeam(String team, Player p) {
          if(this.board.getTeam(team)!=null){
                  if(this.board.getTeam(team).hasPlayer(p)){
                          this.board.getTeam(team).removePlayer(p);
                  }
          }
  }

  public void refreshPlayerScoreboard(Player p) {
    p.setScoreboard(this.board);
  }

  public Scoreboard getPlayerScoreboard(Player p) {
    return p.getScoreboard();
  }

  public void removePlayerScoreboard(Player p) {
      board.getObjective(DisplaySlot.SIDEBAR).unregister();
  }
 

BuseSo

Разработчик
Так ты нигде скор и не выводишь игрокам.
Ты уверен, что сервер игнорирует скорборд?

Да и ещё ты не используешь метод createObjective, поэтому у тебя нет сайдбара.
 

Spokers

Пользователь
Java:
static int ScoreboardUpdater;
public void onEnable() {
        log.info("Your plugin has been enabled.");
        this.ScoreboardUpdater();
        
    }
public Runnable ScoreboardUpdater() {
        final BukkitScheduler updater = Bukkit.getServer().getScheduler();
        Prison.ScoreboardUpdater = updater.scheduleSyncRepeatingTask((Plugin)this, (Runnable)new Runnable() {
            @Override
            public void run() {
                for (final Player p : Bukkit.getOnlinePlayers()) {
                    PrisonScoreBoard.updateScoreboard(p);
                }
            }
        }, 0L, 20L);
        return null;
    }
Java:
public class PrisonScoreBoard implements Listener
{
    ScoreboardManager manager;
    static Scoreboard pboard;
    
    public PrisonScoreBoard() {
        this.manager = Bukkit.getScoreboardManager();
    }
    
    @EventHandler
    public void onJoin(final PlayerJoinEvent e) {
        final Player p = e.getPlayer();
        PrisonScoreBoard.pboard = this.manager.getNewScoreboard();
        final Team admin = PrisonScoreBoard.pboard.registerNewTeam("Admin");
        admin.setPrefix(new StringBuilder().append(ChatColor.RED).toString());
        final Team white = PrisonScoreBoard.pboard.registerNewTeam("White");
        white.setPrefix(new StringBuilder().append(ChatColor.GRAY).toString());
        final Team black = PrisonScoreBoard.pboard.registerNewTeam("Black");
        black.setPrefix(new StringBuilder().append(ChatColor.DARK_GRAY).toString());
        p.setScoreboard(PrisonScoreBoard.pboard);
        for (final Player player : Bukkit.getOnlinePlayers()) {
            final Scoreboard pboard2 = player.getScoreboard();
            final Team pAdmin = pboard2.getTeam("Admin");
            if (p.hasPermission("prison.admin")) {
                pAdmin.addPlayer((OfflinePlayer)p);
            }
        }
        updateScoreboard(p);
    }
    
    public static void updateScoreboard(final Player p) {
        p.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
        File pl_new = new File("plugins/Prison/players", ""+ p.getName() +".yml");
        FileConfiguration pl = YamlConfiguration.loadConfiguration(pl_new);
        int lvl = pl.getInt("users."+p.getName()+".lvl");
        int dead = pl.getInt("users."+p.getName()+".dead");
        int blocks = pl.getInt("users."+p.getName()+".blocks");
        int mobkill = pl.getInt("users."+p.getName()+".kill_mobs");
        int playerkill = pl.getInt("users."+p.getName()+".kill_palayer");
        double balance = pl.getDouble("users."+p.getName()+".balance");
        final Scoreboard playerBoard = p.getScoreboard();
        for (final Objective obj : playerBoard.getObjectives()) {
            obj.unregister();
        }
        final Objective stats = playerBoard.registerNewObjective("Stats", "dummy");
        stats.setDisplaySlot(DisplaySlot.SIDEBAR);
        stats.setDisplayName(ChatColor.BOLD + "Prison");
        stats.getScore(ChatColor.AQUA+"Игрок").setScore(11);
        stats.getScore("Уровень >> "+ChatColor.YELLOW+lvl).setScore(10);
        stats.getScore("Баланс >> "+ChatColor.GREEN+balance+"$").setScore(9);
        stats.getScore("Фракция >> СКОРО").setScore(8);
        stats.getScore("").setScore(7);
        stats.getScore(ChatColor.AQUA+"Статистика").setScore(6);
        stats.getScore("Убийств >> "+playerkill).setScore(5);
        stats.getScore("Смертей >> "+dead).setScore(4);
        stats.getScore("Блоков >> "+ChatColor.GOLD+blocks).setScore(3);
        stats.getScore("Крыс убито >> "+mobkill).setScore(2);
        stats.getScore(" ").setScore(1);
        stats.getScore("CookiesCraft.ru").setScore(0);
    }
}
 

Комнаты в чате

Верх Низ