Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.realistic.scoreboard;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.server.PluginEnableEvent;
- import org.bukkit.scheduler.BukkitRunnable;
- 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 com.realistic.api.API;
- import com.realistic.list.MinecraftList;
- public class ScoreBoard implements Listener {
- private API plugin;
- private MinecraftList ml;
- public ScoreBoard(API plugin) {
- this.plugin = plugin;
- }
- public ScoreBoard(MinecraftList ml) {
- this.ml = ml;
- }
- public void enableScoreboard() {
- for (Player p : Bukkit.getOnlinePlayers()) {
- ScoreboardManager manager = Bukkit.getScoreboardManager();
- Scoreboard board = manager.getNewScoreboard();
- Objective obj = board.registerNewObjective("obj", "dummy");
- obj.setDisplaySlot(DisplaySlot.SIDEBAR);
- obj.setDisplayName(ChatColor.GREEN + "Состояние игрока");
- Score line1 = obj.getScore(" ");
- line1.setScore(20);
- Score playerName = obj.getScore(ChatColor.DARK_AQUA + "Ваш никнейм: " + ChatColor.GOLD + p.getName());
- playerName.setScore(19);
- Score line2 = obj.getScore(" ");
- line2.setScore(18);
- Score tempeture = obj.getScore(ChatColor.DARK_AQUA + "Температура: ");
- tempeture.setScore(17);
- Score line3 = obj.getScore(" ");
- line3.setScore(16);
- Score playerInfo = obj.getScore(ChatColor.GREEN + "Состояние:");
- playerInfo.setScore(15);
- Score line4 = obj.getScore(" ");
- line4.setScore(14);
- if (!ml.bloodingPlayers.containsKey(p.getName()) && !ml.Broken_Bones.containsKey(p.getName())
- && !ml.Disease_Cold.containsKey(p.getName()) && !ml.Disease_Pneumonia.containsKey(p.getName())
- && !p.isDead()) {
- Score nothing = obj.getScore(ChatColor.DARK_AQUA + "Я здоровый!");
- nothing.setScore(13);
- }
- if (ml.bloodingPlayers.containsKey(p.getName())) {
- Score blooding = obj.getScore(ChatColor.DARK_AQUA + "У меня кровотечение!");
- blooding.setScore(13);
- }
- if (ml.Broken_Bones.containsKey(p.getName())) {
- Score broken_bones = obj.getScore(ChatColor.DARK_AQUA + "У меня сломана нога!");
- broken_bones.setScore(12);
- }
- if (ml.Disease_Cold.containsKey(p.getName()) || ml.Disease_Pneumonia.containsKey(p.getName())) {
- Score disease = obj.getScore(ChatColor.DARK_AQUA + "Я болен!");
- disease.setScore(11);
- }
- if (p.isDead()) {
- Score dead = obj.getScore(ChatColor.DARK_AQUA + "Вы мертвы!");
- dead.setScore(13);
- }
- p.setScoreboard(board);
- }
- }
- public void refreshScoreboard() {
- BukkitRunnable run = new BukkitRunnable() {
- @Override
- public void run() {
- enableScoreboard();
- }
- };
- run.runTaskTimer(plugin, 30, 30);
- }
- @EventHandler
- public void startScoreboard(PluginEnableEvent e) {
- refreshScoreboard();
- }
- }
Add Comment
Please, Sign In to add comment